// JavaScript Document
function checkEmail(formelement,text)	
{
	if(formelement.value!='')
	{
		var b=formelement.value.indexOf('@');
		var c=formelement.value.indexOf('.');
		var d=c-b;
		var len=formelement.value.length;
		if((d==0)||(c==-1)||(b==-1)||(d==1)||((len-c)==1))
		{
			alert("Enter a valid "+text);
			formelement.focus();
			return false;
		}
		else
		{
		return true;
		}
	}
}

function checkBlank(formelement,text)
{
	if(formelement.value=='')
	{
  alert('Enter '+text);
  formelement.focus();
	return false;
  }
	else
	{
	return true;
	}
}


function checkSpecialChar2(formelement,text)	
{

	var msg='true';
	var a=formelement.value;
	var b=a.length;
	var cha='*~!@#$%^&()+-[]{}/|;:<>?';
	var ch=cha.length;
	var i,j;
	for(i=0;i<ch;i++)
	{
	var ch1=cha.substring(i,i+1);
		for(j=0;j<b;j++)
		{
			var a1=a.substring(j,j+1);
			if(a1==ch1)
			{
			msg='Special Characters are not allowed in '+text;
			alert(msg);	
			formelement.focus();
			return false;
		}
	}

}
	if (msg=='true')
	{
	return true;
	}
}

function checkLessLen(formelement,text,len)
{
	if(formelement.value.length<parseInt(len))
	{
		alert('The '+text+' should not be less than '+len+' characters');
		formelement.focus();
		return false;
	}
	else
	{
		return true;
	}
}
function checkNaN(formelement,text)
{
	if (isNaN(formelement.value))
	{
  alert('Enter Numeric '+text);
  formelement.focus();
	return false;
  }
	else
	{
	return true;
	}
}

function req_validate() {
		if(!checkBlank(document.frmreq.First_Name,'First Name')) return false;
		if(!checkSpecialChar2(document.frmreq.First_Name,'First Name')) return false;
		if(!checkBlank(document.frmreq.Last_Name,'Last Name')) return false;
		if(!checkSpecialChar2(document.frmreq.Last_Name,'Last Name')) return false;
		if(!checkBlank(document.frmreq.Email,'Email')) return false;
		if(!checkBlank(document.frmreq.Email_confirm,'Confirm Email')) return false;
		//if(!checkLessLen(document.frmreq.lname,'User Id',4)) return false;
		if(!checkEmail(document.frmreq.Email,'Email')) return false;
		if(!checkEmail(document.frmreq.Email_confirm,'Confirm Email')) return false;
		if (document.frmreq.Email.value != document.frmreq.Email_confirm.value) {
			alert("Email & Confirm Email should be same.");
			return false;
		}
		if(!checkBlank(document.frmreq.Country,'Country')) return false;
		//if(!checkBlank(document.frmreq.address,'Address')) return false;
		if(!checkBlank(document.frmreq.City,'City')) return false;
		//if(!checkBlank(document.frmreq.State,'State')) return false;
		if(!checkBlank(document.frmreq.Phone,'Phone no.')) return false;
		if(!checkNaN(document.frmreq.Phone,'Phone no.')) return false;
		if(!checkBlank(document.frmreq.Cell,'Cell No.')) return false;
		if(!checkNaN(document.frmreq.Cell,'Cell No.')) return false;
		if(!checkBlank(document.frmreq.BestTime,' Best Time to Call')) return false;
		if(!checkBlank(document.frmreq.Capital,' Capital to Invest')) return false;
		if(!checkBlank(document.frmreq.Timeframe,'Investment Timeframe')) return false;
		if(!checkBlank(document.frmreq.Franchise_Location,'Franchise Location')) return false;
		if (document.frmreq.agree.checked==false) { 
		alert("Please accept 'I certify that..'.");
		return false; }
}