// JavaScript Document
function checking(name)
		{
			var extension = name.split(".");
			if(extension[1]=="jpg")
			{
			return(0);
			}
			else if(extension[1]=="gif")
			{
			return(0);
			}
			else if(extension[1]=="png")
			{
			return(0);
			}
			else if(extension[1]=="bmp")
			{
			return(0);
			}
		}
		
function checkEmail(emailString) {
	splitVal = emailString.split('@');
	
	if(splitVal.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) {
		alert("Please enter a valid email address");
		return false;
	}
	
	splitDomain = splitVal[1].split('.');
	if(splitDomain.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	return true;
}
function trimSpaces(stringValue) {
	// Checks the first occurance of spaces and removes them
	for(i = 0; i < stringValue.length; i++) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i > 0) {
		stringValue = stringValue.substring(i);
	}
	
	// Checks the last occurance of spaces and removes them
	strLength = stringValue.length - 1;
	for(i = strLength; i >= 0; i--) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i < strLength) {
		stringValue = stringValue.substring(0, i + 1);
	}
	
	// Returns the string after removing leading and trailing spaces.
	return stringValue;
}
function chkContact()
{
	name=trimSpaces(document.forms[0].name.value);
	email=trimSpaces(document.forms[0].email.value);
	addr=trimSpaces(document.forms[0].addr.value);
	if(name.length<=0)
	{
		alert("Plese Enter your Name");
		document.forms[0].name.focus();
		return false;
	}
	if(email.length<=0)
	{
		alert("Plese Enter your E-mail Address");
		document.forms[0].email.focus();
		return false;
	}
	if(email.length>0)
	 {
	if(!checkEmail(email)) 
	{
		document.forms[0].email.focus();
		return false;
	} 
	 }
	 if(addr.length<=0)
	{
		alert("Plese Enter your Address");
		document.forms[0].addr.focus();
		return false;
	}
	 document.forms[0].frmAction.value = "put";
}