//alert ("mahi here");
function errorbox(id,msg)
{
	errbox = document.getElementById(id);
	errbox.innerHTML ="";
	errbox.innerHTML = msg;
	errbox.style.display = "block";
}
function hideerrorbox(id)
{
	errbox = document.getElementById(id);
	errbox.innerHTML ="";
	errbox.style.display ="none";
}
function Trim(s)
{
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
	{
	s = s.substring(1,s.length);
	}
	// Remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
	{
		s = s.substring(0,s.length-1);
	}
	return s;
}
function number(value,length)
{
	chkl="0123456789-+ ";
	for(i=0;i<length;i++)
	{
		chl=value.charAt(i);
		rtn1=chkl.indexOf(chl);
		if(rtn1==-1)
		return false;
	}
	return true;
}
function formvalid()
{          
	if(Trim(document.form1.Name.value)=="" || Trim(document.form1.Name.value)=="Your Name")
	{
		errorbox("lblname","Enter Your Name");
		document.form1.Name.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblname");
	}
		
	if(Trim(document.form1.Address.value)=="" || Trim(document.form1.Address.value)=="Your Name")
	{
		errorbox("lblAddress","Enter Your Address");
		document.form1.Address.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblAddress");
	}	

	if(Trim(document.form1.Country.value)=="" || Trim(document.form1.Country.value)=="Your Name")
	{
		errorbox("lblCountry","Enter Your Country");
		document.form1.Country.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblCountry");
	}	

	if(Trim(document.form1.email.value)=="" || Trim(document.form1.email.value)=="Email")
	{
	//	alert ("hi");
		errorbox("lblmail","Enter Your Email");
		document.form1.email.focus();
		return false;
	}
	else
	{	
		hideerrorbox("lblmail");
		if (!evaluateEmail(document.form1.email.value))
		{	
			errorbox("lblmail","Invalid E-mail Address");
			document.form1.email.focus();
			return false;
		}
		else
		{
			hideerrorbox("lblmail");
		}
	}
		
	if(Trim(document.form1.cpacha.value)=="" || Trim(document.form1.cpacha.value)=="Verification Code")
	{
		errorbox("lblcode","Enter Code");
		document.form1.cpacha.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblcode");
	}		
	return true;
}
function formvalid2()
{          
	if(Trim(document.form2.Name.value)=="" || Trim(document.form2.Name.value)=="Your Name")
	{
		errorbox("lblname1","Enter Your Name");
		document.form2.Name.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblname1");
	}
		
	if(Trim(document.form2.Address.value)=="" || Trim(document.form2.Address.value)=="Your Name")
	{
		errorbox("lblAddress1","Enter Your Address");
		document.form2.Address.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblAddress1");
	}	

	if(Trim(document.form2.Country.value)=="" || Trim(document.form2.Country.value)=="Your Name")
	{
		errorbox("lblCountry1","Enter Your Country");
		document.form2.Country.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblCountry1");
	}	

	if(Trim(document.form2.email.value)=="" || Trim(document.form2.email.value)=="Email")
	{
	//	alert ("hi");
		errorbox("lblmail1","Enter Your Email");
		document.form2.email.focus();
		return false;
	}
	else
	{	
		hideerrorbox("lblmail1");
		if (!evaluateEmail(document.form2.email.value))
		{	
			errorbox("lblmail1","Invalid E-mail Address");
			document.form2.email.focus();
			return false;
		}
		else
		{
			hideerrorbox("lblmail1");
		}
	}
		
	if(Trim(document.form2.cpacha.value)=="" || Trim(document.form2.cpacha.value)=="Verification Code")
	{
		errorbox("lblcode1","Enter Code");
		document.form2.cpacha.focus();
		return false; 
	}
	else
	{
		hideerrorbox("lblcode1");
	}		
	return true;
}
function evaluateEmail(f)
{
	var value = f;
	if (value.length == 0)
	return true;
	var rx = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)*\.\w{2,8}$/;
	var matches = rx.exec(value);
	return (matches != null);
}


	 