function Validate()
{
	var LB='\n';
	var MsgHdr='Please Enter:'+LB+LB;
	var Msg='';
	
	var chk=false
	if(document.sponsor.contact_name.value=='') Msg+='Contact Name' +LB;
	if(document.sponsor.company_name.value=='') Msg+='Company Name' +LB;
	if(document.sponsor.address1.value=='') Msg+='Address #1' +LB;
	if(document.sponsor.city.value=='') Msg+='City' +LB;
	if(document.sponsor.state.value=='') Msg+='State' +LB;
	if(document.sponsor.zip.value=='') Msg+='Zip' +LB;
	if(document.sponsor.phone1.value=="" || document.sponsor.phone2.value=="" || document.sponsor.phone3.value=="") Msg+="Phone #" +LB;
	if(document.sponsor.email.value=='') Msg+='Email Address' +LB;
	if(document.sponsor.platinum.checked) chk=true;
	if(document.sponsor.gold.checked) chk=true;
	if(document.sponsor.silver.checked) chk=true;
	if(document.sponsor.bronze.checked) chk=true;
	if(!(chk))
		Msg+= LB+'Select at least one Sponsorship Type' +LB;

	//if(document.sponsor.sponsorship_type(0).checked==false && document.sponsor.sponsorship_type(1).checked==false && document.sponsor.sponsorship_type(2).checked==false && document.sponsor.sponsorship_type(3).checked==false) Msg+='Sponsorship Type' +LB;
	
	if(Msg.length>0)
	{
		alert(MsgHdr+Msg);
		return false;
	}
}

/*function checkmail(frm)
{
	if(frm.email.value!='')
	{
		var len1=frm.email.value
		var len2=len1.length
		if(len2 != 0)
		{
			mail=frm.email.value
			mailat=(mail.indexOf('@'))
			maildot=(mail.indexOf('.'))
			if(mailat=='-1'|| maildot=='-1')
			{
				alert('Invalid Email Address')
				frm.email.focus();
				frm.email.select();
				return false;
			}
		}
	}
}			*/

