


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validContact      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function validContact() {

	if (isWhitespace(document.frmContactUs.fname.value)) 
	{
	     alert("Please enter First Name");
	     document.frmContactUs.fname.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.lname.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmContactUs.lname.focus();
	     return false;
	}  

	if (isWhitespace(document.frmContactUs.address.value)) 
	{
	     alert("Please enter Address ");
	     document.frmContactUs.address.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.city.value)) 
	{
	     alert("Please enter City");
	     document.frmContactUs.city.focus();
	     return false;
	}  
	if ( (document.frmContactUs.state.options[document.frmContactUs.state.options.selectedIndex].value)=="0")
	{
	     alert("Please enter State");
	     document.frmContactUs.state.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.zip.value)) 
	{
	     alert("Please enter Zip");
	     document.frmContactUs.zip.focus();
	     return false;
	}  
	 if (validateZIP(document.frmContactUs.zip)==false) {
				document.frmContactUs.zip.focus();
				return false;
	} 
	
	if (!check3Phone( 'phone1', 'phone2', 'phone3', true )) return false;
	if (!check3Phone( 'fax1', 'fax2', 'fax3', false )) return false;
	
	
	if (isWhitespace(document.frmContactUs.email.value)) 
	{
	     alert("Please enter email ");
	     document.frmContactUs.email.focus();
	     return false;
	}  
	if (document.frmContactUs.email.value.length>0){ 
	var myEmail = NonSpace(document.frmContactUs.email.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmContactUs.email.focus();
			return false;
	}  
	}			

	if (isWhitespace(document.frmContactUs.comments.value)) 
	{
	     alert("Please enter Message ");
	     document.frmContactUs.comments.focus();
	     return false;
	}  
	 
	 return true;
}







//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validBilling      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function validBilling() {

	if (isWhitespace(document.myform.BilFirstName.value)) 
	{
	     alert("Please enter First Name");
	     document.myform.BilFirstName.focus();
	     return false;
	}  	
	if (isWhitespace(document.myform.BilLastName.value)) 
	{
	     alert("Please enter Last Name");
	     document.myform.BilLastName.focus();
	     return false;
	}  

	if (isWhitespace(document.myform.BilAddress.value)) 
	{
	     alert("Please enter Address ");
	     document.myform.BilAddress.focus();
	     return false;
	}  
	if (isWhitespace(document.myform.BilCity.value)) 
	{
	     alert("Please enter City");
	     document.myform.BilCity.focus();
	     return false;
	}  
	
	if ( (document.myform.BilState.options[document.myform.BilState.options.selectedIndex].value)=="0")
	{
	     alert("Please select State");
	     document.myform.BilState.focus();
	     return false;
	} 
	
	if ( (document.myform.BilCountry.options[document.myform.BilCountry.options.selectedIndex].value)=="0")
	{
	     alert("Please select Country");
	     document.myform.BilCountry.focus();
	     return false;
	} 
	 
	if (isWhitespace(document.myform.BilZip.value)) 
	{
	     alert("Please enter Zip");
	     document.myform.BilZip.focus();
	     return false;
	}  
	 if (validateZIP(document.myform.BilZip)==false) {
				document.myform.BilZip.focus();
				return false;
	} 
	
	if (!check3Phone( 'phone1', 'phone2', 'phone3', true )) return false;
	
	if (isWhitespace(document.myform.BilEmail.value)) 
	{
	     alert("Please enter email ");
	     document.myform.BilEmail.focus();
	     return false;
	}  
	
	if (document.myform.BilEmail.value.length>0){ 
	var myEmail = NonSpace(document.myform.BilEmail.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.BilEmail.focus();
			return false;
	}  
	}			


	 return true;
}




//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidEmail      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidEmail() {
	if (isWhitespace(document.myform.email.value)) 
	{
	     alert("Please enter Email ! ");
	     document.myform.email.focus();
	     return false;
	} 
	if (document.myform.email.value.length>0){ 
	var myEmail = NonSpace(document.myform.email.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.email.focus();
			return false;
	}  
	}		
	if (document.myform.email.value.length>0){ 
		document.myform.email.value = NonSpace(document.myform.email.value);
		myext = getEmail(document.myform.email.value);
		if (myext=="aol.com"){ 
				alert("Texans Can sincerely appreciates your interest in our Academy.\n\n Due to high turnover of Aol accounts, \n we would appreciate your entering another email address.");
			document.myform.email.focus();
			return false;
		}	
	}	
	document.myform.action ="e_newsletter.asp";
	document.myform.submit();
	return true;
}



//--------------------------CarInfoFrm-------------------------------------------------------------

