// 
// #																	     #
// #  plp.js																 #
// #																	     #
//
function ChangeUOM(theform, obj, pCID, pCatalogID,prodid, itemid, attrid, BuyerDefinedFlag){
	var ctldrpdn = document.getElementById("drpdn_attrid_" + itemid + "_" + attrid);

	var sUOM;
		
		sUOM = ctldrpdn.value;	
		
		GetUOMFromBack(pCID, pCatalogID, prodid, itemid, attrid, sUOM, BuyerDefinedFlag);
		
		//theform.submit();
       
       // return true;
}

function GetUOMFromBack(pCID, pCatalogID, prodid, itemid, attrid, sUOM, BuyerDefinedFlag)
{
// I may want to use this later
var stmp;

stmp=RequestInformation.GetUOMData(pCID, pCatalogID,prodid, itemid, attrid, sUOM, BuyerDefinedFlag, GetUOMData_CallBack);

// Validation() 
}
  
function GetUOMData_CallBack(response)
{
   var stmp = response.value;
   var attid;
   var ipos = stmp.indexOf("|");
   var label, AttInfo;
   var thevalue;
   var arr;
   var stmpAttInfo, stmpattid, stmpAttItemid;

   if (ipos>0)
    {
      stmpattid =stmp.substring(0, ipos);
        jpos = stmpattid.indexOf("_");
        if (jpos>0)
        {
          stmpAttItemid =stmpattid.substring(0, jpos);
            kpos = stmpAttItemid.indexOf("-");
            if (kpos>0)
            {
              attid =stmpAttItemid.substring(0, kpos);
              sitemid = stmpAttItemid.substring(kpos + 1);
            } 
          measurename = stmpattid.substring(jpos + 1);
        } 
      stmp = stmp.substring(ipos + 1);
    } 
    
    ipos = stmp.indexOf("|");
    if (ipos>0)
    {
      label =stmp.substring(0, ipos);
      AttInfo = stmp.substring(ipos + 1);
    } 
     
    if (frmPlpMain.hdnIsBuyerDefPresent.value=='true'){
        if(frmPlpMain.hdnBuyerDefinedFlag.length > 1){
		    for (i=0; i < frmPlpMain.hdnBuyerDefinedFlag.length; i++)
		    {		
			    thevalue = frmPlpMain.hdnBuyerDefinedFlag[i].value;
			    arr = thevalue.split("|");
    					
			    prodid = arr[0];
			    itemid = arr[1];
			    carttype = arr[2];
			    seqid = arr[3];
			    sattrid = arr[4];
			    displaytype = arr[5];
			    yesno = arr[6];
			    stmpAttInfo = prodid + "|" + itemid + "|" + carttype + "|" + seqid + "|" + sattrid + "|" + displaytype + "|" + yesno;
    			
			    ipos = thevalue.indexOf(stmpAttInfo);
			    if ((ipos==0) && (attid == sattrid) && (sitemid==itemid))
                {
                  frmPlpMain.hdnBuyerDefinedFlag[i].value = stmpAttInfo+AttInfo; 
                  
                  var labelMessage = document.getElementById("lbl_" + itemid + "_" + attid);

                  labelMessage.innerHTML = label;
                
                  var attMeasureName = document.getElementById("hdnAttMeasureName_attrid_" + itemid + "_" + attid);

                  attMeasureName.value = measurename;	

                } 
            }
        } 
        else
        {
            thevalue = frmPlpMain.hdnBuyerDefinedFlag.value;
		    arr = thevalue.split("|");
					
		    prodid = arr[0];
		    itemid = arr[1];
		    carttype = arr[2];
		    seqid = arr[3];
		    sattrid = arr[4];
		    displaytype = arr[5];
		    yesno = arr[6];
		    stmpAttInfo = prodid + "|" + itemid + "|" + carttype + "|" + seqid + "|" + sattrid + "|" + displaytype + "|" + yesno;
			
		    ipos = thevalue.indexOf(stmpAttInfo);
		    if ((ipos==0) && (attid == sattrid) && (sitemid==itemid))
            {
                frmPlpMain.hdnBuyerDefinedFlag.value = stmpAttInfo+AttInfo; 
              
                var labelMessage = document.getElementById("lbl_" + itemid + "_" + attid);

                labelMessage.innerHTML = label;
                
                var attMeasureName = document.getElementById("hdnAttMeasureName_attrid_" + itemid + "_" + attid);

                attMeasureName.value = measurename;	
            }     
         } 
    } 
 
}

function changeLocation(piUrl)
{
    window.top.location.href = piUrl;
}

function ReadCookie(piKey)
{
    var dc = document.cookie;
    var prefix = piKey + "=";
    var begin = dc.indexOf("; " + prefix);
    
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0)
           return null;
    }
    else
    {
        begin += 2;
    }
    
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    
    return unescape(dc.substring(begin + prefix.length, end));
} 

function GetCMGURL(piurl, piCID)
{
   var appid = "";
   var cov = "";
   var heading = "";
   var tgid = "";
   var tinid = "";
   var ipos;
   var sTmp = "";
   var Tmpappid = ""
   var cid = "";

   Tmpappid = ReadCookie('appid');
   
   if (Tmpappid == "" || Tmpappid == null)
   {
     return piurl;
   }
   else
   {
      ipos = Tmpappid.indexOf("_");
      if (ipos>0)
      {
         appid = Tmpappid.substring(ipos + 1);
         cid =Tmpappid.substring(0, ipos);
      } 
      
      if ((appid == "124") && ( cid == piCID))
      {      
          cov = ReadCookie('plp_cov');
          heading = ReadCookie('plp_heading');
          tgid = ReadCookie('tgid');
          tinid = ReadCookie('tinid');
          
          if (piurl == "" )
          {
            sTmp = "&cov=" + cov + "&heading=" + heading + "&tgid=" + tgid + "&tinid=" + tinid + "&appid=" + appid;
          }
          else
          {
              if (piurl.indexOf("?") < 0)
              {
                sTmp = "?&cov=" + cov + "&heading=" + heading + "&tgid=" + tgid + "&tinid=" + tinid + "&appid=" + appid;
	          }
	          else
	          {
	            sTmp = "&cov=" + cov + "&heading=" + heading + "&tgid=" + tgid + "&tinid=" + tinid + "&appid=" + appid;
	          }
	      }
	  }
	  
      return piurl + sTmp;
   }

}

function SetUOMCookie()
{
   /* var objrdo = document.getElementById("rdoUOM");
	if (objrdo)
	{
	    PlpSetCookie("plp_UOM",objrdo.value)
	} */
}

function SetCheckUOM(UOMSystem, pCID, pVer)
{
   PlpSetCookie("plp_UOM_" + pCID + pVer, UOMSystem);
   PlpRemoveCookie("plp_UOM_Click_Change"+ "_" + pCID + pVer)
   if(document.getElementById("hdnUOMClicked"))
   {
        var UOM = document.getElementById("hdnUOMClicked");
        UOM.value="YES";
   }
   PlpSetCookie("plp_UOM_Click_Change_" + pCID + pVer, "YES");
}

function CheckUOM(UOMSystem, piFormName, pCID, pVer)
{
   var bPost = false;
   var oForm;

   SetCheckUOM (UOMSystem, pCID, pVer);
   
   if (piFormName != "")
   {
    oForm = document.getElementById(piFormName);
    if (oForm != null)
       bPost = true;
   }
   
   if (bPost)
   {
       if ( piFormName != "frmPlpMain" && null!=document.getElementById("hdnPageSize"))
       {
           oForm.hdnPageSize.value = oForm.drpdnItemsPerPage.value;
       }
       if ( piFormName == "frmViewItems" || piFormName == "frmItemDetail")
       {
            var sAction = oForm.action;
            sAction = sAction.replace("&PDF=T","");
            if (sAction.indexOf("&isUOM=1") <0)
                sAction += piFormName == "frmItemDetail" ? "&isUOM=1" : "";
            oForm.action = sAction;
       }
       oForm.submit();
       
       return true;
   }
   else
   {
       var sURL = document.location.href;
       var nIndex = sURL.indexOf('action=');
       
       sURL = sURL.replace("#","");
       sURL = sURL.replace("&PDF=T","");
       
       if (nIndex>0)
       {
         sURL = sURL.substring(0, nIndex);
       }       
 if (piFormName == "AdditionalOptions.aspx")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "AdditionalOptions.aspx" ? "&isUOMCheckedChanged=1" : "";            
            }
       }  
       
       if (piFormName == "ChangeOptions.aspx")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "ChangeOptions.aspx" ? "&isUOMCheckedChanged=1" : "";            
            }
       } 
       
       if (piFormName == "AdvancedSearch.aspx")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "AdvancedSearch.aspx" ? "&isUOMCheckedChanged=1" : "";            
            }
       } 
       
       if (piFormName == "AdvancedSearch3.aspx")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "AdvancedSearch3.aspx" ? "&isUOMCheckedChanged=1" : "";            
            }
       }  
        if (piFormName == "AdvancedSearch4.aspx")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "AdvancedSearch4.aspx" ? "&isUOMCheckedChanged=1" : "";            
            }
       } 
       if (piFormName == "AdvancedSearchResults.aspx")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "AdvancedSearchResults.aspx" ? "&isUOMCheckedChanged=1" : "";            
            }
       } 
       
        if (piFormName == "ProductDetail.aspx")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "ProductDetail.aspx" ? "&isUOMCheckedChanged=1" : "";            
            }
       } 
       
       if (piFormName == "frmViewItems")
       {
            if(sURL.indexOf("&isUOMCheckedChanged=1") < 0)
            {
                sURL += piFormName == "frmViewItems" ? "&isUOMCheckedChanged=1" : "";            
            }
       }     
       window.location = sURL;
       
       return true;	   
   }
}


function SetTextBox(theform,obj,theText)
{
// START :: 24-July-2009 :: Surekha Deshmukh :: Issue#4066 :: temporary solution we will enable all <other> edit boxes on RFx to allow for entry at all times.
    var objText;
    var stmp = obj.value;   
    if(document.all) 
    {
       if (document.all(theText) != null) 
        {
            objText = document.all(theText);
        }
    }
    if(document.layers) 
    {
         if (document.layers(theText) != null) 
         {
              objText = document.layers(theText);
         }
    }   
    if (document.getElementById(theText) != null) 
    {    
        objText = document.getElementById(theText);
    } 
    if(obj.type=='checkbox' )
    {
   
        if(typeof(objText)=='undefined')
        {
           objText=theform[theText];
        }       
       if (objText)
	    {
	        
	        if(obj.value.indexOf('~buyerdefined~') >0 && obj.checked==true )
	        {
	       
	            objText.disabled = false;
	            objText.focus();
	            if(theText.indexOf('_rfi_')>-1)
	            {
	                if(theform('hdnBuyerdefinedValues').value != "")
	                {
	                    theform('hdnBuyerdefinedValues').value= theform('hdnBuyerdefinedValues').value + "|" + theText;
	                }
	                else
	                {
	                    theform('hdnBuyerdefinedValues').value= theText;
	                }
	            }
	        }
	        else
	        {
	            if(theText.indexOf('_rfi_') > -1 ) 
	            {
	                 objText.disabled = true;
	                objText.value='';
	            }
	            else
	            {
	                objText.disabled = true;
	                objText.value='';
	            }
	        }
	    }
    }
    else if(obj.type=='radio')
    {
        //var icnt=theform[obj.id].length;
        //-------------------------------------------------
        if(theText.indexOf('_rfi_') > -1)
        {
            var icnt=0;
            var Temp=null;
            
                if (document.all)
                {
                    Temp = document.all(theText);               
                }
                if(document.layers) 
                {
                    Temp = document.layers(theText);             
                }
//                else 
//                {        
//                   
//                } 
                if(Temp ==null)
                {
                     Temp=document.getElementById(theText);
                }              
                if(theform[obj.id].length > -1)
                {
                   for (icnt=0;icnt < theform[obj.id].length; icnt ++)
                    {      
                        	
			            if (theform[obj.id][icnt])
			            {
			                   var SVal;
			                   SVal=theform[obj.id][icnt].value;
			                   var tempID;
			                   tempID = theform[obj.id][icnt].id;
			                 if(SVal.indexOf('buyerdefined') > 0 )
				             {
				                if(SVal.indexOf('~') > 0)
				                {
				                     SVal=SVal.substring(0,SVal.indexOf('~'));   
				                }			               
			                    Temp=tempID + "_buyerdefined_" + SVal;
			                    Temp=Temp.replace('radio','editbox');			                   
				             }
				             else
				             {
				                Temp=tempID + SVal;
				                Temp=Temp.replace('radio','editbox');
				             }
				             if(theform[obj.id][icnt].checked==true)
				             {	
				                if(theform[Temp])
    				            {
    				                theform[Temp].disabled = false;
    				                theform[Temp].focus();
    				              
    				                if(theText.indexOf('_rfi_')>-1)
	                                {  
	                                    if(document.all)
                                        {
                                             if(theform('hdnBuyerdefinedValues').value != "")
	                                        {
	                                            theform('hdnBuyerdefinedValues').value= theform('hdnBuyerdefinedValues').value + "|" + theText;
	                                        }
	                                        else
	                                        {
	                                            theform('hdnBuyerdefinedValues').value= theText;
	                                        }	                                                                       
                                        }
                                        else
                                        {
                                             if(document.getElementById('hdnBuyerdefinedValues') != "")
	                                        {
	                                            document.getElementById('hdnBuyerdefinedValues').value= document.getElementById('hdnBuyerdefinedValues').value + "|" + theText;
	                                        }
	                                        else
	                                        {
	                                            document.getElementById('hdnBuyerdefinedValues').value= theText;
	                                        }	                                                                      
                                        }	                                   
	                                }	                                
	                                                                                
    				            }
				             }
				             if(theform[obj.id][icnt].checked==false)
				             {
				                if(theform[Temp])
    				            {
    				                theform[Temp].disabled = true;
    				                theform[Temp].value='';    				               
    				            }
				             }   
			            }	
		            }		
                 } 
             }
             else
             {
                //----------------------
                
                if(obj.value.indexOf('~buyerdefined~') >0 && obj.checked==true )
	            {   
	                if(objText) 
	                {
	                    objText.disabled = false;
	                    objText.focus();
	                }
	            }
	            else
	            {
	                if(theText.indexOf('_rfi_') > -1 )
	                {
	                    if(objText) 
	                    {
	                        objText.disabled = false;
	                        objText.focus();
	                    }
	                }
	                else
	                {
	                     if(objText) 
	                    {
	                         objText.disabled = true;
	                         objText.value='';
	                    }
	                   
	                }
	            }               
                //-----------------------
             }     
  //------------------------------------
    }    
	else 
	{
	    if (objText)
	    {
    	
	        objText.value = "";
    	    
		    if (stmp.indexOf('~buyerdefined~',0) > 0)
		    {
			    objText.disabled = false;
			    objText.focus();
		    }
		    else
		    {
			    objText.disabled = true;
		    }
	    }
	}
}

function ValidateKeywordSearch(theform, cid, plpver, categid, prodid)
{
	var j, key;
	var searchstring;
	var isapiurl;
	var sUrl = "";
	var sCMGUrl = "";
	//alert(form);	
	//sCMGUrl = GetCMGURL(sCMGUrl,cid);
	sCMGUrl = theform.hdnCMGSetting.value;
	if(theform==null)theform=document.forms[0];
	    
	searchstring = trim(theform.ctlSearchCatalog_searchbox.value);
	isapiurl = theform.hdnIsapiKeywordSearchUrl.value;
	isapikwallurl = theform.hdnIsapiKeywordSearchAllUrl.value;
	
	if (searchstring.length == 0)
	{
		alert('Please enter a search term.');
		theform.ctlSearchCatalog_searchbox.value = '';
		theform.ctlSearchCatalog_searchbox.focus();
		return;
	}
	
	if (searchstring.length < 2)
	{
		alert('Please enter at least two characters.');
		theform.ctlSearchCatalog_searchbox.value = trim(theform.ctlSearchCatalog_searchbox.value);
		theform.ctlSearchCatalog_searchbox.focus();
		return;
	}
	
	if (theform.key.length > 1)
	{
		for (j=0; j < theform.key.length; j++){		
			if (theform.key[j].checked==true){
				key = theform.key[j].value;
				break;
			}	
		}		
	}
	else
	{
		key = 'all';
	}

	//var browser=navigator.appName;
	var cboSearchType = theform.ddlSearchType;
	var sSchType = cboSearchType.options[cboSearchType.selectedIndex].value;
	
    if (sSchType == 'undefined')
       sSchType = 2;
  
    if (plpver =='')
    {
        if (key == 'all'){
	        if (isapikwallurl=='')
		        sUrl = theform.action + '?cid=' + cid  + '&key=all' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
	        else
		        sUrl = isapikwallurl  + '&key=all' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
        }
        else if (key == 'category')
        {
	        if (isapiurl=='')
		        sUrl = theform.action + '?cid=' + cid  + '&categid=' + categid + '&key=category' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;		
	        else
		        sUrl = isapiurl  + '&categid=' + categid + '&key=category' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
        }
        else if (key == 'product')
        {
	        if (isapiurl=='')
		        sUrl = theform.action + '?cid=' + cid  + '&categid=' + categid + '&prodid=' + prodid + '&key=product' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
	        else
		        sUrl = isapiurl  + '&categid=' + categid + '&prodid=' + prodid + '&key=product' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
        }

    }
    else
    {
        if (key == 'all'){
	        if (isapikwallurl=='')
		        sUrl = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&key=all' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
	        else
		        sUrl = isapikwallurl + '&plpver=' + plpver + '&key=all' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
        }
        else if (key == 'category')
        {
	        if (isapiurl=='')
		        sUrl = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&key=category' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;		
	        else
		        sUrl = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&key=category' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
        }
        else if (key == 'product')
        {
	        if (isapiurl=='')
		        sUrl = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&key=product' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
	        else
		        sUrl = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&key=product' + '&keycateg=' + theform.hdnKeyCateg.value + '&keyprod=' + theform.hdnKeyProd.value + '&SchType=' + sSchType;
        }
    }
	var skeyword;
	if (window.encodeURIComponent)
		skeyword = encodeURIComponent(theform.ctlSearchCatalog_searchbox.value);
	else if (window.escape)
		skeyword = escape(theform.ctlSearchCatalog_searchbox.value);

    PlpSetCookie ("plp_sel_ids", "");
    
    //sUrl = sUrl + "&keyword=" + encodeURI(theform.ctlSearchCatalog_searchbox.value);
    sUrl = sUrl + "&keyword=" + skeyword + sCMGUrl;
    
    document.location.href = sUrl;
}

function SubmitViewItemsPage(form)
{
 form.hdnPageSize.value = form.drpdnItemsPerPage.value;
 form.hdnAction.value = "Other";
 form.submit();
 return true;	
 
	//alert(form.action);
	var sBackToName;
	 
	sBackToName = form.hdnBackToName.value;
	if (window.encodeURIComponent)
	   sBackToName = encodeURIComponent(sBackToName);
	else if (window.escape)
		sBackToName = escape(sBackToName);

	if (form.hdnIsapiViewItemsUrl.value==''){
		strPath = "ViewItems.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
	                                  "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1" + 
	                                  "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value  + 
	                                  "&forward=" + form.hdnForward.value + "&backtoname=" + sBackToName;
	}else{
		/*strPath = form.hdnIsapiViewItemsUrl.value + "cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
	                                  "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1" + 
	                                  "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value  + 
	                                  "&forward=" + form.hdnForward.value + "&backtoname=" + sBackToName;
		*/
		strPath = form.hdnIsapiViewItemsUrl.value + "&plpver=" + form.hdnPlpVer.value + 
									  "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1" + 
	                                  "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value  + 
	                                  "&forward=" + form.hdnForward.value + "&backtoname=" + sBackToName;
	}
	
	
	//alert(form.action);
	//form.submit();
	window.location = strPath;
	return true;	
}

function SubmitGroupDetailPage(form){
	//alert(form.action);
	var isapiurl;
	
	isapiurl = form.hdnIsapiGroupDetailUrl.value;
	if (isapiurl==''){
		strPath = "GroupDetail.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
			      "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1"  + 
				  "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&grpid=" + form.hdnGroupID.value;		
	}else{
		/*strPath = isapiurl + "cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				  "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1"  + 
				  "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&grpid=" + form.hdnGroupID.value;
		*/
		strPath = isapiurl + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				  "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1"  + 
				  "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value;
	}

	//alert(form.action);
	//form.submit();
	window.location = strPath;
	return true;	
}

