var showBackgroundImage=false;
var backgroundImagePath="back.jpg";
var backgroundImgeLocationX = 100;
var backgroundImgeLocationY = 60;
var showBackgroundColor=true;
var backgroundColor="#D6E2F2";

var isIE = navigator.appName.indexOf("Microsoft Internet Explorer")!= -1 ? true : false;

var targetSaver="http://www.4schools.com/schools/formEducation/education2.jsp";

var progressText="Progress ";
var text1="Check the subjects you are interested in:";
var text2="(Check at least one checkbox)";



// continue button
var showImageForConButton=false;
var imageConButtonPath="submit.jpg";
var conButtonText="Next >> ";

var areasTextValues=["Accounting/Finance","Arts / Design","Business","Criminal Justice Security","Education","Health/Human Services","IT/Technology","Legal/Paralegal","General Studies","Nursing","Project Management","Vocational"];
var leadSubjectValues=["ACCTG_FINANCE","ARTS_DESIGN","BUSINESS","CRIM_JUSTICE_SECURITY","EDUCATION","HEALTH_HUMAN_SERVICES","IT_TECHNOLOGY","LEGAL_PARALEGAL","GENERAL_STUDIES","NURSING","PROJ_MANAGEMENT","VOCATIONAL"];

//panel 2
var panel2Text="How old are you?";
var panel2Value=["Please select one:","50","49","48","47","46","45","44","43","42","41","40","39","38","37","36","35","34","33","32","31","30","29","28","27","26","25","24","23","22","21","20","19","18"];
var panel2Text2 = "Online or physical";
var panel2Value2 =["Please select one","Online","Physical","Hibrid","No preference"];
var panel2LeadValues=["ONLINE","PHYSICAL","HYBRID","NO_PREF"];


//panel 3
var panel3Text="What year did you obtain your high school diploma or GED?";
var panel3Value=["Please select one:","2008","2007","2006","2005","2004","2003","2002","2001","1999","1998","1997","1996","1995","1994","1993","1992","1991","1990","1989","1988","1987","1986","1985","1984","1983","1982","1981","1980","1979","1978","1977","1976"];
var panel3Text2 = "Desired degree";
var panel3Value2 =["Please select one","Certificate","Associate","Bachelors","Master","Doctorate"];
var panel3LeadValues=["CERTIFICATE","ASSOCIATES","BACHELORS","MASTERS","DOCTORATE"];

//panel 4
var panel4Text="What is the highest level of education you've obtained?";
var panel4Value=["Please select one:","GED","High school","same college","Associate degree","Bachelor degree","Master degree","Doctorate"];
var panel4LeadValues=["GED","HIGH_SCHOOL_DIPLOMA","SOME_COLLEGE","ASSOCIATES","BACHELORS","MASTERS","DOCTORATE"];
var panel4Text2 = "Desired start date";
var panel4Value2 =["Please select one","Less than a month","Between 1 and 3 months","Between 4 to 6 months","More than 6 months"];
var panel4LeadValues2=["LESS_THAN_1_MONTH","1_3_MONTHS","4_6_MONTHS","6_MONTHS_OR_MORE"];
var panel4Text2 = "Desired start date";
var panel4Value2 =["Please select one","Less than a month","Between 1 and 3 months","Between 4 to 6 months","More than 6 months"];
var panel4LeadValues2=["LESS_THAN_1_MONTH","1_3_MONTHS","4_6_MONTHS","6_MONTHS_OR_MORE"];
//panel 5
var panel5Text="What country do you reside in?";
var panel5Value=["Please select one:","United States","Canada","Other"];
var panel5Text2 = "Work experience in years";
var panel5Value2 =["Please select one","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"];
//panel 6
var panel6Text="Are you a U.S. Citizen?";
var panel6Value=["Yes","No"];
var panel6InitValue="";
var panel6LeadValues=["US_CITIZEN","NON_CITIZEN"];

