/* Created by Shweta Parbhakar
* Date: March 19th, 2007
* Reason:For general purposes
* Version 1.0 */
function trim_all(strObjName){ 
	//this function removes the spaces from the variables
        var strObj = strObjName;
        var strRet = "";
        for (i = 0;i < strObj.length;i++)
        {
                if(strObj.charAt(i) != " " && strObj.charAt(i) != "")
                        strRet = strRet+strObj.charAt(i);
        }
        return strRet;
}

function checkme(){
		
	var firstname = document.contactus.firstname;
	var lastname = document.contactus.lastname;
	var email = document.contactus.user_email;
    var contactno = document.contactus.contactno;	
	var description = document.contactus.description;	
		
	
	var reTESTfirstchar = /^[a-zA-Z]*$/;
	var reEmail         = /^[0-9a-zA-Z_\.-]+\@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z_\.-]*$/;
	
	if(trim_all(firstname.value) == ""){
		document.getElementById('firstnamealert').style.display='block';
		firstname.focus();
		return false;
	}else{
		document.getElementById('firstnamealert').style.display='none';
	}
	
	if(trim_all(lastname.value) == ""){
		document.getElementById('lastnamealert').style.display='block';
		lastname.focus();
		return false;
	}else{
		document.getElementById('lastnamealert').style.display='none';
	}
	
	if(trim_all(email.value) == ""){
		document.getElementById('emailalert').style.display='block';
		email.focus();
		return false;
	}else if(!reTESTfirstchar.test(email.value.charAt(0))){
		document.getElementById('emailalert').style.display='none';
		document.getElementById('email1alert').style.display='block';
		email.focus();
		return false;
	}else if(!reEmail.test(email.value)){
		document.getElementById('emailalert').style.display='none';
		document.getElementById('email1alert').style.display='none';
		document.getElementById('email2alert').style.display='block';
		email.focus();
		return false;
	}else{
		document.getElementById('emailalert').style.display='none';
		document.getElementById('email1alert').style.display='none';
		document.getElementById('email2alert').style.display='none';
	}
		
	if(trim_all(contactno.value) == ""){
		document.getElementById('contactnoalert').style.display='block';
		contactno.focus();
		return false;
	}else{
	    document.getElementById('contactnoalert').style.display='none';
	}
	if(isNaN(contactno.value)){
		document.getElementById('contactno1alert').style.display='block';
		contactno.value = "";
		contactno.focus();
		return false;
	}else{
		document.getElementById('contactno1alert').style.display='none';
	}
	
	if(trim_all(description.value) == ""){
		document.getElementById('descriptionalert').style.display='block';
		description.focus();
		return false;
	}else{
		document.getElementById('descriptionalert').style.display='none';
	}

	document.contactus.updte.value = 1;
	return true;
}