function validateCarInfoFrm(myform) {
			
		var oForm = document.forms.CarInfoFrm;
			
		if (oForm.first.value.replace( / /g, "") == "")
		{
			alert("Please enter First Name !");
			oForm.first.focus();
			return false;
		}  
		if (oForm.last.value.replace( / /g, "") == "")
		{
			alert("Please enter Last Name !");
			oForm.last.focus();
			return false;
		}  
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please enter Email !");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
		if(oForm.Address.value.replace( / /g, "") == ""){
			alert("Please fill the Address field !");
			oForm.Address.focus();
			return false;
		}
		if(oForm.City.value.replace( / /g, "") == ""){
			alert("Please fill the City field !");
			oForm.City.focus();
			return false;
		}
		if(oForm.donorState.value.length<1){
			alert("Please select State !");
			oForm.donorState.focus();
			return false;
		}
		if(oForm.Zip.value==""){
			alert("Please fill the Zip field !");
			oForm.Zip.focus();
			return false;
		}
		if (!validZIP(oForm.Zip.value)) {
			oForm.Zip.focus();
			return false;
		}
		
		if (!check3Phone( 'Hphone1', 'Hphone2', 'Hphone3', false )) return false;
		if (!check3Phone( 'Wphone1', 'Wphone2', 'Wphone3', false )) return false;
		if ((oForm.Hphone1.value=="") && (oForm.Wphone1.value=="")){
			alert("Please provide at least one phone number!");
			oForm.Wphone1.focus();
			return false;
		}
		
		if ((oForm.SameD.checked) == false) {
		if (oForm.CarZip.value != "" && !validZIP(oForm.CarZip.value)) {
			oForm.CarZip.focus();
			return false;
		}
		}
		
		if(oForm.Make.value.length<1){
			alert("Please select Car Make !");
			oForm.Make.focus();
			return false;
		}
		if(oForm.Model && oForm.Model.value.length<1){
			alert("Please select Car Model field !");
			oForm.Model.focus();
			return false;
		}
		if(oForm.CarYear.value==""){
			alert("Please fill the Car Year field !");
			oForm.CarYear.focus();
			return false;
		}
		if (oForm.CarYear.value !="" && !checkYear(oForm.CarYear) ){
			oForm.CarYear.focus();
			return false;
		}
		crtDate = new Date();
		if (oForm.CarYear.value.length>0){ 
		if ((oForm.CarYear.value < 1950 )||(crtDate.getFullYear() < oForm.CarYear.value)) {
			    alert("Please provide a valid Year!");
				return false;
			}				
		}	
		if(oForm.CarColor.value.length<1){
		    alert("Please provide the Car Color!");
			oForm.CarColor.focus();
			return false;
		}
	return true;
}	
 


//-------------------------- Short CarInfoFrm -------------------------------------------------------------

function validateShortCarInfoFrm(myform) {
			
		var oForm = document.forms.CarInfoFrm;
			
		if (oForm.first.value.replace( / /g, "") == "")
		{
			alert("Please enter First Name !");
			oForm.first.focus();
			return false;
		}  
		if (oForm.last.value.replace( / /g, "") == "")
		{
			alert("Please enter Last Name !");
			oForm.last.focus();
			return false;
		}  
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please enter Email !");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
				
		if (!check3Phone( 'Hphone1', 'Hphone2', 'Hphone3', false )) return false;
		if (!check3Phone( 'Wphone1', 'Wphone2', 'Wphone3', false )) return false;
		if ((oForm.Hphone1.value=="") && (oForm.Wphone1.value=="")){
			alert("Please provide at least one phone number!");
			oForm.Wphone1.focus();
			return false;
		}
		
		if(oForm.Make.value.length<1){
			alert("Please select Car Make !");
			oForm.Make.focus();
			return false;
		}
		if(oForm.Model && oForm.Model.value.length<1){
			alert("Please select Car Model field !");
			oForm.Model.focus();
			return false;
		}
		if(oForm.CarYear.value==""){
			alert("Please fill the Car Year field !");
			oForm.CarYear.focus();
			return false;
		}
		if (oForm.CarYear.value !="" && !checkYear(oForm.CarYear) ){
			oForm.CarYear.focus();
			return false;
		}
		crtDate = new Date();
		if (oForm.CarYear.value.length>0){ 
		if ((oForm.CarYear.value < 1950 )||(crtDate.getFullYear() < oForm.CarYear.value)) {
			    alert("Please provide a valid Year!");
			    oForm.CarYear.focus();
				return false;
			}				
		}	
		
		if(oForm.CarZip.value==""){
			alert("Please fill the ZIP code of Pickup Location field !");
			oForm.CarZip.focus();
			return false;
		}
		if (!validZIP(oForm.CarZip.value)) {
			oForm.CarZip.focus();
			return false;
		}
		
	return true;
}	
 

//-------------------------- Quick Form Set up -------------------------------------------------------------

function setQuickFrm() {
			
		var oForm = document.forms.QuickFrm;
		
		if (oForm.VehicleType[0].checked)
		{
			openSection("divCarSection", true);
			openSection("divBoatSection", false);
			openSection("divMiscSection", false);
		}
		else if (oForm.VehicleType[1].checked)
		{
			openSection("divCarSection", false);
			openSection("divBoatSection", true);
			openSection("divMiscSection", false);
		}
		else if (oForm.VehicleType[2].checked)
		{
			openSection("divCarSection", false);
			openSection("divBoatSection", false);
			openSection("divMiscSection", true);
		}
}


//-------------------------- Quick Form Validation -------------------------------------------------------------