//panel 7
var panel7Text="What is your US military affiliation?";
//var panel7Value=["Please select one:","No, I am not associated with US Military","LabelU.S. Air Force","AF - Active Duty(AD)","AF - Selective Reserve(SR)","AF - Spouse of AD or SR","AF - Veteran","AF - Civilian","LabelU.S. Air Force","LabelU.S. Army","AR - Active Duty(AD)","AR - Selective Reserve(SR)","AR - Spouse of AD or SR","AR - Veteran","AR - Civilian","LabelU.S. Army","LabelU.S. Coast Guard","CG - Active Duty(AD)","CG - Selective Reserve(SR)","CG - Spouse of AD or SR","CG - Veteran","CG - Civilian","LabelU.S. Coast Guard","LabelU.S. Navy","NV - Active Duty(AD)","NV - Selective Reserve(SR)","NV - Spouse of AD or SR","NV - Veteran","NV - Civilian","LabelU.S. Navy","DoD CIVILIAN"];
var panel7Value=["Please select one:","None","Active duty","Reserve","Spouse"];
var panel7LeadValues=["NONE","ACTIVE_DUTY","RESERVE","SPOUSE"];


//panel 8
var panel8Text1="What is your zip or postal code?";
var panel8Text2="What is your email address?";

var elemWapper;
var barColor;
var mainStep=1;
var step2Build=false;
var step3Build=false;
var step4Build=false;
var step5Build=false;
var step6Build=false;
var step7Build=false;
var step8Build=false;

function drawEducationForm(elemid){
var formE;

if(document.getElementById){
                             elemWapper=document.getElementById(elemid); 
                             var elem=document.createElement("div");
                              elem.style.position="relative";
                              elem.style.width="100%";
                              elem.style.height="100%";
                              elem.id="panel1";
                              elem.style.overflow="hidden";
                              
                             if(isIE) {formE=document.createElement("<form name='forma'>");
                                       var inE=document.createElement("<input name='interestedArea'>");
                                            inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='age'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='yearSDH'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='typeDH'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='country'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='citizen'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE); 
                                       inE=document.createElement("<input name='military'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='zip'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='email'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='psyH'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='dDegre'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='dstart'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("<input name='wExp'>");
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                      }
                             else { 
                                   formE=document.createElement("form");
                                   formE.name="forma";
                                   var inE=document.createElement("input");
                                       inE.name="interestedArea"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="age"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE); 
                                       inE=document.createElement("input");
                                       inE.name="yearSDH"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE); 
                                       inE=document.createElement("input");
                                       inE.name="typeDH"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="country"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="citizen"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="military"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="zip"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="email"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="psyH"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="dDegre"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="dstart"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);
                                       inE=document.createElement("input");
                                       inE.name="wExp"; 
                                       inE.type="hidden";
                                       formE.appendChild(inE);  
                                 }   
                             if(showBackgroundImage) {     
                             elem.style.backgroundImage="url('"+backgroundImagePath+"')";
                             elem.style.backgroundRepeat="no-repeat";
                             elem.style.backgroundPosition=""+backgroundImgeLocationX+" "+backgroundImgeLocationY;
                              }
                             if(showBackgroundColor) elem.style.backgroundColor=backgroundColor;

                              var tableE=document.createElement("table");
                                  tableE.width="100%";
                              var tbodyE=document.createElement("tbody");
                              var trE=document.createElement("tr");
                                  trE.id="progressRow";
                              var tdE=document.createElement("td");
                                  tdE.width="100px";
                                  tdE.innerHTML="&nbsp;";
                                  tdE.id="bTD";
                                  trE.appendChild(tdE);
                                  tdE=document.createElement("td");
                                  tdE.height="30px";
                                  tdE.appendChild(createProgresBar(140,7,"#215890",false));
                              trE.appendChild(tdE);
                              tbodyE.appendChild(trE);
                              tableE.appendChild(tbodyE);
                              elem.appendChild(tableE);
                              var elem1=document.createElement("div");
                                  elem1.id="pan1";
                                  tableE=document.createElement("table");
                                  tableE.id="mainTable";
                                  tableE.width="100%";
                                  tbodyE=document.createElement("tbody");
                              trE=document.createElement("tr");
                              tdE=document.createElement("td");
                              tdE.colSpan="2";
                              trE.id="txt1";
                              tdE.innerHTML=text1;
                              trE.appendChild(tdE);
                              tbodyE.appendChild(trE);
                             // trE=document.createElement("tr");
                             //// tdE=document.createElement("td");
                             // tdE.colSpan="2";
                             /// trE.id="txt2";
                             // tdE.innerHTML=text2;
                              ///trE.appendChild(tdE);
                             // tbodyE.appendChild(trE);
                              for(var i=0;i<areasTextValues.length;i++){
                                            if(i%2==0){
                                            trE=document.createElement("tr");
                                            trE.id="tempRowa"+(i/2); 
                                            }
                                            tdE=document.createElement("td");
                                            tdE.appendChild(createCheckbox(areasTextValues[i].substring(0,4),i));
                                            tdE.appendChild(document.createTextNode(areasTextValues[i]));
                                            trE.appendChild(tdE);
                                            if(i==areasTextValues.length-1 && i%2==0){
                                                           tdE=document.createElement("td");
                                                           tdE.innerHTML="&nbsp;";
                                                           trE.appendChild(tdE);i++;
                                                                                     }
                                            if(i%2==1) tbodyE.appendChild(trE);
                                           }
                               tableE.appendChild(tbodyE); 
                               elem1.appendChild(tableE);
                               elem.appendChild(elem1);                                 
                            
                               var buttonDiv=document.createElement("div");
                                   buttonDiv.style.textAlign="center";
                                   buttonDiv.id="butt";
                              if(showImageForConButton){
                               
                               var imgEl=document.createElement("img");
                                   imgEl.src=imageConButtonPath;
                                   imgEl.onclick=actionContinuePerformed; 
                                   imgEl.style.cursor="pointer";   
                                   buttonDiv.appendChild(imgEl);

                            }
                              else{
                                 inputE=document.createElement("input");
                                 inputE.type="button";
                                 inputE.value=conButtonText;
                                 inputE.onclick=actionContinuePerformed;
                                 buttonDiv.appendChild(inputE); 
                            }
                             
                              elem.appendChild(buttonDiv);
                              


 elemWapper.appendChild(elem);
 document.body.appendChild(formE);
}
}