function AdvSearchDropdownPage(form){
	//alert(form.action);
	var sBackToName;
	var isapiurl; 
	var sPcatName;
	
    if (! window.navigator.cookieEnabled)
    {
        var sMsg="Your internet settings currently block cookies.\nYou will not be able to do this."
        alert(sMsg);
		return false;
    }
    else
    { 
		isapiurl = form.hdnIsapiAdvancedSearchResultsUrl.value;
		sPcatName = form.hdnPCAT.value;
		
		sBackToName = form.hdnBackToName.value;
		if (window.encodeURIComponent)
		sBackToName = encodeURIComponent(sBackToName);
		else if (window.escape)
			sBackToName = escape(sBackToName);
		
		if (sPcatName=='')
		{	
		    if (isapiurl==''){
			    strPath = "AdvancedSearchResults.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				    "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1" + 
				    "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
				    "&backtoname=" + sBackToName;
		    }else{
			    strPath = isapiurl +  "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				    "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1" + 
				    "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
				    "&backtoname=" + sBackToName;	
		    }
		 }
		 else
		 {
		 	if (isapiurl==''){
			    strPath = "AdvancedSearchResults.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				    "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1" + 
				    "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
				    "&backtoname=" + sBackToName + "&pcat=" + sPcatName;
		    }else{
			    strPath = isapiurl +  "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				    "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1" + 
				    "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
				    "&backtoname=" + sBackToName + "&pcat=" + sPcatName;	
		    }

		 
		 }	
		
		//alert(form.action);
		//form.submit();
		window.location = strPath;
		return true;
	}	
}

function KeywordSearchDropdownPage(form){
	//alert(form.action);
	var isapiurl;
	var sPcatName;
	
	isapiurl = form.hdnIsapiKeywordResultsUrl.value;
	sPcatName = form.hdnPCAT.value;
	
	if (isapiurl.indexOf('/internal/',0) > -1)
		isapiurl='';
	
	if (sPcatName=="")
	{		  
	    if (isapiurl==""){
		    strPath = "KeywordSearchResults.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				    "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1"  + 
				    "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
				    "&keyword=" + form.hdnKeyword.value + "&key=" + form.hdnKey.value + "&keycateg=" + form.hdnKeyCateg.value +
				    "&keyprod=" + form.hdnKeyProd.value + "&SchType=" + form.hdnSearchType.value;	
	    }else{
		    strPath = isapiurl + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
			      "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1"  + 
			      "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
			      "&keyword=" + form.hdnKeyword.value + "&key=" + form.hdnKey.value + "&keycateg=" + form.hdnKeyCateg.value +
			      "&keyprod=" + form.hdnKeyProd.value + "&SchType=" + form.hdnSearchType.value;
	    }
	}
	else
	{
	   if (isapiurl==""){
		    strPath = "KeywordSearchResults.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
				    "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1"  + 
				    "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
				    "&keyword=" + form.hdnKeyword.value + "&key=" + form.hdnKey.value + "&keycateg=" + form.hdnKeyCateg.value +
				    "&keyprod=" + form.hdnKeyProd.value + "&SchType=" + form.hdnSearchType.value + "&pcat=" + sPcatName;	
	    }else{
		    strPath = isapiurl + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + 
			      "&prodid=" + form.hdnProdID.value  + "&pagesize=" + form.drpdnItemsPerPage.value  + "&pagenum=1"  + 
			      "&sortid=" + form.hdnSortID.value + "&sortorder=" + form.hdnSortOrder.value + "&filter=" + form.hdnFilter.value + 
			      "&keyword=" + form.hdnKeyword.value + "&key=" + form.hdnKey.value + "&keycateg=" + form.hdnKeyCateg.value +
			      "&keyprod=" + form.hdnKeyProd.value + "&SchType=" + form.hdnSearchType.value + "&pcat=" + sPcatName;
	    }
	}

	//alert(form.action);
	//form.submit();
	window.location = strPath;
	return true;	
}

function drpdnImageList_OnChange(form){
	var isapiurl;
	
	isapiurl = form.hdnIsapiBrowserUrl.value;
	
	if (form.drpdnImageList.value!='0'){
		if (isapiurl==''){
			strPath = "ImageBrowser.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value  + "&itemid=" + form.hdnItemID.value  + "&assetid="  + form.drpdnImageList.value + "&qlty=" + form.hdnQuality.value + "&size=" + form.hdnSize.value + "&mode=" + form.hdnMode.value;	
		}else{
			//strPath = isapiurl + "cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value  + "&itemid=" + form.hdnItemID.value  + "&assetid="  + form.drpdnImageList.value + "&qlty=" + form.hdnQuality.value + "&size=" + form.hdnSize.value + "&mode=" + form.hdnMode.value;		
			strPath = isapiurl + "&plpver=" + form.hdnPlpVer.value + "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value  + "&itemid=" + form.hdnItemID.value  + "&assetid="  + form.drpdnImageList.value + "&qlty=" + form.hdnQuality.value + "&size=" + form.hdnSize.value + "&mode=" + form.hdnMode.value;		
		}
		
		window.location = strPath;
		return true;	
	}else{
		return false;	
	}
}

function IsAnyItemChecked_RFQ(form){
	var is_ItemChecked = false; 
	var is_Capabilities = false;
	
	form.hdnProductIDs.value='';
	
	var chkItemGroup=eval(form.chkItemGroup);
	
	if (chkItemGroup)
	{
		//check if chkItemGroup is an array or a single object
		if (form.chkItemGroup.length > 1){
			for (i=0; i < form.chkItemGroup.length; i++){
				if (form.chkItemGroup[i].checked){
					is_ItemChecked = true;
					//build ProductIDs
					form.hdnProductIDs.value = form.hdnProductIDs.value + form.hdnProductIDGroup[i].value + ',';
					//BEGIN 2.5 *********
					if (form.hdnCapabilitiesFlag[i].value=="True"){
					   is_Capabilities = true;
					   //Start:: 12-Mar-2009 :: Ganga Sagar :: Issue#3674 (Change Request) :: Suppress Add to Cart button from Capabilities
					   //form.chkItemGroup[i].checked=false;
					   form.chkItemGroup[i].checked=true;
					   //End:: 12-Mar-2009 :: Ganga Sagar :: Issue#3674 (Change Request) :: Suppress Add to Cart button from Capabilities
					}
					//END 2.5 *********
				}
			}
		}else{
			if (form.chkItemGroup.checked){
				is_ItemChecked = true;
				form.hdnProductIDs.value = form.hdnProductIDGroup.value;
				//BEGIN 2.5 *********
				if (form.hdnCapabilitiesFlag.value=="True"){
					is_Capabilities = true;
					//Start:: 12-Mar-2009 :: Ganga Sagar :: Issue#3674 (Change Request) :: Suppress Add to Cart button from Capabilities
					//form.chkItemGroup.checked=false;
					form.chkItemGroup.checked=true;
					//End:: 12-Mar-2009 :: Ganga Sagar :: Issue#3674 (Change Request) :: Suppress Add to Cart button from Capabilities
				}
				//END 2.5 *********
			}		
		}
			
		if (is_ItemChecked == false){		
			alert('You must select at least one product');
			return false;
		}
		else{
		    if(is_Capabilities == true)
		    {
		         //Start:: 12-Mar-2009 :: Ganga Sagar :: Issue#3674 (Change Request) :: Suppress Add to Cart button from Capabilities
				//alert("A capabilities item cannot be added to the shopping cart.");
				//return false;
				//End:: 12-Mar-2009 :: Ganga Sagar :: Issue#3674 (Change Request) :: Suppress Add to Cart button from Capabilities
		    }
		    else
		    {
		        if ( form.id == "frmCompareItems" ) 
		        {
		           form.hdnAction.value = "Cart";
		        }
		        
				//form.submit();
				return true;
			}		
		}
	}
	else
	{
		alert('You must select at least one item.');
		return false;
	}
}

function IsAnyItemChecked(form){
	var is_ItemChecked = false; 
	var is_Capabilities = false;
	var is_CSI_CANNOT_ORDER = false;
    var sInventoryMsg = form.hdnInventoryMessage.value;
    
    var sIsCSI = "";
	var hdnisCSI = eval(form.hdnisCSI);
	if (hdnisCSI)
	{
	    sIsCSI = hdnisCSI.value;
	}
	
	form.hdnProductIDs.value='';
	var chkItemGroup=eval(form.chkItemGroup);
	if (chkItemGroup)
	{
		//check if chkItemGroup is an array or a single object
		if (form.chkItemGroup.length > 1){
			for (i=0; i < form.chkItemGroup.length; i++){
				if (form.chkItemGroup[i].checked){
					is_ItemChecked = true;
					//build ProductIDs
					form.hdnProductIDs.value = form.hdnProductIDs.value + form.hdnProductIDGroup[i].value + ',';
					//BEGIN 2.5 *********
					if (form.hdnCapabilitiesFlag[i].value=="True"){
					   is_Capabilities = true;
					   form.chkItemGroup[i].checked=false;
					}
					
					if (sIsCSI == "Y" )
					{
					    if (form.hdnInventoryQty[i].value=="N"){
					       is_CSI_CANNOT_ORDER = true;
					       form.chkItemGroup[i].checked=false;
					    }				
					}
					//END 2.5 *********
				}
			}
		}else{
			if (form.chkItemGroup.checked){
				is_ItemChecked = true;
				form.hdnProductIDs.value = form.hdnProductIDGroup.value;
				//BEGIN 2.5 *********
				if (form.hdnCapabilitiesFlag.value=="True"){
					is_Capabilities = true;
					form.chkItemGroup.checked=false;
				}
				
				if (sIsCSI == "Y")
				{
				    if (form.hdnInventoryQty.value=="N"){
				       is_CSI_CANNOT_ORDER = true;
				       form.chkItemGroup.checked=false;
				    }				
				}
				//END 2.5 *********
			}		
		}
			
		if (is_ItemChecked == false){		
			alert('You must select at least one product');
			return false;
		}
		else{
		    if(is_Capabilities == true)
		    {
				alert("A capabilities item cannot be added to the shopping cart.");
				return false;
		    }
		    else
		    {
		        if(is_CSI_CANNOT_ORDER == true)
		        {
		            if (sInventoryMsg == "" )
		            {
				        alert("There is no more inventory for the item(s).");
				    }
				    else
				    {
				        alert(sInventoryMsg);
				    }
				    return false;
		        }
		        else
		        {
		            if ( form.id == "frmCompareItems" ) 
		            {
		            form.hdnAction.value = "Cart";
		            }
		        
				    //form.submit();
				    return true;
			    }		
			}		
		}
	}
	else
	{
		alert('You must select at least one item.');
		return false;
	}
}


function IsAnyItemChecked2(oForm)
{
 if (! PlpDetectCookie())
    return false;

 return IsAnyItemChecked(oForm);
}

function IsAnyItemChecked2_RFQ(oForm)
{
 if (! PlpDetectCookie())
    return false;

 return IsAnyItemChecked_RFQ(oForm);
}

function ValidateItemSelection(form,type,cid,plpver,categid,prodid,origin){
//function ValidateItemSelection(form){
	var nCount;
	var itemids='';
	var prodids='';
	var i;
	var prevpage='';
	nCount = 0;
	
	//check if chkItemGroup is an array or a single object
	var chkItemGroup=eval(form.chkItemGroup);
	
	if (chkItemGroup)
	{
		if (form.chkItemGroup.length > 1){
			for (i=0; i < form.chkItemGroup.length; i++){
				if (form.chkItemGroup[i].checked){
					itemids = itemids + form.chkItemGroup[i].value + '+';
					prodids = prodids + form.hdnProductIDGroup[i].value + '+';
					nCount = nCount + 1;
				}
			}
		}else{
			if (form.chkItemGroup.checked){
				itemids = itemids + form.chkItemGroup.value + '+';
				prodids = prodids + form.hdnProductIDGroup.value + '+';
				nCount = nCount + 1;
			}
		}
	}
	
	if (type=='compare'){
	//Start :: 29-Sep-2009 :: Sujit Singh :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content
	            var sValue;
	            sValue = document.URL;
	            //alert(sValue)
	            PlpSetCookie("plp_PreviousURL", sValue);
                 //End :: 29-Sep-2009 :: Sujit Singh :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content
		if ((nCount > 1) && (nCount <= 5)){	
			//alert('CompareItems.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&itemids=' + itemids);
			//alert(form.hdnIsapiCompareItemsUrl.value);
			if (form.hdnIsapiCompareItemsUrl.value==''){
				window.location = "CompareItems.aspx?cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin;
			}else{
				//window.location = form.hdnIsapiCompareItemsUrl.value + "cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin;
				window.location = form.hdnIsapiCompareItemsUrl.value + "&plpver=" + plpver + "&categid=" + categid + "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin;
			}
			
			return true;
		}else{
			alert('Please select between 2 and 5 items.');
			return false;		
		}
	}else if (type=='request'){
		if ((nCount >= 1) && (nCount <= 5)){	
			prevpage = document.URL;			
			if (origin=='keyword'){
				if (prevpage.indexOf('keyword=')==-1){
					prevpage = prevpage + '&keyword=' + form.hdnKeyword.value;
				}
			}
			//Start :: 29-Sep-2009 :: Sujit Singh :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content
	            var sValue;
	            sValue = document.URL;
	            //alert(sValue)
	            PlpSetCookie("plp_PreviousURL", sValue);
                 //End :: 29-Sep-2009 :: Sujit Singh :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content
			//SetCookie('plp_previous_page', prevpage);	
			
			// this is for ISAPI version of Request Information originating from View Items, KW and Group Detail
			// when ISAPI is true, cookie saved via javascript is not recognized by Readcookie() from code-behind
			if (window.encodeURIComponent)
				prevpage = encodeURIComponent(prevpage);
			else if (window.escape)
				prevpage = escape(prevpage);	
			
			if (form.hdnIsapiRequestInfoUrl.value==''){
				window.location = "RequestInformation.aspx?cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
			                      "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin + 
			                      "&prevpage=" + prevpage;
			}else{
				/*window.location = form.hdnIsapiRequestInfoUrl.value + "cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
			                      "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin + 
			                      "&prevpage=" + prevpage;
			    */
			    window.location = form.hdnIsapiRequestInfoUrl.value + "&plpver=" + plpver + "&categid=" + categid + 
			                      "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin + 
			                      "&prevpage=" + prevpage;
			}
			return true;

			/*			
			if (form.hdnIsapiRequestInfoUrl.value==''){
				form.action = "RequestInformation.aspx?cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
			                      "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin;
			}else{
				form.action = form.hdnIsapiRequestInfoUrl.value + "cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
			                      "&prodid=" + prodid + "&prodids=" + prodids + "&itemids=" + itemids + "&origin=" + origin;
			}			
			form.submit();
					
			return true;			
			*/
            
		}else{
			if (origin=='compare'){
				alert('Please select at least one item.');
			}else{
				alert('Please select between 1 and 5 items.');
			}
			return false;		
		}
	}
}

function ValidateProductSelection(form,type,cid,plpver,categid,prodid,origin){
	var nCount;
	var prodids='';
	var prevpage='';
	var prodid='';
	nCount = 0;
		
	//check if chkProdGroup is an array or a single object
	if (form.chkProdGroup.length > 1){
		for (i=0; i < form.chkProdGroup.length; i++){
			if (form.chkProdGroup[i].checked){
				prodids = prodids + form.chkProdGroup[i].value + '+';
				nCount = nCount + 1;
				prodid = form.chkProdGroup[i].value;
			}
		}
	}else{
		//alert('here2');
		if (form.chkProdGroup.checked){
			prodids = prodids + form.chkProdGroup.value + '+';
			prodid = form.chkProdGroup.value;
			nCount = nCount + 1;
		}
	}
	
	if ((nCount >= 1) && (nCount <= 5)){	
		if (type=='request'){
			prevpage = document.URL;			
			if (origin=='keyword'){
				if (prevpage.indexOf('keyword=')==-1){
					prevpage = prevpage + '&keyword=' + form.hdnKeyword.value;
				}
			}
			//SetCookie('plp_previous_page', prevpage);
			
			// this is for ISAPI version of Request Information originating from View Items, KW and Group Detail
			// when ISAPI is true, cookie saved via javascript is not recognized by Readcookie() from code-behind
			if (window.encodeURIComponent)
				prevpage = encodeURIComponent(prevpage);
			else if (window.escape)
				prevpage = escape(prevpage);				

			if (form.hdnIsapiRequestInfoUrl.value==''){
			    if (nCount == 1)
			    {
			        window.location = "RequestInformation.aspx?cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
					              "&prodid=" + prodid + "&prodids=" + "&origin=" + origin +  "&itemids=" + 
			                      "&prevpage=" + prevpage;

			    }
			    else
			    {
				    window.location = "RequestInformation.aspx?cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
					              "&prodid=" + "&prodids=" + prodids + "&origin=" + origin +  "&itemids=" + 
			                      "&prevpage=" + prevpage;
			    }
			}else{
				if (nCount == 1)
			    {
				    window.location = form.hdnIsapiRequestInfoUrl.value + "&plpver=" + plpver + "&categid=" + categid + 
					              "&prodid=" + prodid + "&prodids=" + "&origin=" + origin +  "&itemids=" + 
			                      "&prevpage=" + prevpage;
			    }
			    else
			    {
			        window.location = form.hdnIsapiRequestInfoUrl.value + "&plpver=" + plpver + "&categid=" + categid + 
					              "&prodid=" + "&prodids=" + prodids + "&origin=" + origin +  "&itemids=" + 
			                      "&prevpage=" + prevpage;
			    }
			}

		}		
		return true;
	}
	else{
		alert('Please select up to five categories.');
		return false;		
	}
}

function IsNumeric(strCheck) {
    var cnt = 0, c;
    
    strCheck = strCheck.replace(/(\d),(\d)/g, '$1$2');
    for ( cnt = 0; cnt < strCheck.length; cnt++  ) {
      c = strCheck.charAt(cnt);
        if ( c < "0" || c > "9" ) {
            return false;
        }
    } return true;
}

function IsFloatNumeric(strCheck) {
    var cnt = 0, c;
    
    if (strCheck.indexOf("/", 0) > 0 )
    {
       if(!isLegalFraction(strCheck))
       {
            return false;
       }
       else
       {
            return true;
       }
    }
    else
    {
        strCheck = strCheck.replace(/(\d),(\d)/g, '$1$2');
        for ( cnt = 0; cnt < strCheck.length; cnt++  ) {
          c = strCheck.charAt(cnt);
            if (( c < "0" || c > "9" ) && c != ".") {
                return false;
            }
        } return true;
    }
}

function isLegalFraction (pString) 
{   
    var strValidChars = "0123456789/-";
	var strChar, firstSlashPos, lastSlashPos;
	var legal = true;
	var i;
	
	//first, strip the leading + or -, if it exists
	if (pString.indexOf("-")==0 || pString.indexOf("+")==0)
    {
        pString=pString.substr(1);
    } 
	
    //if there is no "/", or it's the first char, or the last char
    if ((pString.indexOf("/") <= 0) || (pString.charAt(pString.length-1) == "/"))
	{	
	return false;}
    
    firstSlashPos = pString.indexOf("/",0);       
    lastSlashPos = pString.lastIndexOf("/");
    if ((firstSlashPos != lastSlashPos) && (firstSlashPos != -1 && lastSlashPos != -1))
    {   //msOurValidationErr = "There is more than one slash in the value.";
        return false;    
    }
    else//only one slash, but is it surrounded by any zeroes?
    {	var slashPos = pString.indexOf("/");
        var firstchar = pString.charAt(0)
		if (((pString.charAt(slashPos-1) == 0) && (firstchar == 0) || (pString.charAt(slashPos+1) == 0)))
		{	
		return false;}		
    }
// Make sure dashes are correct
// First - there can never be more than 1 dash (the one for negative was stripped)
    var dashcount = 0;
    var dashpos = 0;
    var slashpos = 0;
    for (i = 0; i < pString.length; i++)
    {   
        strChar = pString.charAt(i);
        if (strChar == "-")
        {
            dashpos = i;
            dashcount = dashcount + 1;
        }
        if (strChar == "/")
        {
            slashpos = i;
        }
        if (dashcount > 1)
        {
            //alert("too many dashes");
            legal = false;
        }
    }
    if (dashpos > slashpos)
    {
        //alert("slash can't be before dash");
        legal = false;
    }
    if (dashpos > 0 && slashpos == dashpos + 1)
    {
        //alert("dash can't be next to slash");
        legal = false;
    }  
     
//second - dash can never be in last position
    if (pString.charAt(pString.length-1) == "-")
	{	
	//alert("dash can't be in last position");
	return false;}  
//third - dash must come before slash but not be next to it

// test strString consists of valid characters listed above
    for (i = 0; i < pString.length && legal == true; i++)
    {   strChar = pString.charAt(i);
        if  (strValidChars.indexOf(strChar) == -1)
        {
        legal = false;
        }
    } 
return legal;		
}

function IsInteger(strCheck) {
	//checks for positive and negative integers
    var cnt = 0, c;
    
	strCheck = strCheck.replace(/(\d),(\d)/g, '$1$2');
    for ( cnt = 0; cnt < strCheck.length; cnt++  ) {
      c = strCheck.charAt(cnt);
		if (((c == "+") || (c == "-")) && (cnt==0)) {
			//do nothing
        }else if ( c < "0" || c > "9" ) {
            return false;
        }
    } return true;
}