function validateQuickFrm() {
			
		var oForm = document.forms.QuickFrm;
			
		if (oForm.first.value.replace( / /g, "") == "")
		{
			alert("Please enter First Name !");
			oForm.first.focus();
			return false;
		}  
	 
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please enter Email !");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
	
	
		if (oForm.VehicleType[0].checked)
		{
			oForm.action = "short_car_form.asp#info"
			
			if(oForm.Make && oForm.Make.value.length<1){
			alert("Please select Car Make !");
			oForm.Make.focus();
			return false;
		}
		if(oForm.CarYear.value==""){
			alert("Please fill the Car Year field !");
			oForm.CarYear.focus();
			return false;
		}
		if (oForm.CarYear.value !="" && !checkYear(oForm.CarYear) ){
			oForm.CarYear.focus();
			return false;
		}
		crtDate = new Date();
		if (oForm.CarYear.value.length>0){ 
		if ((oForm.CarYear.value < 1950 )||(crtDate.getFullYear() < oForm.CarYear.value)) {
			    alert("Please provide a valid Year!");
			    oForm.CarYear.focus();
				return false;
			}				
		}	
		}
		else if (oForm.VehicleType[1].checked)
		{
			oForm.action = "boat_form.asp#info"
		
			if(oForm.BTName && oForm.BTName.value.length<1){
				alert("Please select Boat Make !");
				oForm.BTName.focus();
				return false;
			}
			if(oForm.BTYear.value==""){
				alert("Please fill the Boat Year field !");
				oForm.BTYear.focus();
				return false;
			}
			if (oForm.BTYear.value !="" && !checkYear(oForm.BTYear) ){
				oForm.BTYear.focus();
				return false;
			}
			crtDate = new Date();
			if (oForm.BTYear.value.length>0){ 
			if ((oForm.BTYear.value < 1950 )||(crtDate.getFullYear() < oForm.BTYear.value)) {
					alert("Please provide a valid Year!");
					oForm.BTYear.focus();
					return false;
				}
			}
		}
		else if (oForm.VehicleType[2].checked)
		{
			oForm.action = "misc_form.asp#info"
			
			if (oForm.MiscItem.value.replace( / /g, "") == "")
			{
				alert("Please fill the Name of Item(s)!");
				oForm.MiscItem.focus();
				return false;
			}  	
		}
		
	return true;
}	
  
 
//-------------------------- Misc Donation Form -------------------------------------------------------------

function validateMiscDonatationFrm(myform) {
			
		var oForm = document.forms.MiscInfoFrm;
			
		if (oForm.first.value.replace( / /g, "") == "")
		{
			alert("Please fill in the First Name!");
			oForm.first.focus();
			return false;
		}  
		if (oForm.last.value.replace( / /g, "") == "")
		{
			alert("Please fill in the Last Name!");
			oForm.last.focus();
			return false;
		}  
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please fill in the Email!");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
		
		if(oForm.Address.value=="" || oForm.Address.value.replace( / /g, "")=="" || isWhitespace(oForm.Address.value) ){
			alert("Please fill in the Address!");
			oForm.Address.focus();
			return false;
		}
		
		if(oForm.City.value=="" || oForm.City.value.replace( / /g, "")=="" || isWhitespace(oForm.City.value) ){
			alert("Please fill in the City!");
			oForm.City.focus();
			return false;
		}
		
		if(oForm.donorState.value.length<1){
			alert("Please select the State!");
			oForm.donorState.focus();
			return false;
		}
		
		
		
		if(oForm.Zip.value=="" || oForm.Zip.value.replace( / /g, "")=="" || isWhitespace(oForm.Zip.value) ){
			alert("Please fill in the Zip!");
			oForm.Zip.focus();
			return false;
		}
		
		if (!isWhitespace(oForm.Zip.value) && !validZIP(oForm.Zip.value)) {
			oForm.Zip.focus();
			return false;
		}
				
		if (!check3Phone( 'Hphone1', 'Hphone2', 'Hphone3', false )) return false;
		if (!check3Phone( 'Wphone1', 'Wphone2', 'Wphone3', false )) return false;
		if ((oForm.Hphone1.value=="") && (oForm.Wphone1.value=="")){
			alert("Please provide at least one phone number!");
			oForm.Wphone1.focus();
			return false;
		}
		
		
		if (!isWhitespace(oForm.MiscZip.value) && !validZIP(oForm.MiscZip.value)) {
			oForm.MiscZip.focus();
			return false;
		}
		
		if(oForm.MiscItem.value=="" || oForm.MiscItem.value.replace( / /g, "")=="" || isWhitespace(oForm.MiscItem.value) ){
			alert("Please fill in the Name of Item(s)!");
			oForm.MiscItem.focus();
			return false;
		}
					
		
		
	return true;
}	

 
// Format Currency 
function autoNumber(CtrlID) 
{			
	var oCtrl = eval("document.forms.donationForm." + CtrlID);
	if(oCtrl){
		if(oCtrl.value.length > 0){
			oCtrl.value = oCtrl.value.replace(/-/,"");
		}
		
		var num = new NumberFormat();
		num.setInputDecimal('.');
		num.setNumber(oCtrl.value);
		num.setPlaces('0', false);
		num.setCurrencyValue('$');
		num.setCurrency(true);
		num.setCurrencyPosition(num.LEFT_OUTSIDE);
		num.setNegativeFormat(num.LEFT_DASH);
		num.setNegativeRed(false);
		num.setSeparators(true, ',', ',');
		oCtrl.value = num.toFormatted();
	}
}
 
 

