
	function searchPost() 
		{ 
		var f=document.frmcustomSearchResults; 		
		var s = f.fldKeyword.value;
		f.action = "http://www.costore.com/spraysystems/SearchResultAsList.asp?keyword=" + s;		
		f.submit(); 		
		}
	
	var gblnIsIE = navigator.userAgent.indexOf('MSIE') > -1 ? true : false;
	var gintMonth=11, gintDay=29, gintYear=2010;
	
	function w(s) { document.write(s);}
	function j(a) { jumpToURL(a);}	
	function jc(a1,a2) { jumpToCategory(a1,a2);}	
	function isSel(v1, v2) { return (v1 == v2 ? ' selected ' : '');	}
	function isChkd(v1, v2) { return (v1 == v2 ? ' checked ' : '');	}
	//function isVis(a, chk) { return (chk.length == 0 ? true : (chk.indexOf(a) > 0)); }
		
	function isVis(a, chk) { 
		var b=true;
		
		if (a==null) a='';
		//document.write (+ '<br>');
		if (a.length > 0 || chk.length > 0)	b=(chk.indexOf(a) > -1);
		//alert('a=' + a + '; chk=' + chk + '; b=' + b + '; -' + chk.indexOf(a));
		if (a.length > 0 && chk.length == 0) b=true; //#1 SMD 02212007
		return (b);
	}
	
	function isBlank(a) { return (trimStr(a).length==0)};
	function trimStr(a) {while (a.substring(0,1) == ' ') a = a.substring(1); while (a.substring(a.length-1,a.length) == ' ') a = a.substring(0,a.length-1); return(a); }
	function jumpToURL(a) { a=verifyURL(a); var f=document.frmRedirect; f.hdnCookieId.value=gstrSessionId; f.action=a; f.submit(); }
	

	
	function jumpToCategory(a1,a2) { j('prccategories.asp?CategoryIdLevel1=' + a1 + '&CategoryIdLevel2=' + a2);	}
	function isThere(a) { return !((a==null) || ('' + a)=='undefined'); }
	function wSectTitle(a) { w('<table width=565 cellspacing=0 cellpadding=0 border=0><tr><td class=col height=20 width=565 align=left>' + a + '</td></tr></table>'); }

	function roundNum(a,b) { return Math.round(a*Math.pow(10,b))/Math.pow(10,b);}

	function val(a) {
		var i=0, u=-1, s='', strNums = '0123456789.-';
		a='' + a; u=a.length-1;
		for (i=0; i <= u; i++) { if (strNums.indexOf(a.charAt(i)) >= 0) s+=a.charAt(i); }
		return (s.length==0) ? '0' : parseFloat(s);
	}

	function clipStr(a, c) {
		var u=c.length, s=trimStr(a), l=s.length;
		if (l.length < u) return (a);
		if (s.substr(l-u, u)==c) s=s.substring(0,l-u);
		return (s);
	}

	function getBDV(ie, ns) {	return(gblnIsIE ? ie:ns);	}