function createProgresBar(length,steps,color,fir){
barColor=color;

var e=document.createElement("div");
    e.style.position="relative";
    e.style.width="100%";
    e.style.height="100%";
    e.id="divPB";
var spanE=document.createElement("span");
    spanE.innerHTML=progressText;
    spanE.style.position="absolute";
    spanE.style.top="2px";
    spanE.style.left="25px";
    e.appendChild(spanE);
var bar=document.createElement("div");
    bar.style.position="absolute";
    bar.style.top="5px";
    bar.style.left="80px";
    bar.style.border="1px solid gray"; 
var tableE=document.createElement("table");
    tableE.style.width=length;
    tableE.style.height="10px";
var tbodyE=document.createElement("tbody");
    tbodyE.id="pB";
var trE=document.createElement("tr");
var tdE;
    for(var i=0;i<steps;i++){
                             tdE=document.createElement("td");
                             if(fir && i==0) tdE.style.backgroundColor=color;
                             trE.appendChild(tdE);
                            }
    tbodyE.appendChild(trE);
    tableE.appendChild(tbodyE);
    bar.appendChild(tableE);      
    e.appendChild(bar);

   return e;
}

function createCheckbox(nam,i){
var elemE;
 if(isIE) elemE=document.createElement("<input type='checkbox' name='"+nam+"'>");
 else {
       elemE=document.createElement("input");
       elemE.name=nam;
       elemE.type="checkbox";
      }

elemE.id=i+"checkFP";
return elemE;  
}


