function checkNumeric(aForm) {
		if (isNaN(aForm.ResidenceCost.value)) {
			    alert( "Enter Valid numbers" );
			aForm.ResidenceCost.focus();
		}
		if (isNaN(aForm.s1.value)) {
			    alert( "Enter Valid numbers" );
			aForm.s1.focus();
		}
		if (isNaN(aForm.s2.value)) {
			    alert( "Enter Valid numbers" );
			aForm.s2.focus();
		}		
		if (isNaN(aForm.s3.value)) {
			    alert( "Enter Valid numbers" );
			aForm.s3.focus();
		}
		if (isNaN(aForm.home_phone1.value)) {
			    alert( "Enter Valid numbers" );
			aForm.home_phone1="";	
			aForm.home_phone1.focus();
		}			
		if (isNaN(aForm.home_phone2.value)) {
			    alert( "Enter Valid numbers" );
			aForm.home_phone2="";
			aForm.home_phone2.focus();
		}
		if (isNaN(aForm.home_phone3.value)) {
			alert( "Enter Valid numbers" );
			aForm.home_phone3="";
			aForm.home_phone3.focus();
		}
		if (isNaN(aForm.zip.value)) {
			alert( "Enter Valid numbers" );
			aForm.zip="";	
			aForm.zip.focus();
		}			
		
		if (isNaN(aForm.work_phone1.value)) {
			alert( "Enter Valid numbers" );
			aForm.work_phone1="";
			aForm.work_phone1.focus();
		}			
		if (isNaN(aForm.work_phone2.value)) {
		    alert( "Enter Valid numbers" );
			aForm.work_phone2="";	
			aForm.work_phone2.focus();
		}
		if (isNaN(aForm.work_phone3.value)) {
		    alert( "Enter Valid numbers" );
			aForm.work_phone3="";
			aForm.work_phone3.focus();
		}		
		if (isNaN(aForm.monthly_income.value)) {
		    alert( "Enter Valid numbers" );
			aForm.monthly_income.focus();
		}				
		if (isNaN(aForm.LoanAmount.value)) {
		    alert( "Enter Valid numbers" );
			aForm.LoanAmount.focus();
		}		
	}
  //onblur="validateEmail(this,false);"
  function checkform (form)
	{
	
	form._Power_sport_type.value  = form.Power_sport_type.options[form.Power_sport_type.selectedIndex].text;	
	form._Power_sport_make.value  = form.Power_sport_make.options[form.Power_sport_make.selectedIndex].text;	
	form._Power_sport_model.value = form.Power_sport_model.options[form.Power_sport_model.selectedIndex].text;	
		
	if (form.first_name.value == "") {
    alert( "Please fill out First name" );
    form.first_name.focus();
    return false ;
	}
	else if (form.last_name.value == "") {
    alert( "Please fill out Last name" );
    form.last_name.focus();
    return false ;
	}
	else if (form.Maiden_name.value == "") {
    alert( "Please fill out maiden name" );
    form.Maiden_name.focus();
    return false ;
	}	
		else if ( (form.s1.value.length != 3 ) || isNaN(form.s1.value)) {
    alert( "Please fill out social security and it should be numeric" );
    form.s1.focus();
    return false ;
	}
		else if ( (form.s2.value.length != 2 ) || isNaN(form.s3.value)) {
    alert( "Please fill out social security and it should be numeric" );
    form.s2.focus();
    return false ;
	}	
		else if (form.s3.value.length !=4 || isNaN(form.s3.value)) {
    alert( "Please fill out social security and it should be numeric" );
    form.s3.focus();
    return false ;
	}
		else if (form.employer_name.value == "") {
    alert( "Please fill out Employer" );
    form.employer_name.focus();
    return false ;
	}	
/*		else if (form.email.value == "") {
    alert( "Please fill out Email" );
    form.email.focus();
    return false ;
	}
*/	else if (!(CheckEmail(form.email.value))){
						 // alert("I am here");
		form.email.focus();
		return false;
	}
		else if (form.address.value == "") {
    alert( "Please fill out Address" );
    form.address.focus();
    return false ;
	}
		else if (form.city.value == "") {
    alert( "Please fill out City" );
    form.city.focus();
    return false ;
	}

		else if (form.state.value == "") {
    alert( "Please fill out State" );
    form.state.focus();
    return false ;
	}
	else if (form.zip.value.length !=5 || isNaN(form.zip.value)){
    alert( "Please select zip and it should be numeric" );
    form.zip.focus();
    return false ;
	}

	else if (form.Power_sport_type.value == "" || ((form.Power_sport_type.options[form.Power_sport_type.selectedIndex].text) == "Choose Powersport")) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("please select any Power sport type");
	form.Power_sport_type.focus();
	return false ;		
	}
	else if (form.Power_sport_make.value == "" || ((form.Power_sport_make.options[form.Power_sport_make.selectedIndex].text) == "Choose Make")) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("please select any Power sport make");
	form.Power_sport_make.focus();
	return false ;		
	}
	else if (form.Power_sport_model.value == "" || ((form.Power_sport_model.options[form.Power_sport_model.selectedIndex].text) == "Choose Model")) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("please select any Power sport model");
	form.Power_sport_model.focus();
	return false ;		
	}
		else if (form.monthly_income.value == "" || isNaN(form.monthly_income.value)) {
    alert( "Please fill out monthly income and it should be numeric");
    form.monthly_income.focus();
    return false ;
	}	
		else if (form.LoanAmount.value == "" ||  isNaN(form.LoanAmount.value)) {
    alert( "Please fill out loan amount and it should be numeric" );
    form.LoanAmount.focus();
    return false ;
	}		

