var is=new Object();
var display_menus=true;
is.version = new Number(navigator.appVersion.substr(0,1));
is.netscape = (navigator.appName == "Netscape");
is.netscape6 = (is.netscape && is.version >= 5);
is.ie = (navigator.appVersion.toLowerCase().indexOf("msie") >= 0);
is.opera = (navigator.appName == "Opera");
var get_menus = WM_readCookie("GracoMenus");
if (get_menus == false) {
   display_menus = true;
} else if (get_menus == "off") {
   display_menus = false;
}
function FlashWrite(url,width,height)
{
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ');
	document.write('  WIDTH=' + width + ' HEIGHT=' + height + '>');
	document.write(' <PARAM NAME=movie VALUE="' + url + '"> <PARAM NAME=quality VALUE=high> ');
	document.write(' <PARAM NAME="wmode" value="opaque"> '); 
	document.write(' <EMBED src="' + url + '" quality=high ');
	document.write(' swLiveConnect=FALSE WIDTH=' + width + ' HEIGHT=' + height);
	document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"');
	document.write(' wmode="opaque"> ');
	document.write(' </EMBED></OBJECT>');
}
function startSearch(type, key) {
  var f = document.forms[type];
  
}

function checkAction(type, key) {
  var f = document.forms[type];
  if (f.q.value == "") {
	alert("You must supply a search query!");
	return false;
  } else if (f.action != "") { 
	f.action = "http://www.graco.com/Internet/SiteSearch.nsf/Search?OpenAgent&Mode="+escape(key)+"&Query="+encodeURIComponent(f.q.value);
	return true; 
  } else { 
	return false; 
  }
}

var WM_acceptsCookies = false;
if(document.cookie == '') {
    document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
    if(document.cookie.indexOf('WM_acceptsCookies=yes') != -1) {
	WM_acceptsCookies = true; 
    }// If it succeeds, set variable
} else { // there was already a cookie
  WM_acceptsCookies = true;
}


function WM_setCookie (name, value, hours, path, domain, secure) {
    if (WM_acceptsCookies) { 
	var not_NN2 = (navigator && navigator.appName 
		       && (navigator.appName == 'Netscape') 
		       && navigator.appVersion 
		       && (parseInt(navigator.appVersion) == 2))?false:true;

	if(hours && not_NN2) { // NN2 cannot handle Dates, so skip this part
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
		var numHours = hours;
	    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); 
    }
} // WM_setCookie


function WM_readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
	return false; 
    } else { // there is a cookie
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
	var NN2Hack = firstChar + name.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) { // if you found the cookie
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else { // If there was no cookie of that name, return false.
	    return false;
	}
    }	
} // WM_readCookie

function WM_killCookie(name, path, domain) {
  var theValue = WM_readCookie(name); // We need the value to kill the cookie
  if(theValue) {
      document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
  }
} // WM_killCookie

function switchMenu(op) {
	WM_killCookie("GracoMenus", "/", "graco.com") ;
	WM_setCookie ("GracoMenus", op, null, "/", "graco.com") ;
            location.reload();
}

function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}
var bgBad = "#CCCCCC";
var bgGood = "white";

