function blank()
{
	var emailID=document.forminfo.email
	var listCheck = document.forminfo.category.selectedIndex;
	var urlregex = new RegExp("^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&amp;%\$#\=~_\-]+))*$");
	var str = document.forminfo.t1.value;
	var str1 = document.forminfo.t3.value;
	var attach = new String("www.")
	if(str1.substring(0,4)!="www.")
		{
			attach = attach.concat(str1);
			str1=attach;
		}
	else
		{str1=str1;}

if (document.forminfo.t1.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	document.forminfo.t1.focus();
	return false;}
else if (URLcheck(str)==false)
{
		document.forminfo.t1.focus();
		return false;
}
else if (document.forminfo.t2.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	document.forminfo.t2.focus();
	return false;}
else if (document.forminfo.textarea.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	document.forminfo.textarea.focus();
	return false;}
else if (document.forminfo.t3.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	document.forminfo.t3.focus();
	return false;}

else if (str.substring(0,8) !=  str1.substring(0,8))
{
	alert("Domain Of Both URL's Should be Same");
	document.forminfo.t3.focus();
	return(false);
}
else if (document.forminfo.category.options[listCheck].value=="none")
{
alert("select a category");
document.forminfo.category.focus();
return false;
}
else if (document.forminfo.name.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	document.forminfo.name.focus();
	return false;}
else if ((emailID.value==null)||(emailID.value==""))
{
		alert("Please Enter your Email ID")
		emailID.focus();
		return false;
}
else if (echeck(emailID.value)==false)
{
		emailID.focus();
		return false;
}

else if((document.forminfo.radiobutton[0].checked==false) && (document.forminfo.radiobutton[1].checked==false) && (document.forminfo.radiobutton[2].checked==false))
{
		alert("Please select a Other Info");
		return false;
}

else if(document.getElementById("radiobutton").checked==true)
{

		var listCheck1 = document.forminfo.select.selectedIndex;
		if (document.forminfo.select.options[listCheck1].value=="none")
		{
		alert("select a search engine");
		document.forminfo.select.focus();
		return false;
		}


}
else if(document.getElementById("radiobutton1").checked==true)
{
		var info=document.forminfo.special.value;

		if (document.forminfo.special.value == "" || URLcheck(info)==false)
		{
		alert("Invalid Site Name");
		document.forminfo.special.focus();
		return false;
		}

}


else
	{return true;}


}


function RemoveText()
		{
				if(document.forminfo.special.value=="Site Name")
				{
				document.forminfo.special.value="";
				document.forminfo.special.focus();
				}
				else
				{
				document.forminfo.special.focus();
				}


		}


function show()
{
	spanStyle=document.getElementById("1").style
	spanStyleCombo=document.getElementById("2").style

if(document.getElementById("radiobutton1").checked==true)
{
	if(spanStyle.display=="none")
	{
		spanStyle.display=""
		spanStyleCombo.display="none"
	}
	else
	{
		spanStyle.display="none"
	}
}

if(document.getElementById("radiobutton").checked==true)
{
	if(spanStyleCombo.display=="none")
	{
		spanStyleCombo.display=""
		spanStyle.display="none"

	}
	else
	{
		spanStyleCombo.display="none"
	}
}

if(document.getElementById("radiobutton2").checked==true)
{

		spanStyleCombo.display="none"
		spanStyle.display="none"
}
}


function echeck(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 || str.indexOf("!")!=-1 || str.indexOf("?")!=-1 || str.indexOf("$")!=-1 || str.indexOf("^")!=-1 || str.indexOf("*")!=-1 || str.indexOf("{")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true
	}

function URLcheck(str) {


		var dot="."
		var lstr=str.length
		var ldot=str.indexOf(dot)
		StopPos= str.lastIndexOf(".")
		sublen=str.substring(StopPos+1,lstr)
		domlen=str.substring(ldot+1,StopPos)
		//document.write(domlen);


       if(str.substring(0,4)!="www.")
			{
				alert("www. is must");
				return false

			}
		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid URL")
		    return false
		}

		else if (sublen.length>4 || domlen.length<3){
				    alert("Invalid URL")
				    return false
		 }
		else if (str.indexOf("/")!=-1){
					alert("Invalid URL: '/' is not allowed in the Domain Name")
					return false
		 }

	 	else  if (str.indexOf(" ")!=-1 || str.indexOf("!")!=-1 || str.indexOf("@")!=-1 || str.indexOf("$")!=-1 || str.indexOf("^")!=-1 || str.indexOf("*")!=-1 || str.indexOf("{")!=-1){
		    alert("Invalid URL: Special Character are not allowed")
		    return false
		 }

 		 return true
	}
