<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//CAT NAV FUNCTIONS
function OnSearchBoxKeyPress(theform, cid, plpver, categid, prodid, e)
{
	var key=e.keyCode||e.which

	if(key==13){
		ValidateKeywordSearch(theform, cid, plpver, categid, prodid)
	}
	return true;
}

// 
// #																	     #
// #  plp.js																 #
// #																	     #
// 

function ValidateKeywordSearch(theform, cid, plpver, categid, prodid)
{
	var j, key;
	var searchstring;
	var isapiurl;
	var sUrl;
	
	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 cboSearchType = theform.ddlSearchType;
	var sSchType = cboSearchType.item (cboSearchType.selectedIndex).value;
  
  	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;
    sUrl = "http://ampcosafetytools.thomasnet.com" + sUrl
	
    document.location.href = sUrl;
}

function SubmitViewItemsPage(form)
{
 form.hdnPageSize.value = form.drpdnItemsPerPage.value;
 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; 
	 
    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;
		
		sBackToName = form.hdnBackToName.value;
		if (window.encodeURIComponent)
		sBackToName = encodeURIComponent(sBackToName);
		else if (window.escape)
			sBackToName = escape(sBackToName);
			
		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 + "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;	
			*/
			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;	
		}	
		
		//alert(form.action);
		//form.submit();
		window.location = strPath;
		return true;
	}	
}

function KeywordSearchDropdownPage(form){
	//alert(form.action);
	var isapiurl;
	
	isapiurl = form.hdnIsapiKeywordResultsUrl.value;
	if (isapiurl.indexOf('/internal/',0) > -1)
		isapiurl='';
			  
	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 + "&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;
		*/
		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;
	}

	//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(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;
					   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;
				}
				//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
		    {
				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 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'){
		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;
				}
			}
			
			//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='';
	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;
			}
		}
	}else{
		//alert('here2');
		if (form.chkProdGroup.checked){
			prodids = prodids + 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==''){
				window.location = "RequestInformation.aspx?cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
					              "&prodid=" + prodid + "&prodids=" + prodids + "&origin=" + origin +  "&itemids=" + 
			                      "&prevpage=" + prevpage;
			}else{
				/*window.location = form.hdnIsapiRequestInfoUrl.value + "cid=" + cid + "&plpver=" + plpver + "&categid=" + categid + 
					              "&prodid=" + prodid + "&prodids=" + prodids + "&origin=" + origin +  "&itemids=" + 
			                      "&prevpage=" + prevpage;
				*/
				window.location = form.hdnIsapiRequestInfoUrl.value + "&plpver=" + plpver + "&categid=" + categid + 
					              "&prodid=" + prodid + "&prodids=" + prodids + "&origin=" + origin +  "&itemids=" + 
			                      "&prevpage=" + prevpage;
			}

		}		
		return true;
	}
	else{
		alert('Please select up to five products.');
		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;
    
    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 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;
	}
	
	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";
	}	

	form.submit();
	return true;
}

function ValidateOrderQty(obj, hdnMinOrderQty, prodid, itemid, carttype, seqid){
	var okay;
	var minorder;
	
	//get the minimum order qty
	minorder = hdnMinOrderQty.value;
	
	if(IsNumeric(obj.value)){
		//check if order qty is at least min order qty
		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.');
	}
	
	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);

	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 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;   
					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'){					
						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 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;  
				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 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";
						}
						
						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 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;    
				    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'){
					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 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";
						}
						
						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 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;    
				    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;
		
		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{
				if (action=='changeoptions'){
					isapiurl = form.hdnIsapiChangeOptionsUrl.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 + "&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 + "&uid=" + form.hdnUID.value + "&cart_itemid=" + form.hdnCartItemID.value + 
							"&plpurl=" + form.hdnPlpUrl.value + "&action=" + action;						
					}
				}else{
					isapiurl = form.hdnIsapiAdditionaOptionsUrl.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 + "&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 + "&action=" + action;											
					}

				}
				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;
    //  BEGIN 2.5 *********
    var isNumeric,valMin, valMax;
    //  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];
				//  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')
                {
					if (!CheckBuyerDefinedValuesByDisplayType(form, prodid, itemid, carttype, seqid, attrid, displaytype, isNumeric, valMin, valMax)){
						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((displaytype=='chk') || (displaytype=='radio')){
				displaytype='edtOption';
			}
		    //  BEGIN 2.5 *********
               isNumeric= arr[6];
               valMin= arr[7];
               valMax= arr[8];
               if (arr[9] != 'memo')
               {
				if (!CheckBuyerDefinedValuesByDisplayType(form, prodid, itemid, carttype, seqid, attrid, displaytype, isNumeric, valMin, valMax)){
			    		okay=false;
				}
			   }
		   //  END 2.5 *********	   
		}
	}	
	
	if (okay==false){
		//alert('Please complete buyer-defined values.');
		return false;
	}else{
		return true;
	}				
}

