function openGlossary(pLinkName) {
	var wAPP;
	wAPP = window.open("../resources/glossary.htm#" + pLinkName, "APP", "menubar=no,status,scrollbars,resizable=no,width=580,height=300,left=0,top=0");
}

function GetEstimateButton_onclick(){
// modified by Sherry Chen on 8/21/02 to control a user entry which must be a number, 
// but allow a $ or . or , entry.
// the function SubmitCheck() no longer used. Add a new function validateNum() 
// and call the function on this click event.
// stop validation of values and do not submit if State not chosen    
    if (document.IntroQuest1Form1.cboHomeState.selectedIndex == "0") {
        document.IntroQuest1Form1.cboHomeState.focus();
        alert("Please Select State of Home Purchase from pull-down list");
       return;
       }
    var result = CheckCountyFunction();
// stop validation of values and do not submit if County not chosen    
    if (!result){
       return;
       }
    if (result){
// the price entered on form number 1 must be copied to form number 2 so
// it will be passsed on submit of 2nd form    
    document.IntroQuest1Form2.txtLoanEstimatorPrice == document.IntroQuest1Form1.txtLoanEstimatorPrice.value;
// test Sale Price and Available Cash for numeric validity; they may also
// contain dollar sign, comma, and period (decimal point) 
    var bad=false;   
    result = validateNum(document.IntroQuest1Form1.txtLoanEstimatorPrice,"Home Sale Price","required");
    if (!result){
       bad = true;
       }
    if (!bad){   
       result = validateNum(document.IntroQuest1Form2.txtAvailableCash,"Cash Available for Downpayment","optional");
       if (!result){
          bad = true;
          }
       }   
    // below will only submit form if SubmitCheck returned True    
    if (!bad){
       document.IntroQuest1Form2.submit();
       return true;
		}
	}	
 }

 
function validateNum(field,fieldName,fieldUse) {
var aFlag=true;
		if (field.value!=""){
		     var msg="";		     
			  var temp = field.value;
			  var out = "."; com = ",";
			  var dol = "$";
			  var add = "";			  
			  while (temp.indexOf(out)>-1) {
					pos= temp.indexOf(out);
					temp = "" + (temp.substring(0, pos) + add +	temp.substring((pos + out.length), temp.length));	
					}
			  while (temp.indexOf(com)>-1) {
					pos= temp.indexOf(com);
					temp = "" + (temp.substring(0, pos) + add +	temp.substring((pos + com.length), temp.length));	
					}					
			  while (temp.indexOf(dol)>-1) {
					pos= temp.indexOf(dol);
					temp = "" + (temp.substring(0, pos) + add +	temp.substring((pos + dol.length), temp.length));	
					}			  
			if (isNaN(temp)!=false) {			    
				alert ("Please enter numbers only for the field: \n" + fieldName + "."); 
				field.focus();
				aFlag=false;
				return false;
					}
				}
		else {
// give messages about optional fields if format or content is wrong;
// give no message about optional field if value is not supplied		
  		    if (fieldUse == "optional"){
               aFlag = true;
      	       return true;
   		    }    
			alert ("Please enter a value for the field: \n" + fieldName + ".");
			field.focus();
			aFlag=false;
			return false;			
				}
return aFlag;
}

function SubmitStateFunction() {
    result = SubmitForm1Check();
// below will only submit form if SubmitForm1Check returned True    
    if (result){
       document.IntroQuest1Form1.cboLoanTerm.value = document.IntroQuest1Form2.cboLoanTerm.options[document.IntroQuest1Form2.cboLoanTerm.selectedIndex].value;
       document.IntroQuest1Form1.cboLoanRateInt.value = document.IntroQuest1Form2.cboLoanRateInt.options[document.IntroQuest1Form2.cboLoanRateInt.selectedIndex].value;
       document.IntroQuest1Form1.cboLoanRateDec.value = document.IntroQuest1Form2.cboLoanRateDec.options[document.IntroQuest1Form2.cboLoanRateDec.selectedIndex].value;
       document.IntroQuest1Form1.txtAvailableCash.value = document.IntroQuest1Form2.txtAvailableCash.value;
       document.IntroQuest1Form1.submit();
    }   
 }

function CheckStateFunction() {
    if (document.IntroQuest1Form1.cboHomeState.selectedIndex == "0") {
        document.IntroQuest1Form1.cboHomeState.focus();
        alert("Please Select State before selecting County");
   }   
 }

function SubmitForm1Check(){
    if (document.IntroQuest1Form1.cboHomeState.selectedIndex == "0") {
        alert("Please Select State of Home Purchase from pull-down list");
        document.IntroQuest1Form1.cboHomeState.focus();
        document.IntroQuest1Form1.action.value = "get_state";
        return false;
    }  
    return true;   
 } 

function CheckCountyFunction(){
    if (document.IntroQuest1Form2.cboHomeCounty.selectedIndex == "0") {
        alert("Please Select County of Home Purchase from pull-down list");
        document.IntroQuest1Form2.cboHomeCounty.focus();
        return false;
    } 
    return true;   
 } 

function ChangePrice() {
  document.IntroQuest1Form2.txtLoanEstimatorPrice.value = document.IntroQuest1Form1.txtLoanEstimatorPrice.value;
 }
