// JavaScript Document

function check()
{
	var CName 		= document.form1.name.value;
	var CEmail 		= document.form1.email.value;
	var CPhone 		= document.form1.phone.value;
	var CCustomic 	= document.form1.customic_content.value;
	
	if(Trim(CName) == 0)
	{
		alert("Please enter the name");
		document.form1.name.select(); 
		document.form1.name.focus();
		return false;
	}
	if(Trim(CEmail) == 0)
	{
		alert("Please enter the email");
		document.form1.email.select(); 
		document.form1.email.focus();
		return false;
	}
	else
	{
		var email1 = document.form1.email.value;
		var e3,e4;
		var err1 = new Array(0,0);
		e3 = email1.indexOf("@");
		e4 = email1.lastIndexOf("@");
		
		if(e3 != -1 && e3 == e4)
		{
			var a = email1.indexOf(".",e3);
			if((a-e3) < 2)
			err1[0] = 1;
		}
		else{	err1[0] = 1;		}
		
		if(err1[0] == 1)
		{
			alert("The email id you have entered is in an invalid format. Please check and re-enter again");
			document.form1.email.select();	
			document.form1.email.focus();
			return false;			
		}
	}
	
	if(Trim(CPhone) == 0)
	{
		alert("Please enter the phone");
		document.form1.phone.select(); 
		document.form1.phone.focus();
		return false;
	}
	
	if(Trim(CCustomic) == 0)
	{
		alert("Please enter your template requirements");
		document.form1.customic_content.select(); 
		document.form1.customic_content.focus();
		return false;
	}
	
	if(document.form1.captchaCode.value=="")
	{
		alert("Please enter the verification code in the box");
		document.form1.captchaCode.focus();
		return false;
	}
	
}
	
// Trims all spaces to the left of a specific string
function LTrim(str)
{
		var whitespace = new String(" \t\n\r "); 
		var s = new String(str);
		if (whitespace.indexOf(s.charAt(0)) != -1) {
			var j=0, i = s.length;
			while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
				j++;
			s = s.substring(j, i);
		}
		return s;
}
// Trims all spaces to the right of a specific string
function RTrim(str)
{
		var whitespace = new String(" \t\n\r "); 
		var s = new String(str);
		if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
			var i = s.length - 1;       // Get length of string
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
				i--;
			s = s.substring(0, i+1);
		}
		return s;
}
	
// Trims all spaces to the left and right of a specific string by calling RTim and LTrim
function Trim(str)
{
	return RTrim(LTrim(str));
}