function actionContinuePerformed(){
if(mainStep==1){var val="";
                var una=false;
                var elems=document.getElementById("mainTable").getElementsByTagName("input");
                for(var i=0;i<elems.length;i++){
                                                if(elems[i].type=="checkbox" && elems[i].checked == true) 
                                                   {if(una == true) val+=","; una=true;val+=leadSubjectValues[i];}
                                               }
                if(una == false) {showErrMsg("Select at least one field",110);return;}
                document.forma.interestedArea.value=val;
                hideStep1();
                showStep2();
                increasColor();
                mainStep++;
                return;
              }  
//if(mainStep==2){
  //              alert(document.forma.innerHTML);
    //           } 
}

function showStep1(){
document.getElementById("pan1").style.display="block"; 
document.getElementById("butt").style.display="block";
}

function hideStep1(){
  document.getElementById("pan1").style.display="none";
  document.getElementById("butt").style.display="none";
}

function showStep2(){
  addBackLink();
  if(step2Build) document.getElementById("pan2").style.display="block";
  else{
       var elem2=document.createElement("div");
           elem2.id="pan2";
           elem2.style.width="100%";
           elem2.style.height="100px";
           elem2.style.position="relative";
       var spanE=document.createElement("span");
           spanE.style.position="absolute";
           spanE.style.top="20px";
           spanE.style.left="50px";
           spanE.style.textAlign="left";
           spanE.innerHTML=panel2Text;
           spanE.appendChild(document.createElement("br"));
       var ageS=createSelect("agesel","agesel",panel2Value,false,1);
           ageS.onchange=ageSelection;
           spanE.appendChild(ageS);
           elem2.appendChild(spanE);
           elem2.appendChild(document.createElement("br"));
       var spanE2=document.createElement("span");
           spanE2.style.position="absolute";
           spanE2.style.top="100px";
           spanE2.style.left="50px";
           spanE2.style.textAlign="left";
           spanE2.innerHTML=panel2Text2;
           spanE2.appendChild(document.createElement("br"));
       var psy=createSelect("psyID","psyID",panel2Value2,false,1);
           psy.onchange=psySelection;
           spanE2.appendChild(psy);
           elem2.appendChild(spanE2); 
        
           document.getElementById("panel1").appendChild(elem2);
      step2Build=true;
      }
}

function hideStep2(erass){
if(erass)document.getElementById("bTD").removeChild(document.getElementById("backLink"));
document.getElementById("pan2").style.display="none";
}

function showStep3(){
  if(step3Build) document.getElementById("pan3").style.display="block";
  else{
       var elem2=document.createElement("div");
           elem2.id="pan3";
           elem2.style.width="100%";
           elem2.style.height="100px";
           elem2.style.position="relative";
       var spanE=document.createElement("span");
           spanE.style.position="absolute";
           spanE.style.top="20px";
           spanE.style.left="50px";
           spanE.style.textAlign="left";
           spanE.innerHTML=panel3Text;
           spanE.appendChild(document.createElement("br"));
       var ageS=createSelect("yearSD","yearSD",panel3Value,false,1);
           ageS.onchange=yearDSelection;
           spanE.appendChild(ageS);
           elem2.appendChild(spanE); 
           elem2.appendChild(document.createElement("br"));
       var spanE3=document.createElement("span");
           spanE3.style.position="absolute";
           spanE3.style.top="100px";
           spanE3.style.left="50px";
           spanE3.style.textAlign="left";
           spanE3.innerHTML=panel3Text2;
           spanE3.appendChild(document.createElement("br"));
       var dd=createSelect("dd","dd",panel3Value2,false,1);
           dd.onchange=ddSelection;
           spanE3.appendChild(dd);
           elem2.appendChild(spanE3); 
           document.getElementById("panel1").appendChild(elem2);
      step3Build=true;
      }
}

function hideStep3(){
document.getElementById("pan3").style.display="none";
}