function ValidateExpressOrder(form){
	var isapiurl;
    isapiurl = form.hdnIsapiExpressUrl.value;
    
	if ((form.txtItem1.value=='') && (form.txtItem2.value=='') &&
	    (form.txtItem3.value=='') && (form.txtItem4.value=='') &&
	    (form.txtItem5.value=='') && (form.txtItem6.value=='')){
	    
	    alert('Please enter an Item ID.');
	    return false;
	}else if (((!form.txtItem1.value=='') && (!IsNumeric(form.txtQty1.value))) || 
	    ((!form.txtItem2.value=='') && (!IsNumeric(form.txtQty2.value))) || 
	    ((!form.txtItem3.value=='') && (!IsNumeric(form.txtQty3.value))) || 
	    ((!form.txtItem4.value=='') && (!IsNumeric(form.txtQty4.value))) || 
	    ((!form.txtItem5.value=='') && (!IsNumeric(form.txtQty5.value))) ||
	    ((!form.txtItem6.value=='') && (!IsNumeric(form.txtQty6.value)))){
	    
		alert('Please enter whole integers for quantity.');
		return false;
	}else if (((!form.txtItem1.value=='') && (form.txtQty1.value<=0)) || 
	          ((!form.txtItem2.value=='') && (form.txtQty2.value<=0)) || 
			  ((!form.txtItem3.value=='') && (form.txtQty3.value<=0)) || 
			  ((!form.txtItem4.value=='') && (form.txtQty4.value<=0)) ||
			  ((!form.txtItem5.value=='') && (form.txtQty5.value<=0)) ||
			  ((!form.txtItem6.value=='') && (form.txtQty6.value<=0))){
			  
		alert('Please enter a positive value for quantity.');
		return false;
	}else{
		var i,j;
		arr = new Array();
		arr[0]=form.txtItem1.value;
		arr[1]=form.txtItem2.value;
		arr[2]=form.txtItem3.value;
		arr[3]=form.txtItem4.value;
		arr[4]=form.txtItem5.value;
		arr[5]=form.txtItem6.value;
			
		for ( i=0 ; i< 6; i++)
		{
		   for (j=i+1; j<6; j++)
		   {
		      if (arr[i] != "" )
		      {
		         if (arr[i] == arr[j])
		         {
		           alert('Please add same items in one bucket.');
		           return false;
		         }
		      }
	       }
		}
	}
	
	if (form.hdnCatalogName.value == '' )
	{
	    if (isapiurl==''){
		    form.action = "ExpressOrdering.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
		  		          "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + "&action=additems";
	    }else{
		    //form.action = isapiurl + "cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
		    //  		      "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + "&action=additems";
		    form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
		  		          "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + "&action=additems";
	    }
	}	
	else
	{
	    if (isapiurl==''){
		    form.action = "ExpressOrdering.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
		  		          "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + "&action=additems" + "&pcat=" + form.hdnCatalogName.value;
	    }else{
		    form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
		  		          "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + "&action=additems" + "&pcat=" + form.hdnCatalogName.value;
	    }
	}

	form.submit();
	return true;
}

function ValidateOrderQty(obj, hdnMinOrderQty, prodid, itemid, carttype, seqid, InventoryQty){
	var okay;
	var minorder;
	var sInventoryMsg = document.frmPlpMain.hdnInventoryMessage.value;
	

	//get the minimum order qty
	minorder = hdnMinOrderQty.value;
	//START :: 25-Jun-2008 :: Ganga Sagar ::Issue#3252 ::PLP-problems adding to cart....also "Secure/Non Secure items pop up"....
	if((obj.value >=1))
	{
	 if((obj.value != ''))
	{
    //End :: 25-Jun-2008 :: Ganga Sagar ::Issue#3252 ::PLP-problems adding to cart....also "Secure/Non Secure items pop up"....	
	if(IsNumeric(obj.value)){
		//check if order qty is at least min order qty
		//START :: 25-Jun-2008 :: Ganga Sagar ::Issue#3252 ::PLP-problems adding to cart....also "Secure/Non Secure items pop up"....
		if ( carttype == "order") {
		//End :: 25-Jun-2008 :: Ganga Sagar ::Issue#3252 ::PLP-problems adding to cart....also "Secure/Non Secure items pop up"....
		if(parseInt(obj.value) < parseInt(minorder)){
			okay = false;
			alert('Order quantity should be at least ' + minorder + ".");
		}}
	}else{
		okay = false;
		alert('Please enter a numeric value.');
	}
	//START :: 25-Jun-2008 :: Ganga Sagar ::Issue#3252 ::PLP-problems adding to cart....also "Secure/Non Secure items pop up"....
	}
	else
	{
	okay = false;
		alert('Please enter a numeric value Greater than 0.');
	}
	}
	else
	{
	okay = false;
		alert('Please enter a numeric value Greater than 0.');
	}
	//End :: 25-Jun-2008 :: Ganga Sagar ::Issue#3252 ::PLP-problems adding to cart....also "Secure/Non Secure items pop up"....
	if ( carttype == "order")
	{
	    if (InventoryQty != "")
	    {
	      if(parseInt(obj.value) > parseInt(InventoryQty)){
			    okay = false;
			    if (sInventoryMsg == "" )
			    {
			        alert('Order quantity should not exceed the original inventory value ' + InventoryQty + ".");
			    }
			    else
			    {
			        alert(sInventoryMsg);
			    }
		    }
	    }
	}
	
	if(okay==false){
		obj.value = minorder;
		return false;
	}else{
		return true;
	}
}