//--------------------------DonationFrm-------------------------------------------------------------

function validateDonationFrm(theForm) {
			
		var oForm = eval("document.forms." + theForm);
		
		if (oForm.Amount.value.replace(/ /g, "") == "")
		{
			alert("Please enter Amount !");
			oForm.Amount.focus();
			return false;
		}  
		
		if (oForm.Amount.value.replace(/\$/g, "").replace(/,/g, "") < 1)
		{
			alert("Minimum Amount is $1");
			oForm.Amount.value = "$1";
			oForm.Amount.focus();
			return false;
		} 
		
		if (oForm.Amount.value.replace(/\$/g, "").replace(/,/g, "") > 5000)
		{
			alert("Maximum Amount is between $1 and $5,000")
			oForm.Amount.value = "$5,000";
			oForm.Amount.focus();
			return false;
		} 
		
		if (oForm.FirstName.value.replace( / /g, "") == "")
		{
			alert("Please enter First Name !");
			oForm.FirstName.focus();
			return false;
		}  
		if (oForm.LastName.value.replace( / /g, "") == "")
		{
			alert("Please enter Last Name !");
			oForm.LastName.focus();
			return false;
		}  
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please enter Email !");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
		if(oForm.Address.value.replace( / /g, "") == ""){
			alert("Please fill the Address field !");
			oForm.Address.focus();
			return false;
		}
		if(oForm.City.value.replace( / /g, "") == ""){
			alert("Please fill the City field !");
			oForm.City.focus();
			return false;
		}
		if(oForm.State.selectedIndex == 0){
			alert("Please select State !");
			oForm.State.focus();
			return false;
		}
		if(oForm.Zip.value==""){
			alert("Please fill the Zip field !");
			oForm.Zip.focus();
			return false;
		}
		if (!validZIP(oForm.Zip.value)) {
			oForm.Zip.focus();
			return false;
		}
		
		if (!check3Phone( 'Hphone1', 'Hphone2', 'Hphone3', false )) return false;
		
		
		if(oForm.CCardCheckCash[0] && !oForm.CCardCheckCash[0].checked && !oForm.CCardCheckCash[1].checked && !oForm.CCardCheckCash[2].checked) {
			alert("Please select Payment Type !");
			oForm.CCardCheckCash[0].focus();
			return false;
		}
		
		if(oForm.CCardCheckCash[0] && oForm.CCardCheckCash[2].checked && oForm.CheckNo.value.replace( / /g, "").length < 4) {
			alert("Please enter Check No. !");
			oForm.CheckNo.focus();
			return false;
		}
		
		
	return true;
}	
 
 

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidUploadDonation      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidUploadDonation() {

	if (isWhitespace(document.myform.Img.value)) {
	     alert("Please Upload Image! ");
	     document.myform.Img.focus();
	     return false;
	}  
	return getExtension(document.myform.Img.value);
	
}

