/*****************************************************

*Javascript Client Side Form Validation 

*Purpose: Client side enquiry form validation

*Date : 28/March/2005

******************************************************/



function isEmail(str){

	if((str.indexOf("@")<=0) || (str.lastIndexOf(".")<=(str.indexOf("@")+1)) || str.indexOf(" ")>=0)return false;

	return true;

	}

	

function isSpaceName(ch){

	return (ch==' ');

	}



function isAllalphabets(str){

	var i;

	for(i=0;i<str.length;i++){

	if(!isAlphabet(str.charAt(i))&&!isSpaceName(str.charAt(i)))

	return false;

	} 

	return true;

}



function isDigit(ch){

	return (ch>='0'&&ch<='9');

	}



function isAlldigits(str) {var i;

	for (i=0;i<str.length;i++) {

	if(!isDigit(str.charAt(i)))

	return false;

	}

	return true;

}





function isPhoneLength(str){

	if(str.length<10)return false;

	if(str.length>15)return false;

	return true;

}



function verify(friendsForm){

		

		if(friendsForm.name.value == ""){

		alert("Please enter your name.");

		friendsForm.name.focus();

		return false;

        } 



		if(friendsForm.fname.value == ""){

		alert("Please enter your friends name.");

		friendsForm.fname.focus();

		return false;

        } 

	

		if(!isEmail(friendsForm.email.value)){

		alert("Invalid email address.");

		friendsForm.email.focus();

		return false;

        }

if(!isEmail(friendsForm.femail.value)){

		alert("Invalid email address.");

		friendsForm.femail.focus();

		return false;

        }
		
		if(friendsForm.msg.value == ""){

		alert("Please enter your comments.");

		friendsForm.msg.focus();

		return false;

        } 


	return true;

}






