



var tabNormalClassName="normalTab";
var tabActivatedClassName="activateTab";

var W3C,IE4,IE6CSS,NN4,isCSS,IE;

var State = new Array();
var Code = new Array();

var mainElement;



var wasDrawn=false;
var proTypeValue=["Primary - Single Family","Primary - Condo","Primary - Townhouse","2-4 Plex","2nd Home","Investment Property","Other"];
var rateCreditValue=["Excellent","Good","Fair","Needs improvement","Poor"];
var loanTypeValue=["Refinance","Home Equity","Debt Consolidation","Home Purchase"];
var showStartImage=true;
var showStartImagePath="http://www.brokermatch.com/jsp/mortgageForms/version2/startTab1.gif";
var startText="Start saving here";
var showNumber=false;
var target="http://www.billcut.com/billcut/mortgageForms/version2/step2.jsp";






function initBarbosDHTMLAPI(){
 if(document.images){
                     isCSS=(document.body && document.body.style) ? true : false;
                     W3C=(isCSS && document.getElementById) ? true : false;
                     IE4=(isCSS && document.all) ? true : false;
                     NN4=(document.layers) ? true : false;
                     IE6CSS=(document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
                     IE= navigator.appName.indexOf("Internet Explorer")!= -1 ? true : false;
                    }
} 




function drawForm(elemID){
   initBarbosDHTMLAPI();
   BuildStateArrays();
    var elem=document.getElementById(elemID);
        mainElement=elem; 
        if(elem.style) elem.style.overflow="hidden";

   if(W3C){
           drawElem(elem);
           }

} 
             

function drawElem(elem){
  if(wasDrawn==false){
                            var divContainer=document.createElement("div");
                                divContainer.id="Container1"; 
                                var tableE=document.createElement("table");
                                    tableE.width="100%";
                                   // tableE.height="100%";
                                var tbod=document.createElement("tbody");
                                var trE=document.createElement("tr");
                                var tdE=document.createElement("td");
                                var txt=document.createTextNode("State");
                                var sele=createSelect("stateTab1","stateTab1",State,true,1);
                                var noE;
                                    if(showNumber){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.realtymatcher.com/jsp/mortgageForms/version2/one.gif";
                                                       tdEE.appendChild(noI);
                                                       tdEE.valign="bottom";
                                                       trE.appendChild(tdEE);
                                                       }     
                                    tdE.appendChild(txt);
                                    tdE.appendChild(document.createElement("br"));
                                    tdE.appendChild(sele);
                                    trE.appendChild(tdE);
                                    tdE=document.createElement("td");
                                    if(showNumber){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.realtymatcher.com/jsp/mortgageForms/version2/two.gif";
                                                       tdEE.appendChild(noI);
                                                       tdEE.valign="bottom";
                                                       trE.appendChild(tdEE);
                                                       } 
                                    txt=document.createTextNode("Property type"); 
                                    tdE.appendChild(txt);
                                    tdE.appendChild(document.createElement("br"));
                                    sele=createSelect("ProTypeTab1","ProTypeTab1",proTypeValue,true,1);
                                    tdE.appendChild(sele);
                                    trE.appendChild(tdE);
                                    tbod.appendChild(trE);
                                    trE=document.createElement("tr");
                                    tdE=document.createElement("td");
                                    if(showNumber){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.realtymatcher.com/jsp/mortgageForms/version2/three.gif";
                                                       tdEE.appendChild(noI);
                                                       trE.appendChild(tdEE);
                                                       }    
                                    txt=document.createTextNode("Rate your credit"); 
                                    tdE.appendChild(txt);
                                    tdE.appendChild(document.createElement("br"));
                                    sele=createSelect("RateCreditTab1","RateCreditTab1",rateCreditValue,true,1);
                                    tdE.appendChild(sele);
                                    trE.appendChild(tdE);
                                    tdE=document.createElement("td");
                                    if(showNumber){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.realtymatcher.com/jsp/mortgageForms/version2/four.gif";
                                                       tdEE.appendChild(noI);
                                                       tdEE.valign="bottom";
                                                       trE.appendChild(tdEE);
                                                       } 
                                    txt=document.createTextNode("Loan type"); 
                                    tdE.appendChild(txt);
                                    tdE.appendChild(document.createElement("br"));
                                    sele=createSelect("LoanTypeTab1","LoanTypeTab1",loanTypeValue,true,1);
                                    tdE.appendChild(sele);
                                    trE.appendChild(tdE);
                                    tbod.appendChild(trE);
                                    tableE.appendChild(tbod);
                             divContainer.appendChild(tableE);
                              if(showStartImage){
                                                      var divEE=document.createElement("div");
                                                      divEE.style.position="relative";
                                                      divEE.style.textAlign="center";
                                          var inE=document.createElement("span");
                                          var imgE=document.createElement("img");   
                                              imgE.src=showStartImagePath;
                                              inE.appendChild(imgE);
                                          divEE.appendChild(inE);
                                          imgE.onclick=performAction;
                                          divEE.style.paddingTop="10px";
                                          divEE.style.cursor="pointer";
                                          divContainer.appendChild(divEE);

                                                          }
                                    else {
                                          var divEE=document.createElement("div");
                                              divEE.style.position="relative";
                                              divEE.style.textAlign="center";
                                          var inE=document.createElement("input");
                                              inE.type="button";
                                              inE.value=startText;
                                              inE.onclick=performAction;
                                          divEE.appendChild(inE);
                                          divEE.style.paddingTop="10px";
                                          divContainer.appendChild(divEE);
                                          }  
                                         
                             elem.appendChild(divContainer); 
                             wasTabDrawnTab1=true;
                            }
 else{
      document.getElementById("Container1").style.zIndex=3;
      document.getElementById("Container1").style.display="block";
     }
     
}











function BuildStateArrays()
{
 State[0] = "Alabama";         Code[0] = "AL";
 State[1] = "Alaska";          Code[1] = "AK";
 State[2] = "Arizona";         Code[2] = "AZ";
 State[3] = "Arkansas";        Code[3] = "AR";
 State[4] = "California";      Code[4] = "CA";
 State[5] = "Colorado";        Code[5] = "CO";
 State[6] = "Connecticut";     Code[6] = "CT";
 State[7] = "Delaware";        Code[7] = "DE";
 State[8] = "Florida";         Code[8] = "FL";
 State[9] = "Georgia";         Code[9] = "GA";
State[10] = "Hawaii";         Code[10] = "HI";
State[11] = "Idaho";          Code[11] = "ID";
State[12] = "Illinois";       Code[12] = "IL";
State[13] = "Indiana";        Code[13] = "IN";
State[14] = "Iowa";           Code[14] = "IA";
State[15] = "Kansas";         Code[15] = "KS";
State[16] = "Kentucky";       Code[16] = "KY";
State[17] = "Louisiana";      Code[17] = "LA";
State[18] = "Maine";          Code[18] = "ME";
State[19] = "Maryland";       Code[19] = "MD";
State[20] = "Massachusetts";  Code[20] = "MA";
State[21] = "Michigan";       Code[21] = "MI";
State[22] = "Minnesota";      Code[22] = "MN";
State[23] = "Mississippi";    Code[23] = "MS";
State[24] = "Missouri";       Code[24] = "MO";
State[25] = "Montana";        Code[25] = "MT";
State[26] = "Nebraska";       Code[26] = "NE";
State[27] = "Nevada";         Code[27] = "NV";
State[28] = "New Hampshire";  Code[28] = "NH";
State[29] = "New Jersey";     Code[29] = "NJ";
State[30] = "New Mexico";     Code[30] = "NM";
State[31] = "New York";       Code[31] = "NY";
State[32] = "North Carolina"; Code[32] = "NC";
State[33] = "North Dakota";   Code[33] = "ND";
State[34] = "Ohio";           Code[34] = "OH";
State[35] = "Oklahoma";       Code[35] = "OK";
State[36] = "Oregon";         Code[36] = "OR";
State[37] = "Pennsylvania";   Code[37] = "PA";
State[38] = "Rhode Island";   Code[38] = "RI";
State[39] = "South Carolina"; Code[39] = "SC";
State[40] = "South Dakota";   Code[40] = "SD";
State[41] = "Tennessee";      Code[41] = "TN";
State[42] = "Texas";          Code[42] = "TX";
State[43] = "Utah";           Code[43] = "UT";
State[44] = "Vermont";        Code[44] = "VT";
State[45] = "Virginia";       Code[45] = "VA";
State[46] = "Washington";     Code[46] = "WA";
State[47] = "West Virginia";  Code[47] = "WV";
State[48] = "Wisconsin";      Code[48] = "WI";
State[49] = "Wyoming";        Code[49] = "WY";
}  

function createSelect(name,id,val,first,sizes){
  var sel=document.createElement("select");
      if(IE) sel=document.createElement("<select name='"+name+"' size='"+sizes+"'>");
      sel.name=name;
      sel.id=id;
      if(!IE)sel.size=sizes;
      if(first) {
                 var op=document.createElement("option");
                                   op.value="";
                                   op.innerHTML="Select";
                                   sel.appendChild(op); 
                }
      for(i=0;i<val.length;i++){
                               var op=document.createElement("option");
                                   op.value=val[i];
                                   op.innerHTML=val[i];
                                   sel.appendChild(op);
                               }
      
      
return sel;      
}  

function createSelectInterval(name,id,val,first,sizes,increment){
  var sel=document.createElement("select");
      if(IE) sel=document.createElement("<select name='"+name+"' size='"+sizes+"'>");
      sel.name=name;
      sel.id=id;
      if(!IE)sel.size=sizes;
      if(first) {
                 var op=document.createElement("option");
                                   op.value="";
                                   op.innerHTML="Select";
                                   sel.appendChild(op); 
                }
      for(i=0;i<val.length;i++){
                               var op=document.createElement("option");
                                   op.value=val[i]-increment;
                                   if(val[i]<=10000 )op.innerHTML="$"+(val[i]-increment)+" - $"+(val[i]-1);
                                   else op.innerHTML="$"+(val[i]-2*increment)+" - $"+(val[i]-1);
                                   sel.appendChild(op);
                               }
      
      
return sel;      
}  



function performAction(){
var val = document.getElementById("stateTab1").value;
    if(val.length<1) {showErrMsg("Select a state");return;}
    val= document.getElementById("ProTypeTab1").value;
    if(val.length<1) {showErrMsg("Select a property type");return;}
    val= document.getElementById("RateCreditTab1").value;
    if(val.length<1) {showErrMsg("Select a credit rate");return;}
    val= document.getElementById("LoanTypeTab1").value;
    if(val.length<1) {showErrMsg("Select a loan type");return;}
    var t=target;
    t+="?st="+encodeURIComponent(document.getElementById("stateTab1").value);
    t+="&proT="+encodeURIComponent(document.getElementById("ProTypeTab1").value);
    t+="&rateC="+encodeURIComponent(document.getElementById("RateCreditTab1").value);
    t+="&loanT="+encodeURIComponent(document.getElementById("LoanTypeTab1").value);
    window.location=t;
}




function showErrMsg(txt){

var divE=document.createElement("div");
    divE.id="tempDiv";
    divE.style.position="absolute";
    divE.style.zIndex="5";
    divE.style.textAlign="center";
    divE.style.backgroundColor="yellow";
    divE.style.fontWeight="bold";
    divE.style.fontStyle="italic";
    divE.style.top="3px";
    divE.style.left="200px";
    divE.style.fontSize="1.2em";
    divE.innerHTML=txt;
    mainElement.appendChild(divE); 
    setTimeout("hideErrMsg()",2000);   
}

function hideErrMsg(){
  if(document.getElementById("tempDiv")) mainElement.removeChild(document.getElementById("tempDiv"));
}