//--------------------------BoatInfoFrm-------------------------------------------------------------

	function validateBoatInfoFrm(myform) {


		var oForm = document.forms.BoatInfoFrm;
			
		if (oForm.first.value.replace( / /g, "") == "")
		{
			alert("Please enter First Name !");
			oForm.first.focus();
			return false;
		}  
		if (oForm.last.value.replace( / /g, "") == "")
		{
			alert("Please enter Last Name !");
			oForm.last.focus();
			return false;
		}  
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please enter Email !");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
		if(oForm.Address.value.replace( / /g, "")==""){
			alert("Please fill the Address field !");
			oForm.Address.focus();
			return false;
		}
		if(oForm.City.value.replace( / /g, "")==""){
			alert("Please fill the City field !");
			oForm.City.focus();
			return false;
		}
		if(oForm.donorState.value.length<1){
			alert("Please fill the Donor State field !");
			oForm.donorState.focus();
			return false;
		}
		if(oForm.Zip.value==""){
			alert("Please fill the Zip field !");
			oForm.Zip.focus();
			return false;
		}
		if (!validZIP(oForm.Zip.value)) {
			oForm.Zip.focus();
			return false;
		}
		
		if (!check3Phone( 'Hphone1', 'Hphone2', 'Hphone3', false )) return false;
		if (!check3Phone( 'Wphone1', 'Wphone2', 'Wphone3', false )) return false;
		if ((oForm.Hphone1.value=="") && (oForm.Wphone1.value=="")){
			alert("Please provide at least one phone number!");
			oForm.Wphone1.focus();
			return false;
		}
		
		if ((oForm.SameD.checked) ==false) {
		if (oForm.BoatZip.value != "" && !validZIP(oForm.BoatZip.value)) {
			oForm.BoatZip.focus();
			return false;
		}
		}

		if(oForm.BTName.value.length<1){
			alert("Please fill Boat Make field !");
			oForm.BTName.focus();
			return false;
		}
		
		if (!isEmpty(oForm.BTLength.value)){ 
			if ((!isNonnegativeInteger(oForm.BTLength.value))&&(oForm.BTLength.value!="")){
				alert("Length fields should contain only numbers !");
				oForm.BTLength.focus();
				return false;
			}
			if (oForm.BTLength.value.charAt(0) == 0){
				alert("Length fields should contain positive numbers !");
				oForm.BTLength.focus();
				return false;
			}
			if (oForm.BTLength.value > 1000){
				alert("Length fields should not exceed 1000 feet's !");
				oForm.BTLength.focus();
				return false;
			}
		}			

		if (!isEmpty(oForm.BTLengthIN.value)){ 
			if (isEmpty(oForm.BTLength.value)){ 
				alert("Please complete Vehicle Length (ft.) !");
				oForm.BTLength.focus();
				return false;
			}
			if ((!isNonnegativeInteger(oForm.BTLengthIN.value))&&(oForm.BTLengthIN.value!="")){
				alert("Length fields should contain only numbers !");
				oForm.BTLengthIN.focus();
				return false;
			}
			if (oForm.BTLengthIN.value.charAt(0) == 0){
				alert("Length fields should contain positive numbers !");
				oForm.BTLengthIN.focus();
				return false;
			}
			if (oForm.BTLengthIN.value > 11){
				alert("Inch fields should be less than 12 inches !");
				oForm.BTLengthIN.focus();
				return false;
			}
		}			

		if (!isEmpty(oForm.HeightFT.value)){ 
			if ((!isNonnegativeInteger(oForm.HeightFT.value))&&(oForm.HeightFT.value!="")){
				alert("Height fields should contain only numbers !");
				oForm.HeightFT.focus();
				return false;
			}
			if (oForm.HeightFT.value.charAt(0) == 0){
				alert("Height fields should contain positive numbers !");
				oForm.HeightFT.focus();
				return false;
			}
			if (oForm.HeightFT.value > 1000){
				alert("Height fields should not exceed 1000 feet's !");
				oForm.HeightFT.focus();
				return false;
			}
		}			

		if (!isEmpty(oForm.HeightIn.value)){ 
			if (isEmpty(oForm.HeightFT.value)){ 
				alert("Please complete Vehicle Height (ft.) !");
				oForm.HeightFT.focus();
				return false;
			}
			if ((!isNonnegativeInteger(oForm.HeightIn.value))&&(oForm.HeightIn.value!="")){
				alert("Height fields should contain only numbers !");
				oForm.HeightIn.focus();
				return false;
			}
			if (oForm.HeightIn.value.charAt(0) == 0){
				alert("Height fields should contain positive numbers !");
				oForm.HeightIn.focus();
				return false;
			}
			if (oForm.HeightIn.value > 11){
				alert("Inch fields should be less than 12 inches !");
				oForm.HeightIn.focus();
				return false;
			}
		}		
				
			
		if(oForm.BTYear.value==""){
			alert("Please fill the Boat Year field !");
			oForm.BTYear.focus();
			return false;
		}
		if (oForm.BTYear.value !="" && !checkYear(oForm.BTYear) ){
			oForm.BTYear.focus();
			return false;
		}
		crtDate = new Date();
		if (oForm.BTYear.value.length>0){ 
		if ((oForm.BTYear.value < 1950 )||(crtDate.getFullYear() < oForm.BTYear.value)) {
			    alert("Please provide a valid Year, like: 1987!");
			    oForm.BTYear.focus();
				return false;
			}				
		}	
		

		if (oForm.BTMotorHP){
			if ((!isNonnegativeInteger(oForm.BTMotorHP.value)) && (oForm.BTMotorHP.value != "")){
				alert("This field should contain a positive integer !");
				oForm.BTMotorHP.focus();
				return false;
			}
			if ((oForm.BTMotorHP.value.charAt(0) == 0) && (oForm.BTMotorHP.value != "")){
				alert("This field should contain a positive integer !");
				oForm.BTMotorHP.focus();
				return false;
			}
			if (oForm.BTMotorHP.value > 1000){
				alert("This field should not exceed 1000 HP's !");
				oForm.BTMotorHP.focus();
				return false;
			}
		}

		if (oForm.BTMotorYear.value !="" && !checkYear(oForm.BTMotorYear) ){
			oForm.BTMotorYear.focus();
			return false;
		}
		if (oForm.BTMotorYear.value.length>0){ 
		if ((oForm.BTMotorYear.value < 1950 )||(crtDate.getFullYear() < oForm.BTMotorYear.value)) {
			    alert("Please provide a valid Year, like: 1987!");
			    oForm.BTMotorYear.focus();
				return false;
			}				
		}
		
		if (oForm.TrailerYear.value !="" && !checkYear(oForm.TrailerYear) ){
			oForm.TrailerYear.focus();
			return false;
		}
		if (oForm.TrailerYear.value.length>0){ 
		if ((oForm.TrailerYear.value < 1950 )||(crtDate.getFullYear() < oForm.TrailerYear.value)) {
			    alert("Please provide a valid Year, like: 1987!");
			    oForm.TrailerYear.focus();
				return false;
			}				
		}				


		var dateInWater = new Date(Date.parse(oForm.LastDateInWater.value));
		dateInWater = new Date((dateInWater.getMonth()+1)+"/"+(dateInWater.getDate())+"/"+(dateInWater.getFullYear()));
		
		var dateNow = new Date();
			dateNow = new Date((dateNow.getMonth()+1)+"/"+(dateNow.getDate())+"/"+(dateNow.getFullYear()));
		
		
		if(dateNow < dateInWater)
		{
			oForm.LastDateInWater.focus();
			alert("Last Date In Water must be smaller than Today!");
			return false;
		}

return true;
}	
	
		
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidTaxr()      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidTaxr() {
	if (isWhitespace(document.myform.FName.value)) 
	{
			alert("Please enter First Name !");
			document.myform.FName.focus();
			return false;
	}	
	if (isWhitespace(document.myform.LName.value)) 
	{
			alert("Please enter Last Name !");
			document.myform.LName.focus();
			return false;
	}	
	if (isWhitespace(document.myform.StockNo1.value)) 
	{
			alert("Please enter Reference Number !");
			document.myform.StockNo1.focus();
			return false;
	}	
	if (!(isWhitespace(document.myform.StockNo1.value))){ 
		if (StockValidation(document.myform.StockNo1.value)==false) {
				document.myform.StockNo1.focus();
				return false;
		}	
	}	
	if (!(isWhitespace(document.myform.StockNo1.value))){ 
		if (document.myform.StockNo1.value.length != 2 && document.myform.StockNo1.value.length != 3) {
			    alert(" Please enter the Reference Number in the correct format. \n If you do not have the correct Reference Number, \n please contact us at 1-866-835-KIDS.");
				document.myform.StockNo1.focus();
				return false;
		}	
	}		
	if (isWhitespace(document.myform.StockNo2.value)) 
	{
			alert("Please enter Reference Number !");
			document.myform.StockNo2.focus();
			return false;
	}		
	if (!(isWhitespace(document.myform.StockNo2.value))){ 
		if (StockValidation(document.myform.StockNo2.value)==false) {
				document.myform.StockNo2.focus();
				return false;
		}	
	}		
	if (!(isWhitespace(document.myform.StockNo2.value))){ 
		if (document.myform.StockNo2.value.length <5 || document.myform.StockNo2.value.length >10) {
			    alert(" Please enter the Reference Number in the correct format. \n If you do not have the correct Reference Number, \n please contact us at 1-866-835-KIDS.");
				document.myform.StockNo2.focus();
				return false;
		}	
	}		 }
 