function showStep4(){
  if(step4Build) document.getElementById("pan4").style.display="block";
  else{
       var elem2=document.createElement("div");
           elem2.id="pan4";
           elem2.style.width="100%";
           elem2.style.height="100px";
           elem2.style.position="relative";
       var spanE=document.createElement("span");
           spanE.style.position="absolute";
           spanE.style.top="20px";
           spanE.style.left="50px";
           spanE.style.textAlign="left";
           spanE.innerHTML=panel4Text;
           spanE.appendChild(document.createElement("br"));
       var ageS=createSelect("typeD","typeD",panel4Value,false,1);
           ageS.onchange=typeDSelection;
           spanE.appendChild(ageS);
           elem2.appendChild(spanE); 
           document.getElementById("panel1").appendChild(elem2);
            elem2.appendChild(document.createElement("br"));
       var spanE4=document.createElement("span");
           spanE4.style.position="absolute";
           spanE4.style.top="100px";
           spanE4.style.left="50px";
           spanE4.style.textAlign="left";
           spanE4.innerHTML=panel4Text2;
           spanE4.appendChild(document.createElement("br"));
       var ds=createSelect("ds","ds",panel4Value2,false,1);
           ds.onchange=dateStartSelection;
           spanE4.appendChild(ds);
           elem2.appendChild(spanE4); 
      step4Build=true;
      }
}

function hideStep4(){
document.getElementById("pan4").style.display="none";
}

function showStep5(){
  if(step5Build) document.getElementById("pan5").style.display="block";
  else{
       var elem2=document.createElement("div");
           elem2.id="pan5";
           elem2.style.width="100%";
           elem2.style.height="100px";
           elem2.style.position="relative";
       var spanE=document.createElement("span");
           spanE.style.position="absolute";
           spanE.style.top="20px";
           spanE.style.left="50px";
           spanE.style.textAlign="left";
           spanE.innerHTML=panel5Text;
           spanE.appendChild(document.createElement("br"));
       var ageS=createSelect("countryS","countryS",panel5Value,false,1);
           ageS.onchange=countrySelection;
           spanE.appendChild(ageS);
           elem2.appendChild(spanE); 
           elem2.appendChild(document.createElement("br"));
       var spanE5=document.createElement("span");
           spanE5.style.position="absolute";
           spanE5.style.top="100px";
           spanE5.style.left="50px";
           spanE5.style.textAlign="left";
           spanE5.innerHTML=panel5Text2;
           spanE5.appendChild(document.createElement("br"));
       var we=createSelect("we","we",panel5Value2,false,1);
           we.onchange=workESelection;
           spanE5.appendChild(we);
           elem2.appendChild(spanE5); 
           document.getElementById("panel1").appendChild(elem2);
      step5Build=true;
      }
}

function hideStep5(){
document.getElementById("pan5").style.display="none";
}

function showStep6(){
  if(step6Build) document.getElementById("pan6").style.display="block";
  else{
       var elem2=document.createElement("div");
           elem2.id="pan6";
           elem2.style.width="100%";
           elem2.style.height="100px";
           elem2.style.position="relative";
       var spanE=document.createElement("span");
           spanE.style.position="absolute";
           spanE.style.top="20px";
           spanE.style.left="50px";
           spanE.style.textAlign="left";
           spanE.innerHTML=panel6Text;
           spanE.appendChild(document.createElement("br"));
           addMultipleRadioButtons(spanE,"vertical",panel6Value,panel6InitValue,"uscitizen")
           elem2.appendChild(spanE); 
           document.getElementById("panel1").appendChild(elem2);
      step6Build=true;
      }
}

function hideStep6(){
document.getElementById("pan6").style.display="none";
}