/*********/
		else if ( form.home_phone1.value.length !=3 || isNaN(form.home_phone1.value)) {
    alert( "Please fill out Home phone and it should be numeric" );
    form.home_phone1.focus();
    return false ;
	}
		else if (isNaN(form.home_phone2.value) || form.home_phone2.value.length !=3) {
    alert( "Please fill out Home phone and it should be numeric" );
    form.home_phone2.focus();
    return false ;
	}
		else if (form.home_phone3.value.length !=4 || isNaN(form.home_phone3.value)) {
    alert( "Please fill out Home phone and it should be numeric" );
    form.home_phone3.focus();
    return false ;
	}
		else if (form.ResidenceCost.value == "" || isNaN(form.ResidenceCost.value)) {
    alert( "Please fill out mortgage/residence amount \n and it should be numeric" );
    form.ResidenceCost.focus();
    return false ;
	}
			else if (form.work_phone1.value.length != 3 || isNaN(form.work_phone1.value)) {
    alert( "Please fill out Work phone and it should be numeric" );
    form.work_phone1.focus();
    return false ;
	}
		else if (form.work_phone2.value.length != 3 || isNaN(form.work_phone2.value)) {
    alert( "Please fill out Work phone and it should be numeric" );
    form.work_phone2.focus();
    return false ;
	}
		else if (form.work_phone3.value.length != 4 || isNaN(form.work_phone3.value)) {
    alert( "Please fill out Work phone and it should be numeric" );
    form.work_phone3.focus();
    return false ;
	}
		else if (form.living_from_years.value == "") {
    alert( "Please fill out how long at this address?" );
    form.living_from_years.focus();
    return false ;
	}
		else if (form.living_from_months.value == "") {
    alert( "Please fill out how long at this address?" );
    form.living_from_months.focus();
    return false ;
	}	
	/*else if (form.Debt_amount.value == "0" && form.more_info.checked == true) {
    alert( "Please select some debt amount" );
    form.Debt_amount.focus();
    return false ;
	}	
	else if (form.more_info.checked == false && form.Debt_amount.value !="0") {
	alert( "Please check debt cosolidation services button thanks. " );
    form.more_info.focus();
    return false ;
	}*/
		else if (form.Credit_rating.value == "" || ((form.Credit_rating.options[form.Credit_rating.selectedIndex].text) == "--")) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("please select your credit rating");
	form.Credit_rating.focus();
	return false ;		
	}
		else if (form.bankruptcy.value == "" || ((form.bankruptcy.options[form.bankruptcy.selectedIndex].text) == "--")) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("please select bankruptcy value YES/NO ");
	form.bankruptcy.focus();
	return false ;		
	}
		else if ( ((form.bankruptcy.options[form.bankruptcy.selectedIndex].text) == "Yes") && (((form.Bankruptcy_date_month.options[form.Bankruptcy_date_month.selectedIndex].text) == "Month")) ) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("You have to selcet month ");
	form.Bankruptcy_date_month.focus();
	return false ;		
	}
		else if ( ((form.bankruptcy.options[form.bankruptcy.selectedIndex].text) == "Yes") && (((form.Bankruptcy_date_year.options[form.Bankruptcy_date_year.selectedIndex].text) == "Year")) ) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("You have to selcet year ");
	form.Bankruptcy_date_year.focus();
	return false ;		
	}
	
		else if (form.Debt_amount.value != "0" && ((form.more_info.options[form.more_info.selectedIndex].text) == "--")) {
		//document.all.ResidenceCost.innerHTML="Enter Valid numbers";
	alert("please select the value YES/NO ");
	form.more_info.focus();
	return false ;		
	}

		else if (form.authorize.value == "" || form.authorize.checked == false) {
    alert( "Please check the authorize checkbox" );
    form.authorize.focus();
    return false ;
	}

		return true;
}