//=============================================================== ORDER NOW VALIDATIONS

function verifyvalues()
{	
	
	
	var ClearValidation
	var SetForm=document.forminfo
	if(blank1() && emailCheck(document.forminfo.email.value))	
	{
		ClearValidation=2;	
	}	
	else
	{
		return false;
	}
	
	Frname = new String(SetForm.fname.value);
	Ltname = new String(SetForm.lname.value);
	Coname = new String(SetForm.cname.value);
	EmailAd = new String(SetForm.email.value);
	Tele = new String(SetForm.tel.value);
	PoM = new String(SetForm.PO.value);
	Loc = new String(SetForm.location.value);
	FrmOthr = new String(SetForm.fromother.value);
	ToVer = new String(SetForm.toversion.value);
	ToOthr = new String(SetForm.toother.value);
	SplI = new String(SetForm.special.value);
	SndTo = new String(SetForm.sendto.value);

	Frname= Frname.replace(/'/g,"''");
	Ltname = Ltname.replace(/'/g,"''");
	Coname = Coname.replace(/'/g,"''");
	EmailAd = EmailAd.replace(/'/g,"''");
	Tele = Tele.replace(/'/g,"''");
	PoM = PoM.replace(/'/g,"''");
	Loc = Loc.replace(/'/g,"''");
	FrmOthr = FrmOthr.replace(/'/g,"''");
	ToVer=ToVer.replace(/'/g,"''");
	ToOthr=ToOthr.replace(/'/g,"''");
	SplI=SplI.replace(/'/g,"''");
	SndTo=SndTo.replace(/'/g,"''");

	SetForm.fname.value=Frname
	SetForm.lname.value=Ltname
	SetForm.cname.value=Coname
	SetForm.email.value=EmailAd
	SetForm.tel.value=Tele
	SetForm.PO.value=PoM
	SetForm.location.value=Loc
	SetForm.fromother.value=FrmOthr
	SetForm.toversion.value=ToVer
	SetForm.toother.value=ToOthr
	SetForm.special.value=SplI
	SetForm.sendto.value=SndTo

	if (ClearValidation==2)
	{
		return true;
	}
	return false;
	

}

function PopulateDays()
{
	
	var Yearing,Monthing,NOofDays,Counter
	Yearing=parseInt(forminfo.yyyy.value)
	Monthing=parseInt(forminfo.mm.value)
	forminfo.dd.length=0
	if(Monthing==0 || Monthing==2  || Monthing==4 || Monthing==6 || Monthing==7 || Monthing==9 || Monthing==11)
	{
		NOofDays=31;	
		
	}
	else if(Monthing==1)
	{
		if (((Yearing)>0) && !((Yearing)%4) && ( ((Yearing)%100) || !((Yearing)%400)))
		{
			NOofDays=29;		
		}
		else
		{
			NOofDays=28;
		}
		
	}
	else if(Monthing==3 || Monthing==5 || Monthing==8 || Monthing==10)
	{
		
		NOofDays=30;
	}
	for(Counter=1;Counter<=NOofDays;Counter++)
	{	 
		forminfo.dd.options[Counter-1]=new Option(Counter,Counter)
	}
	return true;	
}

function blank1() 
{
	var iChars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?";
	var a;
if (forminfo.cdate.value == "")
{
alert("This entry must be completed before you can submit this form for processing.");
forminfo.cdate.focus();
	return false;}
else if (forminfo.fname.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	forminfo.fname.focus();
	return false;
}
else if(checkspecial(forminfo.fname.value))
{
	alert ("Special characters are not allowed.");
	forminfo.fname.focus();
	return false;
}
else if (forminfo.lname.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	forminfo.lname.focus();
	return false;}
else if(checkspecial(forminfo.lname.value))
{
	alert ("Special characters are not allowed.");
	forminfo.lname.focus();
	return false;
}
else if (forminfo.cname.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	forminfo.cname.focus();
	return false;}
else if(checkspecial(forminfo.cname.value))
{
	alert ("Special characters are not allowed.");
	forminfo.cname.focus();
	return false;
}
else if (forminfo.email.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	forminfo.email.focus();
	return false;}
else if (forminfo.tel.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	forminfo.tel.focus();
	return false;}
else if(checkspecial(forminfo.tel.value))
{
	alert ("Special characters are not allowed.");
	forminfo.tel.focus();
	return false;
}
else if(checkspecial(forminfo.PO.value))
{
	alert ("Special characters are not allowed.");
	forminfo.PO.focus();
	return false;
}
else if(checkspecial(forminfo.location.value))
{
	alert ("Special characters are not allowed.");
	forminfo.location.focus();
	return false;
}
else if (forminfo.country.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	forminfo.country.focus();
	return false;}
else if(checkspecial(forminfo.fromother.value))
{
	alert ("Special characters are not allowed.");
	forminfo.fromother.focus();
	return false;
}
else if(checkspecial(forminfo.toother.value))
{
	alert ("Special characters are not allowed.");
	forminfo.toother.focus();
	return false;
}
else if(checkspecial(forminfo.toversion.value))
{
	alert ("Special characters are not allowed.");
	forminfo.toversion.focus();
	return false;
}	
else if(checkspecial(forminfo.special.value))
{
	alert ("Special characters are not allowed.");
	forminfo.special.focus();
	return false;
}
else if (forminfo.sendto.value == "")
{
	alert("This entry must be completed before you can submit this form for processing.");
	forminfo.sendto.focus();
	return false;}
else if(checkspecial(forminfo.sendto.value))
{
	alert ("Special characters are not allowed.");
	forminfo.sendto.focus();
	return false;
}

else if (forminfo.verifycode.value =="")
{
	alert("This entry must be completed before you can submit this form for processing Verify code field.");
	forminfo.verifycode.focus();
	return false;}
else if(checkspecial(forminfo.verifycode.value))
{
	alert ("Special characters are not allowed.");
	forminfo.verifycode.focus();
	return false;
}
else if (forminfo.verifycode.value != forminfo.strRnd.value)
{
	alert("Enter verify code Number.");
	forminfo.verifycode.focus();
	return false;}
	
else 
	{return true;}
}
function emailCheck (emailStr) 
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) 
{
alert("Email address seems incorrect (check @ and .'s)");
document.forminfo.email.focus();
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) 
{
if (user.charCodeAt(i)>127) 
{
alert("Ths username contains invalid characters.");
document.forminfo.email.focus();
return false;   
}
}
for (i=0; i<domain.length; i++) 
{
if (domain.charCodeAt(i)>127) 
{
alert("Ths domain name contains invalid characters.");
document.forminfo.email.focus();
return false;   
}
}
if (user.match(userPat)==null) 
{
alert("The username doesn't seem to be valid.");
document.forminfo.email.focus();
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) 
{
for (var i=1;i<=4;i++) 
{
if (IPArray[i]>255) 
{
alert("Destination IP address is invalid!");
document.forminfo.email.focus();return false;   
}
}
return true;
}
 var atomPat=new RegExp("^" + atom + "$");
 var domArr=domain.split(".");
 var len=domArr.length;
 for (i=0;i<len;i++) 
 {
 if (domArr[i].search(atomPat)==-1) 
 {
 alert("The domain name does not seem to be valid.");
 document.forminfo.email.focus();
 return false;   
 }
 }
 if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
 {
 alert("The address must end in a well-known domain or two letter " + "country.");
 document.forminfo.email.focus();
 return false;
 }
 if (len<2) 
 {
 alert("This address is missing a hostname!");
 document.forminfo.email.focus();
 return false;
 }
 return true;
 }
 function filterNum(str) 
 {
 re = /^\$|,/g;// remove ","return str.replace(re, "");
 }
 function resetvalues()
 {
 	document.forminfo.fname.value="";
	document.forminfo.lname.value="";
	document.forminfo.cname.value="";
	document.forminfo.email.value="";
	document.forminfo.tel.value="";
	document.forminfo.location.value="";
	document.forminfo.country.value="";
	document.forminfo.sendto.value="";
	document.forminfo.verifycode.value="";
	//document.forminfo.state.value="";
	//document.forminfo.zip.value="";
	//document.forminfo.country.value="";
	//document.forminfo.verifycode.value="";
	//alert("blank"); 
			
 }
 
function checkspecial(checkfield)
{
 	var iChars = "!$%^&()[]\\\';,/{}|\":<>?";
	for (var i = 0; i < checkfield.length; i++)
	{
		if (iChars.indexOf(checkfield.charAt(i)) != -1)
		{
			//alert("yes")
			return true;
		}			
	}					
}