function isEmailValid(emailStr) {

/* alert(emailStr);
										/* The following pattern is used to check if the entered e-mail address
											 fits the user@domain format.  It also is used to separate the username
											 from the domain. */

var emailPat=/^(.+)@(.+)$/							 /* The following string represents the pattern for matching all special
											 characters.  We don't want to allow special characters in the address. 
											 These characters include ( ) < > @ , ; : \ " . [ ]    */

var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"				/* The following string represents the range of characters allowed in a 
											  username or domainname.  It really states which chars aren't allowed. */

var validChars="\[^\\s" + specialChars + "\]"					/* The following pattern applies if the "user" is a quoted string (in
											  which case, there are no rules about which characters are allowed
											  and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
											  is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")"							/* The following pattern applies for domains that are IP addresses,
										   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
										   e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/		/* The following string represents an atom (basically a series of
											 non-special characters.) */

var atom=validChars + '+'							/* The following string represents one word in the typical username.
											   For example, in john.doe@somewhere.com, john and doe are words.
											   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"                                    // The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$")			/* The following pattern describes the structure of a normal symbolic
											   domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")			/* Begin with pattern to simply break up user@domain into
											   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  
alert("Email address seems incorrect (check @ and .'s)")			/* Too many/few @'s or something; basically, this address doesn't
											   even fit the general mould of a valid e-mail address. */

document.sponsor.email.select();
return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The username doesn't seem to be valid.")
	document.sponsor.email.select();
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
  for (var i=1;i<=4;i++) {
    if (IPArray[i]>255) {
        alert("Destination IP address is invalid!")
		document.sponsor.email.select();
return false
    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
alert("The domain name doesn't seem to be valid.")
	document.sponsor.email.select();
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
	   document.sponsor.email.select();
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}


	function InitCaps(ref){
		if(ref.value!=''){
			name=ref.value;
			temp1=name.substring(0,1);
			if(name.length>1){
				temp2=name.substring(1);
				ref.value=temp1.toUpperCase()+temp2;
			}
			else{
			ref.value=temp1.toUpperCase();
			}
		}
	}

	function ZipF(valZip)
		{
			var valZip1=valZip.Zip.value.length
			if (!(valZip1==5))
			{
				valZip.Zip.focus()
			}
			else
			{
				valZip.Ext.focus()
			}
		}

		function ZipL(valZip,fw)
		{
			var valZip1=valZip.Ext.value.length
			if (!(valZip1==4))
			{
				valZip.Ext.focus()
			}
			else
			{
				if(fw=="true"){
					valZip.txtssn1.focus()
				}
				else{
					valZip.HomePhoneFirst.focus()
				}	
			}
	}

function fnIsFloat ( strValue )
{
	strRef =",-()[]1234567890";
	for (i=0; i < strValue.length; i++) 
	{
		chTemp = strValue.substring (i, i+1);
		if (strRef.indexOf (chTemp, 0)== -1)
		{  
			return (false);
		}
	}
return(true);
}

function validInt(frm)
{
	if(fnIsFloat(frm.zip.value) == false)
	{
           alert('Please enter numbers only ')
           frm.zip.focus()
           frm.zip.select()
	}
}
function ph1(Ref)
{
	var len1=Ref.phone1.value.length
	if (len1==3)
	{
		Ref.phone2.focus()
	}
}
function ph2(Ref)
{
	var len2=Ref.phone2.value.length
	if (len2==3)
	{
		Ref.phone3.focus()
	}
}
function ph3(Ref)
{
	if (fnIsFloat(Ref.phone1.value) == false || (Ref.phone1.value!="" && Ref.phone2.value=="" && Ref.phone3.value=="") || (Ref.phone1.value!="" && Ref.phone2.value!="" && Ref.phone3.value=="")||  (Ref.phone1.value=="" && Ref.phone2.value=="" && Ref.phone3.value!="") || (Ref.phone1.value=="" && Ref.phone2.value!="" && Ref.phone3.value!="") || (Ref.phone1.value=="" && Ref.phone2.value!="" && Ref.phone3.value=="") || (Ref.phone1.value!="" && Ref.phone2.value=="" && Ref.phone3.value!=""))
	{
		alert("Please enter a valid Phone Number")
		Ref.phone1.focus();
		Ref.phone1.select();
	}
}

function fx1(Ref)
{
	var len1=Ref.fax1.value.length
	if (len1==3)
	{
		Ref.fax2.focus()
	}
}
function fx2(Ref)
{
	var len2=Ref.fax2.value.length
	if (len2==3)
	{
		Ref.fax3.focus()
	}
}
function fx3(Ref)
{
	if (fnIsFloat(Ref.fax1.value) == false || (Ref.fax1.value!="" && Ref.fax2.value=="" && Ref.fax3.value=="") || (Ref.fax1.value!="" && Ref.fax2.value!="" && Ref.fax3.value=="")||  (Ref.fax1.value=="" && Ref.fax2.value=="" && Ref.fax3.value!="") || (Ref.fax1.value=="" && Ref.fax2.value!="" && Ref.fax3.value!="") || (Ref.fax1.value=="" && Ref.fax2.value!="" && Ref.fax3.value=="") || (Ref.fax1.value!="" && Ref.fax2.value=="" && Ref.fax3.value!=""))
	{
		alert("Please enter a valid Fax Number")
		Ref.fax1.focus();
		Ref.fax1.select();
	}
}


function RegValidation()
{
	var LB="\n";
	var MsgHdr="Please enter:"+LB+LB;
	var Msg='';

	if(document.reg.school.value=="") Msg+="School Name" +LB;
	if(document.reg.contact.value=="") Msg+="Contact Name" +LB;
	if(document.reg.county.value=="") Msg+="County" +LB;
	if(document.reg.email.value=="") Msg+="E-mail" +LB;
	if(document.reg.phone1.value=="" || document.reg.phone2.value=="" || document.reg.phone3.value=="") Msg+="Phone #" +LB;
	if(document.reg.grades.value=="") Msg+="Grades" +LB;
	if(document.reg.wish[0].checked==false && document.reg.wish[1].checked==false) Msg+="Our school plans to participate 2006 Numbers Bee competition" +LB+LB;
	
	if(Msg.length >0)
	{
		alert(MsgHdr+Msg);
		return false
	}
	
}



function RegValidation_02222004()
{
	var LB="\n";
	var MsgHdr="Please enter:"+LB+LB;
	var Msg='';

	if(document.reg.fname.value=="") Msg+="First Name" +LB;
	if(document.reg.lname.value=="") Msg+="Last Name" +LB;
	if(document.reg.job.value=="") Msg+="Job Title" +LB;
	if(document.reg.school.value=="") Msg+="School Name" +LB;
	if(document.reg.Address1.value=="") Msg+="Address #1" +LB;
	if(document.reg.city.value=="") Msg+="City" +LB;
	if(document.reg.state.value=="") Msg+="State" +LB;
	if(document.reg.zip.value=="") Msg+="Zip Code" +LB;
	if(document.reg.phone1.value=="" || document.reg.phone2.value=="" || document.reg.phone3.value=="") Msg+="Phone #" +LB;
	if(document.reg.email.value=="") Msg+="Email ID" +LB;
	if(document.reg.students(0).checked==false && document.reg.students(1).checked==false && document.reg.students(2).checked==false && document.reg.students(3).checked==false) Msg+='No. of Students' +LB+LB;
	if(document.reg.HowMany.value=="") Msg+="How many computers do you have in your School?" +LB+LB;
	if(document.reg.haveyou[0].checked==false && document.reg.haveyou[1].checked==false ) Msg+="Have you conducted Mathematical Matches in your School?" +LB+LB;
	if(document.reg.wish[0].checked==false && document.reg.wish[1].checked==false) Msg+="Do you wish to conduct Mathematical Matches in your School?" +LB+LB;
//	if(fnIsFloat(document.reg.zip.value == false)) Msg+='Numbers only in Zip Code' +LB+LB;
//	if(fnIsFloat(document.reg.phone1.value == false)) Msg+='Numbers only in Phone #' +LB+LB;
//	if(fnIsFloat(document.reg.fax1.value == false)) Msg+='Numbers only in Fax #' 
	
	if(Msg.length >0)
	{
		alert(MsgHdr+Msg);
		return false
	}
	
}

function EmailValid(emailStr) {
								 /* The following pattern is used to check if the entered e-mail address
											 fits the user@domain format.  It also is used to separate the username
											 from the domain. */

var emailPat=/^(.+)@(.+)$/							 /* The following string represents the pattern for matching all special
											 characters.  We don't want to allow special characters in the address. 
											 These characters include ( ) < > @ , ; : \ " . [ ]    */

var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"				/* The following string represents the range of characters allowed in a 
											  username or domainname.  It really states which chars aren't allowed. */

var validChars="\[^\\s" + specialChars + "\]"					/* The following pattern applies if the "user" is a quoted string (in
											  which case, there are no rules about which characters are allowed
											  and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
											  is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")"							/* The following pattern applies for domains that are IP addresses,
										   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
										   e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/		/* The following string represents an atom (basically a series of
											 non-special characters.) */

var atom=validChars + '+'							/* The following string represents one word in the typical username.
											   For example, in john.doe@somewhere.com, john and doe are words.
											   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"                                    // The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$")			/* The following pattern describes the structure of a normal symbolic
											   domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")			/* Begin with pattern to simply break up user@domain into
											   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  
alert("Enter a Valid E-mail")			/* Too many/few @'s or something; basically, this address doesn't
											   even fit the general mould of a valid e-mail address. */

document.reg.email.select();
return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The username doesn't seem to be valid.")
	document.reg.email.select();
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
  for (var i=1;i<=4;i++) {
    if (IPArray[i]>255) {
        alert("Destination IP address is invalid!")
		document.reg.email.select();
return false
    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
alert("The domain name doesn't seem to be valid.")
	document.reg.email.select();
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
	   document.reg.email.select();
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}


function prin()
{
	var newwindow;
	if(!newwindow || newwindow.closed)
	{
		newwindow=window.open("RegisterPrintForm.html","Flashwin","width=640,height=500,top=0,left=75,scrollbars=yes,maximize=yes,resizable=yes,menubar='yes'");
	}
}

function prin1()
{
	var newwindow;
	if(!newwindow || newwindow.closed)
	{
		newwindow=window.open("OnlinePrintForm.html","Flashwin","width=640,height=470,top=0,left=75,scrollbars=yes,maximize=yes,resizable=yes,menubar='yes'");
	}
}

function ph1(Ref)
{
	var len1=Ref.phone1.value.length
	if (len1==3)
	{
		Ref.phone2.focus()
	}
}
function ph2(Ref)
{
	var len2=Ref.phone2.value.length
	if (len2==3)
	{
		Ref.phone3.focus()
	}
}
function ph3(Ref)
{
	if (fnIsFloat(Ref.phone1.value) == false || (Ref.phone1.value!="" && Ref.phone2.value=="" && Ref.phone3.value=="") || (Ref.phone1.value!="" && Ref.phone2.value!="" && Ref.phone3.value=="")||  (Ref.phone1.value=="" && Ref.phone2.value=="" && Ref.phone3.value!="") || (Ref.phone1.value=="" && Ref.phone2.value!="" && Ref.phone3.value!="") || (Ref.phone1.value=="" && Ref.phone2.value!="" && Ref.phone3.value=="") || (Ref.phone1.value!="" && Ref.phone2.value=="" && Ref.phone3.value!=""))
	{
		alert("Please enter a valid Phone Number")
		Ref.phone1.focus();
		Ref.phone1.select();
	}
}

function fx1(Ref)
{
	var len1=Ref.fax1.value.length
	if (len1==3)
	{
		Ref.fax2.focus()
	}
}
function fx2(Ref)
{
	var len2=Ref.fax2.value.length
	if (len2==3)
	{
		Ref.fax3.focus()
	}
}
function fx3(Ref)
{
	if (fnIsFloat(Ref.fax1.value) == false || (Ref.fax1.value!="" && Ref.fax2.value=="" && Ref.fax3.value=="") || (Ref.fax1.value!="" && Ref.fax2.value!="" && Ref.fax3.value=="")||  (Ref.fax1.value=="" && Ref.fax2.value=="" && Ref.fax3.value!="") || (Ref.fax1.value=="" && Ref.fax2.value!="" && Ref.fax3.value!="") || (Ref.fax1.value=="" && Ref.fax2.value!="" && Ref.fax3.value=="") || (Ref.fax1.value!="" && Ref.fax2.value=="" && Ref.fax3.value!=""))
	{
		alert("Please enter a valid Fax Number")
		Ref.fax1.focus();
		Ref.fax1.select();
	}
}

function fnIsFloat ( strValue )
{
	strRef ="1234567890";
	for (i=0; i < strValue.length; i++) 
	{
		chTemp = strValue.substring (i, i+1);
		if (strRef.indexOf (chTemp, 0)== -1)
		{  
			return (false);
		}
	}
return(true);
}

function validZip(frm)
{
	if(fnIsFloat(frm.zip.value) == false)
	{
           alert('Please enter numbers only ')
           frm.zip.focus()
           frm.zip.select()
	}
}

function validStudent(frm)
{
	if(fnIsFloat(frm.HowMany.value) == false)
	{
           alert('Please enter numbers only ')
           frm.HowMany.focus()
           frm.HowMany.select()
	}
}

function InitCaps(ref)
{
	if(ref.value!='')
	{
		name=ref.value;
		temp1=name.substring(0,1);
		if(name.length>1)
		{
			temp2=name.substring(1);
			ref.value=temp1.toUpperCase()+temp2;
		}
		else{
		ref.value=temp1.toUpperCase();
		}
	}
}
function isEmpty(aTextField)
{
			alert(aTextField.fname.substring(0,1)); 
} 

function OnlineReg(frm)
{
	var LB="\n";
	var MsgHdr="Please enter:"+LB+LB;
	var Msg='';

	if(document.reg.name.value=="") Msg+="Name" +LB;
	if(document.reg.email.value=="") Msg+="Email ID" +LB;
	if(document.reg.school.value=="") Msg+="School Name" +LB;
	if(Msg.length >0)
	{
		alert(MsgHdr+Msg);
		return false
	}
	
}