function validateForm() { //v4.0
try{
  var i,p,q,nm,test,num,min,max,errors='',chkValue,b_NoInfo,b_SelLatino,b_SelSex,b_SelRace,args=validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { 
    test=args[i+2]; 
    val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
  }catch(e){
    //alert(e);
  }
  	if (document.savingsanalysis.Borrower_No_Info.checked==false){
		chkValue=false;
		b_NoInfo=false;
  	}else{chkValue=true;b_NoInfo=true;}
  	if(document.savingsanalysis.Borrower_Latino[0].checked==true){
		b_SelLatino=true;
	}else if(document.savingsanalysis.Borrower_Latino[1].checked==true){
		b_SelLatino=true;
	}else{b_SelLatino=false;}
	if(document.savingsanalysis.Borrower_Sex[0].checked==true){
		b_SelSex=true;
	}else if(document.savingsanalysis.Borrower_Sex[1].checked==true){
		b_SelSex=true;
	}else{b_SelSex=false;}
	if(document.savingsanalysis.Borrower_Race.value==''){
		b_SelRace=false;
	}else{b_SelRace=true;}
	
	if(b_NoInfo==false){
			if(b_SelRace==false){
			errors +='- Borrowers race is required.\n';}
	  		if(b_SelLatino==false){
			  errors +='- Option Hispanic/Latino yes or no is required.\n';}
			if(b_SelSex==false){
				errors +='- Option borrowers sex is required.\n';}
	}
	
	var cb_chkValue,cb_NoInfo,cb_SelLatino,cb_SelSex,cb_SelRace

	//CHECK FOR CO BORROWER INFORMATION IF LASTNAME IS FILLED IN
	if(document.savingsanalysis.elements[38].value != '')
	{
		if(document.savingsanalysis.elements[79].checked == false) 
		{
			cb_chkValue=false;
			cb_NoInfo=false;
		}
		else
		{
			cb_chkValue=true;
			cb_NoInfo=true;
		}
		if(document.savingsanalysis.elements[82].checked==true)
		{
			cb_SelLatino=true;
		}
		else if(document.savingsanalysis.elements[83].checked==true)
		{
			cb_SelLatino=true;
		}
		else
		{
			cb_SelLatino=false;
		}
		if(document.savingsanalysis.elements[88].checked==true)
		{
			cb_SelSex=true;
		}
		else if(document.savingsanalysis.elements[89].checked==true)
		{
			cb_SelSex=true;
		}
		else
		{
			cb_SelSex=false;
		}
		if(document.savingsanalysis.elements[85].value=='')
		{
			cb_SelRace=false;
		}
		else
		{
			cb_SelRace=true;
		}
	}
	if(cb_NoInfo==false)
	{
		if(cb_SelRace==false)
		{
			errors +='- Co Borrowers race is required.\n';
		}
		if(cb_SelLatino==false)
		{
		  	errors +='- Option Hispanic/Latino yes or no is required for Co Borrower.\n';
		}
		if(cb_SelSex==false)
		{
			errors +='- Option borrowers sex is required for Co Borrower.\n';
		}
	}
	
  	if (errors){
		alert('The following error(s) occurred:\n'+errors);
  		document.MM_returnValue = (errors == '');}
	else{
		document.MM_returnValue = ('');
	}	
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function validateGovtForm(){
  
  
  var val;
  
  //val = MM_findObj('Borrower_OK');
  //'Borrower_OK', 'Co-Borrower_OK'
  var args = validateForm.arguments
  //alert(args.length);
   for(var i=0; i<args.length; i++){
     val=MM_findObj(args[i]);
     //alert(val.value);
  }
}
/////////////////
 function imgOver(img, loc){
   if(img!=section && img!=section2)
     document[img].src= "../images/nav/"+loc+img+"_on.gif";
 }
 
 function imgOut(img, loc){
   var imgsrc = document[img].src;
   if(section!=img && section2!=img)
     document[img].src= "../images/nav/"+loc+img+".gif";
 }



 function getObj(){
   var oDiv = document.all
   if (document.all)
     oDiv = document.all.tags("div");
   else if (document.layers)
     oDiv = document.layers();
   else if (document.getElementById)
     oDiv = document.getElementsByTagName("div");
     
   return oDiv;
 }
 
function changeMenu(obj, newsection, newsection2){

  obj.parent.section = newsection;
  obj.parent.document[newsection].src= "../images/nav/"+newsection+"_on.gif";
  if(newsection2!=""){
    obj.parent.section2 = newsection2;
    obj.parent.document[newsection2].src= "../images/nav/sec_nav/"+newsection+"/"+newsection2+"_on.gif";
  }
}

function imgFade(){
   opac++;   
   if(document['experts'].style)
     document['experts'].style.filter='alpha(Opacity='+opac+')';
   else
     document['experts'].filter='alpha(Opacity='+opac+')';
   if(opac<100)
     setTimeout('imgFade()', 100);   
}

function setImg(){
   var rand = randImg(1, 7);
   document['experts'].src="images/home/experts"+ rand +".gif"     
}

function randImg(from,to){
  var rand = new String(Math.random());  
  rand = rand.substr(rand.length-1, rand.length);  
  while(rand<from || rand>to){  
    var rand = new String(Math.random());  
    rand = rand.substr(rand.length-1, rand.length);  
  }
  return rand;
}

function updateIframe(){
}

function openFinanWin(url){
  window.open(url, 'finan', 'height=700 width=490, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=20,top=20')  
}

function openValuesWin(){
  window.open('../values.asp', 'values', 'width=550 height=500, toolbar=no,location=no,directories=no,statusbar=no,menubar=no,scrollbars=no,resizable=yes,left=20,top=20');
}

function openSubscribeWin(){
  window.open('../about/subscribe.asp', 'values', 'width=500 height=500, toolbar=no,location=no,directories=no,statusbar=no,menubar=no,scrollbars=no,resizable=yes,left=20,top=20');
}

function openCCWin(){
  window.open('../customer_connect.asp', 'cc', 'height=200 width=505, history=no, statusbar=no, scroll=no');
}

var opac = 10;
var section = "";
var section2 = "";
var url = "";