//Ron:
//We may need to replace 2.0 by this version. 
function CheckBuyerDefinedValuesByDisplayType(form, prodid, itemid, carttype, seqid, attrid, displaytype, isNumeric, valMin, valMax){
//---------------------------------------------
// 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){
	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].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 ValidateAdvSearchForm(theform, cid, plpver, categid, prodid, srchaction, displayresults){
	var isSelected, isDataTypeOkay, isRangeOkay, attrid, displaytype, datatype;
	var sBackToName;
	var isapiurl;
//debugger
	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;
			
			isSelected = IsItemSelected(theform, displaytype, attrid);					
			if (isSelected==true){
				break;
			}
		}			
	}else{
		attrid = theform.hdnAttrIDs.value;
		displaytype = theform.hdnAttrTypes.value;
		datatype = theform.hdnDataTypes.value;
			
		isSelected = IsItemSelected(theform, displaytype, attrid);
	}

	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;
				//validate entries based on data type
                //alert (datatype + ' ' + displaytype);
				isDataTypeOkay = ValidateDataType(theform, datatype, displaytype, attrid);
				if (isDataTypeOkay==false){
					return false;
					break;	
				}
				
				//check for value within available range
				
				isRangeOkay = ValidateRange(theform, datatype, displaytype, attrid);
				if (isRangeOkay==false){
					return false;
					break;	
				}
			}		
		}else{
			attrid = theform.hdnAttrIDs.value;
			displaytype = theform.hdnAttrTypes.value;
			datatype = theform.hdnDataTypes.value;
			
			//validate entries based on data type
			isDataTypeOkay = ValidateDataType(theform, datatype, displaytype, attrid);
			if (isDataTypeOkay==false){
				return false;
			}									
			
			//check for value within available range
			isRangeOkay = ValidateRange(theform, datatype, displaytype, attrid);
			if (isRangeOkay==false){
				return false;
			}		
		}
	}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){
	var j;
	
	if (displaytype=='chk'){
	    if(theform["chk_" + "attrid_" + attrid].length==undefined)
	    {
		    if (theform["chk_" + "attrid_" + attrid].checked==true){
				return true;
			}
		}
		else
		{
			for (j=0; j < theform["chk_" + "attrid_" + attrid].length; j++){
				if (theform["chk_" + "attrid_" + attrid][j].checked==true){
					return true;
				}
			}
		}	
	}else if (displaytype=='radio'){
	    if (theform["radio_" + "attrid_" + attrid].length==undefined)
	    {
			if (theform["radio_" + "attrid_" + attrid].checked==true){
				if (theform["radio_" + "attrid_" + attrid].value != '0'){
					return true
				}
			}
		}
		else
		{
			for (j=0; j < theform["radio_" + "attrid_" + attrid].length; j++){
				if (theform["radio_" + "attrid_" + attrid][j].checked==true){
					if (theform["radio_" + "attrid_" + attrid][j].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){
				if (theform["bool_radio_" + "attrid_" + attrid].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){
					if (theform["bool_radio_" + "attrid_" + attrid][j].value != '0'){
						return true;
					}
				}
			}
		}			
	}else if (displaytype=='drpdn'){
		if (theform["drpdn_" + "attrid_" + attrid].value!='0'){
			return true;
		}
	}else if (displaytype=='listbox'){
	 	for (j=0; j < theform["listbox_" + "attrid_" + attrid].options.length; j++){
			if (theform["listbox_" + "attrid_" + attrid].options[j].selected==true){
				if (theform["listbox_" + "attrid_" + attrid].options[j].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].value)!=''){
			return true;			
		}
	}else if (displaytype=='drpdn_range'){
		//alert("editbox_" + "attrid_" + attrid + ' is : ' + theform["editbox_" + "attrid_" + attrid].value);
		if (trim(theform["editbox_" + "attrid_" + attrid].value)!=''){
			return true;
		}
	}else if (displaytype=='memobox'){
		if (trim(theform["memobox_" + "attrid_" + attrid].value)!=''){
			return true;
		}
	}else if (displaytype=='range'){
		if ((trim(theform["range_" + "attrid_" + attrid + "_from"].value)!='') || (trim(theform["range_" + "attrid_" + attrid + "_to"].value)!='')){
			return true;
		}
	}
	
	return false;
}

function ValidateDataType(theform, datatype, displaytype, attrid){

	if (datatype=='10'){
		//check if integer
		if (displaytype=='editbox'){
			//alert('here1');
			if (!IsInteger(trim(theform["editbox_" + "attrid_" + attrid].value))){
				alert('Search input must be an integer.');
				theform["editbox_" + "attrid_" + attrid].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].value))){
				alert('Search input must be an integer.');
				theform["editbox_" + "attrid_" + attrid].focus();
				return false; 
			}else{
				theform["editbox_" + "attrid_" + attrid].value = theform["editbox_" + "attrid_" + attrid].value.replace(/(\d),(\d)/g, '$1$2');
			}
		}else if (displaytype=='memobox'){
			//alert('here3');
			if (!IsInteger(trim(theform["memobox_" + "attrid_" + attrid].value))){
				alert('Search input must be an integer.');
				theform["memobox_" + "attrid_" + attrid].focus();
				return false; 
			}else{
				theform["memobox_" + "attrid_" + attrid].value = theform["memobox_" + "attrid_" + attrid].value.replace(/(\d),(\d)/g, '$1$2');
			}
		}else if (displaytype=='range'){
			//alert('here4');
			if (!IsInteger(trim(theform["range_" + "attrid_" + attrid + "_from"].value))){
				//alert('try1');
				alert('Search input must be an integer.');
				theform["range_" + "attrid_" + attrid + "_from"].focus();
				return false; 
			}else if (!IsInteger(trim(theform["range_" + "attrid_" + attrid + "_to"].value))){
				//alert('try2');
				alert('Search input must be an integer.');
				theform["range_" + "attrid_" + attrid + "_to"].focus();
				return false; 
			}else{
				theform["range_" + "attrid_" + attrid + "_from"].value = theform["range_" + "attrid_" + attrid + "_from"].value.replace(/(\d),(\d)/g, '$1$2');
				theform["range_" + "attrid_" + attrid + "_to"].value = theform["range_" + "attrid_" + attrid + "_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].value)!=''){
				if (isNaN(RemoveCommasIfIsFloatNumeric(trim(theform["editbox_" + "attrid_" + attrid].value)))){
					alert('Search input must be numeric.');
					theform["editbox_" + "attrid_" + attrid].focus();
					return false; 
				}						
			}
		}else if (displaytype=='drpdn_range'){
			//alert('here6');
			//alert('value is : ' + trim(theform["editbox_" + "attrid_" + attrid].value));
			if (trim(theform["editbox_" + "attrid_" + attrid].value)!=''){
				if (isNaN(RemoveCommasIfIsFloatNumeric(trim(theform["editbox_" + "attrid_" + attrid].value)))){
					alert('Search input must be numeric.');
					theform["editbox_" + "attrid_" + attrid].focus();
					return false; 
				}
			}
		}else if (displaytype=='memobox'){
			//alert('here7');
			if (trim(theform["memobox_" + "attrid_" + attrid].value)!=''){
				if (isNaN(RemoveCommasIfIsFloatNumeric(trim(theform["memobox_" + "attrid_" + attrid].value)))){
					alert('Search input must be numeric.');
					theform["memobox_" + "attrid_" + attrid].focus();
					return false; 
				}
			}
		}else if (displaytype=='range'){
			//alert('here8');
			if ((trim(theform["range_" + "attrid_" + attrid + "_from"].value)!='') || (trim(theform["range_" + "attrid_" + attrid + "_to"].value)!='')){
				if (isNaN(RemoveCommasIfIsFloatNumeric(trim(theform["range_" + "attrid_" + attrid + "_from"].value)))){
					alert('Search input must be numeric.');
					theform["range_" + "attrid_" + attrid + "_from"].focus();
					return false; 
				}else if (isNaN(RemoveCommasIfIsFloatNumeric(trim(theform["range_" + "attrid_" + attrid + "_to"].value)))){
					alert('Search input must be numeric.');
					theform["range_" + "attrid_" + attrid + "_to"].focus();
					return false; 
				}					
			}
		}
	}
	return true;
}

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 ValidateRange(theform, datatype, displaytype, attrid){

    if (displaytype=='drpdn_range')
    {
		var nMin = theform["hdn_range_" + "attrid_" + attrid + "_min"].value;
		var nMax = theform["hdn_range_" + "attrid_" + attrid + "_max"].value;
		var nInputValue = theform["editbox_" + "attrid_" + attrid].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 (displaytype=='range')
    {
		var nMin = theform["hdn_range_" + "attrid_" + attrid + "_min"].value;
		var nMax = theform["hdn_range_" + "attrid_" + attrid + "_max"].value;
		//var nInputValue = theform["editbox_" + "attrid_" + attrid].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;
    }
    //	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].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].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].focus();
					return false; 
			}				
		}	
	}else if (displaytype=='range'){
		//alert('here10');
		if ((trim(theform["range_" + "attrid_" + attrid + "_from"].value)!='') || (trim(theform["range_" + "attrid_" + attrid + "_to"].value)!='')){
			if ((theform["hdn_range_" + "attrid_" + attrid + "_min"].value=='infinitymin') && (nMax=='infinitymax')){
				// do nothing
			}else if ((nMax=='infinitymax') && (nMin!='infinitymin')){
				if (parseFloat(theform["range_" + "attrid_" + attrid + "_from"].value) < parseFloat(nMin)){
					//alert('me1');
					//validate the min entry
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_from"].focus();
					return false; 
				}else if ((parseFloat(theform["range_" + "attrid_" + attrid + "_to"].value)) < (parseFloat(theform["range_" + "attrid_" + attrid + "_from"].value))){
					//check if to is greater than from
					alert('Minimum value must be less than maximum value.');
					theform["range_" + "attrid_" + attrid + "_from"].focus();
					return false; 
				}
			}else if ((nMin=='infinitymin') && (nMax!='infinitymax')){
				if (parseFloat(theform["range_" + "attrid_" + attrid + "_to"].value) > parseFloat(nMax)){
					//alert('me1');
					//validate the max entry
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_to"].focus();
					return false; 
				}else if ((parseFloat(theform["range_" + "attrid_" + attrid + "_to"].value)) < (parseFloat(theform["range_" + "attrid_" + attrid + "_from"].value))){
					//check if to is greater than from
					alert('Minimum value must be less than maximum value.');
					theform["range_" + "attrid_" + attrid + "_from"].focus();
					return false; 
				}						
			}else if ((parseFloat(theform["range_" + "attrid_" + attrid + "_from"].value) < parseFloat(nMin)) || 
				(parseFloat(theform["range_" + "attrid_" + attrid + "_from"].value) > parseFloat(nMax))){
					//alert('me1');
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_from"].focus();
					return false; 
			}else if ((parseFloat(theform["range_" + "attrid_" + attrid + "_to"].value) < parseFloat(nMin)) || 
				(parseFloat(theform["range_" + "attrid_" + attrid + "_to"].value) > parseFloat(nMax))){
					//alert('me2');
					alert('Search input must be within available range.');
					theform["range_" + "attrid_" + attrid + "_to"].focus();
					return false; 
			}else if ((parseFloat(theform["range_" + "attrid_" + attrid + "_to"].value)) < (parseFloat(theform["range_" + "attrid_" + attrid + "_from"].value))){
				//check if to is greater than from
				//alert('me3');
				alert('Minimum value must be less than maximum value.');
				theform["range_" + "attrid_" + attrid + "_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;
	
	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;
					  
			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{
			isapiurl = theform.hdnIsapiKeywordResultsUrl.value;
			
			if (isapiurl.indexOf('/internal/',0) > -1)
			isapiurl='';
			  
			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;				
			}else{
				strPath = isapiurl + '&plpver=' + plpver + '&categid=' + categid + '&prodid=' + prodid + '&filter=1' + 
			           '&keyword=' + keyword + '&key=product' + '&keycateg=' + keycateg + '&keyprod=' + prodid + '&SchType=' + searchType;			
			}
		}
		window.location = strPath;	
		return true;	
	}else{
		return false;	
	}
}

function FilterByProduct(theform, cid, plpver, categid, obj, keyword, keycateg, keyprod, backtoname){
	var prodid, strPath;
	var sBackToName;
	
	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;
				
				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{
				isapiurl = theform.hdnIsapiKeywordResultsUrl.value;
				
				if (isapiurl.indexOf('/internal/',0) > -1)
				isapiurl='';
				
				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;			
				}
			}
			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){
	if (theform.txtName.value==''){
		alert('Please enter your name.');
		theform.txtName.focus();
		return false;
	}else if (theform.txtEmail.value==''){
		alert('Please enter your email address.');
		theform.txtEmail.focus();
		return false;		
	}else{
		return(CheckEmailAddress(theform.txtEmail));
	}
	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 GetAttachFile()
{
   var strReturn;
   strReturn = window.showModalDialog('http://localhost/thomastechnology/FileAttachment','','scrollbars: yes; resizable: Yes; dialogWidth: 420px; dialogHeight: 380px; help: no;');
}

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;
    }
}

