
function resetmsg()
	{
		document.getElementById("internal_msg").innerHTML="&nbsp;";
	}
function trimString (str)
{
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function valid()
{
	if(trimString(document.frm1.name.value)=="")
	{
		alert("Please enter name");
		document.frm1.name.focus();
		document.frm1.name.select();
		return false;
	}
	
	if(trimString (document.frm1.email.value)==""){
		alert("Please enter email address");
		document.frm1.email.focus();
		document.frm1.email.select();
		return false;
	}else if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.frm1.email.value)) == false){
		alert("Please enter valid email address");
		document.frm1.email.focus();
		document.frm1.email.select();
		return false;
	}
	
	if(trimString(document.frm1.phone.value)==""){
		alert("Please enter telephone no.");
		document.frm1.phone.focus();
		document.frm1.phone.select();
		return false;
	}else if(check_phonenumber(document.frm1.phone)==false){
			alert("Please enter valid telephone no.");
			document.frm1.phone.focus();
			document.frm1.phone.select();
			return(false);		
	}
	
	
	return true;
}
function check_phonenumber(phoneBox)
{
	var phoneVal = trimString(phoneBox.value.toString()); 
	phoneBox.value=trimString(phoneBox.value.toString());
	
	var valid;
	valid=true;
	var mstr=phoneVal.toString();
	var count=0;
	for (var i = 0;i < mstr.length;i++)
	{
		var oc = mstr.charAt(i);
		if ((oc < "0" ||oc > "9"))
		{
			count++;
		}
	}
	
	if(mstr.length>0)
	{
		var oc = mstr.charAt(0);
		if ((oc < "0" ||oc > "9")&& oc!="+")
		{
			valid=false;
		}
	}
	for (var i = 1;i < mstr.length;i++)
	{
		var oc = mstr.charAt(i);
		if ((oc < "0" ||oc > "9")&& oc!=" "&& oc!=","&& oc!="-"&& oc!="+" && oc!="(" && oc!=")")
		{
			valid=false;
		}
	}
	if (valid == false)
	{		
		return(false);
	}
	return(true);
}





function submitForm()
{
	if(valid()==true)
	{
		document.getElementById("internal_msg").innerHTML="&nbsp;";
		document.getElementById("internal_msg").innerHTML="Please wait, while processing...";
		document.frm1.submit();
	}
}