function StockValidation(nString)  {
        var RefString="0123456789";
		var InString = nString;
	
        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
           
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only!");
				return false;
			}
		}
	    return true;
} 


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validSurvey      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

		function validSurvey() {

			if(!document.frmContactUs.call_center[0].checked && !document.frmContactUs.call_center[1].checked && !document.frmContactUs.call_center[2].checked)
			{
				alert("Please answer the first question!");
				return false;
			}
			if(!document.frmContactUs.call_contact[0].checked && !document.frmContactUs.call_contact[1].checked)
			{
				alert("Please answer the second question!");
				return false;
			}
			if(!document.frmContactUs.call_schedule[0].checked && !document.frmContactUs.call_schedule[1].checked)
			{
				alert("Please answer the third question!");
				return false;
			}
			if(!document.frmContactUs.tow_service[0].checked && !document.frmContactUs.tow_service[1].checked)
			{
				alert("Please answer the fourth question!");
				return false;
			}
			if(!document.frmContactUs.call_donating[0].checked && !document.frmContactUs.call_donating[1].checked)
			{
				alert("Please answer the sixth question!");
				return false;
			}

	if(document.forms.frmContactUs.reason.value == "0")
	{
		if(document.forms.frmContactUs.other_reason && document.forms.frmContactUs.other_reason.value.replace( / /g, "") == "") 
		{
			alert("Please enter other donation reason!");
			document.frmContactUs.other_reason.focus();
			return false;
		}
	}
	else if(document.forms.frmContactUs.reason.value == "-1")
	{
		alert("Please select donation reason!");
		document.frmContactUs.reason.focus();
		return false;
	}

		/* 
			if (isWhitespace(document.frmContactUs.firstname.value)) 
			{
				alert("Please enter First Name");
				document.frmContactUs.firstname.focus();
				return false;
			}  
			if (isWhitespace(document.frmContactUs.lastname.value)) 
			{
				alert("Please enter Last Name");
				document.frmContactUs.lastname.focus();
				return false;
			}  

			if (isWhitespace(document.frmContactUs.phone.value)) 
			{
				alert("Please enter Telephone ");
				document.frmContactUs.phone.focus();
				return false;
			}
		*/  
			if (!check3Phone( 'phone1', 'phone2', 'phone3', false )) return false;
			
		/*	
			if (isWhitespace(document.frmContactUs.email.value)) 
			{
				alert("Please enter email ");
				document.frmContactUs.email.focus();
				return false;
			}  
		*/
			if (document.frmContactUs.email.value != "" && isEmail(document.frmContactUs.email.value)==false) {
					alert("Please enter a valid E-Mail address, like: name@companyname.com ");
					document.frmContactUs.email.focus();
					return false;
			}  
			
			return true;
		}

	

	
