/*
	Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


var agt=navigator.userAgent.toLowerCase();
var is_major=parseInt(navigator.appVersion);
var is_minor=parseFloat(navigator.appVersion);
var is_nav=((dojo.isMozilla>0)||(dojo.isSafari>0));
var is_nav6up=is_nav;
var is_firefox=(dojo.isFF>0);
var is_opera=(dojo.isOpera>0);
var is_ie=(dojo.isIE>0);
var is_ie3=(dojo.isIE==3);
var is_ie4=(dojo.isIE==4);
var is_ie5=(dojo.isIE==5);
var is_ie5_5=(dojo.isIE==5.5);
var is_ie5up=(dojo.isIE>=5);
var is_ie5_5up=(dojo.isIE>=5.5);
var is_ie6=(dojo.isIE==6);
var is_ie6up=(dojo.isIE>=6);
var is_ie7=(dojo.isIE==7);
var is_iframe_compliant=(is_ie5up||is_nav6up||is_opera||(dojo.isChrome>0));
var is_win=((agt.indexOf("win")!=-1)||(agt.indexOf("32bit")!=-1));
var is_mac=(agt.indexOf("mac")!=-1);
function activeXCheck(){
document.cookie="ActiveXEnabled=true; path=/";
if(is_ie){
try{
if(window.ActiveXObject){
return new ActiveXObject(getControlPrefix()+".XmlHttp");
}
}
catch(ex){
if(window.XMLHttpRequest==undefined){
document.cookie="ActiveXEnabled=false; path=/";
}
}
}
};
function getControlPrefix(){
if(getControlPrefix.prefix){
return getControlPrefix.prefix;
}
var _1=["MSXML2","Microsoft","MSXML","MSXML3"];
var o,o2;
for(var i=0;i<_1.length;i++){
try{
o=new ActiveXObject(_1[i]+".XmlHttp");
o2=new ActiveXObject(_1[i]+".XmlDom");
return getControlPrefix.prefix=_1[i];
}
catch(ex){
}
}
throw new Error("Could not find an installed XML parser");
};
activeXCheck();
function openPromoWindow(_5,_6){
var _7=(document.cookie.indexOf(_6)==-1);
var _8=document.cookie.indexOf(_6+"viewed=");
if(_7&&(_8==-1)){
var _9=window.open(_5,"SitePromotions","noresizable,noscrollbars,screenX=100, screenY=100,width=310,height=230");
_9.moveTo(100,100);
}
};
function detectIframeAdobe(_a,_b,_c){
var _d=createCatalogUrlString(_a,_b,_c);
window.location=_d;
};
function createCatalogUrlString(_e,_f,_10){
var _11,_12=false;
var _13=false;
if(is_iframe_compliant){
_12=detectAdobe();
}
var _14="?";
var _15="browserCompatable="+is_iframe_compliant+"&adobeCompatable="+_12;
if(detectAdobe(true)){
_13=true;
}
_15=_15+"&toolbar="+_13;
if(_e!=null&&_e!=""){
_15=_15+"&CatPage="+_e;
}
if(_f==null||_f==""){
_15=_15+"&Catalog=main";
_11="viewCatalogPDF.shtml"+_14+_15;
var _16=window.location.pathname;
var _17=_16.indexOf("/cgi-bin/");
if(_16.indexOf("wwg")==-1){
if(_17==-1){
_11="/Grainger/wwg/"+_11;
}else{
var _18=_16.indexOf("/",9);
var _19=_16.substring(_17,_18);
_11=_19+"/wwg/"+_11;
}
}
}else{
if(_f.indexOf("?")!=-1){
_14="&";
}else{
_15=_15+"&Catalog=main";
}
_11=_f+_14+_15;
}
if(_10){
_11="/Grainger/"+_11;
}
return _11;
};
function iframeRefresh(_1a){
if(detectAdobe(true)){
parent.location.reload();
if(_1a!=null){
alert("Please click OK to view the Help Pop-up Window.");
openIt(_1a);
}
}
};
function showPopup(url,_1c,_1d){
var _1e=window.open(url,"childwin","width="+_1c+",height="+_1d+",menubar=no,scrollbars,status=no");
iframeRefresh(_1e);
};
function popUpPositionWidth(_1f){
var _20=(_1f)/2;
var _21=screen.width;
var _22=((_21)/2)-_20;
return _22;
};
function popUpPositionHeight(_23){
var _24=(_23)/2;
yMax=screen.height;
yOffset=((yMax)/2)-_24;
return yOffset;
};
function popWin(url,_26,_27,_28,_29,_2a,_2b,_2c,_2d,_2e){
if(_26==null||_26==""){
_26=400;
}
if(_27==null||_27==""){
_27=400;
}
if(_29==null||_29==""){
_29="no";
}
if(_2a==null||_2a==""){
_2a="no";
}
if(_2b==null||_2b==""){
_2b="no";
}
if(_2c==null||_2c==""){
_2c="no";
}
if(_2d==null||_2d==""){
_2d="no";
}
if(_2e==null||_2e==""){
_2e="childwin";
}
goBack(_28);
if(window.location.pathname.indexOf("PDF")==-1){
popupwindow=window.open(url,_2e,"width="+_26+",height="+_27+",menubar="+_2b+",scrollbars,status="+_2d+",toolbar="+_29+",location="+_2a+",resizable="+_2c);
if(_2e=="mastersetWindow"){
moveX=0;
moveY=0;
if(is_firefox){
moveY=500;
}
openIt(popupwindow,moveX,moveY);
}else{
openIt(popupwindow);
}
}else{
showPopup(url,_26,_27);
}
};
function popWinSurvey(url,_30){
goBack(_30);
popupwindow=window.open(url,"childwin","menubar=no,scrollbars,status=no");
openIt(popupwindow);
};
function openIt(_31,_32,_33){
_31.focus();
if(!_31.opener){
_31.opener=window;
}
if((_32!=null)&&(_33!=null)){
_31.moveTo(_32,_33);
}
};
function goBack(qty){
if(qty!=null&&qty.length>0){
window.history.go(qty);
}
};
function submitSearch(_35,obj){
if(!isNullSearch(obj)){
_35.submit();
}
};
function isNullSearch(obj){
var _38=obj.value;
_38=_38.replace(/^\s+/,"").replace(/\s+$/,"");
if((_38==null)||(_38=="")){
alert("Please enter text to search.");
return true;
}
return false;
};
function isValidQuantity(obj){
var qty=obj.value;
qty=qty.replace(/^\s+/,"").replace(/\s+$/,"");
if(qty==""||qty=="Qty"){
return true;
}
var _3b=/^[0-9]*$/;
if(_3b.test(qty)==false||parseInt(qty,10)<=0){
alert("You have entered an invalid character in the quantity field for one or more item \nnumbers.  Please double check the quantity field(s) on this page and ensure that\neach one only contains a positive number.");
unlocksubmit();
obj.focus();
return false;
}
return true;
};
function isEmptyItemRow(_3c,_3d){
if((_3d.value.replace(/^(\s)+$/,"")==""||_3d.value.toUpperCase()=="ITEM #")){
return true;
}else{
return false;
}
};
function isValidItemRow(_3e,_3f){
if(isValidQuantity(_3e)){
if(_3f.value.toUpperCase()=="ITEM #"||_3f.value.replace(/^(\s)+$/,"")==""){
alert("Please enter an item number.");
unlocksubmit();
_3f.focus();
}else{
if(_3e.value=="Qty"){
_3e.value="";
}
return true;
}
}else{
_3e.focus();
}
return false;
};
function validateSearchQuery(_40){
return (!isNullSearch(_40));
};
var cansubmit=true;
function _submitOnce(){
if(cansubmit){
cansubmit=false;
return true;
}
return false;
};
function unlocksubmit(){
cansubmit=true;
};
unlocksubmit();
function forward(_41){
document.location=_41;
};
function getElmtRef(_42){
if(!document.getElementById){
return document.all[_42];
}else{
return document.getElementById(_42);
}
};
String.prototype.trim=function(){
return this.replace(/^\s+|\s+$/g,"");
};
String.prototype.endsWith=function(){
if(arguments.length!=1){
return true;
}
var s=arguments[0];
if(this.length>=s.length){
return this.substring(this.length-s.length,this.length)==s;
}else{
return false;
}
};
function createCookie(_44,_45,_46){
if(_46){
var _47=new Date();
_47.setTime(_47.getTime()+(_46*24*60*60*1000));
var _48="; expires="+_47.toGMTString();
}else{
var _48="";
}
document.cookie=_44+"="+_45+_48+"; path=/";
};
function readCookie(_49){
var _4a=_49+"=";
var ca=document.cookie.split(";");
for(var i=0;i<ca.length;i++){
var c=ca[i];
while(c.charAt(0)==" "){
c=c.substring(1,c.length);
}
if(c.indexOf(_4a)==0){
return c.substring(_4a.length,c.length);
}
}
return null;
};
function eraseCookie(_4e){
createCookie(_4e,"",-1);
};
function elipsis(_4f,_50){
if(_4f&&_50){
_50=parseInt(_50);
var _51;
if(_4f.length>_50){
_51="<span title=\""+_4f+"\">"+_4f.substring(0,_50-4)+"&nbsp;...</span>";
}else{
_51=_4f;
}
return _51;
}
return _4f;
};
function decodeUrlChars(_52){
return _52.replace(/%22/g,"\"").replace(/%27/g,"'");
};
var cookiesEnabled=true;
function cookieCheck(){
var _53=new Date();
_53.setFullYear(_53.getFullYear()+1);
document.cookie="cookies=true; expires="+_53.toGMTString()+"; path=/";
document.cookie="grainger=true; path=/";
var _54=!(document.cookie.indexOf("grainger=")==-1);
var _55=!(document.cookie.indexOf("cookies=")==-1);
if(!_54||!_55){
cookiesEnabled=false;
}
};
cookieCheck();
function alternateTableRows(_56){
if(document.getElementsByTagName){
var _57=document.getElementById(_56);
var _58=_57.getElementsByTagName("tr");
for(i=0;i<_58.length;i++){
if(i%2!=0){
_58[i].className="trgray";
}
}
}
};
function getBaseApplicationURL(){
var uri=location.protocol+"//"+document.domain+location.pathname;
var _5a=new RegExp("(https*://.*?/(Grainger|gcom_a[0-9]+|cgi-bin/gcom_a[0-9]+))/.*");
return (uri.replace(_5a,"$1"));
};
function loadJavaScript(_5b){
var _5c=document.getElementsByTagName("head").item(0);
var js=document.createElement("script");
js.setAttribute("language","javascript");
js.setAttribute("type","text/javascript");
js.setAttribute("src",_5b);
if(_5b.indexOf("dojo.js")>=0){
js.setAttribute("djConfig","parseOnLoad: true");
}
_5c.appendChild(js);
};
function loadCSS(_5e){
var _5f=document.getElementsByTagName("head").item(0);
var _60=document.createElement("link");
_60.setAttribute("rel","stylesheet");
_60.setAttribute("type","text/css");
_60.setAttribute("href",_5e);
_5f.appendChild(_60);
};
function submitEnter(_61){
var _62;
if(window.event){
_62=window.event.keyCode;
}else{
if(_61){
_62=_61.which;
}else{
return true;
}
}
if(_62==13){
document.signinForm.submit();
return false;
}else{
return true;
}
};
function enterKeyPressed(_63){
var _64;
if(window.event){
_64=window.event.keyCode;
}else{
if(_63){
_64=_63.which;
}else{
return false;
}
}
if(_64==13){
return true;
}else{
return false;
}
};
function showSignIn(){
var _65=readCookie("ActiveXEnabled");
if(_65=="false"){
window.location=getBaseApplicationURL()+"/wwg/loginOrRegister.shtml";
}
var _66;
if(window.location.href.indexOf("viewCatalogPDF.shtml")>-1){
_66="56px";
}else{
_66="150px";
}
dojo.extend(dijit.Dialog,{_position:function(){
if(!dojo.hasClass(dojo.body(),"dojoMove")){
var _67=this.domNode;
var _68=dijit.getViewport();
var p=this._relativePosition;
var mb=p?null:dojo.marginBox(_67);
dojo.style(_67,{left:Math.floor(_68.l+(p?p.l:(_68.w-mb.w)/2))+"px",top:_66});
}
}});
var _6b=dijit.byId("signin");
_6b.show();
var _6c=dojo.byId("loginSubmit");
if(_6c!=null){
_6c.onclick=function(){
_6c.disabled=true;
dojo.byId("signinForm").submit();
return (false);
};
}
document.signinForm.currentPageURL.value=window.location.href;
document.signinForm.userName.focus();
};
var performKeywordSearch=function(_6d){
if(null!=_6d.searchQuery&&_6d.searchQuery.value.length>0){
if(_6d.searchQuery.value=="Enter keyword or part number"){
alert("Please enter a search value.");
return (false);
}
_6d.searchQuery.value=_6d.searchQuery.value.replace(/^\s*|\s*$/g,"");
if(getQueryParam("sst")!=""){
_6d.sst.value=getQueryParam("sst");
}
if(_6d.searchQuery.value.length>0){
if(_6d.Ntt.value.length>0){
_6d.Ntt.value+="|"+_6d.searchQuery.value;
}else{
_6d.Ntt.value=_6d.searchQuery.value;
}
_6d.submit();
return (true);
}
}
alert("Please enter a search value.");
return (false);
};
function getQueryParam(key){
var _6f=window.location.search.substring(1);
var _70=_6f.split("&");
for(var i=0;i<_70.length;i++){
var _72=_70[i].split("=");
if(_72[0]==key){
return _72[1];
}
}
return "";
};
function searchTypeChange(obj){
if(dojo.byId("mixedviewSearchType").value!=obj.value){
dojo.byId("mixedviewSearchType").value=obj.value;
var _74="";
var _75="";
if(window.location.href.indexOf("homepage.jsp")!=-1){
_74="homepage.jsp";
_75="?searchType="+obj.value;
}else{
if(window.location.href.indexOf("start.shtml")!=-1){
_74="start.shtml";
_75="?searchType="+obj.value;
}else{
if(window.location.href.indexOf("search.shtml")!=-1){
_74="search.shtml";
_75="?op=search&searchType="+obj.value;
}else{
if(window.location.href.indexOf("compareItemsRender.shtml")!=-1){
_74="compareItemsRender.shtml";
_75="?searchType="+obj.value;
}else{
if(window.location.href.indexOf("/ecatalog/")!=-1){
_74="/ecatalog/";
_75="N-?searchType="+obj.value;
}
}
}
}
}
if(_75!=""){
var idx=window.location.href.indexOf(_74);
window.location.href=window.location.href.substr(0,idx+_74.length)+_75;
}
}
};
var containsElement=function(arr,ele){
var _79=false,_7a=0;
while(!_79&&_7a<arr.length){
if(arr[_7a]==ele){
_79=true;
}else{
_7a++;
}
}
return _79;
};
var autoCursor=function(_7b,len,e){
var _7e=(is_nav)?e.which:e.keyCode;
var _7f=(is_nav)?[0,8,9]:[0,8,9,16,17,18,37,38,39,40,46];
if(_7b.value.length>=len&&!containsElement(_7f,_7e)){
_7b.value=_7b.value.slice(0,len);
var _80=getIndex(_7b);
for(var i=(_80+1)%_7b.form.length;i!=_80;i=++i%_7b.form.length){
try{
_7b.form[i].focus();
break;
}
catch(e){
continue;
}
}
}
return true;
};
var getIndex=function(_82){
var _83=-1,i=0,_85=false;
while(i<_82.form.length&&_83==-1){
if(_82.form[i]==_82){
_83=i;
}else{
i++;
}
}
return _83;
};
function vmiddleimg(_86,_87){
var _88=getElmtRef(_86);
_88.style.top=-(_87/2);
};
var showMSDS=function(_89,_8a){
var url=_8a+"/grainger/loadmsds.asp?id=";
url+=_89;
var top=100;
var _8d=200;
var _8e="toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=no,width=765,height=500,top="+top+",left="+_8d;
var _8f=window.open(url,null,_8e);
if(window.focus){
_8f.focus();
}
};
function partialWipeOut(_90){
var _91=_90.node=dojo.byId(_90.node),s=_91.style,o;
var _94=(_90.height&&_90.height.end)?_90.height.end:1;
var _95=dojo.animateProperty(dojo.mixin({properties:{height:{end:_94}}},_90));
return _95;
};
var seoLinkHandler=function(obj,_97){
if(typeof obj=="object"&&obj.tagName=="A"){
_97=_97.replace(/^(\?|&)/,"");
if(obj.href.indexOf("?")!=-1){
document.location=obj.href+"&"+_97;
}else{
document.location=obj.href+"?"+_97;
}
}
};