function showStep7(){
  if(step7Build) document.getElementById("pan7").style.display="block";
  else{
       var elem2=document.createElement("div");
           elem2.id="pan7";
           elem2.style.width="100%";
           elem2.style.height="100px";
           elem2.style.position="relative";
       var spanE=document.createElement("span");
           spanE.style.position="absolute";
           spanE.style.top="20px";
           spanE.style.left="50px";
           spanE.style.textAlign="left";
           spanE.innerHTML=panel7Text;
           spanE.appendChild(document.createElement("br"));
        var militaryS=createSelect("miliS","miliS",panel7Value,false,1);
           militaryS.onchange=militarySelection;
           spanE.appendChild(militaryS);  
           elem2.appendChild(spanE); 
           document.getElementById("panel1").appendChild(elem2);
      step7Build=true;
      }
}

function hideStep7(){
document.getElementById("pan7").style.display="none";
}

function showStep8(){
  if(step8Build) {
                  document.getElementById("pan8").style.display="block";
                  }
  else{
       var elem2=document.createElement("div");
           elem2.id="pan8";
           elem2.style.width="100%";
           elem2.style.height="100px";
           elem2.style.position="relative";
       var spanE=document.createElement("span");
           spanE.style.position="absolute";
           spanE.style.top="20px";
           spanE.style.left="50px";
           spanE.style.textAlign="left";
           spanE.innerHTML=panel8Text1;
           spanE.appendChild(document.createElement("br"));
       var inE=document.createElement("input");
           inE.size="5";
           inE.id="zipID";
           spanE.appendChild(inE);  
           spanE.appendChild(document.createElement("br"));
           spanE.appendChild(document.createTextNode(panel8Text2));
           spanE.appendChild(document.createElement("br"));
       var inE=document.createElement("input");
           inE.id="emailID";
           spanE.appendChild(inE);    
           elem2.appendChild(spanE);
           elem2.appendChild(document.createElement("br"));
            var buttonDiv=document.createElement("div");
                                   buttonDiv.style.textAlign="center";
                                   buttonDiv.id="butt2";
                                   buttonDiv.style.position="absolute";
                                   buttonDiv.style.left="100px";
                                   buttonDiv.style.top="120px";
                              if(showImageForConButton){
                               
                               var imgEl=document.createElement("img");
                                   imgEl.src=imageConButtonPath;
                                   imgEl.onclick=doSave; 
                                   imgEl.style.cursor="pointer";   
                                   buttonDiv.appendChild(imgEl);

                            }
                              else{
                                 inputE=document.createElement("input");
                                 inputE.type="button";
                                 inputE.value=conButtonText;
                                 inputE.onclick=doSave;
                                 buttonDiv.appendChild(inputE); 
                            } 
           elem2.appendChild(buttonDiv);   
           document.getElementById("panel1").appendChild(elem2);
      step8Build=true;
      }
}

function hideStep8(){
document.getElementById("pan8").style.display="none";
}

function createSelect(name,id,val,first,sizes){
  var sel=document.createElement("select");
      if(isIE) sel=document.createElement("<select name='"+name+"' size='"+sizes+"'>");
      sel.name=name;
      sel.id=id;
      if(!isIE)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 createSelectWithLabel(name,id,val,first,sizes){
  var lastGroup;
  var toGroup=false;
  var sel=document.createElement("select");
      if(isIE) sel=document.createElement("<select name='"+name+"' size='"+sizes+"'>");
      sel.name=name;
      sel.id=id;
      if(!isIE)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;
                                   if(val[i].indexOf("Label")==0){
                                      if(toGroup){
                                                  sel.appendChild(lastGroup);
                                                  toGroup=false;
                                                  }
                                    else{
                                              lastGroup=document.createElement("optgroup");
                                              lastGroup.label=val[i].substring(5);
                                        toGroup=true;
                                        }
                                    }
                                   else{
                                   op=document.createElement("option");
                                   op.value=val[i];
                                   op.innerHTML=val[i];
                                   if(toGroup==false)sel.appendChild(op);
                                   else lastGroup.appendChild(op);
                                       }
                               }
      
      
return sel;      
} 