function ChangeListPrice_old(theform, obj, prodid, itemid, carttype, seqid, attrid, priceplus, origlistprice){

	var pricelabel = document.getElementById("lbl_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var labelMessage = document.getElementById("lbl_Message_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var dprice, dorigprice, newprice, prevprice;
	var pricelabel;
	var attrvalueid;
	var i;
	var objListBox;

	pricelabelvalue = pricelabel.childNodes.item(0).nodeValue;
	
  	if (pricelabelvalue=='QUOTE'){
		labelMessage.style.display = 'none';		// do not display the message for revised price		
	}else{
		dorigprice = pricelabel.childNodes.item(0).nodeValue.substring(1);		
		dorigprice = dorigprice.replace(/(\d),(\d)/g, '$1$2');
		dorigprice = parseFloat(dorigprice);			
		
		if(obj.type=='checkbox'){
			dprice = priceplus;
			dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
			dprice = parseFloat(dprice.substring(1));
			
			if (obj.checked == true){
				newprice = dorigprice + dprice;
			}else{
				newprice = dorigprice - dprice;
			}		
		
			//round off to 2 decimal places
			newprice = (Math.round(newprice*100))/100;
			
			newprice = newprice.toString();
			if (newprice.indexOf(".") < 0){
				newprice = newprice + ".00";
			}
			
			if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
				newprice = newprice + "0";
			}

			//change the List Price
			pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
		
			//display message
			if (newprice != origlistprice){
				labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
			}else{
				labelMessage.childNodes.item(0).nodeValue = '';    					
			}	
					
		}else if(obj.type=='select-multiple'){
			if (theform["hdnListBoxAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes'){
				newprice = dorigprice;
				
				objListBox = theform["listbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid];
				
				for (i=0; i < objListBox.options.length; i++){
					attrvalueid = objListBox.options[i].value;
					if (attrvalueid != '0'){					
						if (objListBox.options[i].selected==true){
							//if not previously selected, then add
							if (theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value == 'no'){
								//add the price increment
								dprice = theform["hdnListBoxPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
								dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
								dprice = parseFloat(dprice.substring(1));	
								newprice = newprice + dprice;
								
								theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value = 'yes';
							}
						}else{
							//if previously selected, then minus
							if (theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value == 'yes'){
								dprice = theform["hdnListBoxPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
								dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
								dprice = parseFloat(dprice.substring(1));	
								newprice = newprice - dprice;
								
								theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value = 'no';
							}			
						}
					}
				}	
				
				
				//round off to 2 decimal places
				newprice = (Math.round(newprice*100))/100;
				
				newprice = newprice.toString();
				if (newprice.indexOf(".") < 0){
					newprice = newprice + ".00";
				}				
				
				if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
					newprice = newprice + "0";
				}

				//change the List Price
				pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
			
				//display message
				if (newprice != origlistprice){
					labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
				}else{
					labelMessage.childNodes.item(0).nodeValue = '';    					
				}					
			}	
							
		}else if(obj.type=='radio'){
			if (theform["hdnRadioAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes'){
				dprice = priceplus;
				dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
				dprice = parseFloat(dprice.substring(1));	
				
				prevprice = theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
				prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
				prevprice = parseFloat(prevprice.substring(1));	
				
				newprice = dorigprice + dprice - prevprice;
				
				theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = priceplus;
				
				//round off to 2 decimal places
				newprice = (Math.round(newprice*100))/100;
				
				newprice = newprice.toString();
				if (newprice.indexOf(".") < 0){
					newprice = newprice + ".00";
				}

				if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
					newprice = newprice + "0";
				}
				
				//change the List Price
				pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
			
				//display message
				if (newprice != origlistprice){
					labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
				}else{
					labelMessage.childNodes.item(0).nodeValue = '';    					
				}	
			}
			
		}else if(obj.type=='select-one'){
			newprice = dorigprice;
			
			if (theform["hdnDrpdnAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes'){				
				attrvalueid = theform["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
				
				if (attrvalueid != '0'){
					dprice = theform["hdnDrpdnPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
					dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
					dprice = parseFloat(dprice.substring(1));	
				}else{
					dprice = 0;	
				}
				
				prevprice = theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
				prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
				prevprice = parseFloat(prevprice.substring(1));	
				
				if ((dprice > 0) || (prevprice > 0)){
					newprice = dorigprice + dprice - prevprice;
						
					theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = '$' + dprice;				
					
					//round off to 2 decimal places
					newprice = (Math.round(newprice*100))/100;
					
					newprice = newprice.toString();
					if (newprice.indexOf(".") < 0){
						newprice = newprice + ".00";
					}

					if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
						newprice = newprice + "0";
					}

					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
				}		
			}
			
			//display message
			if (newprice != origlistprice){
				labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
			}else{
				labelMessage.childNodes.item(0).nodeValue = '';    					
			}	
		}		
	}
}


function ChangeListPrice(theform, obj, prodid, itemid, carttype, seqid, attrid, priceplus, origlistprice){

	var pricelabel = document.getElementById("lbl_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var labelMessage = document.getElementById("lbl_Message_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var dprice, dorigprice, newprice, prevprice;
	var pricelabel;
	var attrvalueid;
	var i;
	var objListBox;
    var sNumber;
    var ctlhdnOriginalPrice	= document.getElementById("hdnOriginalPrice_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var ctlhdnQuoteForOrder	= document.getElementById("hdnQuoteForOrder_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
if(pricelabel==null) 
{
    return true;
}
if(document.getElementById('hdnCheckIsFormulaForListPrice_'+itemid+'_'+seqid)!=null) {
var CheckIsFormulaForListPrice=document.getElementById('hdnCheckIsFormulaForListPrice_'+itemid+'_'+seqid).value;
if(CheckIsFormulaForListPrice=='True') { return true; }
}

	pricelabelvalue = pricelabel.childNodes.item(0).nodeValue;
	
	//alert(ronron);
	
  	if ((pricelabelvalue=='QUOTE')&&(ctlhdnOriginalPrice.value=='QUOTE')) {
		labelMessage.style.display = 'none';		// do not display the message for revised price		
	}else{
		//dorigprice = pricelabel.childNodes.item(0).nodeValue.substring(1);
		
		dorigprice = ctlhdnOriginalPrice.value;	
		dorigprice = dorigprice.replace(/(\d),(\d)/g, '$1$2');
		dorigprice = parseFloat(dorigprice);			
		
		if(obj.type=='checkbox'){
								
			if(priceplus=='QUOTE')
			{
			    sNumber = ctlhdnQuoteForOrder.value;
			    
			    var iNumber = new Number(sNumber)
			    if (obj.checked == true){
				   iNumber= iNumber + 1;
				}else{
				   iNumber = iNumber - 1;
				}
				
				ctlhdnQuoteForOrder.value =	iNumber;	
				pricelabel.childNodes.item(0).nodeValue = priceplus;
				
			}
			else
			{
					dprice = priceplus;
					dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
					dprice = parseFloat(dprice.substring(1));
				
					if (obj.checked == true){
						newprice = dorigprice + dprice;
					}else{
						newprice = dorigprice - dprice;
					}		
				
					//round off to 4 decimal places
					newprice = (Math.round(newprice*10000))/10000;
						if(isNaN(newprice))
				        {
                            return true;
				        }
					newprice = newprice.toString();
					if (newprice.indexOf(".") < 0){
						newprice = newprice + ".00";
					}
					
					if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
						newprice = newprice + "0";
					}

					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + newprice;   
					ctlhdnOriginalPrice.value= newprice;   
			}
		
		    if(ctlhdnQuoteForOrder.value =='0')
			{
				//change the List Price
				pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
			}
			else
			{
				pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
			}
			//display message
			if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
			{
				labelMessage.childNodes.item(0).nodeValue = '';   
			}
			else
			{
				if (newprice != origlistprice){
					labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
				}else{
					labelMessage.childNodes.item(0).nodeValue = '';    					
				}	
			}		
		}else if(obj.type=='select-multiple'){
			if (theform["hdnListBoxAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes'){
				newprice = dorigprice;
				
				objListBox = theform["listbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid];
				
				for (i=0; i < objListBox.options.length; i++){
					attrvalueid = objListBox.options[i].value;
					if (attrvalueid != '0'){
					    var iPos = attrvalueid.indexOf('~buyerdefined~',0);
						if (iPos > 0)
						{
							attrvalueid = attrvalueid.substring(0, iPos)
						}					
						if (objListBox.options[i].selected==true){
							//if not previously selected, then add
							if (theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value == 'no'){
								//add the price increment
								dprice = theform["hdnListBoxPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
								
								if (dprice=='QUOTE')
								{
									sNumber = ctlhdnQuoteForOrder.value;			    
									var iNumber = new Number(sNumber)
									iNumber= iNumber + 1;								
									ctlhdnQuoteForOrder.value=	iNumber;
								}
								else
								{
									dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
									dprice = parseFloat(dprice.substring(1));	
									newprice = newprice + dprice;
								}
								theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value = 'yes';
							}
						}else{
							//if previously selected, then minus
							if (theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value == 'yes'){
								dprice = theform["hdnListBoxPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
								
								if (dprice=='QUOTE')
								{
									sNumber = ctlhdnQuoteForOrder.value;			    
									var iNumber = new Number(sNumber)
									iNumber= iNumber - 1;								
									ctlhdnQuoteForOrder.value=	iNumber;
								}
								else
								{
									dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
									dprice = parseFloat(dprice.substring(1));	
									newprice = newprice - dprice;
								}
								
								
								theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value = 'no';
							}			
						}
					}
				}	
				
				
				//round off to 4 decimal places
				newprice = (Math.round(newprice*10000))/10000;
				if(isNaN(newprice))
				{
				    return true;
				}
				newprice = newprice.toString();
				if (newprice.indexOf(".") < 0){
					newprice = newprice + ".00";
				}				
				
				if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
					newprice = newprice + "0";
				}

				//change the List Price
				pricelabel.childNodes.item(0).nodeValue = '$' + newprice;  
				ctlhdnOriginalPrice.value= newprice;   
			
                if(ctlhdnQuoteForOrder.value =='0')
				{
					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
				}
				else
				{
					pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
				}
				//display message
				if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
				{
					labelMessage.childNodes.item(0).nodeValue = '';   
				}
				else
				{
					if (newprice != origlistprice){
						labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
					}else{
						labelMessage.childNodes.item(0).nodeValue = '';    					
					}	
				}		
				
			}	
							
		}else if(obj.type=='radio'){
			if (theform["hdnRadioAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes')
			{
				if(priceplus=='QUOTE')
				{
					sNumber = ctlhdnQuoteForOrder.value;
				    
					var iNumber = new Number(sNumber)
					prevprice = theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;

					if ((obj.checked == true) && (prevprice !='QUOTE'))
					{
						iNumber= iNumber + 1;
									
						ctlhdnQuoteForOrder.value=	iNumber;	
						pricelabel.childNodes.item(0).nodeValue = priceplus;
						
						if ( prevprice != 0 )
						{
							prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
							prevprice = parseFloat(prevprice.substring(1));	
						}
						
						newprice = dorigprice  - prevprice;
											
						//round off to 4 decimal places
						newprice = (Math.round(newprice*10000))/10000;
							if(isNaN(newprice))
				            {
				                return true;
				            }
						newprice = newprice.toString();
						if (newprice.indexOf(".") < 0){
							newprice = newprice + ".00";
						}

						if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
							newprice = newprice + "0";
						}
						
						ctlhdnOriginalPrice.value= newprice;   
				
						theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = priceplus;
					}
				}
				else
				{

					dprice = priceplus;
					dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
					dprice = parseFloat(dprice.substring(1));	
					
					prevprice = theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
					if (prevprice =='QUOTE')
					{	
					    sNumber = ctlhdnQuoteForOrder.value;
						var jNumber = new Number(sNumber)
							jNumber = jNumber - 1;
							ctlhdnQuoteForOrder.value=	jNumber;	
						    prevprice=0;
					}
					else
					{
						prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
						prevprice = parseFloat(prevprice.substring(1));	
					}
					newprice = dorigprice + dprice - prevprice;
				
					theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = priceplus;
					
					//round off to 4 decimal places
					newprice = (Math.round(newprice*10000))/10000;
						if(isNaN(newprice))
				        {
				            return true;
				        }	
					newprice = newprice.toString();
					if (newprice.indexOf(".") < 0){
						newprice = newprice + ".00";
					}

					if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
						newprice = newprice + "0";
					}
					
					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
				    ctlhdnOriginalPrice.value= newprice;   





					if(ctlhdnQuoteForOrder.value =='0')
					{
						//change the List Price
						pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
					}
					else
					{
						pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
					}
					//display message
					if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
					{
						labelMessage.childNodes.item(0).nodeValue = '';   
					}
					else
					{
						if (newprice != origlistprice){
							labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
						}else{
							labelMessage.childNodes.item(0).nodeValue = '';    					
						}	
					}
				}	
		   }
		}else if(obj.type=='select-one'){
			//newprice = dorigprice;
			
			if (theform["hdnDrpdnAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes'){				
		
		        attrvalueid = theform["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
				
				if (attrvalueid != '0'){
				    var iPos = attrvalueid.indexOf('~buyerdefined~',0);
				    if (iPos > 0)
				    {
				        var sTmpattrvalueid = attrvalueid.substring(0, iPos)
				        dprice = theform["hdnDrpdnPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + sTmpattrvalueid].value;
				    }
				    else
				    {
						dprice = theform["hdnDrpdnPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
					}
				}else{
					dprice = 0;	
				}
				
				if(dprice=='QUOTE')
				{
					sNumber = ctlhdnQuoteForOrder.value;
				    
					var iNumber = new Number(sNumber)
					prevprice = theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;

					if (prevprice !='QUOTE')
					{
						iNumber= iNumber + 1;
									
						ctlhdnQuoteForOrder.value=	iNumber;	
						pricelabel.childNodes.item(0).nodeValue = dprice;
						
						if ( prevprice != 0 )
						{
							prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
							prevprice = parseFloat(prevprice.substring(1));	
						}
						
						newprice = dorigprice  - prevprice;
							
						//round off to 4 decimal places
						newprice = (Math.round(newprice*10000))/10000;
							if(isNaN(newprice))
				        {
				            return true;
				        }	
						newprice = newprice.toString();
						if (newprice.indexOf(".") < 0){
							newprice = newprice + ".00";
						}

						if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
							newprice = newprice + "0";
						}
						
						ctlhdnOriginalPrice.value= newprice;   
						theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = dprice;
					}
				}
				else
				{

					//dprice = priceplus;
					if ( dprice != 0 )
					{
						dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
						dprice = parseFloat(dprice.substring(1));
					}
					
					prevprice = theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
					if (prevprice =='QUOTE')
					{	
					    sNumber = ctlhdnQuoteForOrder.value;
						var jNumber = new Number(sNumber)
							jNumber = jNumber - 1;
							ctlhdnQuoteForOrder.value=	jNumber;	
						    prevprice=0;
					}
					else
					{
					    if ( prevprice != 0 )
						{
							prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
							prevprice = parseFloat(prevprice.substring(1));	
						}
					}
					newprice = dorigprice + dprice - prevprice;
					
					theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = "$" + dprice;
					
					//round off to 4 decimal places
					newprice = (Math.round(newprice*10000))/10000;
						if(isNaN(newprice))
				        {
				            return true;
				        }	
					
					newprice = newprice.toString();
					if (newprice.indexOf(".") < 0){
						newprice = newprice + ".00";
					}

					if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
						newprice = newprice + "0";
					}
					
					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
				    ctlhdnOriginalPrice.value= newprice;   

					if(ctlhdnQuoteForOrder.value =='0')
					{
						//change the List Price
						pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
					}
					else
					{
						pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
					}
					//display message
					if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
					{
						labelMessage.childNodes.item(0).nodeValue = '';   
					}
					else
					{
						if (newprice != origlistprice){
							labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
						}else{
							labelMessage.childNodes.item(0).nodeValue = '';    					
						}	
					}
					
				}	
			}	
		}		
	}

}

function ResetListPrice(theform, objDrpdn, type, prodid, itemid, carttype, seqid, attrid, priceplus, origlistprice, mid){
	var pricelabel = document.getElementById("lbl_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var labelMessage = document.getElementById("lbl_Message_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
    var ctlhdnOriginalPrice	= document.getElementById("hdnOriginalPrice_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var ctlhdnQuoteForOrder	= document.getElementById("hdnQuoteForOrder_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);

    var sMeasureDrpdnValue = objDrpdn.options[objDrpdn.selectedIndex].value;
    var arr = sMeasureDrpdnValue.split("|");
    var selectedMeasureID = arr[0];
    var selectedMeasureSeqID = arr[1];
    
    var ctlhdnFirstpriceplusforspan;
        
    alert('ResetListPrice ');
    alert('origlistprice: ' + origlistprice);
	ctlhdnOriginalPrice.value = origlistprice;
	    
	alert('test-type: ' + type);
	    
    if (type=='radio'){
        //also reset prev price plus
        theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = '$0';
        
        ctlhdnFirstpriceplusforspan = document.getElementById("hdnFirstPricePlusForSpan_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_mid_" + selectedMeasureID);        
        firstpriceplusforspan = ctlhdnFirstpriceplusforspan.value;
        
        alert("hdnFirstPricePlusForSpan_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_mid_" + selectedMeasureID);
        alert('firstpriceplusforspan1: ' + firstpriceplusforspan);
        alert('firstpriceplusforspan.substring(1): ' + firstpriceplusforspan.substring(1));
        
        if (origlistprice=='QUOTE'){
	        pricelabel.childNodes.item(0).nodeValue = origlistprice;
	        labelMessage.childNodes.item(0).nodeValue = '';	
	    }else{	    
	        if (firstpriceplusforspan != 0 ){
	            labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';
				firstpriceplusforspan = firstpriceplusforspan.replace(/(\d),(\d)/g, '$1$4');
				firstpriceplusforspan = parseFloat(firstpriceplusforspan.substring(1));	
			}else{
			    labelMessage.childNodes.item(0).nodeValue = '';
			}
						
    	    var newprice = parseFloat(origlistprice) + firstpriceplusforspan;
    	    
    	    alert('newprice: ' + newprice);

			//round off to 4 decimal places
			newprice = (Math.round(newprice*10000))/10000;
						
			newprice = newprice.toString();
			if (newprice.indexOf(".") < 0){
			    newprice = newprice + ".00";
			}

			if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
			    newprice = newprice + "0";
			}

	        pricelabel.childNodes.item(0).nodeValue = '$' + newprice;	
	    }
	    
    }else if (type=='select-one'){
        alert('here111');
	    //also reset prev price plus
        theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = '$0';
        
	    if (origlistprice=='QUOTE'){
	        pricelabel.childNodes.item(0).nodeValue = origlistprice;	        
	    }else{	
	        pricelabel.childNodes.item(0).nodeValue = '$' + origlistprice;
	    }
	    labelMessage.childNodes.item(0).nodeValue = '';
    
    }else{
    	if (origlistprice=='QUOTE'){
	        pricelabel.childNodes.item(0).nodeValue = origlistprice;	
	    }else{
	        pricelabel.childNodes.item(0).nodeValue = '$' + origlistprice;	
	    }
	    labelMessage.childNodes.item(0).nodeValue = '';
    }
}

function ResetIsValueSelected(theform, prodid, itemid, carttype, seqid, attrid, yesorno){
    alert('function ResetIsValueSelected()');
    theform["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid].value = yesorno;
}

function ChangeListPriceMultUoms(theform, obj, prodid, itemid, carttype, seqid, attrid, priceplus, origlistprice,mid){
	var pricelabel = document.getElementById("lbl_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var labelMessage = document.getElementById("lbl_Message_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var dprice, dorigprice, newprice, prevprice;
	var pricelabel;
	var attrvalueid;
	var i;
	var objListBox;
    var sNumber;
    var ctlhdnOriginalPrice	= document.getElementById("hdnOriginalPrice_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);
	var ctlhdnQuoteForOrder	= document.getElementById("hdnQuoteForOrder_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid);

	pricelabelvalue = pricelabel.childNodes.item(0).nodeValue;
	
	//alert(ronron);
	
	alert('function ChangeListPriceMultUom()');
	alert('test1');
	alert('pricelabelvalue: ' + pricelabelvalue);
	alert('test2');
	alert('obj.type: ' + obj.type);
		
  	if ((pricelabelvalue=='QUOTE')&&(ctlhdnOriginalPrice.value=='QUOTE')) {
		labelMessage.style.display = 'none';		// do not display the message for revised price		
	}else{
		//dorigprice = pricelabel.childNodes.item(0).nodeValue.substring(1);
		
		dorigprice = ctlhdnOriginalPrice.value;	
		dorigprice = dorigprice.replace(/(\d),(\d)/g, '$1$2');
		dorigprice = parseFloat(dorigprice);			
		
		if(obj.type=='checkbox'){
            //mid was not used in checkbox name								
            
			if(priceplus=='QUOTE')
			{
			    sNumber = ctlhdnQuoteForOrder.value;
			    
			    var iNumber = new Number(sNumber)
			    if (obj.checked == true){
				   iNumber= iNumber + 1;
				}else{
				   iNumber = iNumber - 1;
				}
				
				ctlhdnQuoteForOrder.value =	iNumber;	
				pricelabel.childNodes.item(0).nodeValue = priceplus;
				
			}
			else
			{
					dprice = priceplus;
					dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
					dprice = parseFloat(dprice.substring(1));
				
					if (obj.checked == true){
						newprice = dorigprice + dprice;
					}else{
						newprice = dorigprice - dprice;
					}		
				
					//round off to 4 decimal places
					newprice = (Math.round(newprice*10000))/10000;
					
					newprice = newprice.toString();
					if (newprice.indexOf(".") < 0){
						newprice = newprice + ".00";
					}
					
					if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
						newprice = newprice + "0";
					}

					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + newprice;   
					ctlhdnOriginalPrice.value= newprice;   
			}
		
		    if(ctlhdnQuoteForOrder.value =='0')
			{
				//change the List Price
				pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
			}
			else
			{
				pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
			}
			//display message
			if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
			{
				labelMessage.childNodes.item(0).nodeValue = '';   
			}
			else
			{
				if (newprice != origlistprice){
					labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
				}else{
					labelMessage.childNodes.item(0).nodeValue = '';    					
				}	
			}		
		}else if(obj.type=='select-multiple'){
			if (theform["hdnListBoxAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes'){
				newprice = dorigprice;
				
				objListBox = theform["listbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid];
				
				for (i=0; i < objListBox.options.length; i++){
					attrvalueid = objListBox.options[i].value;
					if (attrvalueid != '0'){
					    var iPos = attrvalueid.indexOf('~buyerdefined~',0);
						if (iPos > 0)
						{
							attrvalueid = attrvalueid.substring(0, iPos)
						}					
						if (objListBox.options[i].selected==true){
							//if not previously selected, then add
							if (theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value == 'no'){
								//add the price increment
								dprice = theform["hdnListBoxPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
								
								if (dprice=='QUOTE')
								{
									sNumber = ctlhdnQuoteForOrder.value;			    
									var iNumber = new Number(sNumber)
									iNumber= iNumber + 1;								
									ctlhdnQuoteForOrder.value=	iNumber;
								}
								else
								{
									dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
									dprice = parseFloat(dprice.substring(1));	
									newprice = newprice + dprice;
								}
								theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value = 'yes';
							}
						}else{
							//if previously selected, then minus
							if (theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value == 'yes'){
								dprice = theform["hdnListBoxPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
								
								if (dprice=='QUOTE')
								{
									sNumber = ctlhdnQuoteForOrder.value;			    
									var iNumber = new Number(sNumber)
									iNumber= iNumber - 1;								
									ctlhdnQuoteForOrder.value=	iNumber;
								}
								else
								{
									dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
									dprice = parseFloat(dprice.substring(1));	
									newprice = newprice - dprice;
								}
								
								
								theform["hdnListBoxPrevSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value = 'no';
							}			
						}
					}
				}	
				
				
				//round off to 4 decimal places
				newprice = (Math.round(newprice*10000))/10000;
				
				newprice = newprice.toString();
				if (newprice.indexOf(".") < 0){
					newprice = newprice + ".00";
				}				
				
				if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
					newprice = newprice + "0";
				}

				//change the List Price
				pricelabel.childNodes.item(0).nodeValue = '$' + newprice;  
				ctlhdnOriginalPrice.value= newprice;   
			
                if(ctlhdnQuoteForOrder.value =='0')
				{
					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
				}
				else
				{
					pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
				}
				//display message
				if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
				{
					labelMessage.childNodes.item(0).nodeValue = '';   
				}
				else
				{
					if (newprice != origlistprice){
						labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
					}else{
						labelMessage.childNodes.item(0).nodeValue = '';    					
					}	
				}		
				
			}	
							
		}else if(obj.type=='radio'){
		
		    alert('radio');
		    alert("hdnRadioAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid);
		    alert('hdnRadioAttrHasPricePlus: ' + theform["hdnRadioAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value);
		
			if (theform["hdnRadioAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes')
			{
	            alert('priceplus: ' + priceplus);   // TEST ONLY
					    
				if(priceplus=='QUOTE')
				{
					sNumber = ctlhdnQuoteForOrder.value;
				    
					var iNumber = new Number(sNumber)
					prevprice = theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;

					if ((obj.checked == true) && (prevprice !='QUOTE'))
					{
						iNumber= iNumber + 1;
									
						ctlhdnQuoteForOrder.value=	iNumber;	
						pricelabel.childNodes.item(0).nodeValue = priceplus;
						
						if ( prevprice != 0 )
						{
							prevprice = prevprice.replace(/(\d),(\d)/g, '$1$4');
							prevprice = parseFloat(prevprice.substring(1));	
						}
						
						newprice = dorigprice  - prevprice;
											
						//round off to 4 decimal places
						newprice = (Math.round(newprice*10000))/10000;
						
						newprice = newprice.toString();
						if (newprice.indexOf(".") < 0){
							newprice = newprice + ".00";
						}

						if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
							newprice = newprice + "0";
						}
						
						ctlhdnOriginalPrice.value= newprice;   
				
						theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = priceplus;
					}
				}
				else
				{
					dprice = priceplus;
					dprice = dprice.replace(/(\d),(\d)/g, '$1$4');
					dprice = parseFloat(dprice.substring(1));	
					
					prevprice = theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
					
					alert('prevprice: ' + prevprice);
					
					if (prevprice =='QUOTE')
					{	
					    sNumber = ctlhdnQuoteForOrder.value;
						var jNumber = new Number(sNumber)
							jNumber = jNumber - 1;
							ctlhdnQuoteForOrder.value=	jNumber;	
						    prevprice=0;
					}
					else
					{
						prevprice = prevprice.replace(/(\d),(\d)/g, '$1$4');
						prevprice = parseFloat(prevprice.substring(1));	
					}
					newprice = dorigprice + dprice - prevprice;
					
					theform["hdnRadioPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = priceplus;
					
					//round off to 4 decimal places
					newprice = (Math.round(newprice*10000))/10000;
					
					newprice = newprice.toString();
					if (newprice.indexOf(".") < 0){
						newprice = newprice + ".00";
					}

					if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
						newprice = newprice + "0";
					}
					
					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
				    ctlhdnOriginalPrice.value= newprice;   

					if(ctlhdnQuoteForOrder.value =='0')
					{
						//change the List Price
						pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
					}
					else
					{
						pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
					}
					//display message
					if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
					{
						labelMessage.childNodes.item(0).nodeValue = '';   
					}
					else
					{
						if (newprice != origlistprice){
							labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
						}else{
							labelMessage.childNodes.item(0).nodeValue = '';    					
						}	
					}
				}	
		   }
		}else if(obj.type=='select-one'){
			//newprice = dorigprice;
			alert('mid: ' + mid);
			alert('hdnDrpdnAttrHasPricePlus_ value: ' + theform["hdnDrpdnAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value);
			alert('drpdn_ length: ' + theform["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length);
			alert("drpdnMeasureNames_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid);
		
			var objDrpdn = theform["drpdnMeasureNames_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid];
			var sMeasureDrpdnValue = objDrpdn.options[objDrpdn.selectedIndex].value;
			var arr = sMeasureDrpdnValue.split("|");
            var selectedMeasureID = arr[0];
            var selectedMeasureSeqID = arr[1];
        
            alert('sMeasureDrpdnValue: ' + sMeasureDrpdnValue);
            alert('selectedMeasureID: ' + selectedMeasureID);
            alert('selectedMeasureSeqID: ' + selectedMeasureSeqID);
            
        
			if (theform["hdnDrpdnAttrHasPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='yes'){				
		
		        attrvalueid = theform["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][selectedMeasureSeqID].value;
		        alert('attrvalueid: ' + attrvalueid);
				
				if (attrvalueid != '0'){
				    var iPos = attrvalueid.indexOf('~buyerdefined~',0);
				    if (iPos > 0)
				    {
				        var sTmpattrvalueid = attrvalueid.substring(0, iPos)
				        dprice = theform["hdnDrpdnPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + sTmpattrvalueid].value;
				    }
				    else
				    {
						dprice = theform["hdnDrpdnPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrvalueid_" + attrvalueid].value;
					}
				}else{
					dprice = 0;	
				}
				
				if(dprice=='QUOTE')
				{
					sNumber = ctlhdnQuoteForOrder.value;
				    
					var iNumber = new Number(sNumber)
					prevprice = theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;

					if (prevprice !='QUOTE')
					{
						iNumber= iNumber + 1;
									
						ctlhdnQuoteForOrder.value=	iNumber;	
						pricelabel.childNodes.item(0).nodeValue = dprice;
						
						if ( prevprice != 0 )
						{
							prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
							prevprice = parseFloat(prevprice.substring(1));	
						}
						
						newprice = dorigprice  - prevprice;
											
						//round off to 4 decimal places
						newprice = (Math.round(newprice*10000))/10000;
						
						newprice = newprice.toString();
						if (newprice.indexOf(".") < 0){
							newprice = newprice + ".00";
						}

						if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
							newprice = newprice + "0";
						}
						
						ctlhdnOriginalPrice.value= newprice;   
						theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = dprice;
					}
				}
				else
				{

					//dprice = priceplus;
					if ( dprice != 0 )
					{
						dprice = dprice.replace(/(\d),(\d)/g, '$1$2');
						dprice = parseFloat(dprice.substring(1));
					}
					
					prevprice = theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value;
					if (prevprice =='QUOTE')
					{	
					    sNumber = ctlhdnQuoteForOrder.value;
						var jNumber = new Number(sNumber)
							jNumber = jNumber - 1;
							ctlhdnQuoteForOrder.value=	jNumber;	
						    prevprice=0;
					}
					else
					{
					    if ( prevprice != 0 )
						{
							prevprice = prevprice.replace(/(\d),(\d)/g, '$1$2');
							prevprice = parseFloat(prevprice.substring(1));	
						}
					}
					newprice = dorigprice + dprice - prevprice;
					
					theform["hdnDrpdnPrevPricePlus_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value = "$" + dprice;
					
					//round off to 4 decimal places
					newprice = (Math.round(newprice*10000))/10000;
					
					newprice = newprice.toString();
					if (newprice.indexOf(".") < 0){
						newprice = newprice + ".00";
					}

					if (newprice.substring(newprice.indexOf(".") + 1).length == 1){
						newprice = newprice + "0";
					}
					
					//change the List Price
					pricelabel.childNodes.item(0).nodeValue = '$' + newprice;    
				    ctlhdnOriginalPrice.value= newprice;   

					if(ctlhdnQuoteForOrder.value =='0')
					{
						//change the List Price
						pricelabel.childNodes.item(0).nodeValue = '$' + ctlhdnOriginalPrice.value;    
					}
					else
					{
						pricelabel.childNodes.item(0).nodeValue = 'QUOTE';
					}
					//display message
					if ((pricelabel.childNodes.item(0).nodeValue =='QUOTE'))
					{
						labelMessage.childNodes.item(0).nodeValue = '';   
					}
					else
					{
						if (newprice != origlistprice){
							labelMessage.childNodes.item(0).nodeValue = 'Revised price includes options selected below.';    					
						}else{
							labelMessage.childNodes.item(0).nodeValue = '';    					
						}	
					}
					
				}	
			}	
		}		
	}
}

function ValidateRequiredFields(form, action){
	var isapiurl;

	// Call ValidateBuyerDefinedValues first
	if (ValidateBuyerDefinedValues(form)){  
		// for each hdnBuyerRequiredFlag, check the value
		// if YES, get the hdnIsValueSelected_<prodid>_<itemid>_<carttype>_<seqid>_<attrid>
	
		var thevalue, prodid, itemid, carttype, seqid, attrid, reqdflag;
		var arr, okay;
		var isMoreThanOneAttr;
		var isRange;
		okay=true;
		isMoreThanOneAttr = false;
		for (i=0; i < form.hdnBuyerRequiredFlag.length; i++){
			isMoreThanOneAttr = true;
		
			thevalue = form.hdnBuyerRequiredFlag[i].value;
			arr = thevalue.split("|");
			
			prodid = arr[0];
			itemid = arr[1];
			carttype = arr[2];
			seqid = arr[3];
			attrid = arr[4];
			reqdflag = arr[5];
			//measureid = arr[5];
			isRange=arr[6]
					
			if (reqdflag=='yes'){
			    	   //Start :: 26-Aug-2009 :Ganga Sagar ::Issue#3823 Fix for Buyer Required for Range 
			    	   var j=0;
			    	   var attrValueRange;
			    	if(isRange=='range') {   
			    	   var ctlTmp="radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid;
		                var ChkCtl=document.getElementsByName(ctlTmp);		
		                    for (j=ChkCtl.length-1; j > -1; j--)
		                        {		
			                         if (ChkCtl[j].checked) 
			                            {
				                            attrValueRange =ChkCtl[j] .value;
	                                     }
			                    } 	  
			                if(attrValueRange=='0' ) 
			                {
			                okay=false;
			                }
			    
			                else
			                {
			                okay=true;
			                }	  
			            }
			    	 // //End :: 26-Aug-2009 :Ganga Sagar ::Issue#3823 Fix for Buyer Required for Range 
			    else
			    {	   
			    	   
				//check isSelected hidden
				if (form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid ].value=='no'){
					okay=false;
					break;
					 }   
					
				}
			}
		}
		
		if (isMoreThanOneAttr == false){		
			//check for single hdnBuyerRequiredFlag
			thevalue = form.hdnBuyerRequiredFlag.value;
			arr = thevalue.split("|");
			
			prodid = arr[0];
			itemid = arr[1];
			carttype = arr[2];
			seqid = arr[3];
			attrid = arr[4];
			reqdflag = arr[5];
					
			if (reqdflag=='yes'){
				//check isSelected hidden
				if(document.all)
                {
                   	if (form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid ].value=='no')
                   	{
					   
					    okay=false;  
					}                                                                   
                }
                else
                {
                    if (document.getElementById["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid ].value=='no')
                    {
					    okay=false;
					}                                                              
                }
                
//				if (form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid ].value=='no'){
//					okay=false;
//				}
			}			
		}
		
	
		if (okay==false){
			if (action=='rfi'){
				alert('Please complete all required fields.');
			}else{
				alert('You must complete all required fields before adding any items to the cart.');
			}
			return false;
		}else{	
			if (action=='rfi'){
				return true;				
			}else{
				if (action=='changeoptions'){
					isapiurl = form.hdnIsapiChangeOptionsUrl.value;	
					if (form.hdnPCATName.value=='')
					{
					     if (isapiurl==''){
						    form.action = "ChangeOptions.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
							    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
							    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
							    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value +
							    "&sid=" + form.hdnSID.value + "&lsid=" + form.hdnLSID.value + "&uid=" + form.hdnUID.value + "&cart_itemid=" + form.hdnCartItemID.value + 
							    "&plpurl=" + form.hdnPlpUrl.value + "&action=" + action;	
					    }else{
						    form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
							    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
							    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
							    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value +
							    "&sid=" + form.hdnSID.value + "&lsid=" + form.hdnLSID.value + "&uid=" + form.hdnUID.value + "&cart_itemid=" + form.hdnCartItemID.value + 
							    "&plpurl=" + form.hdnPlpUrl.value + "&action=" + action;						
					    }
					}
					else
					{
					    if (isapiurl==''){
						    form.action = "ChangeOptions.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
							    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
							    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
							    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value +
							    "&sid=" + form.hdnSID.value + "&lsid=" + form.hdnLSID.value + "&uid=" + form.hdnUID.value + "&cart_itemid=" + form.hdnCartItemID.value + 
							    "&plpurl=" + form.hdnPlpUrl.value + "&action=" + action + "&pcat=" + form.hdnPCATName.value;	
					    }else{
						    form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
							    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
							    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
							    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value +
							    "&sid=" + form.hdnSID.value + "&lsid=" + form.hdnLSID.value + "&uid=" + form.hdnUID.value + "&cart_itemid=" + form.hdnCartItemID.value + 
							    "&plpurl=" + form.hdnPlpUrl.value + "&action=" + action + "&pcat=" + form.hdnPCATName.value;						
					    }
					}
				}else{
					isapiurl = form.hdnIsapiAdditionaOptionsUrl.value;
					
					var theplpurl = form.hdnPlpUrl.value;
					if (window.encodeURIComponent)
	                    theplpurl = encodeURIComponent(theplpurl);
	                else if (window.escape)
		                theplpurl = escape(theplpurl);
		            
		            if (form.hdnPCATName.value=='')
		            {
					    if (isapiurl==''){
						    form.action = "AdditionalOptions.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
									    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
									    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
									    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value + "&oln=" + form.hdnOln.value + "&plpurl=" + theplpurl + "&action=" + action;						
					    }else{
						    form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
									    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
									    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
									    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value + "&oln=" + form.hdnOln.value + "&plpurl=" + theplpurl +  "&action=" + action;											
					    }
					}
					else
					{
					    if (isapiurl==''){
						    form.action = "AdditionalOptions.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
									    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
									    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
									    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value + "&oln=" + form.hdnOln.value + "&plpurl=" + theplpurl + "&action=" + action + "&pcat=" + form.hdnPCATName.value;						
					    }else{
						    form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
									    "&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
									    "&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
									    "&type=" + form.hdnCartType.value + "&prodids=" + form.hdnProdIDs.value + "&oln=" + form.hdnOln.value + "&plpurl=" + theplpurl +  "&action=" + action + "&pcat=" + form.hdnPCATName.value;											
					    }
					
					}

				}
				
				form.submit();			
				return true;				
			}
		}	
	}else{		
		return false;
	}
}


function ValidateRequiredFields_new(form, action){
	var isapiurl;
	
	// Call ValidateBuyerDefinedValues first
	if (ValidateBuyerDefinedValues(form)){  
		// for each hdnBuyerRequiredFlag, check the value
		// if YES, get the hdnIsValueSelected_<prodid>_<itemid>_<carttype>_<seqid>_<attrid>
	
		var thevalue, prodid, itemid, carttype, seqid, attrid, reqdflag;
		var arr, okay;
		var isMoreThanOneAttr;
		
		okay=true;
		isMoreThanOneAttr = false;
		for (i=0; i < form.hdnBuyerRequiredFlag.length; i++){
			isMoreThanOneAttr = true;
		
			thevalue = form.hdnBuyerRequiredFlag[i].value;
			arr = thevalue.split("|");
			
			prodid = arr[0];
			itemid = arr[1];
			carttype = arr[2];
			seqid = arr[3];
			attrid = arr[4];
			reqdflag = arr[5];
					
			if (reqdflag=='yes'){
				//check isSelected hidden
				if (form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid].value=='no'){
					okay=false;
					break;
				}
			}
		}
		
		if (isMoreThanOneAttr == false){		
			//check for single hdnBuyerRequiredFlag
			thevalue = form.hdnBuyerRequiredFlag.value;
			arr = thevalue.split("|");
			
			prodid = arr[0];
			itemid = arr[1];
			carttype = arr[2];
			seqid = arr[3];
			attrid = arr[4];
			reqdflag = arr[5];
					
			if (reqdflag=='yes'){
				//check isSelected hidden
				if (form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid].value=='no'){
					okay=false;
				}
			}			
		}
		
	
		if (okay==false){
			if (action=='rfi'){
				alert('Please complete all required fields.');
			}else{
				alert('You must complete all required fields before adding any items to the cart.');
			}
			return false;
		}else{	
			if (action=='rfi'){
				return true;				
			}else{
			    var sCartType;
				if (action=='changeoptions'){
					isapiurl = form.hdnIsapiChangeOptionsUrl.value;	
					if (form.hdnCartType.value=="order")
					{
						sCartType=form.hdnCartType.value + form.hdnQuoteForOrder.value;
					}
					else
					{
						sCartType=form.hdnCartType.value;
					}
					if (isapiurl==''){
						form.action = "ChangeOptions.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
							"&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
							"&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
							"&carttype=" + sCartType + "&prodids=" + form.hdnProdIDs.value +
							"&sid=" + form.hdnSID.value + "&uid=" + form.hdnUID.value + "&cart_itemid=" + form.hdnCartItemID.value + 
							"&plpurl=" + form.hdnPlpUrl.value + "&action=" + action;	
					}else{
						form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
							"&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
							"&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
							"&carttype=" + sCartType + "&prodids=" + form.hdnProdIDs.value +
							"&sid=" + form.hdnSID.value + "&uid=" + form.hdnUID.value + "&cart_itemid=" + form.hdnCartItemID.value + 
							"&plpurl=" + form.hdnPlpUrl.value + "&action=" + action;						
					}
				}else{
					isapiurl = form.hdnIsapiAdditionaOptionsUrl.value;
					if (form.hdnCartType.value=="order")
					{
						sCartType=form.hdnCartType.value + form.hdnQuoteForOrder.value;
					}
					else
					{
						sCartType=form.hdnCartType.value;
					}
					
					if (isapiurl==''){
						form.action = "AdditionalOptions.aspx?cid=" + form.hdnCID.value + "&plpver=" + form.hdnPlpVer.value + 
									"&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
									"&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
									"&type=" + sCartType + "&prodids=" + form.hdnProdIDs.value + "&action=" + action;						
					}else{
						form.action = isapiurl + "&plpver=" + form.hdnPlpVer.value + 
									"&categid=" + form.hdnCategID.value + "&prodid=" + form.hdnProdID.value + 
									"&itemids=" + form.hdnItemIDs.value + "&qtys=" + form.hdnQtys.value + 
									"&type=" + sCartType + "&prodids=" + form.hdnProdIDs.value + "&action=" + action;											
					}

				}
				form.submit();			
				return true;				
			}
		}	
	}else{		
		return false;
	}
}

function ValidateBuyerDefinedValues(form){
var thevalue, prodid, itemid, carttype, seqid, attrid, displaytype;
	var arr, okay;	
	var attrvalueid, buyerdefidx;
	var mid;
    //  BEGIN 2.5 *********
    var isNumeric,valMin, valMax, valStep;
    //  END 2.5 *********
	okay=true;
	if (form.hdnIsBuyerDefPresent.value=='true'){
		if(form.hdnBuyerDefinedFlag.length > 1){
			for (i=0; i < form.hdnBuyerDefinedFlag.length; i++){		
				thevalue = form.hdnBuyerDefinedFlag[i].value;
				arr = thevalue.split("|");
					
				prodid = arr[0];
				itemid = arr[1];
				carttype = arr[2];
				seqid = arr[3];
				attrid = arr[4];
				displaytype = arr[5];
				if(arr.length>9)
				{
				   mid =arr[9];
				}
				else
				{
				    mid ="0";
				}
				//  BEGIN 2.5 *********
				if((displaytype=='chk') || (displaytype=='radio')){
					//displaytype='edtOption';
			    }
                 isNumeric= arr[6];
                 valMin= arr[7];
                 if (valMin=="negative infinity")
                    valMin="~";
                    
                 valMax= arr[8];
                 if (valMax=="infinity")
                    valMax="~";
    
                if (arr[9] != 'memo')
                {
                    valStep = arr[9];
					if (!CheckBuyerDefinedValuesByDisplayType(form, prodid, itemid, carttype, seqid, attrid, displaytype, isNumeric, valMin, valMax, valStep,mid)){
						okay=false; break;
					}
				}
				//  END 2.5 *********
			}
		}else{		
			thevalue = form.hdnBuyerDefinedFlag.value;
			arr = thevalue.split("|");
				
			prodid = arr[0];
			itemid = arr[1];
			carttype = arr[2];
			seqid = arr[3];
			attrid = arr[4];
			displaytype = arr[5];
			if(arr.length>9)
			{
			    mid =arr[9];
			}
			else
			{
			    mid ="0";
			}
			if((displaytype=='chk') || (displaytype=='radio')){
				//displaytype='edtOption';
			}
		    //  BEGIN 2.5 *********
               isNumeric= arr[6];
               valMin= arr[7];
               valMax= arr[8];
               if (arr[9] != 'memo')
               {
                     valStep = arr[9];
				     if (!CheckBuyerDefinedValuesByDisplayType(form, prodid, itemid, carttype, seqid, attrid, displaytype, isNumeric, valMin, valMax, valStep,mid)){
			    		okay=false;
				}
			}
		   //  END 2.5 *********	   
		}
	}	
	
	if (okay==false){
		//alert('Please complete buyer-defined values.');
		return false;
	}else{
		return true;
	}				
}
function CheckBuyerDefinedValuesByDisplayType(form, prodid, itemid, carttype, seqid, attrid, displaytype, isNumeric, valMin, valMax, valStep,mid){
//---------------------------------------------
// loop through the appropriate items.
// check if buyer-defined control is selected.
// if yes, check for the appropraite editbox.
//---------------------------------------------	

	var okay,checkMinMax;
	var i, j, k;
    var isNotValidNumeric, isNotValidInteger;
    
    isNotValidNumeric=false;
    isNotValidInteger=false;
    checkMinMax=false;
	if((displaytype=='chk') || (displaytype=='radio'))
	{

		// this covers checkbox, imagecheckbox, radio, image radio, range, link select
		k=0;
		var ctlTmp=displaytype + '_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid;
		var ChkCtl=document.getElementsByName(ctlTmp);		
		//for (j=0; j < form[displaytype + '_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].length-1; j++){		
		for (j=ChkCtl.length-1; j > -1; j--)
		{		
			//if (form[displaytype + "_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][j].checked==true){
			 if (ChkCtl[j].checked) 
			 {
				// get the value, check if it contains ~buyerdefined~
				//attrvalueid = form[displaytype + "_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][j].value;
				attrvalueid =ChkCtl[j] .value;
	            var formid ='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined';					    				    
				buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
				if (buyerdefidx > 1){
					// check the editbox
					
					if(carttype=='rfi')
					{
					    var sValueid=attrvalueid.substring(0,attrvalueid.indexOf('~'));
					    var formid ='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined_'+ sValueid;					    				    
					}					
					if(form[formid].length==undefined)
					{
						if (trim(form[formid].value)==''){
							okay=false;
							break; 
						}
						else
						{
						    if ((isNumeric == "yes")||(isNumeric == "yes_i"))
						    {
						        if (isNumeric=="yes")
								{
									if(!IsFloatNumeric(trim(form[formid].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=true;
									isNotValidInteger=false;
									break; }
								}
								if (isNumeric=="yes_i")
								{
									if(!IsInteger(trim(form[formid].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=false;
									isNotValidInteger=true;
									break; }
								}
								
								if (!CheckMinAndMaxWithStep(trim(form[formid].value), valMin, valMax, valStep,isNumeric))
								{
								okay=false;
								checkMinMax=true;
								break; 
								}
							}
						}
					}
					else
					{
						if (trim(form[formid][k].value)=='')
						{
						    //START :: 24-July-2009 :: Surekha Deshmukh :: Issue#4066 :: temporary solution we will enable all <other> edit boxes on RFx to allow for entry at all times.
						    if(carttype=="rfi")
						    {
						        var d
						        
						        var bbrokeninForLoop = false;
						        if(form[formid])
						        {
						            var totalBuyerDefined =form[formid].length;
						            for(d=0;d<totalBuyerDefined;d++)
						            {
						                if (trim(form[formid][d].value)!='')
						                {
						                    okay=true;
						                    bbrokeninForLoop = true;
							                break; 
						                }
						            }
						            if(!bbrokeninForLoop)
						            {
						                okay=false;
						            }
						        }
						        break;
						    }
						    else
						    {
							    okay=false;
							    break; 
							}
							//END :: 24-July-2009 :: Surekha Deshmukh :: Issue#4066 :: temporary solution we will enable all <other> edit boxes on RFx to allow for entry at all times.
						}
						else
						{
						    if ((isNumeric == "yes")||(isNumeric == "yes_i"))
						    {
						    
								if (isNumeric=="yes")
								{
									if(!IsFloatNumeric(trim(form[formid][k].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=true;
									isNotValidInteger=false;
									break; }
								}
								if (isNumeric=="yes_i")
								{
									if(!IsInteger(trim(form[formid][k].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=false;
									isNotValidInteger=true;
									break; }
								}
								
								if (!CheckMinAndMaxWithStep(trim(form[formid][k].value), valMin, valMax, valStep, isNumeric))
								{
								okay=false;
								checkMinMax=true;
								break; 
								}
							}
						}
						k=k + 1;
					}							
				}
			}
			else
			{
				//attrvalueid = form[displaytype + "_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][j].value;
				attrvalueid=ChkCtl[j] .value
				buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
				if (buyerdefidx > 1){
				 k=k + 1;
				}
			}
		}
	}else if(displaytype=='listbox'){
		for (j=0; j < form['listbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].options.length; j++){		
			if (form["listbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].options[j].selected==true){
				// get the value, check if it contains ~buyerdefined~
				attrvalueid = form["listbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].options[j].value;
				
				buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
				if (buyerdefidx > 1){
					// check the editbox
					if (trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)==''){
						okay=false;
						break; 
					}
					else
					{
						if ((isNumeric == "yes")||(isNumeric == "yes_i"))
						{
						    
						    if (isNumeric=="yes")
							{
								if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
								{okay=false;
								checkMinMax=true;
								isNotValidNumeric=true;
								isNotValidInteger=false;
								break; }
							}
							if (isNumeric=="yes_i")
							{
								if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
								{okay=false;
								checkMinMax=true;
								isNotValidNumeric=false;
								isNotValidInteger=true;
								break; }
							}
							
							if (!CheckMinAndMaxWithStep(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value), valMin, valMax, valStep, isNumeric))
							{
							okay=false;
							checkMinMax=true;
							break; 
							}
						}
					}
				}
			}
		}
	}else if(displaytype=='drpdn'){
		// get the value, check if it contains ~buyerdefined~
		attrvalueid = form["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].options[form["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].selectedIndex].value;
		
		buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
		if (buyerdefidx > 1){
			// check the editbox
			if (trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)==''){
				okay=false;
			}
			else
			{
				if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				{
				
					if (isNumeric=="yes")
					{
						if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=true;
						isNotValidInteger=false;}
						//break; }
					}
					if (isNumeric=="yes_i")
					{
						if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=false;
						isNotValidInteger=true;}
						//break; }
					}
							
					if (!CheckMinAndMaxWithStep(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value), valMin, valMax, valStep, isNumeric))
					{
					okay=false;
					checkMinMax=true;
					}
				}
			}
		}
	}else if(displaytype=='edt'){
	    var id;
	    if(mid="0")
	    {
	        id='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ;
	    }
	    else
	    {
	        id='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid +'_' + mid ;
	    }
	    if(form[id]!=undefined)
	    {
	    if(form[id].length==undefined)
	    //'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].length==undefined)
	    {
			if (!trim(form[id].value)==''){
			//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value)==''){
				if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				{
				
				    if (isNumeric=="yes")
					{
						if(!IsFloatNumeric(trim(form[id].value)))
						//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=true;
						isNotValidInteger=false;}
						//break; }
					}
					if (isNumeric=="yes_i")
					{
						if(!IsInteger(trim(form[id].value)))
						//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=false;
						isNotValidInteger=true;}
						//break; }
					}
					
					if (!CheckMinAndMaxWithStep(trim(form[id].value), valMin, valMax, valStep, isNumeric))
					//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value), valMin, valMax, valStep, isNumeric))
						{
							okay=false;
							checkMinMax=true;
						}
				}
			}
	    
	    }
	    else
	    {
	          if(mid="0")
	        {
	            id='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ;
	        }
	        else
	        {
	            id='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_' + mid ;
	        }
			for (j=0; j < form[id].length; j++){	
			//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].length; j++){		
				if (!trim(form[id][j].value)==''){
				//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value)==''){
					if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				    {
				    
						if (isNumeric=="yes")
						{
							if(!IsFloatNumeric(trim(form[id][j].value)))
							//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=true;
							isNotValidInteger=false;
							break; }
						}
						if (isNumeric=="yes_i")
						{
							if(!IsInteger(trim(form[id][j].value)))
							//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=false;
							isNotValidInteger=true;
							break; }
						}
						if (!CheckMinAndMaxWithStep(trim(form[id][j].value), valMin, valMax, valStep, isNumeric))
						//'editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value), valMin, valMax, valStep, isNumeric))
						{
							okay=false;
							checkMinMax=true;
							break; 
						}
					}
				}
			}
			}
		}
	}else if(displaytype=='edtOption'){
	    if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].length==undefined)
	    {
			if (!trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)==''){
				if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				{
				
					if (isNumeric=="yes")
					{
						if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=true;
						isNotValidInteger=false;}
						//break; }
					}
					if (isNumeric=="yes_i")
					{
						if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=false;
						isNotValidInteger=true;}
						//break; }
					}
						
					if (!CheckMinAndMaxWithStep(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value), valMin, valMax, valStep, isNumeric))
						{
							okay=false;
							checkMinMax=true;
						}
				}
			}
	     
	    }
	    else
	    {
			for (j=0; j < form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].length; j++){		
				if (!trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value)==''){
					if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				    {
				    
				        if (isNumeric=="yes")
						{
							if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=true;
							isNotValidInteger=false;
							break; }
						}
						if (isNumeric=="yes_i")
						{
							if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=false;
							isNotValidInteger=true;
							break; }
						}
						if (!CheckMinAndMaxWithStep(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value), valMin, valMax, valStep, isNumeric))
						{
							okay=false;
							checkMinMax=true;
							break;
						}
					}
				}
			}
		}
	}
	
	if (okay==false)
	{
		if (checkMinMax==true)
		{
			if (isNumeric == "yes")
			{
			    if (isNotValidNumeric==true)
					alert('This is not a valid numeric value.');
			    else
					{
					if (valMin=="~" && valMax=="~")
						alert('Entry is outside the specified Min/Max Range.');
					else
						{
						 if (valMin=="~")
						     alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range: up to ' + valMax + '.');
					     else if (valMax=="~")
					         alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range: ' + valMin + ' and up.');
					     else
					     {
					         if (valStep == "")
					            alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range [' + valMin + ', ' + valMax + '].');	
					         else
						        alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range [' + valMin + ', ' + valMax + ']' + ' by ' + valStep + '.');	
						 }			
						}			
                    }
			}
			else
			{
				if (isNotValidInteger==true)
					alert('This is not a valid integer value.');
				else
				{
					if (valMin=="~" && valMax=="~")
						alert('Entry is outside the specified Min/Max Range.');
					else
					   {
					     if (valMin=="~")
					         alert('Entry is outside of the specified Min/Max Range.\n Please re-enter an integer value within the range: up to ' + valMax + '.');
					     else if (valMax=="~")
					         alert('Entry is outside of the specified Min/Max Range.\n Please re-enter an integer value within the range: ' + valMin + ' and up.');
					     else
					     {
					         if (valStep == "")
					            alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range [' + valMin + ', ' + valMax + '].');	
					         else
						        alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range [' + valMin + ', ' + valMax + ']' + ' by ' + valStep + '.');	
                         }
					   }
               }
			}
		}
		else
			alert('Please complete buyer-defined values.');
			
        if((displaytype=='chk') || (displaytype=='radio'))
		{
		    var sValueid;
		    var formid ='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined';
		    if(carttype=='rfi')
		    {
		        if(attrvalueid.indexOf('~buyerdefined~')>0) 
		        {
		            sValueid=attrvalueid.substring(0,attrvalueid.indexOf('~'));
		            formid='editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined_' + sValueid;
		        }
		    }
		    if(form[formid].length==undefined)
		    {
		        if(form[formid].disabled =false)
		        {
		            form[formid].focus();
				    form[formid].select();
				}
		    }
		    else
		    {
		         form[formid][k].focus();
				form[formid][k].select();
		    }
		    
		
		}
		
		if(displaytype=='edt')
		{
			if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ].length==undefined)
			{
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ].focus();
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ].select();
			}
			else
			{
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ][j].focus();
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ][j].select();
			}	
		}		
		else
		{	
		     if(carttype=='rfi' && (displaytype=='chk' || displaytype=='radio') )
		     {
		        //return true;
		     }
		     else
		     {
			    if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].length==undefined)
			    {
				    form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].focus();
				    form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].select();
			    }
			    else
			    {
				    form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].focus();
				    form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].select();
			    }
			}
		}
		return false;
	}
	else
	{
		return true;
	}
}

//Ron:
//We may need to replace 2.0 by this version. 
function CheckBuyerDefinedValuesByDisplayType_old(form, prodid, itemid, carttype, seqid, attrid, displaytype, isNumeric, valMin, valMax, valStep){
//---------------------------------------------
// loop through the appropriate items.
// check if buyer-defined control is selected.
// if yes, check for the appropraite editbox.
//---------------------------------------------	
	var okay,checkMinMax;
	var i, j, k;
    var isNotValidNumeric, isNotValidInteger;
    
    isNotValidNumeric=false;
    isNotValidInteger=false;
    checkMinMax=false;
	if((displaytype=='chk') || (displaytype=='radio')){

		// this covers checkbox, imagecheckbox, radio, image radio, range, link select
		k=0;
		for (j=0; j < form[displaytype + '_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].length; j++){		
			if (form[displaytype + "_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][j].checked==true){
				// get the value, check if it contains ~buyerdefined~
				attrvalueid = form[displaytype + "_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][j].value;
	
				buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
				if (buyerdefidx > 1){
					// check the editbox
					if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].length==undefined)
					{
						if (trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)==''){
							okay=false;
							break; 
						}
						else
						{
						    if ((isNumeric == "yes")||(isNumeric == "yes_i"))
						    {
						        if (isNumeric=="yes")
								{
									if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=true;
									isNotValidInteger=false;
									break; }
								}
								if (isNumeric=="yes_i")
								{
									if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=false;
									isNotValidInteger=true;
									break; }
								}
								
								if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value), valMin, valMax,isNumeric))
								{
								okay=false;
								checkMinMax=true;
								break; 
								}
							}
						}
					}
					else
					{
						if (trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].value)==''){
							okay=false;
							break; 
						}
						else
						{
						    if ((isNumeric == "yes")||(isNumeric == "yes_i"))
						    {
						    
								if (isNumeric=="yes")
								{
									if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=true;
									isNotValidInteger=false;
									break; }
								}
								if (isNumeric=="yes_i")
								{
									if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].value)))
									{okay=false;
									checkMinMax=true;
									isNotValidNumeric=false;
									isNotValidInteger=true;
									break; }
								}
								
								if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].value), valMin, valMax,isNumeric))
								{
								okay=false;
								checkMinMax=true;
								break; 
								}
							}
						}
						k=k + 1;
					}							
				}
			}
			else
			{
				attrvalueid = form[displaytype + "_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][j].value;
				buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
				if (buyerdefidx > 1){
				 k=k + 1;
				}
			}
		}
	}else if(displaytype=='listbox'){
		for (j=0; j < form['listbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].options.length; j++){		
			if (form["listbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].options[j].selected==true){
				// get the value, check if it contains ~buyerdefined~
				attrvalueid = form["listbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].options[j].value;
				
				buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
				if (buyerdefidx > 1){
					// check the editbox
					if (trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)==''){
						okay=false;
						break; 
					}
					else
					{
						if ((isNumeric == "yes")||(isNumeric == "yes_i"))
						{
						    
						    if (isNumeric=="yes")
							{
								if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
								{okay=false;
								checkMinMax=true;
								isNotValidNumeric=true;
								isNotValidInteger=false;
								break; }
							}
							if (isNumeric=="yes_i")
							{
								if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
								{okay=false;
								checkMinMax=true;
								isNotValidNumeric=false;
								isNotValidInteger=true;
								break; }
							}
							
							if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value), valMin, valMax,isNumeric))
							{
							okay=false;
							checkMinMax=true;
							break; 
							}
						}
					}
				}
			}
		}
	}else if(displaytype=='drpdn'){
		// get the value, check if it contains ~buyerdefined~
		attrvalueid = form["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].options[form["drpdn_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].selectedIndex].value;
		
		buyerdefidx = attrvalueid.indexOf("~buyerdefined~");
		if (buyerdefidx > 1){
			// check the editbox
			if (trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)==''){
				okay=false;
			}
			else
			{
				if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				{
				
					if (isNumeric=="yes")
					{
						if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=true;
						isNotValidInteger=false;}
						//break; }
					}
					if (isNumeric=="yes_i")
					{
						if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=false;
						isNotValidInteger=true;}
						//break; }
					}
							
					if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value), valMin, valMax,isNumeric))
					{
					okay=false;
					checkMinMax=true;
					}
				}
			}
		}
	}else if(displaytype=='edt'){
	    if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].length==undefined)
	    {
			if (!trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value)==''){
				if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				{
				
				    if (isNumeric=="yes")
					{
						if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=true;
						isNotValidInteger=false;}
						//break; }
					}
					if (isNumeric=="yes_i")
					{
						if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=false;
						isNotValidInteger=true;}
						//break; }
					}
					
					if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].value), valMin, valMax,isNumeric))
						{
							okay=false;
							checkMinMax=true;
						}
				}
			}
	    
	    }
	    else
	    {
			for (j=0; j < form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid].length; j++){		
				if (!trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value)==''){
					if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				    {
				    
						if (isNumeric=="yes")
						{
							if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=true;
							isNotValidInteger=false;
							break; }
						}
						if (isNumeric=="yes_i")
						{
							if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=false;
							isNotValidInteger=true;
							break; }
						}
						if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid][j].value), valMin, valMax,isNumeric))
						{
							okay=false;
							checkMinMax=true;
							break; 
						}
					}
				}
			}
		}
	}else if(displaytype=='edtOption'){
	    if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].length==undefined)
	    {
			if (!trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)==''){
				if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				{
				
					if (isNumeric=="yes")
					{
						if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=true;
						isNotValidInteger=false;}
						//break; }
					}
					if (isNumeric=="yes_i")
					{
						if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value)))
						{okay=false;
						checkMinMax=true;
						isNotValidNumeric=false;
						isNotValidInteger=true;}
						//break; }
					}
						
					if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].value), valMin, valMax,isNumeric))
						{
							okay=false;
							checkMinMax=true;
						}
				}
			}
	    
	    }
	    else
	    {
			for (j=0; j < form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].length; j++){		
				if (!trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value)==''){
					if ((isNumeric == "yes")||(isNumeric == "yes_i"))
				    {
				    
				        if (isNumeric=="yes")
						{
							if(!IsFloatNumeric(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=true;
							isNotValidInteger=false;
							break; }
						}
						if (isNumeric=="yes_i")
						{
							if(!IsInteger(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value)))
							{okay=false;
							checkMinMax=true;
							isNotValidNumeric=false;
							isNotValidInteger=true;
							break; }
						}
						if (!CheckMinAndMax(trim(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid+ '_buyerdefined'][j].value), valMin, valMax,isNumeric))
						{
							okay=false;
							checkMinMax=true;
							break;
						}
					}
				}
			}
		}
	}
	
	if (okay==false)
	{
		if (checkMinMax==true)
		{
			if (isNumeric == "yes")
			{
			    if (isNotValidNumeric==true)
					alert('This is not a valid numeric value.');
			    else
					{
					if (valMin=="~" && valMax=="~")
						alert('Entry is outside the specified Min/Max Range.');
					else
						{
						 if (valMin=="~")
						     alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range: up to ' + valMax + '.');
					     else if (valMax=="~")
					         alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range: ' + valMin + ' and up.');
					     else
						     alert('Entry is outside of the specified Min/Max Range.\n Please re-enter a numeric value within the range [' + valMin + ', ' + valMax + '].');	
										
						}			
                    }
			}
			else
			{
				if (isNotValidInteger==true)
					alert('This is not a valid integer value.');
				else
				{
					if (valMin=="~" && valMax=="~")
						alert('Entry is outside the specified Min/Max Range.');
					else
					   {
					     if (valMin=="~")
					         alert('Entry is outside of the specified Min/Max Range.\n Please re-enter an integer value within the range: up to ' + valMax + '.');
					     else if (valMax=="~")
					         alert('Entry is outside of the specified Min/Max Range.\n Please re-enter an integer value within the range: ' + valMin + ' and up.');
					     else
					         alert('Entry is outside of the specified Min/Max Range.\n Please re-enter an integer value within the range [' + valMin + ', ' + valMax + '].');
					   }
               }
			}
		}
		else
			alert('Please complete buyer-defined values.');
		
		if(displaytype=='edt')
		{
			if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ].length==undefined)
			{
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ].focus();
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ].select();
			}
			else
			{
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ][j].focus();
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid ][j].select();
			}	
		}
		else
		{		
			if(form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].length==undefined)
			{
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].focus();
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'].select();
			}
			else
			{
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].focus();
				form['editbox_' + prodid + '_' + itemid + '_' + carttype + '_'  + seqid + '_attrid_' + attrid + '_buyerdefined'][k].select();
			}
		}
		return false;
	}
	else
	{
		return true;
	}
}