// Sets a Cookie with the given name and value
function PlpSetCookie (piKey, piValue)
{
var sSubDomain;
var nPos;
 
	sSubDomain = location.hostname;
	nPos = sSubDomain.indexOf('.');
	if (nPos > 0)
	{
	 sSubDomain = sSubDomain.substring (nPos);
	 document.cookie= piKey + '=' + escape(piValue) + ';domain=' + sSubDomain + '; path=/';
	}
	else
	{
	 document.cookie= piKey + '=' + escape(piValue) + '; path=/';
	}

}

// Read the value of the specified cookie
function PlpReadCookie (piKey)
{
    var dc = document.cookie;
    var prefix = name + "=";
    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));
}

// Remove the specified cookie
// It will damage IE cookie?
function PlpRemoveCookie (piKey)
{
 if (PlpReadCookie (piKey))
 {
  document.cookie = piKey + "=" + 
     ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
 }
}

function PlpDetectCookie ()
{
 if (! window.navigator.cookieEnabled)
 {
// alert('cookie disabled');
   
   window.location.href = "/CookieHelp/";
   return false;
 }
 else
 {
   return true;
 }
}

function GotoReuiredCookieUrl(piUrl)
{
 if (! PlpDetectCookie())
    return false;
     
 window.location.href = piUrl;
 
 return true;
}

function GotoReuiredCookiePlpUrl(piUrl, piPlpUrl)
{
 if (! PlpDetectCookie())
    return false;

 window.location.href = piUrl + "&plpurl=" + escape(piPlpUrl);
 
 return true;
}

function GotoReuiredCookieUrlForAS(piUrl)
{
 if (! window.navigator.cookieEnabled)
 {
   var sMsg="Please Note: Your internet settings currently block cookies.\nYou must Allow Cookies before executing Advanced Search in order for Advanced Search to function without problems.";
   alert(sMsg);
 }
     
 window.location.href = piUrl;
 
 return true;
}

function OnRequiredCookieClick(oForm)
{
 return PlpDetectCookie();
}

function GotoRequiredCookieWarning(piUrl)
{
	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
	{   
		window.location.href = piUrl;
	 
		return true;
	}
}

//-->