function addMultipleRadioButtons(elemE,alig,values,initVal,nam){

    
    for(var i=0;i<values.length;i++){
                                    var cheE;
                                    if(isIE) {
                                        if(values[i]==initVal) cheE=document.createElement("<input type=radio checked name='"+nam+"'>");
                                        else cheE=document.createElement("<input type=radio  name='"+nam+"'>");
                                             } 
                                    else {
                                          cheE=document.createElement("input");
                                          cheE.name=nam;
                                          cheE.type="radio";
                                          if(values[i]==initVal) cheE.checked=true;
                                         }
                                    cheE.id=nam+i; 
                                    cheE.value=values[i];
                                    cheE.onclick=uscitizenSelected;      
                                    elemE.appendChild(cheE);
                                    elemE.appendChild(document.createTextNode(values[i]));
                                    if(alig=="vertical") elemE.appendChild(document.createElement("br"));
                                    }
}

function increasColor(){

var el=document.getElementById("pB");
for(var i=0;i<el.rows[0].cells.length;i++){
                                           if(el.rows[0].cells[i].style.backgroundColor.length > 0){}
                                           else {
                                                 el.rows[0].cells[i].style.backgroundColor=barColor;
                                                 break;
                                                }
                                          } 

}

function decressColor(){
var el=document.getElementById("pB");
var ultim;
for(var i=0;i<el.rows[0].cells.length;i++){
                                           if(el.rows[0].cells[i].style.backgroundColor.length > 0){
                                            ultim=el.rows[0].cells[i];
                                            }
                                           else {
                                                 //el.rows[0].cells[i].style.backgroundColor=barColor;
                                                 break;
                                                }
                                          } 
ultim.style.backgroundColor="";

}

function showErrMsg(txt,left){
var pos=getContainerPosition();
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=pos.top+5+"px";
    divE.style.left=pos.left+left+"px";
    divE.style.fontSize="1.2em";
    divE.innerHTML=txt;
    document.body.appendChild(divE); 
    setTimeout("hideErrMsg()",2000);   
}

function hideErrMsg(){
  if(document.getElementById("tempDiv")) document.body.removeChild(document.getElementById("tempDiv"));
}

function getContainerPosition(){
var parent=elemWapper;
var leftt=0;
var topp=0;
while(parent){
                    leftt+=parent.offsetLeft;
					topp+=parent.offsetTop;
					parent=parent.offsetParent;
			}
if(navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined"){
                    topp+=document.body.topMargin;
					leftt+=document.body.leftMargin;
					} 			
return {left:leftt,top:topp}
}

function addBackLink(){
  var spanE=document.createElement("span");
  var aE=document.createElement("a");
      aE.href="javascript: void goBack();";
      aE.appendChild(document.createTextNode("Back"));
     spanE.style.position="absolute";
     spanE.style.left="10px";
     spanE.style.top="3px";
     spanE.style.zIndex="4";
     spanE.id="backLink";
     spanE.appendChild(aE); 
     document.getElementById("bTD").appendChild(spanE);

}

function goBack(){
  if(mainStep==2){
                  hideStep2(true);
                  showStep1();
                  mainStep--;
                  decressColor();
                 }
 if(mainStep==3){
                  hideStep3(false);
                  showStep2();
                  mainStep--;
                  decressColor();
                 }

if(mainStep==4){
                  hideStep4(false);
                  showStep3();
                  mainStep--;
                  decressColor();
                 }
if(mainStep==5){
                  hideStep5(false);
                  showStep4();
                  mainStep--;
                  decressColor();
                 }
if(mainStep==6){
                  hideStep6();
                  showStep5();
                  mainStep--;
                  decressColor();
                 }
if(mainStep==7){
                  hideStep7();
                  showStep6();
                  mainStep--;
                  decressColor();
                 }
if(mainStep==8){
                  hideStep8();
                  showStep7();
                  mainStep--;
                  decressColor();
                 }
}


function ageSelection(){
if(document.getElementById("agesel").selectedIndex==0) {showErrMsg("Select a value for the age",110);return;}
document.forma.age.value=document.getElementById("agesel").value;
if(document.getElementById("psyID").selectedIndex==0) return;
hideStep2(false);
showStep3();
increasColor();
mainStep++;
}

