function onLoad()
{
    jsonrpc = new JSONRpcClient("/JSON-RPC");
    
}
function getAttributes(val)
{
         //alert("Action = " + val);
         var act = 'quote.jsp?action='+val;
         var info = document.all.tabinfo.tBodies[0].rows[0].cells[0]
         info.innerText="Please Wait..."
             try
             {
        	     if(val=="new"|| val==null)
        	     {
                    var result = jsonrpc.Description.getDescriptions("PIPE");
                    var values = new Array();
                    values = result["list"];
                    clearSelect("frmCreateQuote","cbComodity");
                    AddComboValues(values,"cbComodity");

                 }
             }
             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }

             try
             {
                 if(val=="type")
    	         {

                    var ctype = document.frmCreateQuote.cbType;
                    if( ctype.value !="OTHER")
                    {
                        disableCombos("type");
                        var result = jsonrpc.Description.getDescriptions(ctype.value);
                        var values = new Array();
                        values = result["list"];
                        clearSelect("frmCreateQuote","cbComodity");
                        AddComboValues(values,"cbComodity");
                        //Hide Display Configuration Combo
                         var tdconfig =document.all.tbllines.tBodies[0].rows[1].getElementsByTagName("td")["tdconfig"];
                         var htdconfig =document.all.tbllines.tBodies[0].rows[0].getElementsByTagName("td")["htdconfig"];
                         var htdsize =document.all.tbllines.tBodies[0].rows[0].getElementsByTagName("td")["htdsize"];

                            if(ctype.value =="PLATE" ||ctype.value =="SHEET" ||ctype.value == "SQ & RECT" || ctype.value =="ANGLE" ||ctype.value =="BAR"||ctype.value == "CHANNEL")
                            {
                              htdsize.innerText = "Spec";
                            }
                            else
                            {
                              htdsize.innerText = "Size";
                            }
                            if(ctype.value =="FLANGES" ||ctype.value =="FITTING" )
                            {
                             htdconfig.style.display="block";
                             tdconfig.style.display="block";

                            }
                            else
                            {
                              htdconfig.style.display="none";
                              tdconfig.style.display="none";

                            }
                       info.innerText="Select the Product";
                       document.frmCreateQuote.cbComodity.disabled=false;
                    }
                    else
                    {
                       document.frmCreateQuote.LText.focus();
                       info.innerText="Please enter the special information for the item";

                       disableCombos(val);
                    }
                    setLtypeCombo(val)
                 }
             }

             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }
             try
             {
                 if(val=="desc")
    	         {

                    var ctype = document.frmCreateQuote.cbType;
                    var cComm = document.frmCreateQuote.cbComodity;

                    if(cComm.value!="LT")
                    {

                        if(ctype.value =="FLANGES" ||ctype.value =="FITTING" )
                        {
                           disableCombos("desc");
                           var cConf = document.frmCreateQuote.cbConfig;
                           var result = jsonrpc.Description.getSubtypeFit(ctype.value,cComm.value);
                           var values = new Array();
                           values = result["list"];
                           clearSelect("frmCreateQuote","cbConfig");
                           AddComboValues(values,"cbConfig");
                           info.innerText="Select the Desired Configuration";
                           cConf.disabled = false;
                        }
                        else
                        {
                           disableCombos("desc");
                            var result = jsonrpc.Description.getGradeDescriptions(ctype.value,cComm.value,"");
                            var values = new Array();
                            values = result["list"];
                            clearSelect("frmCreateQuote","cbgradeDes");
                            AddComboValues(values,"cbgradeDes");
                            info.innerText="Select the Commodity";
                            document.frmCreateQuote.cbgradeDes.disabled = false;
                        }

                    }
                    else
                    {
                       document.frmCreateQuote.LText.focus();
                       info.innerText="Please enter the special information for the item";
                       disableCombos(val);

                    }
                 }
             }
             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }
             try
             {
                 if(val=="config")
    	         {

                    var ctype = document.frmCreateQuote.cbType;
                    var cComm = document.frmCreateQuote.cbComodity;
                    var cConf = document.frmCreateQuote.cbConfig;

                    if(cConf.value!="LT")
                    {
                        disableCombos(val);
                        var result = jsonrpc.Description.getGradeDescriptions(ctype.value,cComm.value,cConf.value);
                        var values = new Array();
                        values = result["list"];
                        clearSelect("frmCreateQuote","cbgradeDes");
                        AddComboValues(values,"cbgradeDes");
                        info.innerText="Select the Commodity";
                        document.frmCreateQuote.cbgradeDes.disabled = false;
                    }
                    else
                    {
                       document.frmCreateQuote.LText.focus();
                       info.innerText="Please enter the special information for the item";
                       disableCombos(val);


                    }
                 }

             }
             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }
             try
             {
                 if(val=="gradedesc")
    	         {
                    var ctype = document.frmCreateQuote.cbType;
                    var cComm = document.frmCreateQuote.cbComodity;
                    var cGradeDes = document.frmCreateQuote.cbgradeDes;
                    disableCombos(val);
                    var cValue = cGradeDes.value ;

                    if(cValue == 'LT' )
                    {

                        document.frmCreateQuote.LText.focus();
                        info.innerText="Please enter the special information for the item";
                       // disableCombos(val);


                    }
                    else
                    {
                        if(ctype.value =="FLANGES" ||ctype.value =="FITTING" )
                        {
                          var cConf = document.frmCreateQuote.cbConfig;
                           var result = jsonrpc.Description.getGrade(ctype.value,cComm.value,cConf.value,cGradeDes.value);
                                               }
                        else
                        {

                            var result = jsonrpc.Description.getGrade(ctype.value,cComm.value,"",cGradeDes.value);

                        }
                            var values = new Array();
                            values = result["list"];
                            clearSelect("frmCreateQuote","cbGrade");
                            AddComboValues(values,"cbGrade");
                            info.innerText="Select the Grade";
                            document.frmCreateQuote.cbGrade.disabled = false;
                     }

                 }

             }
             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }
             try
             {
                 if(val=="grade")
    	         {
                    var ctype = document.frmCreateQuote.cbType;
                    var cComm = document.frmCreateQuote.cbComodity;
                    var cGradeDes = document.frmCreateQuote.cbgradeDes;
                    var cGrade = document.frmCreateQuote.cbGrade;
                    disableCombos(val);
                    if(cGrade.value != "LT")
                    {

                        if(ctype.value =="FLANGES" ||ctype.value =="FITTING" )
                        {
                          var cConf = document.frmCreateQuote.cbConfig;
                           var result = jsonrpc.Description.getSize(ctype.value,cComm.value,cConf.value,cGradeDes.value,cGrade.value);
                                               }
                        else
                        {

                            var result = jsonrpc.Description.getSize(ctype.value,cComm.value,"",cGradeDes.value,cGrade.value);

                        }
                            var values = new Array();
                            values = result["list"];
                            clearSelect("frmCreateQuote","cbSize");
                            AddComboValues(values,"cbSize");
                            document.frmCreateQuote.cbSize.disabled = false;
                            info.innerText="Select the Size";

                     }
                     else
                     {
                           document.frmCreateQuote.LText.focus();
                           info.innerText="Please enter the special information for the item";
                           //disableCombos(val);

                     }
                 }

             }
             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }
             try
             {
                 if(val=="size")
    	         {
                    var ctype = document.frmCreateQuote.cbType;
                    var cComm = document.frmCreateQuote.cbComodity;
                    var cGradeDes = document.frmCreateQuote.cbgradeDes;
                    var cGrade = document.frmCreateQuote.cbGrade;
                    var cSize = document.frmCreateQuote.cbSize;
                     disableCombos(val);
                    if(cSize.value != "LT")
                    {

                        if(ctype.value =="FLANGES" ||ctype.value =="FITTING" )
                        {
                          var cConf = document.frmCreateQuote.cbConfig;
                           var result = jsonrpc.Description.getWallRating(ctype.value,cComm.value,cConf.value,cGrade.value,cSize.value);
                        }
                        else
                        {

                            var result = jsonrpc.Description.getWallRating(ctype.value,cComm.value,"",cGrade.value,cSize.value);

                        }
                                var values = new Array();
                                values = result["list"];

                                clearSelect("frmCreateQuote","cbWall");
                                AddComboValues(values,"cbWall");
                                document.frmCreateQuote.cbWall.disabled = false;
                                info.innerText="Select the Wall Rating";

                    }
                    else
                    {
                           document.frmCreateQuote.LText.focus();
                           info.innerText="Please enter the special information for the item";
                           //disableCombos(val);
                    }
                 }

             }
             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }
             try
             {
                 if(val=="wall")
    	         {
                    var ctype = document.frmCreateQuote.cbType;
                    var cComm = document.frmCreateQuote.cbComodity;
                    var cGradeDes = document.frmCreateQuote.cbgradeDes;
                    var cGrade = document.frmCreateQuote.cbGrade;
                    var cSize = document.frmCreateQuote.cbSize;
                    var cWall = document.frmCreateQuote.cbWall;
                    var origin = document.frmCreateQuote.cbImport.value;
                    if(origin=="1")
                          origin = "DOM";
                    else
                          origin = "IMP";


                    if(cWall.value != "LT")
                    {
                        if(ctype.value =="FLANGES" ||ctype.value =="FITTING" )
                        {
                          var cConf = document.frmCreateQuote.cbConfig;
                           var result = jsonrpc.Description.getPartNumber(ctype.value,cComm.value,cConf.value,cGrade.value,cSize.value,cWall.value,origin,cGradeDes.value);
                        }
                        else
                        {

                            var result = jsonrpc.Description.getPartNumber(ctype.value,cComm.value,"",cGrade.value,cSize.value,cWall.value,origin,cGradeDes.value);

                        }

                                document.all.txtpartnum.value = result;
                                info.innerText="Select the Length Type, Enter the Quantity. Press Add Line Button to save your data";

                    }
                    else
                    {
                           document.frmCreateQuote.LText.focus();
                           info.innerText="Please enter the special information for the item";
                           document.all.txtpartnum.value ="XXXXX-XXXX-XXXXX";
                    }
                 }

             }
             catch(e)
             {
              alert("Type = "+ val +"\n"+ e );
             }
      //grade,size,wallgradedesc



    }
    function setLtypeCombo(type)
    {
      var cbLtype = document.frmCreateQuote.cbLtype;
      var ctype = document.frmCreateQuote.cbType;
      var units = document.all.tbllines.tBodies[0].rows[1].getElementsByTagName("td")["units"];
      clearSelect("frmCreateQuote","cbLtype");
      if(ctype.value =="PIPE" ||ctype.value =="TUBE" )
      {
           var o = new Option();
           o.value = "1";
           o.text = "RL";
           cbLtype.add(o);
           var o = new Option();
           o.value = "2";
           o.text = "SRL";
           cbLtype.add(o);
           var o = new Option();
           o.value = "3";
           o.text = "DRL";
           cbLtype.add(o);
           var o = new Option();
           o.value = "4";
           o.text = "CUT";
           cbLtype.add(o);
           units.innerText ="ft";

      }
      else
      {
           var o = new Option();
           o.value = "5";
           o.text = "OTH";
           cbLtype.add(o);
           units.innerText ="ea";


      }

    }


    function clearCombos(val)
    {
            var ctype = document.frmCreateQuote.cbType.value;
            var cComm = document.frmCreateQuote.cbComodity;
            var cGradeDes = document.frmCreateQuote.cbgradeDes;
            var cGrade = document.frmCreateQuote.cbGrade;
            var cSize = document.frmCreateQuote.cbSize;
            var cConf = document.frmCreateQuote.cbConfig;
            var cWall = document.frmCreateQuote.cbWall;
            try
       {


           if(val=="type" ||val=="all" )
           {

             clearSelect("frmCreateQuote","cbComodity");
             AddComboValues(null,"cbComodity");
             clearSelect("frmCreateQuote","cbgradeDes");
             AddComboValues(null,"cbgradeDes");
             clearSelect("frmCreateQuote","cbGrade");
             AddComboValues(null,"cbGrade");
             clearSelect("frmCreateQuote","cbSize");
             AddComboValues(null,"cbSize");
             clearSelect("frmCreateQuote","cbConfig");
             AddComboValues(null,"cbConfig");
             clearSelect("frmCreateQuote","cbWall");
             AddComboValues(null,"cbWall");

           }
           if(val=="desc"  || val=="1")
           {
             clearSelect("frmCreateQuote","cbgradeDes");
             AddComboValues(null,"cbgradeDes");
             clearSelect("frmCreateQuote","cbConfig");
             AddComboValues(null,"cbConfig");
             clearSelect("frmCreateQuote","cbGrade");
             AddComboValues(null,"cbGrade");
             clearSelect("frmCreateQuote","cbSize");
             AddComboValues(null,"cbSize");

             clearSelect("frmCreateQuote","cbWall");
             AddComboValues(null,"cbWall");
           }
           if(val =="config" || val=="2" )
           {
             clearSelect("frmCreateQuote","cbgradeDes");
             AddComboValues(null,"cbgradeDes");
             clearSelect("frmCreateQuote","cbGrade");
             AddComboValues(null,"cbGrade");
             clearSelect("frmCreateQuote","cbSize");
             AddComboValues(null,"cbSize");

             clearSelect("frmCreateQuote","cbWall");
             AddComboValues(null,"cbWall");




           }
           if(val=="gradedesc" || val=="3"  )
           {
             clearSelect("frmCreateQuote","cbGrade");
             AddComboValues(null,"cbGrade");
             clearSelect("frmCreateQuote","cbSize");
             AddComboValues(null,"cbSize");
             clearSelect("frmCreateQuote","cbWall");
             AddComboValues(null,"cbWall");
           }
           if(val=="grade" || val=="4"  )
           {

             clearSelect("frmCreateQuote","cbSize");
             AddComboValues(null,"cbSize");
             clearSelect("frmCreateQuote","cbWall");
             AddComboValues(null,"cbWall");
           }
           if(val=="size" || val=="5"  )
           {
             clearSelect("frmCreateQuote","cbWall");
             AddComboValues(null,"cbWall");
           }

       }
       catch(e)
       {alert("Disable Error" +e);}
    }


    function disableCombos(val)
    {

            var ctype = document.frmCreateQuote.cbType.value;
            var cComm = document.frmCreateQuote.cbComodity;
            var cGradeDes = document.frmCreateQuote.cbgradeDes;
            var cGrade = document.frmCreateQuote.cbGrade;
            var cSize = document.frmCreateQuote.cbSize;
            var cConf = document.frmCreateQuote.cbConfig;
            var cWall = document.frmCreateQuote.cbWall;

       try
       {

           clearCombos(val);
           if(val=="type")
           {
             cComm.disabled = true;
             cGradeDes.disabled = true;
             cGrade.disabled = true;
             cSize.disabled = true;
             cWall.disabled = true;
             cConf.disabled = true;

           }
           if(val=="desc" || val =="config")
           {
             cGradeDes.disabled = true;
             cGrade.disabled = true;
             cSize.disabled = true;
             cWall.disabled = true;
             if(val !="config")
             cConf.disabled = true;
           }
           if(val=="gradedesc")
           {
             cGrade.disabled = true;
             cSize.disabled = true;
             cWall.disabled = true;
           }
           if(val=="grade")
           {

             cSize.disabled = true;
             cWall.disabled = true;
           }
           if(val=="size")
           {
             cWall.disabled = true;
           }

       }
       catch(e)
       {alert("Disable Error" +e);}
    }

         function EditLines(val)
        {
         //alert("Action = " + val);

         var act = 'editQuote.jsp?action='+val;

         document.frmCreateQuote.action= act;
	     document.frmCreateQuote.submit();
         }
         function btnAdd_OnClick()
         {

           var Error="";
           var focus="";
           var qty = new Number(document.frmCreateQuote.txtQty.value);

           try
           {
            if(qty == 0)
            {

             Error = "Please enter the quantity";
             focus = "txtQty" ;
            }
            if(document.frmCreateQuote.cbLtype.value =="4")

            {
               if(document.frmCreateQuote.txtFt.value == "0.00" && document.frmCreateQuote.txtIn.value == "0.000")
                {
                   Error ="Please enter the Feet (Ft) Or Inch (In) Length";
                   focus = "txtFt" ;
                }
            }

            if(Error =="")
            {
                setEmailValues();
                var act = '/internal/SaveInfo.jsp?action=addline';
                document.frmCreateQuote.action= act;
    	        document.frmCreateQuote.submit();
            }
            else
            {
                alert(Error)
                document.frmCreateQuote[focus].focus();
            }
           }
           catch(e)
           {
            alert(e);
           }
         }

         function btnCreate_OnClick()
         {

            try{


                 var errMsg="";
                 //This is to replace Carriage return characters before saving the text

            	 var focuson ="";

             if(document.all["cbShipVia"].value == "" || document.all["cbShipVia"].value == null )
          	     {
                   errMsg="Please Select Ship Via Information";
                   focuson ="cbShipVia";
                 }
             else if(document.all["cbFreight"].value == "" || document.all["cbFreight"].value == null )
        		{
                   errMsg="Please Select Freight Terms";
                   focuson ="cbFreight";
                }
             else if(document.all["txtDelDate"].value == "" || document.all["txtDelDate"].value == null )
                {
                   errMsg="Please Select delivery Date";
                   InitializeMenu('0') ;
                   //focuson ="txtDelDate" ;

                }
             else if(document.all["txtemail"].value == "" || document.all["txtemail"].value == null )
                {
                   errMsg="Please enter your e-mail Id";
                   focuson ="txtemail" ;
                }
             else if(document.all["txtContact"].value == "" || document.all["txtContact"].value == null )
                {
                  errMsg="Please enter your name";
                  focuson ="txtContact" ;
                }
             else if(document.all["ctxtid"].value == "0")
        	    {
                  errMsg="Atleast one Item is required before saving the order";
                }

             //alert(document.all["ctxtid"].value)

             if(errMsg!="")
               {

                    alert("Mandatory Data Missing:\n\n"+errMsg);
                    errMsg="";
                    if(!focuson=="")
                    {
                     document.all[focuson].focus();
                    }
               }
             else
               {
                    var tab = document.all.viewtbllines;
                    var len = tab.rows.length;
                    var pipe = false;
                    var tube = false;
                    var fit = false;
                    var flange = false;

                    for (i=1;i<len;i++)
                    {

                       var type = tab.tBodies[0].rows[i].getElementsByTagName("td")[1].innerText;
                       //type=document.all["icbType"][i];
                     //  alert("----"+type+"----")
                       if(type == "PIPE ")
                         pipe =true;
                       if (type=='TUBE ')
                         tube =true;
                       if(type=='FLANGES ')
                         flange = true;
                       if(type=='FITTING ')
                         fit=true;

                    }
                    var mes ="";
                   // alert(pipe +"----"+tube+"----"+fit+"----"+flange)
                    if(pipe)
                    {
                       if((!fit) && (!flange))
                         mes ="Do you need Fittings or Flanges to match your Pipe ?";
                      /* else if (fit && (!flange))
                         mes ="Do you need Flanges to match your Pipe and Fittings ?";
                       else if(flange && (!fit) )
                         mes ="Do you need Fittings to match your Pipe and Flanges ?";
                      */
                    }



                   if(mes!="")
                    {
                      //var conf =confirm(mes);
                      var conf = window.showModalDialog("alert.jsp","","dialogHeight:200px;dialogWidth:370px;edge:sunken;status:no;unadorned:yes;help:no; ");
                         if(conf=='Yes')
                         {
                           document.all["cbType"].focus();

                           document.all["cbType"].value ="FITTING"
                           getAttributes('type');
                           return false;
                         }
                         else
                        {
                       //  alert("sending Quote");
                         setEmailValues();
                         document.all.btnCreate.value ="Please Wait..";
                         document.all.btnCreate.disabled = true;
                         var act = '/internal/SaveInfo.jsp?action=create';
                         document.frmCreateQuote.action= act;
            	         document.frmCreateQuote.submit();
                        }
                     }
                     else
                     {
                       //  alert("All conditions met");
                         setEmailValues();
                         document.all.btnCreate.value ="Please Wait";
                         document.all.btnCreate.disabled = true;
                         var act = '/internal/SaveInfo.jsp?action=create';
                         document.frmCreateQuote.action= act;
            	         document.frmCreateQuote.submit();
                     }
               }
            }
            catch(e)
            {

            }


         }
         function setEmailValues()
         {
           var val = document.frmCreateQuote.cbSlsRep.value;
          var obj = document.frmCreateQuote.cbSlsRep;
          document.frmCreateQuote.txtslsRepEmail.value =   val.substring(5,val.length);
          document.frmCreateQuote.txtslsRepName.value = obj.options[obj.selectedIndex].text;
          //alert(document.frmCreateQuote.txtslsRepName.value)
          //alert(document.frmCreateQuote.txtslsRepEmail.value)


         }
         function btnView_OnClick(cnt)
         {
            if(cnt ==0)
            {alert("You Have Zero Items in Quote Bin");}
            else
            {
             var act = 'viewquote.jsp';
             document.frmCreateQuote.action= act;
	         document.frmCreateQuote.submit();
            }



         }
         function editprofile_onClick()
         {
           window.location ="register.jsp?action=edit"
           //document.frmCreateQuote.action= act;
	       //document.frmCreateQuote.submit();

         }
         function clearSelect(f,e)
         {

            var objSelect=document.forms[f].elements[e];
                     try
                      {

                       objSelect.options.length=0;

                      }
                      catch(e)
                      {alert(e);}

         }
         function AddOptions(obj,val,text)
         {
             var oOption = document.createElement("OPTION");
              oOption.text = text
              oOption.value = val;

            if(document.all && !window.opera)
             {  obj.add(oOption);      }
            else
             {  obj.add(oOption,null);}





         }
         function cbRegCen_OnChange(obj,value)
         {

            var sls = document.frmCreateQuote.cbSlsRep;
            clearSelect("frmCreateQuote","cbSlsRep");

          try
          {
                   if(value=="HOU")
                  {
                    AddOptions(sls,"2105/scountryman@tiogapipe.com","iQ Team");
                    AddOptions(sls,"2085/kweathers@tiogapipe.com" ,"Karen Weathers");
                    AddOptions(sls,"2190/lsanders@tiogapipe.com" ,"Leslie Sanders");
                    
                    //AddOptions(sls,"2060/nmontoya@tiogapipe.com" ,"Nancy Montoya");
                    //AddOptions(sls,"2150/pdemaret@tiogapipe.com" ,"Pam Demaret");                    
                    

                   document.frmCreateQuote.txtgeneralEmail.value="scountryman@tiogapipe.com";
                   document.frmCreateQuote.txtslsRepEmail.value="houstonweb@tiogapipe.com";
                   document.frmCreateQuote.txtslsRepName.value ="iQ Team";
                  }
                 if(value=="CHA")
                  {
                    AddOptions(sls,"4015/dgregory@tiogapipe.com","iQ Team");                    
                    AddOptions(sls,"4060/dkirkland@tiogapipe.com" ,"Dan Kirkland");
                    AddOptions(sls,"4015/dgregory@tiogapipe.com" ,"Don Gregory");
                    AddOptions(sls,"4066/jmoore@tiogapipe.com" ,"Jim Moore");
                    AddOptions(sls,"5008/kschultz@tiogapipe.com" ,"Kevin Schultz");                    
                    AddOptions(sls,"4080/rclack@tiogapipe.com" ,"Richard Clack");
                    AddOptions(sls,"4050/sparrott@tiogapipe.com" ,"Scott Parrott");

                   document.frmCreateQuote.txtgeneralEmail.value="dgregory@tiogapipe.com";
                   document.frmCreateQuote.txtslsRepEmail.value="dgregory@tiogapipe.com";
                   document.frmCreateQuote.txtslsRepName.value ="iQ Team";
                  }
                  if(value=="PHL")
                  {

                        AddOptions(sls,"1060/jmcnelis@tiogapipe.com" ,"iQ Team");
                        AddOptions(sls,"1005/bkeiser@tiogapipe.com" ,"Bennett Keiser");                        
                        AddOptions(sls,"1755/ccoppola@tiogapipe.com" ,"Chris Coppola");
                        AddOptions(sls,"1135/jshaw@tiogapipe.com" ,"Jeff Shaw");                        
                        AddOptions(sls,"1060/jmcnelis@tiogapipe.com" ,"Joe McNelis");                        
                        AddOptions(sls,"1055/kcostello@tiogapipe.com" ,"Kristy Costello");
                        AddOptions(sls,"1165/ljones@tiogapipe.com" ,"Lisa Jones");                        
                        AddOptions(sls,"1685/mwagner@tiogapipe.com" ,"Michele Wagner");
                        AddOptions(sls,"1320/rquenzer@tiogapipe.com" ,"Ray Quenzer");
                        AddOptions(sls,"1270/rtidy@tiogapipe.com" ,"Rob Tidy");
                        AddOptions(sls,"1205/smulvenna@tiogapipe.com" ,"Sandy Mulvenna");
                        AddOptions(sls,"1690/sclark@tiogapipe.com" ,"Sue Clark");
                        AddOptions(sls,"1716/steves@tiogapipe.com" ,"Steve Sorokanych");                        ;
                        AddOptions(sls,"1715/tmatula@tiogapipe.com" ,"Tom Matula");
                        AddOptions(sls,"1235/tschwegel@tiogapipe.com" ,"Tom Schwegel");


                    document.frmCreateQuote.txtgeneralEmail.value="hhoffman@tiogapipe.com;jmcnelis@tiogapipe.com;saleswebgroup@tiogapipe.com"
                     document.frmCreateQuote.txtslsRepEmail.value="saleswebgroup@tiogapipe.com";
                     document.frmCreateQuote.txtslsRepName.value ="iQ Team";
                  }
                  if(value=="NUC")
                  {
                     AddOptions(sls,"1270/saleswebgroup@tiogapipe.com" ,"iQ Team");
                     AddOptions(sls,"1055/kcostello@tiogapipe.com" ,"Kristy Costello");
                     AddOptions(sls,"1165/ljones@tiogapipe.com" ,"Lisa Jones");
                     AddOptions(sls,"1270/rtidy@tiogapipe.com" ,"Rob Tidy");
                     AddOptions(sls,"4015/dgregory@tiogapipe.com" ,"Don Gregory");
                     AddOptions(sls,"4066/jmoore@tiogapipe.com" ,"Jim Moore");
                     AddOptions(sls,"1135/jshaw@tiogapipe.com" ,"Jeff Shaw");
                     document.frmCreateQuote.txtgeneralEmail.value="jshaw@tiogapipe.com";
                     document.frmCreateQuote.txtslsRepEmail.value="jshaw@tiogapipe.com";
                     document.frmCreateQuote.txtslsRepName.value ="iQ Team";
                  }
          }
          catch(e)
          {
                  alert(e);

          }


         }
         function cbSlsRep_OnChange(obj,val)
          {
//            alert(val.substring(5,val.length))
            document.frmCreateQuote.txtslsRepEmail.value =   val.substring(5,val.length);
            document.frmCreateQuote.txtslsRepName.value = obj.options[obj.selectedIndex].text;

          }
         function btndelte_OnClick(i)
         {
         // alert(i);
          var conf = confirm("Do you want to delete this line?");
          if(conf)
          {
            var act = "quote.jsp?action=del&lineno="+i;
            document.frmCreateQuote.action= act;
	        document.frmCreateQuote.submit();
	      }
         }
         function btnEdit_OnClick(val)
         {
          var i = new Number(val) + new Number(1);
          var line      = val;
         // var redStr = "editQuote.jsp?line="+line;//+"&PartNum="+PartNum+"&cbImport="+cbImport+"&cbComodity="+cbComodity+"&cbgradeDes="+cbgradeDes+"&cbConfig="+cbConfig+"&cbType="+cbType+"&cbGrade="+cbGrade+"&cbSize="+cbSize+"&cbWall="+cbWall;

          setEmailValues();
          var act = '/internal/SaveInfo.jsp?action=edit&line='+line;
          document.frmCreateQuote.action= act;
	      document.frmCreateQuote.submit();


         }
         function cbLtype_OnChange(val1)
         {
           try
           {
                var cut1 =  document.frmCreateQuote.txtFt;
                var cut2 = document.frmCreateQuote.txtIn;
                var lcut1 =  document.all.tbllines.tBodies[0].rows[1].getElementsByTagName("td")[10];
                var lcut2 = document.all.tbllines.tBodies[0].rows[1].getElementsByTagName("td")[11];
                var type1 = document.frmCreateQuote.cbType.value;
                var units = document.all.tbllines.tBodies[0].rows[1].getElementsByTagName("td")["units"];
                var tdcut1 =document.all.tbllines.tBodies[0].rows[0].getElementsByTagName("td")[10];
                var tdcut2 =document.all.tbllines.tBodies[0].rows[0].getElementsByTagName("td")[11];
              //  alert(cut1.innerHTML +"\n---\n"+cut2.innerHTML +"\n---\n"+units.innerHTML +"\n---\n"+tdcut1.innerHTML +"\n---\n"+tdcut2.innerHTML)
          if(document.frmCreateQuote.fline.value == "lintext")
           {

               document.frmCreateQuote.LText.focus();
           }
              if(type1 =="PIPE" || type1=="TUBE")
              {

                   if(val1 == 4 || val1 == 5)
                   {
        		        if(val1 ==4)
                        {


        		          lcut1.style.display = "block" ;
                          lcut2.style.display = "block";

                          tdcut1.style.display = "block" ;
                          tdcut2.style.display = "block";
                          tdcut1.style.width = "30px" ;
                          lcut1.style.width = "30px" ;
                          tdcut2.style.width = "30px" ;
                          lcut2.style.width = "40px" ;
                          units.innerText ="ea";
        		        }
        		        else
                        {

        		          lcut1.style.display = "none" ;
                          lcut2.style.display = "none";
                          tdcut1.style.display = "none" ;
                          tdcut2.style.display = "none";
                          tdcut1.style.width = "1px" ;
                          lcut1.style.width = "1px" ;
                          tdcut2.style.width = "1px" ;
                          lcut2.style.width = "1px" ;

                          cut1.value="0.00";
        			      cut2.value="0.000";
        			      units.innerText ="ea";
        		        }

        	        }
        	        else
                    {

        		          lcut1.style.display = "none" ;
                          lcut2.style.display = "none";
                          tdcut1.style.display = "none" ;
                          tdcut2.style.display = "none";
                          tdcut1.style.width = "1px" ;
                          lcut1.style.width = "1px" ;
                          tdcut2.style.width = "1px" ;
                          lcut2.style.width = "1px" ;

                		units.innerText ="ft";
                		units.style.width="3px";
        		        cut1.value="0.00";
        			      cut2.value="0.000";
        		    }

              }

          }
          catch(e)
          {alert(e)}
         }

        function Qty_OnChange(val)
        {

           //var floatValue=parseFloat(val)
           // alert(floatValue)

           try{
           if(isNaN(val))
           {
            alert("Please enter a valid number");
            document.frmCreateQuote.txtQty.value = 0;
            document.frmCreateQuote.txtQty.focus();
           }
           }
           catch(e)
           {alert(e)}

        }
        function checkNumeric(obj)
        {
           //alert(obj)
           val = document.frmCreateQuote[obj].value;
           //var floatValue=parseFloat(val)


           try
           {
               if(isNaN(val))
               {
                alert("Please enter a valid number");
                if(obj=="txtFt")
                 {
                    //alert("f")
                    document.frmCreateQuote.txtFt.value = "0.00";
                    document.frmCreateQuote.txtFt.focus();
                 }
                else
                 {
                    document.frmCreateQuote.txtIn.value = "0.000";
                    document.frmCreateQuote.txtIn.focus();
                 }

               }
               else
               {
                   document.frmCreateQuote[obj].value = val;
                   ///alert(floatValue)
               }
           }
           catch(e)
           {alert(e)}
        }
