

























var W3C,IE4,IE6CSS,NN4,isCSS,IE;

var State = new Array();
var Code = new Array();

var mainElementI;



//values 
var showStartImagePath="http://www.justbetterloans.com/images/kellygrquotebutton1.gif";
var wasTabDrawnTab2=false;
//var showTitleTextTab2=true;
var titleTextTab2="Save on Insurance Now";
var showTitleImageTab2=false;
//var titleImagePathTab2="http://www.justbetterloans.com/images/kellygrquotebutton1.gif";
var showNumberTab2=false;
var insuranceTab2=["Auto Insurance","Health Insurance","Home Insurance","Life Insurance","Motorcycle Insurance"];
var showStartImageTab2=true;
var startTextTab2="Start saving here";
var targetTab2="http://www.justbetterloans.com/betterloans/smart/insurance/ins2a.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 drawFormIns(elemID){
   initBarbosDHTMLAPI();
   BuildStateArrays();
    var elem=document.getElementById(elemID);
        mainElementI=elem; 
        if(elem.style) elem.style.overflow="hidden";

   if(W3C){
           

          drawfForm(elem);
           }

} 
             



function drawfForm(elem){
   if(wasTabDrawnTab2 == false) {
   var divContainer=document.createElement("div");
       divContainer.id="TabContainer2";
                                 /*if(showTitleTextTab2){
                                                      var spanE=document.createElement("span");
                                                          spanE.innerHTML= titleTextTab2;
                                                          spanE.style.color="#222255";
                                                          spanE.style.fontSize="1.4em";
                                                          spanE.style.fontStyle="italic";
                                                      divContainer.appendChild(spanE);
                                                     } 
                                 else if(showTitleImageTab2){
                                                             var spanE=document.createElement("span");
                                                             var img1=document.createElement("img");
                                                                 img1.src=titleImagePathTab2;
                                                                 spanE.appendChild(img1);
                                                                  divContainer.appendChild(spanE);
                                                             } */
                                 var tableE=document.createElement("table");
                                    tableE.width="100%";
                                   // tableE.height="95%";
                                    tableE.id="insuranceContainer";  
                                var tbod=document.createElement("tbody");
                                var trE=document.createElement("tr");
                                var tdE=document.createElement("td");
                                var txt=document.createTextNode("Insurance type ");
                                var sele=createSelect("insTab2","insTab2",insuranceTab2,true,1);
                                var noE;
                                    if(showNumberTab2){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.justbetterloans.com/script/one.gif";
                                                       tdEE.appendChild(noI);
                                                       tdEE.valign="bottom";
                                                       trE.appendChild(tdEE);
                                                       }     
                                    tdE.appendChild(txt);
                                    trE.appendChild(tdE);  
                                    tdE=document.createElement("td");  
                                    //tdE.appendChild(document.createElement("br"));
                                    tdE.appendChild(sele);
                                    trE.appendChild(tdE);
                                    tbod.appendChild(trE);
                                    trE=document.createElement("tr");
                                    tdE=document.createElement("td");
                                   // tdE=document.createElement("td");
                                    if(showNumberTab2){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.justbetterloans.com/script/two.gif";
                                                       tdEE.appendChild(noI);
                                                       tdEE.valign="bottom";
                                                       trE.appendChild(tdEE);
                                                       } 
                                    txt=document.createTextNode("State"); 
                                    tdE.appendChild(txt);
                                    trE.appendChild(tdE);  
                                    tdE=document.createElement("td");
                                    //tdE.appendChild(document.createElement("br"));
                                    sele=createSelect("stateTab2","stateTab2",State,true,1);
                                    tdE.appendChild(sele);
                                    trE.appendChild(tdE);
                                    tbod.appendChild(trE);
                                   /* trE=document.createElement("tr");
                                    tdE=document.createElement("td");
                                    if(showNumberTab2){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.justbetterloans.com/script/three.gif";
                                                       tdEE.appendChild(noI);
                                                       trE.appendChild(tdEE);
                                                       }    
                                    txt=document.createTextNode("Zip code:"); 
                                    tdE.appendChild(txt);
                                    trE.appendChild(tdE);  
                                    tdE=document.createElement("td"); 
                                    //tdE.appendChild(document.createElement("br"));
                                   var inE=document.createElement("input");
                                       inE.id="zipTab2";
                                       inE.type="text";
                                       inE.size="6";
                                       inE.maxLength="6";  
                                    tdE.appendChild(inE);
                                    trE.appendChild(tdE);
                                    tbod.appendChild(trE);*/
                                    trE=document.createElement("tr");
                                    tdE=document.createElement("td"); 
                                    tdE.colSpan="2"; 
                                    //tdE=document.createElement("td");
                                    if(showNumberTab2){
                                                       var tdEE=document.createElement("td");    
                                                           tdEE.width="40px";
                                                       var noI=document.createElement("img");
                                                           noI.src="http://www.justbetterloans.com/script/four.gif";
                                                       tdEE.appendChild(noI);
                                                       tdEE.valign="bottom";
                                                       trE.appendChild(tdEE);
                                                       } 
                                    if(showStartImageTab2){
                                                      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);
                                              imgE.onclick=performActionI;
                                              imgE.style.cursor="pointer";
                                          divEE.appendChild(inE);
                                          divEE.style.paddingTop="10px";
                                          tdE.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=startTextTab2;
                                              inE.onclick=performActionI;
                                          divEE.appendChild(inE);
                                          divEE.style.paddingTop="10px";
                                          tdE.appendChild(divEE);
                                          }  
                                   // tdE.appendChild(sele);
                                    trE.appendChild(tdE);
                                    tbod.appendChild(trE);
                                    tableE.appendChild(tbod);
                                    divContainer.appendChild(tableE);
       wasTabDrawnTab2=true;
       elem.appendChild(divContainer);
                     }

  else{
      document.getElementById("TabContainer2").style.zIndex=3;
      document.getElementById("TabContainer2").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 performActionI(){
var val = document.getElementById("insTab2").value;
    if(val.length<1) {showErrMsgA("Select an insurance type");return;}
    val= document.getElementById("stateTab2").value;
    if(val.length<1) {showErrMsgA("Select a state");return;}
    var t=targetTab2;
    t+="?statecode=";
    t+=encodeURIComponent(Code[document.getElementById("stateTab2").selectedIndex-1]);
    //t+="&zipcode="+document.getElementById("zipTab2").value;
    t+="&code=";
    if(document.getElementById("insTab2").value=="Auto Insurance") t+="2551";
    if(document.getElementById("insTab2").value=="Health Insurance") t+="2553";
    if(document.getElementById("insTab2").value=="Home Insurance") t+="2554";
    if(document.getElementById("insTab2").value=="Life Insurance") t+="2556";
    if(document.getElementById("insTab2").value=="Motorcycle Insurance") t+="2557";
    window.location=t;
}



function showErrMsgA(txt){

var divE=document.createElement("div");
    divE.id="tempDivA";
    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="10px";
    divE.style.left="30px";
    divE.style.fontSize="1.2em";
    divE.innerHTML=txt;
    mainElementI.appendChild(divE); 
    setTimeout("hideErrMsgA()",2000);   
}

function hideErrMsgA(){
  if(document.getElementById("tempDivA")) mainElementI.removeChild(document.getElementById("tempDivA"));
}