function SetIsValueSelected(obj, form, prodid, itemid, carttype, seqid, attrid,mid)
{

	var isSet;
		
	isSet = false;
	if(obj.type=='checkbox'){
		if(form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){
			for (i=0; i < form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].checked==true){
					isSet = true;
					break;
				}
			}	
		}else{
			if (form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].checked==true){
				isSet = true;				
			}		
		}	

    }else if(obj.type=='radio'){
		if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){		
			for (i=0; i < form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].checked==true){
					if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].value=='0' ){
						isSet = false;
					}else{
                        isSet = true;
					}
					break;				
				}
			}	
		}else{
			if (form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].checked==true){
				if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='0'){
					isSet = false;
				}else{
					isSet = true;
				}
			}			
		}
		
    }else if(obj.type=='select-one'){
		if (obj.value=='0'){
			isSet = false;
		}else{
			isSet = true;
		}
		
    }else if(obj.type=='select-multiple'){
		for (i=0; i < obj.options.length; i++){
			if (obj.options[i].selected==true){
				if (obj.options[i].value!='0'){
					//other than No Preference is selected
					isSet = true;
					break;
				}
			}
		}
     }else if(obj.type=='text'){
     
        if(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid]!=undefined)
	    {
		if(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){				
			for (i=0; i < form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].value)!=''){
					isSet = true;
					break;
				}
			}	
		}else{
			if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value)!=''){
				isSet = true;
			}
		}
		}
		else
		{
		    if(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid +"_" +mid].length > 1){				
			for (i=0; i < form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid+"_" +mid].length; i++){
				if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid+"_" +mid][i].value)!=''){
					isSet = true;
					break;
				}
			}	
		}else{
			if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid+"_" +mid].value)!=''){
				isSet = true;
			}
		}
		}
		
    }else if(obj.type=='textarea'){
    	if(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){				
			for (i=0; i < form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (trim(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].value)!=''){
					isSet = true;
					break;
				}
			}	
		}else{
			if (trim(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value)!=''){
				isSet = true;
			}		
		}
    }

   	if (isSet==false){
		form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid].value = 'no';
	}else{
		form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid].value = 'yes';
	}
}


