
function validPhone(str) {
	var len = str.length;
	var i;
	
	if(len<8)
		return false;
	
	for(i=0;i<len;i++)
		if( (str.charAt(i)<'0' || str.charAt(i)>'9') && str.charAt(i) != '-' && str.charAt(i) != ' ' && str.charAt(i) != '+' && str.charAt(i)!=')' && str.charAt(i)!='(' && str.charAt(i)!=')')
			return false;
	
	return true;	
}

function validate_contactus(FormName){
	var frm;
	frm = document.getElementById(FormName);
	
	if(isEmpty(frm.txtfname.value) || !isAlphabetic(frm.txtfname.value)){
		alert("Please enter your first name (alphabets only)...");
		frm.txtfname.focus();		
		return false;
	}

	if(isEmpty(frm.txtlname.value) || !isAlphabetic(frm.txtlname.value)){
		alert("Please enter your last name (alphabets only)...");
		frm.txtlname.focus();		
		return false;
	}
	
	if(frm.cmb_services.value=='') {
		alert("Please select an service...");
		return false;
	}
	if(!validateEmail(frm.txtemail.value,1,0) || isEmpty(frm.txtemail.value)){
		alert("Please enter a valid email address...");
		frm.txtemail.focus();		
		return false;
	}

	if(isEmpty(frm.txtphone.value) || !validPhone(frm.txtphone.value)){
		alert("Please enter your phone no...");
		frm.txtphone.focus();		
		return false;
	}

	if(isEmpty(frm.txtcomment.value)){
		alert("Please enter your comment...");
		frm.txtcomment.focus();		
		return false;
	}

	if(isEmpty(frm.security_code.value)){
		alert("Please enter the security code...");
		frm.security_code.focus();		
		return false;
	}

	return true;
}