function psySelection(){
if(document.getElementById("psyID").selectedIndex==0) {showErrMsg("Select a value for the online psysical",110);return;}
document.forma.psyH.value=panel2LeadValues[document.getElementById("psyID").selectedIndex-1];
if(document.getElementById("agesel").selectedIndex==0) return;
hideStep2(false);
showStep3();
increasColor();
mainStep++;
}

function yearDSelection(){
if(document.getElementById("yearSD").selectedIndex==0) {showErrMsg("Select a value ",140);return;}
document.forma.yearSDH.value=document.getElementById("yearSD").value;
if(document.getElementById("dd").selectedIndex==0) return;
hideStep3();
showStep4();
increasColor();
mainStep++;
}

function ddSelection(){
if(document.getElementById("dd").selectedIndex==0) {showErrMsg("Select a value for the desire degree",110);return;}
document.forma.dDegre.value=panel3LeadValues[document.getElementById("dd").selectedIndex-1];
if(document.getElementById("yearSD").selectedIndex==0) return;
hideStep3();
showStep4();
increasColor();
mainStep++;
}

function typeDSelection(){
if(document.getElementById("typeD").selectedIndex==0) {showErrMsg("Select a degree type ",100);return;}
document.forma.typeDH.value=panel4LeadValues[document.getElementById("typeD").selectedIndex-1];
if(document.getElementById("ds").selectedIndex==0) return;
hideStep4();
showStep5();
increasColor();
mainStep++;
}

function dateStartSelection(){
if(document.getElementById("ds").selectedIndex==0) {showErrMsg("Select a value for the desire start date",90);return;}
document.forma.dstart.value=panel4LeadValues2[document.getElementById("ds").selectedIndex-1];
if(document.getElementById("typeD").selectedIndex==0) return;
hideStep4();
showStep5();
increasColor();
mainStep++;
}


function countrySelection(){
if(document.getElementById("countryS").selectedIndex==0) {showErrMsg("Select a country ",100);return;}
document.forma.country.value="UNITED_STATES";
if(document.getElementById("we").selectedIndex==0) return;
hideStep5();
showStep6();
increasColor();
mainStep++;
}


function workESelection(){
if(document.getElementById("we").selectedIndex==0) {showErrMsg("Select a value for the work experience",90);return;}
document.forma.wExp.value=document.getElementById("we").value;
if(document.getElementById("countryS").selectedIndex==0) return;
hideStep5();
showStep6();
increasColor();
mainStep++;
}

function uscitizenSelected(){
var index;
for(var i=0;i<panel6Value.length;i++){
                  if(document.getElementById("uscitizen"+i).checked == true) {
                              index=i;
                              break;
                                  }
}
document.forma.citizen.value=panel6LeadValues[index];
hideStep6();
showStep7();
increasColor();
mainStep++;
}

function militarySelection(){
if(document.getElementById("miliS").selectedIndex==0) {showErrMsg("Please, select a value ",100);return;}
document.forma.military.value=panel7LeadValues[document.getElementById("miliS").selectedIndex-1];
hideStep7();
showStep8();
increasColor();
mainStep++;
}

function doSave(){
var emailFilter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var zipFormat=/^\d{5}$/;

if(document.getElementById("zipID").value.length<1) {showErrMsg("Enter your zip code ",100);return;}
if(!document.getElementById("zipID").value.match(zipFormat)) {showErrMsg("The zip code format is XXXXX ",70);return;}
document.forma.zip.value=document.getElementById("zipID").value;
if(document.getElementById("emailID").value.length<1) {showErrMsg("Enter your email address ",100);return;}
if(!document.getElementById("emailID").value.match(emailFilter)) {showErrMsg("The email format is wrong ",100);return;}
document.forma.email.value=document.getElementById("emailID").value;
document.forma.method="post";
document.forma.action=targetSaver;
document.forma.submit();   
}