//________________________________________________________________________________________________
//_____________________      NonSpace     _____________________________________________________________

function NonSpace(field) {

	var xpos =0;
	var xlen =field.length;
	var xpos1 =0;
	var xpos2 =xlen;

	for (var i=0; i < xlen; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == " ") {xpos++;}
		else {var xpos1=xpos;break;  }
	}
	field = field.substring(xpos1, xlen)
	var xlen1 = field.length;

	for (var i=0; i < xlen1; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp != " ") {xpos1++;}
		else {xpos2=i;break;  }
	}
	field = field.substring(0, xpos2)
	return field;
}


//________________________________________________________________________________________________
//_____________________      isEmail     _____________________________________________________________

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}




//________________________________________________________________________________________________
//_____________________      IsPhone     _____________________________________________________________

function IsPhone(str)          // is phone str valid
    {
    if (str.length != 12) 
              // nope - wrong str length
		{
		alert('Invalid PhoneNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
    {
    if (i == 3 || i == 7)
    {
      if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . PhoneNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
    {
      if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. PhoneNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}



//________________________________________________________________________________________________
//_____________________      IsFax     _____________________________________________________________

function IsFax(str)          // is Fax str valid
    {
    if (str.length != 12) 
              // nope - wrong str length
		{
		alert('Invalid FaxNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
    {
    if (i == 3 || i == 7)
    {
      if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . FaxNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
    {
      if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. FaxNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}



//________________________________________________________________________________________________
//_____________________      validateZIP     _____________________________________________________________

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.value.length!=5 && field.value.length!=10) {
alert("Please enter your 5 digit or ( 5 + 4 ) digit  ZIP  code.");
return false;
}
for (var i=0; i < field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your ZIP code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.value.length==10) && ""+field.value.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four  ZIP  code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}


//________________________________________________________________________________________________
//_____________________      isNum     _____________________________________________________________

function isNum(chr)            // is character a number?
  {
  if (chr < "0" || chr > "9")  // nope
    return false;
  else                         // yep
    return true;
  }




//________________________________________________________________________________________________
//_____________________      isNumber09     _____________________________________________________________

function isNumber09(InString)  {
        RefString="0123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 0 - 9 ");
				return false;
			}
		}
        return true;
}

//________________________________________________________________________________________________
//_____________________      isNumberZip     _____________________________________________________________

function isNumberZip(InString)  {
        RefString="0123456789-";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter a valid Zip Code! ");
				return false;
			}
		}
        return true;
}



//________________________________________________________________________________________________
//_____________________      getExtension     _____________________________________________________________

function getExtension(field) {
	var xpos =0;
	var xlen =field.length;
	for (var i=xlen; i > 0 ; i--) {
		temp = "" + field.substring(i, i-1);
		if (temp != ".") {xpos--;}
			else {break;
		}
	}
	var myext =field.substring(xlen+xpos, xlen).toLowerCase();
		if ((myext != "gif") && (myext != "jpg") && (myext != "jpeg") && (myext != "bmp") && (myext != "jpe") && (myext != "swf")){
				alert ("Please Upload an Image with GIF,JPEG,JPE,JPG,BMP or SWF extension !");
		return false; }
		else
		{ return true;}

}


//________________________________________________________________________________________________
//_____________________      getEmail     _____________________________________________________________

function getEmail(field) {
	var xpos =0;
	var xlen =field.length;
	for (var i=xlen; i > 0 ; i--) {
		temp = "" + field.substring(i, i-1);
		if (temp != "@") {xpos--;}
			else {break;
		}
	}
	var xx =field.substring(xlen+xpos, xlen).toLowerCase();
	return (xx);
}




//________________________________________________________________________________________________
//_____________________      warnEmpty     _____________________________________________________________

var reWhitespace = /^\s+$/
// warnEmpty (theField, s)             Notify user that required field theField is empty.


// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s)
{   theField.focus()
    alert(mPrefix + s + mSuffix)
    return false
}


//________________________________________________________________________________________________
//_____________________      isEmpty     _____________________________________________________________

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



//________________________________________________________________________________________________
//_____________________      isWhitespace     _____________________________________________________________

function isWhitespace (s)

{   // Is s empty?
//    return (isEmpty(s));
    return (isEmpty(s) || reWhitespace.test(s));
}






function Start(page) {
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=550,height=250,top=50,left=50");
}



//---------------- valid phone ----------------
// VARIABLE DECLARATIONS

var digits = "0123456789";

// whitespace characters
var whitespace = " \t\n\r";

// decimal point character differs by language and culture
var decimalPointDelimiter = "."

// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-./ ";

// characters which are allowed in US phone numbers
var validUSPhoneChars = digits + phoneNumberDelimiters;

// U.S. phone numbers have 10 digits.
// They are formatted as 123-456-7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;

// CONSTANT STRING DECLARATIONS

// m = "missing"

var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."

// s --- "string"

var sPhone = "Phone Number"

// i is an abbreviation for "invalid"
var iUSPhone = "This field must be a 10 digit U.S. phone number (like 415-555-1212). Please reenter it now."
// p is an abbreviation for "prompt"
var pEntryPrompt = "Please enter a "
var pUSPhone = "10 digit U.S. phone number (like 415-555-1212)."
var defaultEmptyOK = false

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}

// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.


function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}


function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "", 3, "-", 3, "-", 4))
}