function SetIsValueSelectedMultUoms(obj, form, prodid, itemid, carttype, seqid, attrid, mid){
	var isSet;
		
	alert('function SetIsValueSelectedMultUoms()');
		
	isSet = false;
	if(obj.type=='checkbox'){
	    //mid was not used in checkbox name
		if(form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){
			for (i=0; i < form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].checked==true){
					isSet = true;
					break;
				}
			}	
		}else{
			if (form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].checked==true){
				isSet = true;				
			}		
		}	

    }else if(obj.type=='radio'){
		if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){		
			for (i=0; i < form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].checked==true){
					if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].value=='0'){
						isSet = false;
					}else{
						isSet = true;
					}
					break;				
				}
			}	
		}else{
			if (form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].checked==true){
				if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value=='0'){
					isSet = false;
				}else{
					isSet = true;
				}
			}			
		}
		
    }else if(obj.type=='select-one'){
    
        alert('select-one');
        alert('obj.value: ' + obj.value);
        
		if (obj.value=='0'){
			isSet = false;
		}else{
			isSet = true;
		}
		
    }else if(obj.type=='select-multiple'){
		for (i=0; i < obj.options.length; i++){
			if (obj.options[i].selected==true){
				if (obj.options[i].value!='0'){
					//other than No Preference is selected
					isSet = true;
					break;
				}
			}
		}
     }else if(obj.type=='text'){
		if(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){				
			for (i=0; i < form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].value)!=''){
					isSet = true;
					break;
				}
			}	
		}else{
			if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value)!=''){
				isSet = true;
			}
		}
		
    }else if(obj.type=='textarea'){
    	if(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length > 1){				
			for (i=0; i < form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].length; i++){
				if (trim(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid][i].value)!=''){
					isSet = true;
					break;
				}
			}	
		}else{
			if (trim(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid].value)!=''){
				isSet = true;
			}		
		}
    }

   	if (isSet==false){
		form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid].value = 'no';
	}else{
		form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid].value = 'yes';
	}
}

function SetIsValueSelectedRFx(obj, form, prodid, itemid, carttype, seqid, attrid, measureid){
	var isSet;
	
	isSet = false;
	if(obj.type=='checkbox'){
		if(form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length > 1){
			for (i=0; i < form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length; i++){
				if (form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid][i].checked==true){
					isSet = true;
					break;
				}
			}	
		}else{
			if (form["chk_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].checked==true){
				isSet = true;				
			}		
		}	

    }else if(obj.type=='radio'){
		if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length > 1){		
			for (i=0; i < form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length; i++){
				if (form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid][i].checked==true){
					if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid][i].value=='0'){
						isSet = false;
					}else{
						isSet = true;
					}
					break;				
				}
			}	
		}else{
			if (form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].checked==true){
				if(form["radio_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].value=='0'){
					isSet = false;
				}else{
					isSet = true;
				}
			}			
		}
		
    }else if(obj.type=='select-one'){
		if (obj.value=='0'){
			isSet = false;
		}else{
			isSet = true;
		}
		
    }else if(obj.type=='select-multiple'){
		for (i=0; i < obj.options.length; i++){
			if (obj.options[i].selected==true){
				if (obj.options[i].value!='0'){
					//other than No Preference is selected
					isSet = true;
					break;
				}
			}
		}
     }else if(obj.type=='text'){
		if(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length > 1){				
			for (i=0; i < form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length; i++){
				if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid][i].value)!=''){
					isSet = true;
					break;
				}
			}	
		}else{
			if (trim(form["editbox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].value)!=''){
				isSet = true;
			}
		}
		
    }else if(obj.type=='textarea'){
    	if(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length > 1){				
			for (i=0; i < form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].length; i++){
				if (trim(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid][i].value)!=''){
					isSet = true;
					break;
				}
			}	
		}else{
			if (trim(form["memobox_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_attrid_" + attrid + "_" + measureid].value)!=''){
				isSet = true;
			}		
		}
    }

   	if (isSet==false){
		form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid + "_" + measureid].value = 'no';
	}else{
		form["hdnIsValueSelected_" + prodid + "_" + itemid + "_" + carttype + "_" + seqid + "_" + attrid + "_" + measureid].value = 'yes';
	}
}

function ValidateAdvSearchForm(theform, cid, plpver, categid, prodid, srchaction, displayresults){
	var isSelected, isDataTypeOkay, isRangeOkay, attrid, displaytype, datatype;
	var sBackToName;
	var isapiurl;
	var i;

	// START :: 23-Sep-2009 :: Graham D'cunha :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content
	var sValue;
	sValue = document.URL;
	//alert(sValue)
	PlpRemoveCookie("plp_PreviousURL_Adv_Search")
	PlpSetCookie("plp_PreviousURL_Adv_Search", sValue);
    // END :: 23-Sep-2009 :: Graham D'cunha :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content

    if (displayresults=='1'){
		isapiurl = theform.hdnIsapiAdvancedSearchResultsUrl.value;
	}else{
		isapiurl = theform.hdnIsapiAdvancedSearchUrl.value;
	}	
	
	isSelected = false;
	if (theform.hdnAttrIDs.length > 1){
		for (i=0; i < theform.hdnAttrIDs.length; i++){
			attrid = theform.hdnAttrIDs[i].value;
			displaytype = theform.hdnAttrTypes[i].value;
			datatype = theform.hdnDataTypes[i].value;
			MeasureId = theform.hdnMeasureIDs[i].value;
			
			isSelected = IsItemSelected(theform, displaytype, attrid, MeasureId);	
			if (isSelected==true){
				break;
			}
		}			
	}else{
		attrid = theform.hdnAttrIDs.value;
		displaytype = theform.hdnAttrTypes.value;
		datatype = theform.hdnDataTypes.value;
		MeasureId = theform.hdnMeasureIDs.value;
			
		isSelected = IsItemSelected(theform, displaytype, attrid, MeasureId);
	}

	if (isSelected==true)
	{	
		if (theform.hdnAttrIDs.length > 1)
		{
			for (i=0; i < theform.hdnAttrIDs.length; i++)
			{
				attrid = theform.hdnAttrIDs[i].value;
				displaytype = theform.hdnAttrTypes[i].value;
				datatype = theform.hdnDataTypes[i].value;
				MeasureId = theform.hdnMeasureIDs[i].value;
				//validate entries based on data type
                //alert (datatype + ' ' + displaytype);
				isDataTypeOkay = ValidateDataType(theform, datatype, displaytype, attrid, MeasureId);
				if (isDataTypeOkay==false){
					return false;
					break;	
				}
				
				//check for value within available range
				
				isRangeOkay = ValidateRange(theform, datatype, displaytype, attrid, MeasureId);
				if (isRangeOkay==false){
					return false;
					break;	
				}
			}		
		}else{
			attrid = theform.hdnAttrIDs.value;
			displaytype = theform.hdnAttrTypes.value;
			datatype = theform.hdnDataTypes.value;
			MeasureId = theform.hdnMeasureIDs.value;
			
			//validate entries based on data type
			isDataTypeOkay = ValidateDataType(theform, datatype, displaytype, attrid, MeasureId);
			if (isDataTypeOkay==false){
				return false;
			}									
			
			//check for value within available range
			isRangeOkay = ValidateRange(theform, datatype, displaytype, attrid, MeasureId);
			if (isRangeOkay==false){
				return false;
			}		
		}
	}else{
	
	    if (displaytype == "Adv4label")
	    {
	    
	    }
	    else
	    {
		    if (srchaction=='add'){
			    alert('Please enter search input.');
		    }else{
			    alert('Please enter at least one search criteria.');
		    }
		    return false; 
		}
	}
	
	sBackToName = theform.hdnBackToName.value;
	if (window.encodeURIComponent)
	   sBackToName = encodeURIComponent(sBackToName);
	else if (window.escape)
		sBackToName = escape(sBackToName);
		
	if (isapiurl==''){
		theform.action = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + 
	                                    prodid + '&action=' + srchaction + '&forward=' + theform.hdnForward.value +
	                                    '&backtoname=' + sBackToName;		
	}else{
		theform.action = isapiurl + 'cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + 
	                                    prodid + '&action=' + srchaction + '&forward=' + theform.hdnForward.value +
	                                    '&backtoname=' + sBackToName;				
	}

	//alert('theform.action: ' + theform.action);
	theform.submit();
	return true;	
}

function IsItemSelected(theform, displaytype, attrid, MeasureId){
	var j;
	var valueandmid;
	
	if (displaytype=='chk'){
	    if(theform["chk_" + "attrid_" + attrid + "_" + MeasureId].length==undefined)
	    {
		    if (theform["chk_" + "attrid_" + attrid + "_" + MeasureId].checked==true){
				return true;
			}
		}
		else
		{
			for (j=0; j < theform["chk_" + "attrid_" + attrid + "_" + MeasureId].length; j++){
				if (theform["chk_" + "attrid_" + attrid + "_" + MeasureId][j].checked==true){
					return true;
				}
			}
		}	
	}else if (displaytype=='radio'){
	    if (theform["radio_" + "attrid_" + attrid + "_" + MeasureId].length==undefined)
	    {
			if (theform["radio_" + "attrid_" + attrid + "_" + MeasureId].checked==true){
			    valueandmid = theform["radio_" + "attrid_" + attrid + "_" + MeasureId].value.split('_');
		        value = valueandmid[0]; 
				if (value != '0'){
					return true
				}
			}
		}
		else
		{
			for (j=0; j < theform["radio_" + "attrid_" + attrid + "_" + MeasureId].length; j++){
				if (theform["radio_" + "attrid_" + attrid + "_" + MeasureId][j].checked==true){
				    valueandmid = theform["radio_" + "attrid_" + attrid + "_" + MeasureId][j].value.split('_');
		            value = valueandmid[0]; 
					if (value != '0'){
						return true
					}
				}
			}
		}	
	}else if (displaytype=='bool_radio'){
	    if(theform["bool_radio_" + "attrid_" + attrid].length==undefined)
	    {
			if (theform["bool_radio_" + "attrid_" + attrid].checked==true){
				valueandmid = theform["bool_radio_" + "attrid_" + attrid].value.split('_');
		        value = valueandmid[0]; 
				if (value != '0'){
					return true;
				}
			}
		}
		else
		{
			for (j=0; j < theform["bool_radio_" + "attrid_" + attrid].length; j++){
				if (theform["bool_radio_" + "attrid_" + attrid][j].checked==true){
					valueandmid = theform["bool_radio_" + "attrid_" + attrid][j].value.split('_');
		            value = valueandmid[0]; 
					if (value != '0'){
						return true;
					}
				}
			}
		}			
	}else if (displaytype=='drpdn'){
		valueandmid = theform["drpdn_" + "attrid_" + attrid + "_" + MeasureId].value.split('_');
		value = valueandmid[0]; 
		if (value!='0'){
			return true;
		}
	}else if (displaytype=='listbox'){	    
	 	for (j=0; j < theform["listbox_" + "attrid_" + attrid + "_" + MeasureId].options.length; j++){
			if (theform["listbox_" + "attrid_" + attrid + "_" + MeasureId].options[j].selected==true){
			    valueandmid = theform["listbox_" + "attrid_" + attrid + "_" + MeasureId].options[j].value.split('_');
			    value = valueandmid[0]; 
				if (value!='0'){
					//other than No Preference is selected
					return true;
				}
			}
		}
	}else if (displaytype=='editbox'){
		//alert("editbox_" + "attrid_" + attrid + ' is : ' + theform["editbox_" + "attrid_" + attrid].value);
		if (trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value)!=''){
			return true;			
		}
	}else if (displaytype=='drpdn_range'){
		//alert("editbox_" + "attrid_" + attrid + ' is : ' + theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value);
		if (trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value)!=''){
			return true;
		}
	}else if (displaytype=='memobox'){
		if (trim(theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].value)!=''){
			return true;
		}
	}else if (displaytype=='range'){
		if ((trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].value)!='') || (trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].value)!='')){
			return true;
		}
	}
	
	return false;
}