// --------------------------------------------
//                  msg
// Display warn/error message in HTML element.
// commonCheck routine must have previously been called
// --------------------------------------------

function msg(message) // string to display
{
  // setting an empty string can give problems if later set to a 
  // non-empty string, so ensure a space present. (For Mozilla and Opera one could 
  // simply use a space, but IE demands something more, like a non-breaking space.)
alert(message);  
}
//------------------
// --------------------------------------------
//            commonCheck
// Common code for all validation routines to:
// (a) check for older / less-equipped browsers
// (b) check if empty fields are required
// Returns true (validation passed), 
//         false (validation failed) or 
//         proceed (don't know yet)
// --------------------------------------------

var proceed = 2;  

function commonCheck    (valfield,   // element to be validated
//                         infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
  if (!document.getElementById) 
    return true;  // not available on this browser - leave validation to the server
  //var elem = document.getElementById(infofield);
//  if (!elem.firstChild) return true;  // not available on this browser 
 // if (elem.firstChild.nodeType != node_text) return true;  // infofield is wrong type of node  

  if (emptyString.test(valfield.value)) {
    if (required) {
      msg ("Email field is required"); 
      setfocus(valfield);
      return false;
    }
    else {
      return true;  
    }
  }
  return proceed;
}

// --------------------------------------------

// --------------------------------------------
//               validateEmail
// Validate if e-mail address
// Returns true if so (and also if could not be executed because of old browser)
// --------------------------------------------

function validateEmail  (valfield,   // element to be validated
                       //  infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
	//alert("Hello");
//  var stat = commonCheck (valfield, required);
  //if (stat != proceed) return stat;
  var tfld = trim(valfield.value);  // value of field with whitespace trimmed off
  var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
  if (!email.test(tfld)) {
    msg ("Please use valid format: abc@domain.com");
    setfocus(valfield);
    return true;
  }
  
function validateEmail2  (valfield,   // element to be validated
                       //  infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
	//alert("Hello");
//  var stat = commonCheck (valfield, required);
  //if (stat != proceed) return stat;
  var tfld = trim(valfield.value);  // value of field with whitespace trimmed off
  var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
  if (!email.test(tfld)) {
    msg ("Please use valid format: abc@domain.com");
    setfocus(valfield);
    return false;
  }  
}
  //var email2 = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/  ;
  //if (!email2.test(tfld)) 
    //msg ("Unusual e-mail address - If correct, please proceed.");
  //else
  return true;
}

function CheckEmail(email) {
			//email = form1.email.value
			AtPos = email.indexOf("@")
			StopPos = email.lastIndexOf(".")
			l = email.length;
			p=eval("StopPos+3");
			def=eval("l-p");
			Message = ""
			
			if (email == "") {
			Message = "Please fill out email address" + "\n"
			alert (Message)
			return false;
			}
			
			if (AtPos == -1 || StopPos == -1) {
			Message = "Not a valid email address"
			alert (Message)
			return false;
			}
			
			if (StopPos < AtPos) {
			Message = "Not a valid email address"
			alert (Message)
			return false;
			}
			
			if (StopPos - AtPos == 1) {
			Message = "Not a valid email address"
			alert (Message)
			return false;
			}
			
			if (def == 0||def ==1) {
		//	Message="Good Ext. Domain";
		//	alert (Message)
			return true;
			}
			else{
			Message = "Please check domain name"
			alert (Message)
			return false;
			}
}

