      function validateWidth(field){
      //for sliding doors
       if($('#doortype').attr('value')=="sliding"){
         if(field.value<600||field.value>5270){
             field.value="";
             $('#width_dialog').dialog('open');
         }
         else{
             if($('#oheight').attr('value')!=""){
                showDoors(0)
                setDoorNumber(field.value,"sliding");
             }
         }
       }
       else if($('#doortype').attr('value')=="hinged"){
         if(field.value<500||field.value>5068){
             field.value="";
             $('#width_dialog').dialog('open');
         }
         else{
             if($('#oheight').attr('value')!=""){
                showDoors(0);
                setDoorNumber(field.value,"hinged");
             }
         }

       }
      }

      function validateHeight(field){
         if(field.value<0||field.value>2700){
             field.value="";
             $('#height_dialog').dialog('open')
         }
         else{
             if($('#owidth').attr('value')!=""){
                showDoors(0);
                setDoorNumber($('#owidth').attr('value'),$('#doortype').attr('value'));
             }
         }
      }

      function validate(form){
           //if(form.overallheight.value==""){


      }

      function setDoorNumber(width,doortype){
        var parent=document.getElementById("number_of_doors");
        parent.value="";
        var opt=parent.getElementsByTagName("input");
        var txt=parent.getElementsByTagName("span");
        for(i=0;i<opt.length;i++){
           opt[i].disabled=true;
           opt[i].checked=false;
           txt[i].style.color="#CCC";
        }
        switch(doortype){

        case "hideall":
          /* opt[0].style.display="none";
           opt[1].style.display="none";
           opt[2].style.display="none";
           opt[3].style.display="none";
           opt[4].style.display="none";
           opt[5].style.display="none";
           opt[6].style.display="none";
           opt[7].style.display="none";*/

        break;

        case "sliding":
        if(width>0&&width<=2377){
           opt[1].disabled=false;
           txt[1].style.color="#000";
           opt[2].disabled=false;
           txt[2].style.color="#000";
        }
        else if(width>2377&&width<=3418){
           opt[2].disabled=false;
           opt[3].disabled=false;
           txt[2].style.color="#000";
           txt[3].style.color="#000";
        }
        else if(width>3418&&width<=4484){
           opt[3].disabled=false;
           opt[4].disabled=false;
           txt[3].style.color="#000";
           txt[4].style.color="#000";
        }
        else if(width>4484&&width<=5500){
           opt[4].disabled=false;
           txt[4].style.color="#000";

        }
        break;

        case "hinged":
        if(width>0&&width<=838){
           opt[0].disabled=false;
           opt[1].disabled=false;
           txt[0].style.color="#000";
           txt[1].style.color="#000";

        }
        else if(width>838&&width<=1442){
           opt[1].disabled=false;
           txt[1].style.color="#000";

        }
        else if(width>1442&&width<=2046){
           opt[2].disabled=false;
           txt[2].style.color="#000";


        }

        else if(width>2046&&width<=2650){

           opt[3].disabled=false;
           txt[3].style.color="#000";


        }
        else if(width>2650&&width<=3270){

           opt[4].disabled=false;
           txt[4].style.color="#000";

        }
        else if(width>3270&&width<=3874){

           opt[5].disabled=false;
           txt[5].style.color="#000";


        }
        else if(width>3874&&width<=4490){

           opt[6].disabled=false;
           txt[6].style.color="#000";

        }
        else if(width>4490&&width<=5068){

           opt[7].disabled=false;
           txt[7].style.color="#000";

        }

        break;

        }


      }



function showDoors(dn){

    var c=document.getElementById("doortypes").rows[0].cells;
    for(i=0;i<8;i++){
        c[i].getElementsByTagName("DIV")[0].style.display=(i<dn)?"block":"none";
        c[i].getElementsByTagName("DIV")[0].getElementsByTagName("SELECT")[0].style.display=($('#doortype').attr('value')=="hinged")?"none":"block";
        c[i].getElementsByTagName("DIV")[0].getElementsByTagName("SELECT")[0].value=($('#doortype').attr('value')=="hinged")?"Full Panel":c[i].getElementsByTagName("DIV")[0].getElementsByTagName("SELECT")[0].value;
        c[i].getElementsByTagName("DIV")[0].getElementsByTagName("IMG")[0].src=($('#doortype').attr('value')=="hinged")?'images/pricingcalculator/fullpanel.gif':c[i].getElementsByTagName("DIV")[0].getElementsByTagName("IMG")[0].src;
    }
    var ds_text=($('#doortype').attr('value')=="hinged")?"Hinged doors:":"Select type for each sliding door:"
    $('#door_select').text(ds_text);
}

function showType(door,type){
    d=door.getElementsByTagName("IMG")[0];
    switch(type){
    case "Full Panel":
    d.src="images/pricingcalculator/fullpanel.gif";
    break;

    case "2 Panels":
    d.src="images/pricingcalculator/2panels.gif";
    break;

    case "3 Panels":
    d.src="images/pricingcalculator/3panels.gif";
    break;

    case "4 Panels":
    d.src="images/pricingcalculator/4panels.gif";
    break;

    case "5 Panels":
    d.src="images/pricingcalculator/5panels.gif";
    break;
    }


}
