// JavaScript Document
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}
function SpecialValidate2(txtCtrl, val) 
{
	var ctrName = val;
	if (trim(txtCtrl.value) == "")
	{
		alert("Please enter " + ctrName + ".");
		txtCtrl.focus();	
		return false;		
	}
	var iChars = "!@#$%^&*()+=[]\\\;,/{}|\":<>?`~.";
	for (var i = 0; i < txtCtrl.value.length; i++) {
		if (iChars.indexOf(txtCtrl.value.charAt(i)) != -1) {
			alert ("Please don't enter any specail characters!");
			txtCtrl.select();
			txtCtrl.focus();
			return false;
		}
 	 }	
}

function validate()
{
	if(trim(document.contactform.txtname.value) == "")
	{
		alert("Please enter your name");
		document.contactform.txtname.focus();
		return false;
		
	}
	//if(SpecialValidate2(document.contactform.txtname,"your name")==false) {return false;}
	if(trim(document.contactform.txtphone.value) == "")
	{
		alert("Please enter your phone number");
		document.contactform.txtphone.focus();
		return false;		
	}
	//if(SpecialValidate2(document.contactform.txtphone,"your phone number")==false) {return false;}
	document.contactform.action = "mail_process.php";
	document.contactform.submit();
}