//	function getHref(astrHref) { return (astrHref.indexOf('javascript') == -1 ? 'javascript: j(\'' + astrHref + '\');' : astrHref);	}
    function t(w,h) { return('<img height=' + h + ' width=' + w + ' src="/common/images/1ptrans.gif">'); }
	function userTimeout() { alert('Due to inactivity on the site, your account has been logged out.\nTo continue shopping or browsing, please log back in.'); j('prcusersignout.asp');	}
    function ln(a,w,h) { var c = a.length == 0 ? '' : a.indexOf('bgcolor=') >= 0 ? a : 'class=' + a;  return('<table width=' + w + ' cellspacing=0 cellpadding=0 border=0><tbody><tr><td ' + c + ' height=1><img height=' + h + ' width=' + w + ' src="/common/images/1ptrans.gif"><\/td><\/tr><\/tbody><\/table>'); }

	function initPage(aintTimeout) {
		if (aintTimeout > 0 && document.URL.toUpperCase().indexOf('/USERSIGNIN.ASP') > 0) setTimeout('userTimeout();', (aintTimeout * 60 * 1000));
		if (gblnCallOnLoadJScript) pageIsLoaded();
	}

	function getIdxOfCat(a, id) {var i, u=a.length;	for (i=0; i < u; i++) if (a[i][0]==id) {return(i);}	return(-1);	}
	function getCatName(a, id) { var i=getIdxOfCat(a, id); if (i != -1) return (a[i][1]); else return ('');}

	function wBtn(astrIdx, astrCap, astrTarget, astrHref, astrTip) {
		var strCap = astrCap;
		var s='';
		var b = new pBtn();

		if (astrIdx.length > 0) strCap=gb[astrIdx]; else strCap=astrCap;
		if (astrTip.length == 0) astrTip=strCap

		if (b.borderSize > 0) {
			s += '<table width=' + b.width + ' height=' + b.height + ' cellpadding=0 cellspacing=0 border=0>';
			s += '<tr><td height=' + b.height + ' bgcolor=' + b.borderColor + ' align=center valign=middle>';
		}

		s += '<table width=' + b.width + ' height=' + b.height + ' cellpadding=0 cellspacing=' + b.borderSize + ' border=0>';
		s += '<tr><td bgcolor=' + b.bgColor + ' height=' + b.height + ' align=center valign=middle>';
		s += lnk(astrHref,strCap,'btn',astrTip,astrTarget) + '<\/td><\/tr><\/table>';
		if (b.borderSize > 0) s += '<\/td><\/tr><\/table>';

		w(s);
    }
    
    function verifyURL(a) {
		var u = document.location.href.toLowerCase(), intop=true, gotop=true, s='', f=isThere(document.frmCategories);

		if (u.indexOf('usercustom') > -1 || u.indexOf('layout2') > -1) intop=false;
		if (a.indexOf('usercustom') > -1 || a.indexOf('layout2') > -1) gotop=false;

		//if (intop && gotop) // do nothing
		//if (intop && !gotop) // do nothing
		if (!intop && gotop) s = '\/' + gstrStoreURL + '\/' + a;
		if (!intop && !gotop) s = a.replace('usercustom\/', '');
		if (s.length==0) s=a;
		
		if (f)
			{
				if (!intop && !gotop) document.frmCategories.action = '../prccategories.asp'
			}
		return(s);
	}

	//verifyURL('usercustom\/xx.asp');
	
	function lnk(astrURL, astrCap, astrClass, astrTip, astrTarget) {
		var t = '' + astrTarget.length == 0 ? '' : ' target=' + astrTarget; 
		var s = '<a ' + t + ' class=' + astrClass + ' href="';

		if (astrTip.length == 0) astrTip=astrCap;
		var tip = astrTip.replace("'", "\\'");
		if (astrURL.indexOf('javascript') == -1) s += 'javascript: j(\'' + astrURL + '\');"'; else s += astrURL + '"';
		if (astrTip.length > 0) { astrTip = astrTip.replace("'", "\'");	s += ' title="' + astrTip + '" onMouseOut="self.status = \'\'; return(true);" onMouseOver="self.status = \'' + tip + '\'; return(true);"'; }
		return (s + '>' + astrCap + '</a>');
	}

	function formatNumber(avntInNum, aintNumDecimals, ablnLeadingZero, ablnShowParens, ablnShowCommas) {
		if (isNaN(parseInt(avntInNum))) return "NaN";

		var tmp = avntInNum;
		var intSign = avntInNum < 0 ? -1 : 1;		

		tmp *= Math.pow(10,aintNumDecimals);
		tmp = Math.round(Math.abs(tmp))
		tmp /= Math.pow(10,aintNumDecimals);
		tmp *= intSign;

		if (aintNumDecimals==2) 
			tmp = (tmp == Math.floor(tmp)) ? tmp + '.00' : (  (tmp*10 == Math.floor(tmp*10)) ? tmp + '0' : tmp);

		var tmp2 = new String(tmp);

		if (!ablnLeadingZero && avntInNum < 1 && avntInNum > -1 && avntInNum != 0)
			if (avntInNum > 0) tmp2 = tmp2.substring(1,tmp2.length);
			else tmp2 = "-" + tmp2.substring(2,tmp2.length);

		if (ablnShowCommas && (avntInNum >= 1000 || avntInNum <= -1000)) {
			var iStart = tmp2.indexOf(".");
			if (iStart < 0) iStart = tmp2.length;

			iStart -= 3;
			while (iStart >= 1) {
				tmp2 = tmp2.substring(0,iStart) + "," + tmp2.substring(iStart,tmp2.length);
				iStart -= 3;
			}
		}

		if (ablnShowParens && avntInNum < 0) tmp2 = "(" + tmp2.substring(1,tmp2.length) + ")";

		return tmp2;		
	}


	function wPgTitle(astrTitle, ablnShowCrumbs, aintLeadingCrumbTypeId, astrEndingCrumb, aintWidth) {
		var s='',std=565,tmp=0,thiswidth=565;

		if (astrTitle.toUpperCase() == '<@NONE>!') return (true);
		
		// adjust width of title if necessary
		tmp=gblnIsIE ? document.body.offsetWidth: tmp=window.innerWidth;
		if (std > tmp) thiswidth = tmp-35;

		s += '<table width=' + aintWidth + ' cellpadding=0 cellspacing=0 border=0>';
		s += '<tr><td>' + t(5,12) + '<\/td><\/tr>';
		s += '<tr><td width=' + aintWidth + ' align=left valign=bottom class=pgtitle>' + astrTitle + '<\/td><\/tr>';
		s += '<tr><td class=pgbar>' + t(aintWidth-15,1) + '<\/td><\/tr>';

		if (ablnShowCrumbs) {
			s += '<tr><td>' + t(5,2) + '<\/td><\/tr>';
			s += '<tr><td width=' + aintWidth + ' class=bc>' + getBreadCrumbs(aintLeadingCrumbTypeId,astrEndingCrumb) + '<\/td><\/tr>';
		}

		s += '<tr><td>' + t(5,10) + '<\/td><\/tr>';
		s += '<\/table>'

		w(s);
	}

	function wCatDropDown(a, id, num, allopts, favs) {
		var blnCatSet=false, strCap, i, s='', f=isThere(document.frmCategories) ? document.frmCategories.cboCategoryIdLevel1 : null;

		if (allopts.length) {
			s += '<option value="0" ' + isSel(0, id) + '>' + allopts + '</option>';
			if (id < 0) id = 0;
			blnCatSet=true;
		}

		if (favs.length) s += '<option value="-99" ' + isSel(-99, id) + '>' + favs + '</option>';
		if (num > 0 && id <= 0 && !blnCatSet) { 
			if (isThere(f) && f.options.length > 0 && f.options[0].value == -1)
				id = -1;
			else
				id = a[0][0];  
		}

		for (i = 0; i <= num; i++) {
			if (isVis(gstrUserProdCatFilter, a[i][2])) {
				strCap = a[i][1];
				if (a[i][3] == 1) strCap = '...' + strCap;
				s += '<option value="' + a[i][0] + '" ' + isSel(a[i][0], id) + '>' + strCap  + '<\/option>';
			}
		}

		w(s);
	}

	function wUserMsg(astrUserFName, astrUserLName, astrUserCompany, astrStoreGreeting, ablnUsersCanAddThemselves, ablnIsBrowser) {
		var s='', tmp = astrUserFName.length + astrUserLName.length == 0 ? astrUserCompany : astrUserFName + ' ' + astrUserLName;
		//if (!ablnIsBrowser)	s = astrStoreGreeting + ', ' + lnk('uactoc.asp', strUserName, 'stattxt', 'Click to goto your account center', ''); else s = 'My Account ...';
		if (!ablnIsBrowser)	tmp = astrStoreGreeting + ', ' + tmp; else tmp = 'My Account ...';
		s = lnk('uactoc.asp', tmp, 'stattxt', 'My Account', '');
		w('<b>' + s + '</b>');
	}
	
	function jpfind(peid, pid) {
		var s='';
		s = 'prccategories.asp?act=FIND&peid=' + peid + '&pid=' + pid + '&from=';
		if (document.URL.toUpperCase().indexOf('/PRODUCTSEARCHRESULTS.ASP') > 0) s += 'S';
		if (document.URL.toUpperCase().indexOf('/MYFAVS.ASP') > 0) s += '&F';
		j(s);
	}

	
	function jp(peid, pid, spid, a1, a2) {
		var s='';
		switch (spid) {
			case 1: s='productapparel.asp'; break;
			case 2: s='productapparel.asp'; break;
			case 3: s='productorderform.asp';break;
			case 4: s='productorderforminv.asp';break;
			case 5: s='producttemplate.asp?spid=5';break;	
			case 6: s='producttemplate.asp?spid=6';break;
			case 7: s='producttemplate.asp?spid=7';break;
			case 8: s='productdetails.asp';break;
			case 9: s='productsellingpage.asp';break;
			case 10: s='productwithoptions.asp';break;
			case 11: s='productwithrelatedproducts.aspx?session=' + gstrSessionId ;break;
			case 22: s='productwithoptionspricebreaks.asp';break;
			case 21: s='ProductRelatedWizard.asp';break;
			default: s='productenlarged.asp'; break;
		}

		if (spid == 5 || spid == 6 || spid == 7  || spid == 11){
			s += '&peid=' + peid + '&pid=' + pid;
		}else{
		s += '?peid=' + peid + '&pid=' + pid;
		}
		
		if (document.URL.toUpperCase().indexOf('/PRODUCTSEARCHRESULTS.ASP') > 0)
			s += '&search=1';

		if (document.URL.toUpperCase().indexOf('/MYFAVS.ASP') > 0)
			s += '&myfavs=1';
		
		if (a1 > 0) s = 'prccategories.asp?c1=' + a1 + '&c2=' + a2 + '&URL=' + escape(s);		
		j(s);
	}

	function jp_v2(peid, pid, spid,cid,mkid,mdlid) 
	{	
		var s='';
		switch (spid) {
			case 1: s='productapparel.asp'; break;
			case 2: s='productapparel.asp'; break;
			case 3: s='productorderform.asp';break;
			case 4: s='productorderforminv.asp';break;
			case 5: s='producttemplate.asp?spid=5';break;	
			case 6: s='producttemplate.asp?spid=6';break;
			case 8: s='productdetails.asp';break;
			case 10: s='productwithoptions.asp';break;
			default: s='productenlarged.asp'; break;
		}
		s += '?peid=' + peid + '&pid=' + pid;

		if (spid==8)
		{
		   s += '&catid='+ cid + '&makeid='+ mkid +'&modid='+ mdlid;
		}		
		
		if (document.URL.toUpperCase().indexOf('/PRODUCTSEARCHRESULTS.ASP') > 0)
			s += '&search=1';

		if (document.URL.toUpperCase().indexOf('/MYFAVS.ASP') > 0)
			s += '&myfavs=1';
		
		j(s);	
	}

	function nrc(e) {
		var b=true;
		if (gblnIsIE) if (event.button == 2) b=false;
		if (!gblnIsIE) if (e.which == 3) b=false;
		if (!b) { alert('Sorry, this feature is not allowed.'); return false; }
	}

	if (document.URL.toUpperCase().indexOf('/ORDER.ASP') == 0)
		{
			if (!gblnIsIE) document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown=nrc;
		}
	function closeDialog() {
		if (pop.isOpen()) pop.dialogWin.close();
		pop=null;
	}
	
	function showPopup(h, w, pg) {
		pop.pageName=pg;
		pop.height=h;
		pop.width=w;
		pop.openPopup();
	}
	
	function structPopup () {
		var objDialog;
		
		this.dialogWin=objDialog;		
		this.pageName='';
		this.height=0;
		this.width=0;
		this.isOpen=isPopupOpen;
		this.openPopup=openWin;
	}
		
	function openWin(a, h, w, pg) {
		var t=(parseInt(screen.height)-parseInt(this.height))/2, l=(parseInt(screen.width)-parseInt(this.width))/2, ftrs='';
		var r=escape(escape(location.href));
		var p=this.pageName;
		var c='%7BFD700799%2DB9D6%2D460D%2D95DA%2D9085324A28CF%7D';
		
		if (p.indexOf('?') == -1) p += '?sessId=' + c; else p += '&sessId=' + c;
		if (p.indexOf('?') == -1) p += '?refURL=' + r; else p += '&refURL=' + r;
		//document.write (p);
		ftrs='height=' + this.height + ',width=' + this.width + ',status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,directories=no,resizable=no,left=' + l + ',top=' + t;
		if (this.isOpen()) this.dialogWin.close();
		this.dialogWin=window.open(p, '', ftrs); 
		//this.pageName
	}
	
	function isPopupOpen(a) {
		var b=false;

		if (('' + this.dialogWin) != 'undefined')  b = !this.dialogWin.closed;
		return (b);
	}
	
	
	//Added: 03/07/2006	SMD
	function punchOut(astrJumpToPage) {
		var strUAID = '';
		var strEmail = '';

		var strURL = astrJumpToPage;

		gstrUserFName = gstrUserFName.replace('\'', '');
		gstrUserLName = gstrUserLName.replace('\'', '');

		strURL = strURL.replace('@UserEmail', strEmail);
		strURL = strURL.replace('@UserAltId', strUAID);
		strURL = strURL.replace('@FName', gstrUserFName);
		strURL = strURL.replace('@LName', gstrUserLName);
			
		document.location.href = strURL;
	}