function trim(arg,func) {
	var trimvalue = "";
	arglen = arg.length;
	if (arglen < 1) return trimvalue;

	if (func == "left" || func== "both") {
		i = 0;
		pos = -1;
		while (i < arglen) {
			if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) {
				pos = i;
				break;
			}
			i++;
		}
	}

	if (func == "right" || func== "both") {
		var lastpos = -1;
		i = arglen;
		while (i >= 0) {
			if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) {
				lastpos = i;
				break;
			}
			i--;
		}
	}

	if (func == "left") {
			trimvalue = arg.substring(pos,arglen-1);
		}

	if (func == "right") {
		trimvalue = arg.substring(0,lastpos+1);
	}

	if (func == "both") {
		trimvalue = arg.substring(pos,lastpos + 1);
	}

	return trimvalue;

}
function checkFinancialForm() {
 var msg;
 msg = "";
 form = document.forms["fin_info"];
 if (trim(form.FirstName.value, "both") == "") { 
    msg = msg+"\nYour first name." ; 
    form.FirstName.focus() ; 
    setColor(form.FirstName, bgBad) ;
  } else {
    setColor(form.FirstName, bgGood); 
  }
  if (trim(form.LastName.value, "both") == "") { 
    msg = msg+"\nYour last name." ; 
    form.LastName.focus() ; 
    setColor(form.LastName, bgBad) ;
  } else {
    setColor(form.LastName, bgGood); 
  }
  if (trim(form.AddressOne.value, "both") == "") { 
    msg = msg+"\nYour address." ; 
    form.AddressOne.focus() ; 
    setColor(form.AddressOne, bgBad) ;
  } else {
    setColor(form.AddressOne, bgGood); 
  }
   if (trim(form.City.value, "both") == "") { 
    msg = msg+"\nYour city." ; 
    form.City.focus() ; 
    setColor(form.City, bgBad) ;
  } else {
    setColor(form.City, bgGood); 
  }
  s_find = form.State.options[form.State.selectedIndex].text ;
  p_find = form.Province.options[form.Province.selectedIndex].text ;
  c_find = form.Country.options[form.Country.selectedIndex].text ;
  if ((s_find == "Choose State" | s_find == "") & c_find == "UNITED STATES") {
    msg = msg + "\nYour state." ; 
    setColor(form.State, bgBad);
    form.State.focus();
  } else {  
    setColor(form.State, bgGood);
  }
   if (p_find == "Choose Province" & c_find == "CANADA") {
    msg = msg + "\nYour province." ; 
    setColor(form.Province, bgBad);
    form.Province.focus();
  } else {  
    setColor(form.Province, bgGood);
  } 
 if (trim(form.Zip.value, "both") == "") { 
    msg = msg+"\nYour zip/postal code." ; 
    form.Zip.focus() ; 
    setColor(form.Zip, bgBad) ;
  } else {
    setColor(form.Zip, bgGood); 
  } 
  
  if (msg != "") { 
     alert("Please provide: "+msg) ;
     return false ;
  } else { 
     return true ;
  }
}
function popWinUp(URL, atts)  {
	if (atts == "") {
		DEF_ATTRIB = "height=500,width=500,scrollbars,resizable";
	} else {
		DEF_ATTRIB = atts;
	}
	child = window.open(URL, "spawn", DEF_ATTRIB);
	child.opener = self;
	child.focus();
}
function buySearch(form) {
	s_find = form.State.options[form.State.selectedIndex].value;
	form.action = "/Internet/T_IEDDst.nsf/Search?OpenAgent&Query="+s_find;
 	 if (s_find == "Select Location" | s_find == "------------------------" | s_find == "") {
    		return false;
	  } else {  
    		return true;
 	 }
}
function buyCEDSearch(form) {
	//form=this.document.forms[0];
	s_find = form.State.options[form.State.selectedIndex].value;
	form.action = "/Internet/T_CEDDst.nsf/Search?OpenAgent&Query="+s_find;
 	 if (s_find == "Select Location" | s_find == "------------------------" | s_find == "") {
    		return false;
	  } else {  
    		return true;
 	 }
}
function buyLEDSearch(form) {
	s_find = form.State.options[form.State.selectedIndex].value;
	if (form.RepType[0].checked == true)
        		form.action = "/Internet/LED_SalesReps.nsf/Search?OpenAgent&Type="+form.RepType[0].value+"Query="+s_find
    	else
        		form.action = "/Internet/LED_SalesReps.nsf/Search?OpenAgent&Type="+form.RepType[1].value+"Query="+s_find;
 	 if (s_find == "Select Location" | s_find == "------------------------" | s_find == "") {
    		return false;
	  } else {  
    		return true;
 	 }
}
function checkLitForm(form) {
 var msg;
 msg = "";
 form = document.forms["fin_info"];
 //if (trim(form.Companyname.value, "both") == "") { 
    //msg = msg+"\nYour company name." ; 
    //form.Companyname.focus() ; 
    //setColor(form.Companyname, bgBad) ;
  //} else {
    //setColor(form.Companyname, bgGood); 
  //}
  if (trim(form.Name.value, "both") == "") { 
    msg = msg+"\nYour name." ; 
    form.Name.focus() ; 
    setColor(form.Name, bgBad) ;
  } else {
    setColor(form.Name, bgGood); 
  }
  if (trim(form.Address.value, "both") == "") { 
    msg = msg+"\nYour address." ; 
    form.Address.focus() ; 
    setColor(form.Address, bgBad) ;
  } else {
    setColor(form.Address, bgGood); 
  }
   if (trim(form.City.value, "both") == "") { 
    msg = msg+"\nYour city." ; 
    form.City.focus() ; 
    setColor(form.City, bgBad) ;
  } else {
    setColor(form.City, bgGood); 
  }
  s_find = form.State.options[form.State.selectedIndex].text ;
  p_find = form.Province.options[form.Province.selectedIndex].text ;
  c_find = form.Country.options[form.Country.selectedIndex].text ;
  if ((s_find == "Choose State" | s_find == "") & c_find == "UNITED STATES") {
    msg = msg + "\nYour state." ; 
    setColor(form.State, bgBad);
    form.State.focus();
  } else {  
    setColor(form.State, bgGood);
  }
   if (p_find == "Choose Province" & c_find == "CANADA") {
    msg = msg + "\nYour province." ; 
    setColor(form.Province, bgBad);
    form.Province.focus();
  } else {  
    setColor(form.Province, bgGood);
  } 
 if (trim(form.ZipCode.value, "both") == "") { 
    msg = msg+"\nYour zip/postal code." ; 
    form.ZipCode.focus() ; 
    setColor(form.ZipCode, bgBad) ;
  } else {
    setColor(form.ZipCode, bgGood); 
  } 
 if (trim(form.Email.value, "both") == "") { 
    msg = msg+"\nYour Email." ; 
    form.Email.focus() ; 
    setColor(form.Email, bgBad) ;
  } else {
    setColor(form.Email, bgGood); 
  } 
  
  if (msg != "") { 
     alert("Please provide: "+msg) ;
     return false ;
  } else { 
     return true ;
  }
}
function MM_swapImgRestore() { //v3.0
  if (display_menus) {
      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_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_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
 if (display_menus) {
  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];}
}
}

