// JavaScript Document







function validateForm(form)



{



	var name = trim(document.getElementById('name_brochure').value);



	var emailid = trim(document.getElementById('emailid_brochure').value);



	var phoneNo = trim(document.getElementById('phone_brochure').value);
	
	var security_code = trim(document.getElementById('security_code').value);



	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;



	var numberRegex = /^[0-9]*$/;

	

	var charRegex = /^[a-zA-Z-\. ]*$/;



	if(name=='') {



		 inlineMsg('name_brochure','Please Enter Name',2);



    return false;
	}
		
	if(name.length<2) {



		 inlineMsg('name_brochure','Name Should Be Minimum 2 Characters',2);



    return false;



	}
	if(name.length>40) {



		 inlineMsg('name_brochure','Name Can Be Maximum 40 Characters',2);



    return false;



	}

	if(!(name.match(charRegex))){

			inlineMsg('name_brochure','Please Enter Alphabets, . , - Only',2);

		return false;

	}



	if (echeck1(document.getElementById('emailid_brochure').value)==false){
		inlineMsg('emailid_brochure','Please Enter Valid Email Address.',3);
		return false
	     }
	if(emailid=='') {


		inlineMsg('emailid_brochure','Please Enter Email Id',2);

		return false;

	}

	if(!(emailid.match(emailRegex)) && emailid!="") {


		inlineMsg('emailid_brochure','Please Enter Valid Email Id',2);



		return false;



	}
	
	if(security_code=='') {


		inlineMsg('security_code','Please Enter Security Code',2);

		return false;

	}

	return true;

}




function validateName(form)

{

	var name = trim(document.getElementById('name_brochure').value);



	if(name=='') {



		 inlineMsg('name_brochure','Please Enter Name',2);

    return false;



	}

return true;


}

function checkSecuritycode()
{
	var security_code = trim(document.getElementById('security_code').value);
	if(security_code == ''){
		inlineMsg('security_code','Please Enter Security Code',2);
		return false;
	}
}



function validateEmail(form)

{

	var emailid = trim(document.getElementById('emailid_brochure').value);
	var phoneNo = trim(document.getElementById('phone_brochure').value);

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

	var numberRegex = /^[0-9]*$/;

	
	if(emailid=='') {

		inlineMsg('emailid_brochure','Please Enter Email Id',2);


		return false;



	}
 if (echeck1(document.getElementById('emailid_brochure').value)==false){
		inlineMsg('emailid_brochure','Please Enter Valid Email Address.',2);
		return false
	     }

	if(!(emailid.match(emailRegex)) && emailid!="") {



		inlineMsg('emailid_brochure','Please Enter Valid Email Id',2);



		return false;



	}


	return true;

}
function echeck1(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
function stripspaces(input)
{
    //input.value = input.value.replace(/\s/gi,"");
	input.value = input.value.replace(/^\s+|\s+$/g, '') ;
    return true;
}