function ValidateDataType(theform, datatype, displaytype, attrid, MeasureId){

	if (datatype=='10'){
		//check if integer
		if (displaytype=='editbox'){
			//alert('here1');
			if (!IsInteger(trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value))){
				alert('Search input must be an integer.');
				theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].focus();
				return false; 
			}else{
				theform["editbox_" + "attrid_" + attrid].value = theform["editbox_" + "attrid_" + attrid].value.replace(/(\d),(\d)/g, '$1$2');
			}
		}else if (displaytype=='drpdn_range'){
			//alert('here2');
			if (!IsInteger(trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value))){
				alert('Search input must be an integer.');
				theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].focus();
				return false; 
			}else{
				theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value = theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value.replace(/(\d),(\d)/g, '$1$2');
			}
		}else if (displaytype=='memobox'){
			//alert('here3');
			if (!IsInteger(trim(theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].value))){
				alert('Search input must be an integer.');
				theform["memobox_" + "attrid_" + attrid + "_" + MeasureId ].focus();
				return false; 
			}else{
				theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].value = theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].value.replace(/(\d),(\d)/g, '$1$2');
			}
		}else if (displaytype=='range'){
			//alert('here4');
			if (!IsInteger(trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].value))){
				//alert('try1');
				alert('Search input must be an integer.');
				theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].focus();
				return false; 
			}else if (!IsInteger(trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].value))){
				//alert('try2');
				alert('Search input must be an integer.');
				theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].focus();
				return false; 
			}else{
				theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].value = theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].value.replace(/(\d),(\d)/g, '$1$2');
				theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].value = theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].value.replace(/(\d),(\d)/g, '$1$2');
			}
		}
	}else if (datatype=='14'){
		//check if numeric
		if (displaytype=='editbox'){
			//alert('here5');
			if (trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value)!=''){
				if (isNaN(RemoveCommasIfIsFloatNumeric(trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value)))){
					alert('Search input must be numeric.');
					theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].focus();
					return false; 
				}						
			}
		}else if (displaytype=='drpdn_range'){
			//alert('here6');
			//alert('value is : ' + trim(theform["editbox_" + "attrid_" + "_" + MeasureId + attrid].value));
			if (trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value)!=''){
				if (isNaNPLP(RemoveCommasIfIsFloatNumeric(trim(theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value)))){
					alert('Search input must be numeric.');
					theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].focus();
					return false; 
				}
			}
		}else if (displaytype=='memobox'){
			//alert('here7');
			if (trim(theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].value)!=''){
				if (isNaNPLP(RemoveCommasIfIsFloatNumeric(trim(theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].value)))){
					alert('Search input must be numeric.');
					theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].focus();
					return false; 
				}
			}
		}else if (displaytype=='range'){
			//alert('here8');
			if ((trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].value)!='') || (trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].value)!='')){
				if (isNaNPLP(RemoveCommasIfIsFloatNumeric(trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].value)))){
					alert('Search input must be numeric.');
					theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].focus();
					return false; 
				}else if (isNaNPLP(RemoveCommasIfIsFloatNumeric(trim(theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].value)))){
					alert('Search input must be numeric.');
					theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].focus();
					return false; 
				}					
			}
		}
	}
	return true;
}

function isNaNPLP(nValye)
{
   if (nValye.indexOf("/", 0) > 0 )
    {
       if(isLegalFraction(nValye))
       {
            return false;
       }
       else
       {
            return true;
       }
    }
    else
    {
       if(isNaN(nValye))
       {
        return true;
       }
       else
       {
        return false;
       }
    }

}

function RemoveCommasIfIsFloatNumeric(nValue){
  if(IsFloatNumeric(nValue))
  {
//		alert('Yes, ' + nValue + ' is float numeric');
	  nValue = nValue.replace(/(\d),(\d)/g, '$1$2');
  }
  else
  {
//		alert('No, ' + nValue + ' is not numeric');
  }
  return nValue;
}

function GetFractionValue(pString) 
{   
    var strValidChars = "0123456789/-";
	var strChar, firstSlashPos, lastSlashPos;
	var legal = true;
	var sTmpValue = "";
	var sWholeNumber;
	var sTopNumber;
	var sBottomNumber;
	
	//first, strip the leading + or -, if it exists
	if (pString.indexOf("-")==0 || pString.indexOf("+")==0)
    {
        sTmpValue = pString.substring(0,1);
        pString = pString.substring(1);
    } 
	
	 //Find "-"
	jpos = pString.indexOf("-");
    if ( jpos > 0) 
	{	
        sWholeNumber = pString.substring(0, jpos);
        pString.substring(jpos + 1);
    }
    else
    {
        sWholeNumber = 0;
    }
    
    //Find "/"
    jpos = pString.indexOf("/");
    if (jpos > 0)
	{	
	    sTopNumber = pString.substring(0, jpos);
	    sBottomNumber = pString.substring(jpos + 1);
    }
    else
    {
        sTopNumber=0;
        sBottomNumber=1;
    }
   
    sTmpValue = sTmpValue + (parseFloat(sWholeNumber) + parseFloat(sTopNumber) /parseFloat(sBottomNumber));
    return sTmpValue;
}

function parseFloatPLP(piValue)
{
   if (piValue.indexOf("/", 0) > 0 ) 
   {
      return GetFractionValue(piValue)
   }
   else
   {
    return piValue
   }
}

function ValidateRange(theform, datatype, displaytype, attrid, MeasureId)
{
    var nMinInput;
	var nMaxInput;
 
    if (displaytype=='drpdn_range')
    {
		var nMin = theform["hdn_range_" + "attrid_" + attrid + "_" + MeasureId + "_min"].value;
		var nMax = theform["hdn_range_" + "attrid_" + attrid + "_" + MeasureId + "_max"].value;
		var nInputValue = theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value;
		//var nInput;
		
		//alert('FIRST...nMin=' + nMin + ' nMax=' + nMax + ' nInput=' + nInput);
		nMin = RemoveCommasIfIsFloatNumeric(nMin);
		nMax = RemoveCommasIfIsFloatNumeric(nMax);
		nInput = RemoveCommasIfIsFloatNumeric(nInputValue);
		//theform["editbox_" + "attrid_" + attrid].value=nInputValue;
		if (datatype==14)
		{
			nMin = parseFloatPLP(nMin);
		    nMax = parseFloatPLP(nMax);
		    nInput = parseFloatPLP(nInputValue);
		}
    }
    
    if (displaytype=='range')
    {
		var nMin = theform["hdn_range_" + "attrid_" + attrid + "_" + MeasureId + "_min"].value;
		var nMax = theform["hdn_range_" + "attrid_" + attrid + "_" + MeasureId + "_max"].value;
		
		nMinInput = theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].value;
	    nMaxInput = theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].value;
		
		nMin = RemoveCommasIfIsFloatNumeric(nMin);
		nMax = RemoveCommasIfIsFloatNumeric(nMax);
		nMinInput = RemoveCommasIfIsFloatNumeric(nMinInput);
		nMaxInput = RemoveCommasIfIsFloatNumeric(nMaxInput);
		if (datatype==14)
		{
		    nMin = parseFloatPLP(nMin);
		    nMax = parseFloatPLP(nMax);
		    nMinInput = parseFloatPLP(nMinInput);
		    nMaxInput = parseFloatPLP(nMaxInput);
		}
    }
    //	alert('nMin=' + nMin + ' nMax=' + nMax + ' nInput=' + nInput);
	
	if (displaytype=='drpdn_range'){
		//alert('here9');			
		if (trim(nInput)!=''){
			if ((nMin=='infinitymin') && (nMax=='infinitymax')){
				// do nothing
			}else if ((nMax=='infinitymax') && (nMin!='infinitymin')){
				if (parseFloat(nInput) < parseFloat(nMin)){
					//validate the min entry
					alert('Search input must be within available range.');
					theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].focus();
					return false; 
				}
			}else if ((nMin=='infinitymin') && (nMax!='infinitymax')){
				if (parseFloat(nInput) > parseFloat(nMax)){
					//validate the max entry
					alert('Search input must be within available range.');
					theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].focus();
					return false; 
				}				
			}else if ((parseFloat(nInput) < parseFloat(nMin)) || 
				(parseFloat(nInput) > parseFloat(nMax))){
//					alert('theform=' + theform + ' datatype=' + datatype + ' displaytype=' + displaytype + ' attrid=' + attrid);
//					alert(nInput);
//					alert(nMax);
//					alert(nMin);
					alert('Search input must be within available range.');
					theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].focus();
					return false; 
			}				
		}	
	}else if (displaytype=='range'){
		//alert('here10');
		if ((trim(nMinInput)!='') || (trim(nMaxInput)!='')){
			if ((theform["hdn_range_" + "attrid_" + attrid + "_" + MeasureId + "_min"].value=='infinitymin') && (nMax=='infinitymax')){
				// do nothing
			}else if ((nMax=='infinitymax') && (nMin!='infinitymin')){
				if (parseFloat(nMinInput) < parseFloat(nMin)){
					//alert('me1');
					//validate the min entry
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].focus();
					return false; 
				}else if (parseFloat(nMinInput) < parseFloat(nMaxInput)){
					//check if to is greater than from
					alert('Minimum value must be less than maximum value.');
					theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].focus();
					return false; 
				}
			}else if ((nMin=='infinitymin') && (nMax!='infinitymax')){
				if (parseFloat(nMinInput) > parseFloat(nMax)){
					//alert('me1');
					//validate the max entry
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].focus();
					return false; 
				}else if (parseFloat(nMinInput) < (parseFloat(nMaxInput))){
					//check if to is greater than from
					alert('Minimum value must be less than maximum value.');
					theform["range_" + "attrid_" + "_" + MeasureId + attrid + "_from"].focus();
					return false; 
				}						
			}else if ((parseFloat(nMinInput) < parseFloat(nMin)) || 
				(parseFloat(nMinInput) > parseFloat(nMax))){
					//alert('me1');
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].focus();
					return false; 
			}else if ((parseFloat(nMaxInput) < parseFloat(nMin)) || 
				(parseFloat(nMaxInput) > parseFloat(nMax))){
					//alert('me2');
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_to"].focus();
					return false; 
			}else if ((parseFloat(nMaxInput)) < (parseFloat(nMinInput))){
				//check if to is greater than from
				//alert('me3');
				alert('Minimum value must be less than maximum value.');
				theform["range_" + "attrid_" + attrid + "_" + MeasureId + "_from"].focus();
				return false; 
			}							
		}				
	}	
	
//	theform["editbox_" + "attrid_" + attrid].value = nInput;
	return true;
}

function FilterByProductByType(theform, cid, plpver, categid, obj, keyword, keycateg, keyprod, backtoname,searchType){
	var prodid, strPath;
	var sBackToName;
	var sPcatName;
	prodid = obj.value;
	if (prodid != '0'){
		if (keyword==''){	 
			sBackToName = backtoname;
			if (window.encodeURIComponent)
				sBackToName = encodeURIComponent(sBackToName);
			else if (window.escape)
				sBackToName = escape(sBackToName);
		
			isapiurl = theform.hdnIsapiAdvancedSearchResultsUrl.value;
			sPcatName = theform.hdnPCAT.value;
			
			if (sPcatName == '')
			{		  
			    if (isapiurl==''){
				    strPath = 'AdvancedSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			              '&SchType=' + searchType + '&backtoname=' + sBackToName;					
			    }else{
				    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			              '&SchType=' + searchType + '&backtoname=' + sBackToName;							
			    }
			}
			else
			{
			    if (isapiurl==''){
				    strPath = 'AdvancedSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			              '&SchType=' + searchType + '&backtoname=' + sBackToName + "&pcat=" + sPcatName;					
			    }else{
				    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			              '&SchType=' + searchType + '&backtoname=' + sBackToName  + "&pcat=" + sPcatName;							
			    }

			}			

		}else{
			isapiurl = theform.hdnIsapiKeywordResultsUrl.value;
			sPcatName = theform.hdnPCAT.value;
			
			if (isapiurl.indexOf('/internal/',0) > -1)
			isapiurl='';
			
			if (sPcatName == '')
			{ 
			    if (isapiurl==''){
				    strPath = 'KeywordSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			               '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid + '&SchType=' + searchType + '&keyType=P';				
			    }else{
				    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			               '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid + '&SchType=' + searchType + '&keyType=P';			
			    }
			}
			else
			{
				if (isapiurl==''){
				    strPath = 'KeywordSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			               '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid + '&SchType=' + searchType + '&keyType=P' + "&pcat=" + sPcatName;				
			    }else{
				    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			               '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid + '&SchType=' + searchType + '&keyType=P' + "&pcat=" + sPcatName;			
			    }

			}
		}
		window.location = strPath;	
		return true;	
	}else{
		return false;	
	}
}

function FilterByProduct(theform, cid, plpver, categid, obj, keyword, keycateg, keyprod, backtoname){
	var prodid, strPath;
	var sBackToName;
	var sPcatName;
	
	prodid = obj.value;
 
    if (! window.navigator.cookieEnabled)
    {
        var sMsg="Your internet settings currently block cookies.\nYou will not be able to filter the results."
        alert(sMsg);
		return false;
    }
    else
    {
		if (prodid != '0'){
			if (keyword==''){	 
				sBackToName = backtoname;
				if (window.encodeURIComponent)
					sBackToName = encodeURIComponent(sBackToName);
				else if (window.escape)
					sBackToName = escape(sBackToName);
			
				isapiurl = theform.hdnIsapiAdvancedSearchResultsUrl.value;
				sPcatName = theform.hdnPCAT.value;
				
				if (sPcatName=='')
				{
				    if (isapiurl==''){
					    strPath = 'AdvancedSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&backtoname=' + sBackToName;					
				    }else{
					    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&backtoname=' + sBackToName;								
				    }
				}
				else
				{
				    if (isapiurl==''){
					    strPath = 'AdvancedSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&backtoname=' + sBackToName + "&pcat=" + sPcatName;					
				    }else{
					    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&backtoname=' + sBackToName + "&pcat=" + sPcatName;								
				    }
				}			

			}else{
				isapiurl = theform.hdnIsapiKeywordResultsUrl.value;
				sPcatName = theform.hdnPCAT.value;
				
				if (isapiurl.indexOf('/internal/',0) > -1)
				isapiurl='';
				
				if (sPcatName=='')
				{
				    if (isapiurl==''){
					    strPath = 'KeywordSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid;				
				    }else{
					    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid;			
				    }
				}
				else
				{
				    if (isapiurl==''){
					    strPath = 'KeywordSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid + "&pcat=" + sPcatName;				
				    }else{
					    strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
						    '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid + "&pcat=" + sPcatName;			
				    }			
				}
			}
			window.location = strPath;	
			return true;	
		}else{
			return false;	
		}
	}
}


function SubmitAdvSearchViewItems(theform, cid, plpver, categid, prodid){
	var isapiurl;
	
	//alert('theform.hdnCriteria.value: ' + theform.hdnCriteria.value);
	
	//SetCookie('adv_srch_criteria', theform.hdnCriteria.value);
	
	isapiurl = theform.hdnIsapiAdvancedSearchResultsUrl.value;
	sBackToName = theform.hdnBackToName.value;
	if (window.encodeURIComponent)
		sBackToName = encodeURIComponent(sBackToName);
	else if (window.escape)
		sBackToName = escape(sBackToName);
				
	if (isapiurl==''){
		theform.action = 'AdvancedSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
	                      '&backtoname=' + sBackToName;	
	                     
		//theform.action = 'AdvancedSearchResults.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid;
	}else{
		theform.action = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
	                     '&backtoname=' + sBackToName;	
	    
	    //theform.action = isapiurl + 'cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid;
	}

	theform.submit();
}

function SubmitAdvancedSearchForm(theform, cid, plpver, categid, prodid, attrid, attrvalid, srchaction){
	var sBackToName;
	var isapiurl;

	if (srchaction=='clear'){
		attrid = theform.drpdnAvailCriteriaList.value;
	}

	isapiurl = theform.hdnIsapiAdvancedSearchUrl.value;
	sBackToName = theform.hdnBackToName.value;
	if (window.encodeURIComponent)
		sBackToName = encodeURIComponent(sBackToName);
	else if (window.escape)
		sBackToName = escape(sBackToName);
					
	if (srchaction=='removeall'){
		if (confirm('Remove all criteria?')) {
			if (isapiurl==''){
				theform.action = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
								      '&attid=' + attrid + '&attvalid=' + attrvalid + '&forward=' + theform.hdnForward.value +
								      '&backtoname=' + sBackToName;					
			}else{
				theform.action = isapiurl + 'cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
								      '&attid=' + attrid + '&attvalid=' + attrvalid + '&forward=' + theform.hdnForward.value +
								      '&backtoname=' + sBackToName;									
			}
			theform.submit();
		}
	}else{
		if (isapiurl==''){
			theform.action = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
						      '&attid=' + attrid + '&attvalid=' + attrvalid + '&action=' + srchaction + 
						      '&forward=' + theform.hdnForward.value + '&backtoname=' + sBackToName;			
		}else{
			theform.action = isapiurl + 'cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
						      '&attid=' + attrid + '&attvalid=' + attrvalid + '&action=' + srchaction + 
						      '&forward=' + theform.hdnForward.value + '&backtoname=' + sBackToName;	
		}

		theform.submit();
	}	
}

//For 2.5
function SubmitAdvanced4SearchForm(theform, cid, plpver, categid, prodid, attrid, attrvalid, srchaction){
	var sBackToName;
	var isapiurl;

	if (srchaction=='clear'){
	    if (confirm('Are you sure that you want to clear your entire search path? \n All choices will be removed.')) {
			isapiurl = theform.hdnIsapiAdvancedSearchUrl.value;
			sBackToName = theform.hdnBackToName.value;
			if (window.encodeURIComponent)
				sBackToName = encodeURIComponent(sBackToName);
			else if (window.escape)
				sBackToName = escape(sBackToName);
							
			if (srchaction=='removeall'){
				if (confirm('Remove all criteria?')) {
					if (isapiurl==''){
						theform.action = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
											'&attid=' + attrid + '&attvalid=' + attrvalid + '&forward=' + theform.hdnForward.value +
											'&backtoname=' + sBackToName;					
					}else{
						theform.action = isapiurl + 'cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
											'&attid=' + attrid + '&attvalid=' + attrvalid + '&forward=' + theform.hdnForward.value +
											'&backtoname=' + sBackToName;									
					}
					theform.submit();
				}
			}else{
				if (isapiurl==''){
					theform.action = theform.action + '?cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
									'&attid=' + attrid + '&attvalid=' + attrvalid + '&action=' + srchaction + 
									'&forward=' + theform.hdnForward.value + '&backtoname=' + sBackToName;			
				}else{
					theform.action = isapiurl + 'cid=' + cid + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + 
									'&attid=' + attrid + '&attvalid=' + attrvalid + '&action=' + srchaction + 
									'&forward=' + theform.hdnForward.value + '&backtoname=' + sBackToName;	
				}

				theform.submit();
			}
		}
	}	
}

function CancelChangeOptions(theform){
	if (confirm('Cancel Changes?')) {
		theform.action = theform.hdnOolBuyerUrl.value;
		theform.submit();
	}
}

function ModeSelected(theform, mode){	     
	var isapiurl;
	
	isapiurl = theform.hdnIsapiBrowserUrl.value;	 
	if (isapiurl==''){
		theform.action = theform.action + '?cid=' + theform.hdnCID.value + '&plpver=' + theform.hdnPlpVer.value + '&categid=' + 
		                  theform.hdnCategID.value + '&prodid=' + theform.hdnProdID.value + '&itemid=' + theform.hdnItemID.value +
		                  '&assetid=' + theform.hdnAssetID.value + '&qlty=' + theform.hdnQuality.value + 
		                  '&size=' + theform.hdnSize.value + '&mode=' + mode;
	}else{
		theform.action = isapiurl + 'cid=' + theform.hdnCID.value + '&plpver=' + theform.hdnPlpVer.value + '&categid=' + 
		                  theform.hdnCategID.value + '&prodid=' + theform.hdnProdID.value + '&itemid=' + theform.hdnItemID.value +
		                  '&assetid=' + theform.hdnAssetID.value + '&qlty=' + theform.hdnQuality.value + 
		                  '&size=' + theform.hdnSize.value + '&mode=' + mode;
	}

	theform.submit();
}

/*function CadViewSelected(theform){	      
	theform.action = 'CadViewer.aspx?cid=' + theform.hdnCID.value + '&plpver=' + theform.hdnPlpVer.value + '&categid=' + 
		                  theform.hdnCategID.value + '&prodid=' + theform.hdnProdID.value + '&itemid=' + theform.hdnItemID.value + 
		                  '&origin=' + theform.hdnOrigin.value + '&by=' + theform.hdnBy.value + '&filter=' + theform.hdnFilter.value + 
		                  '&assetid=' + theform.hdnAssetID.value + '&cadid=' + theform.hdnCadID.value +
		                  '&cadview=' + theform.hdnCadViewSelected.value; 
		                  
	//theform.hdnCadViewSelected.value = cadview;       
	//theform.submit();
	
	window.location = theform.action;	
	return true;	
}*/