function checkUSPhone (theField, emptyOK)
{   if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return warnInvalid (theField, iUSPhone);
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
          theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}


function isInt(chr)           
{
	if (isNaN(chr))
	{return false; }
	else
	  {
		if (chr>0)
		{ return true;	}
		else
		  { return false; }	  
	   }
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     isZip      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function validZIP(field) {
	var valid = "0123456789-";
	var hyphencount = 0;

	if (field.length!=5 && field.length!=10) {
		alert("Please enter your 5 digit or 5 digit+4 zip code.");
		return false;
	}
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1") {
				alert("Invalid characters in your zip code.  Please try again.");
		return false;
	}
	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
		alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
		return false;
	}
}
return true;
}  

function isValidZIP(field) {
	var valid = "0123456789-";
	var hyphencount = 0;

	if (field.length!=5 && field.length!=10) return false;
	
	for (var i=0; i < field.length; i++)
	{
		temp = "" + field.substring(i, i+1);
		if (temp == "-") hyphencount++;
		if (valid.indexOf(temp) == "-1") return false;
		if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) return false;
	}
	return true;
} 

function changeBox(obj) {
//	obj.checked = !obj.checked;
	obj.checked = true;
}
function changeMediaBox(obj, ref) {
	obj.checked = ref.value==0?false:true;
}

function changeMediaBoxById(obj, ref) {
	document.getElementById(obj).checked = ref.value==0?false:true;
}



function Valid_Date(datein){
        
        var indate=datein;
        if (indate.indexOf("-")!=-1){
                var sdate = indate.split("-")
        }
        else {
                var sdate = indate.split("/")
        }
        var chkDate=new Date(Date.parse(indate))
        var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(chkDate.getFullYear())
        var indate2=(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]))

		if ((chkDate.getFullYear() > 3000)||(chkDate.getFullYear() < 1900)) {
                alert("You've entered an invalid year");
				return false;
		}				
		if ((Math.abs(sdate[2]) > 3000)||(Math.abs(sdate[2])< 1900)) {
                alert("You've entered an invalid year");
				return false;
		}				


   if (indate2=="0/NaN/NaN"){
				return true;
   }        
	else {
 		
        if (indate2!=cmpDate){
                alert("You've entered an invalid date or date format.  Please use the MM/DD/YYYY format.");
				return false;
        }
        else {
                if (cmpDate=="NaN/NaN/NaN"){
                        alert("You've entered an invalid date or date format. Please use the MM/DD/YYYY format.");
						return false;
                }
                else {
						return true;
                }       
        }
}        
}


//--------------year check------------------------------------------------------------------------
// isNonnegativeInteger (s [,eok])     True if string s is an integer >= 0.
var iYear = "This field must be a 4 digit year number.  Please reenter it now."
var pYear = "2 or 4 digit year number."
var cYear = "The year must be lesser than current year.  Please reenter it now."

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}
function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}

function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}

function checkYear (theField, emptyOK)
{   if (checkYear.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isYear(theField.value, false)) 
       return warnInvalid (theField, iYear);
    
     var chkDate=new Date(Date())
     var sYear=chkDate.getFullYear()
    
    if (theField.value>sYear)
    
       return warnInvalid (theField, cYear);
       
    else return true;
}





//	**************  3 fields input PHONE format *****************

function clearCharacters( oCtrl ) {
	oCtrl.value = oCtrl.value.replace(/\D/g,'');
}
function focusNext( oCtrl, NextCtrlID ) {
	if(oCtrl.value.length==3)
	{
		if (document.getElementById(NextCtrlID))
			document.getElementById(NextCtrlID).focus();
	}
}

function check3Phone( PhoneFieldID1, PhoneFieldID2, PhoneFieldID3, isRequired )
{
	
	if( (document.getElementById(PhoneFieldID1)) && (document.getElementById(PhoneFieldID2)) && (document.getElementById(PhoneFieldID3)) )
	{
		var PhoneField1 = document.getElementById(PhoneFieldID1);
		var PhoneField2 = document.getElementById(PhoneFieldID2);
		var PhoneField3 = document.getElementById(PhoneFieldID3);
		
		if ((PhoneField1.value.length > 0 ) || (PhoneField2.value.length > 0) || (PhoneField3.value.length > 0)) {
			
			if (PhoneField1.value.length < 3 ) {
				alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField1.focus();
				return false;
			}
			if (PhoneField2.value.length < 3) {
				alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField2.focus();
				return false;
			}
			if (PhoneField3.value.length < 4) {
				alert('This field must be a 4 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField3.focus();
				return false;
			}
		}
		else
		{
			if ( isRequired ) 
			{
				alert("Please enter Phone ");
				PhoneField1.focus();
				return false;
			}
		}
	}
	
	return true;
}