function CadViewSelected(theform, cid, plpver, categid, prodid, itemid, origin, by, filter, assetid, cadid, cadview){	      
	var isapiurl;
	
	isapiurl=theform.hdnIsapiCadViewerUrl.value;
	
	if (isapiurl==''){
		theform.action = 'CadViewer.aspx?cid=' + cid + '&plpver=' + plpver + '&categid=' + 
		                  categid + '&prodid=' + prodid + '&itemid=' + itemid + '&origin=' + origin + 
		                  '&by=' + by + '&filter=' + filter + '&assetid=' + assetid + '&cadid=' + cadid +
		                  '&cadview=' + cadview; 
	}else{
		theform.action = isapiurl + '&plpver=' + plpver + '&categid=' + 
		                  categid + '&prodid=' + prodid + '&itemid=' + itemid + '&origin=' + origin + 
		                  '&by=' + by + '&filter=' + filter + '&assetid=' + assetid + '&cadid=' + cadid +
		                  '&cadview=' + cadview; 
	}	
		                  
	//theform.hdnCadViewSelected.value = cadview;       
	//theform.submit();
	
	window.location = theform.action;	
	return true;	
}

function ValidateDownload(theform){
	if (theform.drpdnCadFormats.value=='0'){
		alert('Please select a format to download.');
		return false;
	}else{
		theform.hdnCadFormat.value=theform.drpdnCadFormats.value;
		return true;
	}
}

function ValidateRequestInfo(theform){
if (theform.hdnAttributesShown.value=='yes'){
		if (ValidateRequiredFields(theform, 'rfi')){
			return ValidateRequestInfoForm(theform);
		}else{
			return false;
		}
	}else{
		return ValidateRequestInfoForm(theform);
	}
}

function ValidateRequestInfoForm(theform)
{
    var arrRequiredAttIDs;
    var arrRequiredAttNames;
	var sAttID;
	var sAttName;
	var sEmailFlag;
    var sCtlID;

	arrRequiredAttIDs = theform.hdnBuyerRequiredAttsForContact.value.split(";");
	
	sEmailFlag = "";	
	for (var j=0; j <= arrRequiredAttIDs.length-2; j++)
	{
	    sTmp = arrRequiredAttIDs[j];
	    sCtlFlag=sTmp.substring(0,1)
	    sAttID=sTmp.substring(1)
        sAttName = "The field ";
        
        if (sCtlFlag =="C")
        {
           sCtlID = "10";
        }
        else if(sCtlFlag =="M")
        {
            sCtlID = "70";
        }
        else if(sCtlFlag =="D")
        {
            sCtlID = "20";
        }
        else if(sCtlFlag =="L")
        {
            sCtlID = "30";
        }
         else if(sCtlFlag =="R")
        {
            sCtlID = "40";
        }
        else
        {
            sCtlID = "60";
        }
        
        sEmailFlag = "";  
        if (sAttID == "130")
        {
            sEmailFlag = "S"; //For single
        }
        
        if (sAttID == "99999999")
        {
            sEmailFlag = "M"; //For multiple
        }
	    if (CheckIsRequired(sAttID,sAttName, sCtlID)){
	        if (sEmailFlag == "S")
	        {
	            var stmp = "RFX" + sCtlID + "_" + sAttID;
                var objText = document.getElementById(stmp);
                if (objText)
	            {  
		           if(!CheckEmailAddress(objText))
	                {
	                    return false;
	                }
		        }
		    }
		    else if (sEmailFlag == "M")
		    {
		        var stmpMult = "RFX" + sCtlID + "_" + sAttID;
                var objMultText = document.getElementById(stmpMult);
                if (objMultText)
	            {  
		            if(!CheckMultEmailAddress(objMultText,4))
		            {
		                return false;
		            }
		        }
		    }
	    }
	    else
	    {
	       return false;
	    }
	 }   
	    //Patch, We have to check email address
    if(sEmailFlag == "")
    {
        var objEmail = document.getElementById("RFX60_130");
        if (objEmail != null )
        {  
           if(!CheckEmailAddress(objEmail))
            {
                return false;
            }
        }
    }
	
	return true;
}

function CheckIsRequired(piID, pistr, piCtlID)
{
    if(piCtlID == "20" || piCtlID == "30" || piCtlID == "40") return true; 
       
    var stmp = "RFX" + piCtlID + "_" + piID;
    var objText = document.getElementById(stmp);
 
	if (objText != null )
	{   
	    if (piCtlID == "10")
	    {
	        var checkItems=document.getElementsByName(stmp);
	        for (i=0; i<checkItems.length; i++)
	        {
	            if(checkItems[i].checked==true)
	            {
	                return true;
	            }
	        }
			alert(pistr + " is required.");
			//objText.focus();
			return false;    
	    }
	    else
	    {
	        if (objText.value == "")
	        {
			    alert(pistr + " is required.");
			    objText.focus();
			    return false;
		    }
		    else
		    {
			    return true;
		    }
		}
    }
    else
    {
	    if ( piCtlID == "10" )
	    {
	        var checkItems=document.getElementsByName(stmp);
	        for (i=0; i<checkItems.length; i++)
	        {
	            if(checkItems[i].checked==true)
	            {
	                return true;
	            }
	        }
			alert(pistr + " is required.");
			//objText.focus();
			return false;    
	    }
	    return true;
    }
}

function ValidateRequestInfoForm1(theform)
{
 var obj;
 
    obj = document.getElementById("RFX30_105");
    if (obj == null)
        obj = document.getElementById("txtName");
    
    if (obj != null)
    {
	 if (obj.value=='')
	 {
		alert('Please enter your name.');
		obj.focus();
		return false;
     }
    }

    obj = document.getElementById("RFX30_130");
    if (obj == null)
        obj = document.getElementById("txtEmail");
    
    if (obj != null)
    {
	 if (obj.value=='')
	 {
		alert('Please enter your email address.');
		obj.focus();
		return false;
     }
     else
     {
		return(CheckEmailAddress(obj));
     }
    }
    
	return true; 
}

function ValidateEmailPageForm(theform){
    if (theform.txtEmailTo.value==''){
		alert("Please enter recipient's email address.");
		theform.txtEmailTo.focus();
		return false;
	}else if (theform.txtEmailFrom.value==''){
		alert('Please enter your email address.');
		theform.txtEmailFrom.focus();
		return false;		
	}else{
		//check email from
		if (CheckEmailAddress(theform.txtEmailFrom)){
			//check multiple email to
			if (CheckMultEmailAddress(theform.txtEmailTo, 5) != true){
				return false;
			}
		}else{			
			return false;
		}
	}
	return true; 
}

function CheckEmailAddress(oEmail){
   if (IsEmailAddress(oEmail.value)==false){
     alert("Please enter only validly formatted email address.");
     oEmail.focus();
     return false;
   }
   return true;
}

function CheckMultEmailAddress(oEmail, max){
	var arrEmailTo;
	
	arrEmailTo = oEmail.value.split(";");
	if (arrEmailTo.length > max){
		alert("You can only enter up to 5 email addresses.");
		return false;
	}else{
		//check each email add
		for (i=0; i <= arrEmailTo.length-1; i++){
			if (IsEmailAddress(arrEmailTo[i]) != true){
				alert("Please enter only validly formatted email address");
				oEmail.focus();
				return false;
			}
		}
	}
	return true;
}

function IsEmailAddress(sTxt)
    {	  
    var sExclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var sCheck=/@[\w\-]+\./;
    var sCheckEnd=/\.[a-zA-Z]{2,6}$/;
       
    if (((sTxt.search(sExclude) != -1)||(sTxt.search(sCheck)) == -1)||(sTxt.search(sCheckEnd) == -1))
    {				
	   return false;
    }
        
    //var arr;
    //arr=sTxt.split(".");
    //if (arr[arr.length-1].length > 4)
    //      return false;        
    return true;
}

function trim(str){
    return ltrim(rtrim(str));
  }
  
function ltrim(str){
    while (str.charAt(0)==' '){str=str.substring(1);}
    return str;
}

function rtrim(str){
    while (str.charAt(str.length-1)==' '){str=str.substring(0,str.length-1);}
    return str;
}

function SavePrevPageToCookie() {
	var prevpage;
	
	prevpage = document.URL;
//	SetCookie('plp_previous_page', prevpage);
}

function SubmitToRequestInfo(theform, action){
	theform.action = action;
	
	theform.submit();
}

function SubmitToRFxInfo(piURL){
	var strReturn;
	strReturn = piURL;
	//Start :: 23-Sep-2009 :: Sujit Singh :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content
	var sValue;
	sValue = document.URL;
	//alert(sValue)
	PlpSetCookie("plp_PreviousURL", sValue);
    //End :: 23-Sep-2009 :: Sujit Singh :: Issue#2375 ::PLP - Inquiry - email generated from stage does not have data for 'Originating Page' in the email content
	window.location = strReturn;
}


function GetAttachFile()
{
   var strReturn;
   strReturn = window.showModalDialog('http://localhost/thomastechnology/FileAttachment','','scrollbars: yes; resizable: Yes; dialogWidth: 420px; dialogHeight: 380px; help: no;');
}

function CheckMinAndMaxWithStep(piValue, piMin, piMax, piStep, piCheckMinAndMax)
{
   if (piCheckMinAndMax=="yes")
   {
	   if(!IsFloatNumeric(piValue))
       return false;
   }
   if (piCheckMinAndMax=="yes_i")
   {
	   if(!IsInteger(piValue))
       return false;
   }
 
   var iValue=piValue.replace(/(\d),(\d)/g, '$1$2');  
   if (piMin == "~" && piMax == "~")
   {
   
   }
   else if (piMin == "~" && piMax != "~")
   {
      if (parseFloat(iValue) > parseFloat(piMax))
       return false;
   }
   else if (piMin != "~" && piMax == "~")
   {
       if (parseFloat(iValue) < parseFloat(piMin))
       return false;
   }
   else
   {
      if ( (parseFloat(iValue) > parseFloat(piMax)) || (parseFloat(iValue) < parseFloat(piMin)))
      {
        return false;
      }
      else
      {
         if(typeof(piStep)=='string') {  } else { piStep=""; }
         if ((piCheckMinAndMax=="yes_i") && (piStep != ""))
         {
             if (isValidStep(iValue,piMin,piMax,piStep))
                return true;
             else
                return false;  
          }
          else
          {
          if ((piCheckMinAndMax=="yes") && (piStep != ""))
          {
            if (isValidStepFloat(iValue,piMin,piMax,piStep))
                return true;
             else
                return false;  
           }
            return true;
          } 
      }
   }
   return true;
}

function isValidStep(piValue,piMin,piMax,piStep)
{
  if(piMin.length >0 && (parseInt(piValue.replace(",", "")) - parseInt(piMin)) % parseInt(piStep) !=0 )
   {
       //sErrMsg = "Please enter valid number from " + piMin + " up in steps of " + piStep; 
       //alert(sErrMsg);
       return false;
   }
   else
   {
        return true;
   }
}
function isValidStepFloat(piValue,piMin,piMax,piStep)
{
            // if(sAttDataType=="14" || sAttDataType=="57") {
	        if(piMin=="") { piMin="0"; }
	        var fValueEdBoxMinussMin=parseFloat(piValue.replace(",", "")) -parseFloat(piMin);
	        
	        var fValueRound=Math.round(fValueEdBoxMinussMin*10000000000);
	        var fValueforsStep=Math.round(piStep * 10000000000);
	        var fValueCalculateMod=Math.round(fValueRound % fValueforsStep);
    if((piStep.length>0 && piMin.length>0 && (fValueCalculateMod !=0)) || (piStep.length>0 && piMin=="0" && (fValueCalculateMod !=0)) )
   {
   
       //sErrMsg = "Please enter valid number from " + piMin + " up in steps of " + piStep; 
       //alert(sErrMsg);
       return false;
   }
   else
   {
        return true;
   }
}
function CheckMinAndMax(piValue, piMin, piMax,piCheckMinAndMax)
{
   if (piCheckMinAndMax=="yes")
   {
	   if(!IsFloatNumeric(piValue))
       return false;
   }
   if (piCheckMinAndMax=="yes_i")
   {
	   if(!IsInteger(piValue))
       return false;
   }
  // if(!IsNumber(piMax))
  //     return false; 
  //  if(!IsNumber(piMax))
  //     return false;          
 
   var iValue=piValue.replace(/(\d),(\d)/g, '$1$2');  
   if (piMin == "~" && piMax == "~")
   {
   
   }
   else if (piMin == "~" && piMax != "~")
   {
      if (parseFloat(iValue) > parseFloat(piMax))
       return false;
   }
   else if (piMin != "~" && piMax == "~")
   {
       if (parseFloat(iValue) < parseFloat(piMin))
       return false;
   }
   else
   {
      if ( (parseFloat(iValue) > parseFloat(piMax)) || (parseFloat(iValue) < parseFloat(piMin)))
      return false;
   }
   return true;
}

function IsNumber(piValue)
{
    if (IsInteger(piValue))
		return true;
    else
    {
		if (IsNumeric(piValue))
			return true;
		else
			return false;
    }
}

function ValidateOrderQtyConfirmation(obj, hdnMinOrderQty,hdnPrevValue, piInventoryQty, piCartTypeID){  
    
	var okay;
	var minorder;
	var sAlertMsg;
	var sInventoryMsg = document.frmOrderConfirmation.hdnInventoryMessage.value;
	var CartType=document.frmOrderConfirmation.hdnCartType.value;
	//alert("Current TextBox :: " +obj.value + " MinimumOrder :: " + hdnMinOrderQty.value + " hdnPrevValue :: " + hdnPrevValue.value + " piInventoryQty :: " + piInventoryQty);
	
	//get the minimum order qty
	minorder = hdnMinOrderQty.value;
	if (piCartTypeID == 4)
	    minorder = 1
	if(obj.value >=1 )
    {
   	    if((obj.value != ''))
   	    {
	        if(IsNumeric(obj.value))
	        {
		            //check if order qty is at least min order qty
		            if(CartType == "order")
		            {
		                if(parseInt(obj.value) < parseInt(minorder))
		                {
			                okay = false;
			                sAlertMsg = 'Order quantity should be at least ' + minorder + ".";			   
		                }
		            
		                else
		                {
		                    if(piInventoryQty != "")
		                    {
		                        if(CartType == "order")
		                        {
		                          if (IsNumeric(piInventoryQty) )
		                          {
		                              if(parseInt(obj.value) > parseInt(piInventoryQty))
		                              {
		                                    okay = false;
			                                if (sInventoryMsg == "" )
			                                {
			                                    sAlertMsg = 'Order quantity should not exceed the original inventory value ' + piInventoryQty + ".";
			                                }
			                                else
			                                {
			                                    sAlertMsg = sInventoryMsg;
			                                } //End of if (sInventoryMsg == "" )
			                           } //End of if(parseInt(objvalue) > parseInt(piInventoryQty))
			                        } //End of if (IsNumeric(piInventoryQty) )
			                    }//End of if(CartType == "order")
			                } //End of if(piInventoryQty != "")
		                } //End of if(parseInt(obj.value) < parseInt(minorder))
		            }// end of cartype=order
	          } // End of if(IsNumeric(objvalue))	          
              else
              {
	            okay = false;
	            sAlertMsg = 'Please enter a numeric value.';
	          } 
	    }//End of if((objvalue != ''))
	    else
	    {
	        okay = false;
		    sAlertMsg = 'Please enter a numeric value.';
	    } 
	    //START :: 02-Jun-2008 :: Ganga Sagar ::Issue#3182 And 3219 :: PLP - Order Confirmation - Quantity Field	
	 }// End of if(objvalue >=1 ) 
	else{
	    okay = false;
		sAlertMsg = 'Please enter a numeric value greater than 0.';	
		
	}
	//End :: 02-Jun-2008 :: Ganga Sagar ::Issue#3182 And 3219 :: PLP - Order Confirmation - Quantity Field
	if(okay==false){
	        obj.value=hdnPrevValue.value;
			
	        return sAlertMsg;
			//obj.focus();
		    //return false;
	}else{
		 
			return "";
	}
}

function ReinitializeMeasureValueSelections(form,objName,type,objDrpdn,spanPrefixName){
   var sMeasureDrpdnValue, selectedMeasureID, selectedMeasureSeqID;
   var arr, g;
   
    alert('function ReinitializeMeasureValueSelections()');
   
    sMeasureDrpdnValue = objDrpdn.options[objDrpdn.selectedIndex].value;
    arr = sMeasureDrpdnValue.split("|");
    selectedMeasureID = arr[0];
    selectedMeasureSeqID = arr[1];
        
    alert('spanPrefixName: ' + spanPrefixName);
    alert('span to process: ' + spanPrefixName + selectedMeasureID);
    
    var oSelectedSpan = document.getElementById(spanPrefixName + selectedMeasureID);
    //var oSelectedSpan = document.getElementById("spanMeasure_1003_3001003_1016_rfq_1_attrid_1003_mid_1004");
    
    alert('type: ' + type);
    
    if (type=='radio'){  
       //set the first option as selected
       
       //alert('oSelectedSpan.elements.length: ' + oSelectedSpan.elements.length);
       //alert(oSelectedSpan);
       //alert(oSelectedSpan.innerHTML);
       var allelements = oSelectedSpan.getElementsByTagName("*");
       //alert('length: ' + allelements.length);
        
       //alert('objName: ' + objName);
       
       for (g=0; g<allelements.length; g++) {	
           alert(allelements[g].getAttribute("name"));		
           if (allelements[g].getAttribute && allelements[g].getAttribute("name") == objName) {
              allelements[g].checked = true; 
              break;              
           }		             
       }
       
       if(form[objName].length > 1){
		    for (i=0; i < form[objName].length; i++){
		        //alert(form[objName][i].value);
		    	//form[objName][i].value='0';
		    }	
	   }else{
	   		//alert(form[objName].value);
		    //form[objName].value='0';
	   }	
    }
    
//    if (type=='select-one'){  
//        //set the first option as selected
//        var allelements = oSelectedSpan.getElementsByTagName("*");
//        
//        alert('ReinitializeMeasureValueSelections: select-one');
//        alert('objName: ' + objName);
//        
//        for (g=0; g<allelements.length; g++) {	
//           alert(allelements[g].getAttribute("name"));		
//	             
//       }       
//    }
}

function HideAttributeValuesNotSelectedByUom(objDrpdn, spanPrefixName){
   var i, measureID;
   var sMeasureDrpdnValue, selectedMeasureID, selectedMeasureSeqID;
   var arr;
   
   alert('function HideAttributeValuesNotSelectedByUom()');
   
   sMeasureDrpdnValue = objDrpdn.options[objDrpdn.selectedIndex].value;
   arr = sMeasureDrpdnValue.split("|");
   selectedMeasureID = arr[0];
   selectedMeasureSeqID = arr[1];
 
   alert(selectedMeasureID);
   alert(selectedMeasureSeqID);
   alert(spanPrefixName + selectedMeasureID);
 
   //selectedMeasureID = objDrpdn.options[objDrpdn.selectedIndex].value;
   for (i=0; i<objDrpdn.options.length; i++){
        arr = objDrpdn.options[i].value.split("|");
        measureID = arr[0];
        if (measureID == selectedMeasureID){
            document.getElementById(spanPrefixName + measureID).style.display = 'block';
        }else{       
            document.getElementById(spanPrefixName + measureID).style.display = 'none';
        }
   }
}

function ClearAllSelections(form,objName,type){
    var i;

//   alert(form[chkName]);
//   alert(form[chkName].length);
//   alert(form[chkName][0]);
    //type = 'radio';
    
    if (type=='chk'){
       if(form[objName].length > 1){
		    for (i=0; i < form[objName].length; i++){
		    	form[objName][i].checked=false;
		    }	
	   }else{
		    form[objName].checked=false;
	   }	
    }
 
    if (type=='radio'){
       if(form[objName].length > 1){
		    for (i=0; i < form[objName].length; i++){
		    	form[objName][i].value='0';
		    }	
	   }else{
		    form[objName].value='0';
	   }	
    }   
 
}
function CheckIsInteger(param1)
{	
	var iVar = 0;
	if(param1.length != 0 )
	{
		return isNaN(param1)==true ? 0 : parseInt(param1);
	}
	return iVar;
}
function CheckIsNumeric(param1)
{	
	var iVar = 0;
	if(param1.length != 0 )
	{
		return isNaN(param1)==true ? 0 : parseFloat(param1);
	}
	return iVar;
}

//function ValidateConfirmation(form){
//    var okay;
//	var minorder, qty;
//	var i;
//	var iDisplayIndexCount=eval(form.hdnDisplayIndexCount).value;
//	
//	//alert(iDisplayIndexCount);
//	if(iDisplayIndexCount > 0){
//	    for(i=1; i<=iDisplayIndexCount; i++){
//	        minorder = eval("form.hdnMinOrderQty_" + i).value;
//	        qty = eval("form.txtQuantity_" + i).value;
//	        //alert(minorder);
//	        //alert(qty);
//	        if(qty!=''){
//	           if(IsNumeric(qty)){
//		          //check if order qty is at least min order qty
//		          if(parseInt(qty) < parseInt(minorder)){
//			          okay = false;
//			          alert('Order quantity should be at least ' + minorder + ".");
//			          break;
//		          }
//		       }else{
//		          okay = false;
//		          alert('Please enter a numeric value.');
//		          break;
//		       }
//	        }else{
//		        okay = false;
//		        alert('Please enter a numeric value.');
//		        break;
//	        }
//	    }
//	}		
//	
//	if(okay==false){
//		eval("form.txtQuantity_" + i).value = minorder;
//		return false;
//	}else{
//		return true;
//	}
//}

