// ******************************************************************************************

var strAgt = navigator.userAgent.toLowerCase(); 
var blnWin = ((strAgt.indexOf("win") != -1) || (strAgt.indexOf("16bit") != -1) || (strAgt.indexOf("32bit") != -1));
var blnMac = (strAgt.indexOf("mac") != -1);
var blnUnix = ((strAgt.indexOf("x11") != -1) || (strAgt.indexOf("sunos") != -1) || (strAgt.indexOf("irix") != -1) || (strAgt.indexOf("hp-ux") != -1) || (strAgt.indexOf("sco") != -1) || (strAgt.indexOf("unix") != -1) || (strAgt.indexOf("ncr") != -1) || (strAgt.indexOf("dec") != -1) || (strAgt.indexOf("osf1") != -1) || (strAgt.indexOf("ultrix") != -1) || (strAgt.indexOf("alpha") != -1) || (strAgt.indexOf("sinix") != -1) || (strAgt.indexOf("aix") != -1) || (strAgt.indexOf("inux") != -1) || (strAgt.indexOf("bsd") != -1));
var blnNS = ((strAgt.indexOf("mozilla") != -1) && (strAgt.indexOf("compatible") == -1));
var blnIE = (strAgt.indexOf("msie") != -1);
var dblVer = parseFloat(navigator.appVersion);
if (blnIE) {
	var intStart = strAgt.indexOf("msie") + 5;
	var intEnd = strAgt.indexOf(";", intStart)
	dblVer = parseFloat(strAgt.substring(intStart, intEnd));
}
var intBrowserW = intBrowserH = 0;
var blnLoaded = true;
var blnGNSubCatLoaded = false;
var blnModel;
var blnHomePage = false;

var strErrorBoxOpener  =   "<table border='0' cellpadding='0' cellspacing='0' bgcolor='FFFF00' ><tr><td><img src='/images/spacer.gif' height='10'></td></tr><tr>";
strErrorBoxOpener  += "<td><table border='0' cellpadding='0' cellspacing='0' ><tr><td><img src='/images/spacer.gif' width='12' height='10'></td>";
strErrorBoxOpener  += "<td align='left' valign='top'><img src='/images/brochureRequest/icoError.gif' width='23' height='23'></td>";
strErrorBoxOpener  += "<td align='left' valign='top'><img src='/images/spacer.gif' width='12' height='33'></td><td  align='left' valign='top'>";

var strErrorBoxCloser = "</td><td align='left' valign='top'><img src='/images/spacer.gif' width='20' height='10'></td></tr></table></td></tr><tr><td align='left' valign='top'><img src='/images/spacer.gif' width='10' height='5'></td></tr></table>";

// ******************************************************************************************

function pageLoad(){

	buildGNRightSlider(); 
	buildGNRightImages();
	
	if (blnHomePage != true){
		if (strPageCategory != 'Global'){
			initDropDowns();
			}
		drawTopNav();  
		}
	}
	
// ******************************************************************************************

function io(id, nestref) {
	// alert("imgobj id is " + id);
	if (blnNS) {
		if (dblVer >= 5) {
			this.img = document.images[id];
			this.absX = this.x = this.img.offsetLeft;
			this.absY = this.y = this.img.offsetTop;
			ob = this.img;
			do {
				ob = ob.offsetParent;
			} while ((ob.nodeName != "DIV") && (ob.nodeName != "BODY"));
			this.relX = (this.absX - ob.offsetLeft);
			this.relY = (this.absY - ob.offsetTop);
			this.w = this.img.width;
			this.h = this.img.height;
    } else {
      this.img = (nestref) ? eval("nestref.images."+id) : eval("document.images."+id);
      this.relX = this.absX = this.x = this.img.x; 
      this.relX = this.absY = this.y = this.img.y;
      this.w = this.img.width;
      this.h = this.img.height;
    }
  } else if (blnIE) {
    this.img = document.images[id];
		this.relX = this.img.offsetLeft;
		this.relY = this.img.offsetTop;
    this.absX = 0;
    this.absY = 0;
    ob = this.img;
		do {
			this.absX += ob.offsetLeft;
			this.absY += ob.offsetTop;
			ob = ob.offsetParent;
		} while (ob != null);
		this.x = this.absX;
		this.y = this.absY;
    this.w = this.img.width;
    this.h = this.img.height;
  }
	this.imgoff = new Image();
	this.imgoff.src = this.img.src;
  return;
}

// ******************************************************************************************

function changedoc(str) {
	// alert(str);
	if (blnNS && (dblVer < 5)) {
		this.doc.open();
		this.doc.write(str);
		this.doc.close();
	} else if (blnIE || (blnNS && (dblVer >= 5))) {
		this.elm.innerHTML = str;
	}
	return;
}

// ******************************************************************************************

function newImage(imagePath) {
     if (document.images) {
          var rslt = new Image();
          rslt.src = imagePath;
          return rslt;
     }
}

// ******************************************************************************************

function obj(id, nestref) {
	// alert("id is " + id);
	if (blnNS) {
		if (dblVer >= 5) {
			this.elm = this.evt = document.getElementById(id);
			this.ref = this.elm;
			this.css = this.elm.style;
			this.doc = document;
			this.x = this.begx = (nestref) ? this.elm.offsetLeft - nestref.offsetLeft : this.elm.offsetLeft;
			this.y = this.begy = (nestref) ? this.elm.offsetTop - nestref.offsetTop : this.elm.offsetTop;
			this.clipW = this.scrollW = this.elm.offsetWidth;
			this.clipH = this.scrollH = this.elm.offsetHeight;
			this.self = id; 
			eval(this.self + "=this");
		} else { // synchronized
			this.css = (nestref) ? eval("nestref.document.layers." + id) : eval("document.layers." + id);
			this.ref = this.css;
			this.elm = this.evt = this.css;
			this.doc = this.css.document;
			this.x = this.begx = this.css.left;
			this.y = this.begy = this.css.top;
			//this.w,h alaises added for GN DHTML
			this.clipW = this.scrollW = this.w = this.css.clip.width;
			this.clipH = this.scrollH = this.h = this.css.clip.height;
			this.self = id; 
			eval(this.self + " = this");
		}
	} else if (blnIE) {// synchronized
		this.elm = this.evt = document.all[id];
		this.css = this.elm.style;
		this.doc = document;
		this.x = this.begx = this.elm.offsetLeft;
		this.y = this.begy = this.elm.offsetTop;
		//width and height added by geoff for GN DHTML
		//this.w = this.elm.offsetWidth;
    //this.h = this.elm.offsetHeight;
		this.clipW = this.elm.offsetWidth;
		this.clipH = this.elm.offsetHeight;
		this.scrollW = this.elm.scrollWidth;
		this.scrollH = this.elm.scrollHeight;
		this.self = id + "Obj";
		eval(this.self + " = this"); 
	}
	this.id = id; // synchronized
	this.i = 1;
	this.slidingTID = null;
	this.fading = false;
	this.copyFrom = copyFrom;
	this.clip = clip;
	this.num = 0;
	// this.alphafade = alphafade;
	// Added for GN DHTML
	this.slidecoords = slidecoords;
	this.menuslide = menuslide;
	this.changedoc = changedoc;
  this.scroll = scroll;
	this.down = true;
	this.sliding = false;
	this.clipping = false;
	return;
}
				
// *****************************************************************************************
		
function menuslide(whichMenu) {
	var slideVariation = (whichMenu == 'panel2') ? 6 : 3;
	var func = "";
	var steps = 1;
	var amount = 0;
	if (this.sliding) {
		clearTimeout(slidingID2);
		this.i = 1;
	}
	this.sliding = true;
	if (this.down) {
		steps = Math.max(1, Math.floor(-this.y / 30));
		func = this.self+".slidecoords("+this.x+", "+this.y+", "+this.x+", 0, "+ steps +", 60)";
		this.down = false;
	} else {
		steps = Math.max(1, Math.floor((this.scrollheight + this.y) / 30));
		amount = -this.scrollheight + slideVariation;
		// amount = -this.scrollH + slideVariation;
		func = this.self+".slidecoords("+this.x+", "+this.y+", "+this.x+", "+ amount +", "+ steps +", 60)";
		this.down = true;
	}
	eval(func);
	return;
}

// *****************************************************************************************

function slidecoords(xbeg, ybeg, xend, yend, steps, rate) {
	if (blnNS && (dblVer >= 5)) {
		this.x = Math.round(xbeg+((xend-xbeg)*(this.i/steps)));
		this.css.left = this.x + "px";
		this.y = Math.round(ybeg+((yend-ybeg)*(this.i/steps)))
		this.css.top = this.y + "px";
	} else {
		this.css.left = this.x = Math.round(xbeg+((xend-xbeg)*(this.i/steps)));
		this.css.top = this.y = Math.round(ybeg+((yend-ybeg)*(this.i/steps)));
	}
	this.i++;
	if (this.i <= steps) {
		slidingID2 = setTimeout(this.self+".slidecoords("+xbeg+", "+ybeg+", "+xend+", "+yend+", "+steps+", "+rate+")", rate);  
	} else { 
		this.i = 1;
		this.sliding = false;
	}
}
		
// ******************************************************************************************

function copyFrom(srcObj) {
	for (var prop in srcObj) {
		this.prop = srcObj[prop];
	}
	return;
} 

// ******************************************************************************************

function clip(T, R, B, L) {
  if (blnNS) {
    this.css.clip.top = T;
    this.css.clip.right = R;
    this.css.clip.bottom = B;
    this.css.clip.left = L;
    this.clipW = this.css.clip.width;
    this.clipH = this.css.clip.height;
  } else if (blnIE) {
    this.css.clip = "rect("+T+", "+R+", "+B+", "+L+")";
    this.css.width = R;
    this.css.height = B;
    this.clipW = R-L;
    this.clipH = B-T;
  }
  return;
}  

// ******************************************************************************************

function checksize() {
	if ((intBrowserW <= 0) || (intBrowserH <= 0)) {
		return;
	}
	if (blnNS) {
		if (intBrowserW != window.innerWidth || intBrowserH != window.innerHeight) {
			location.reload();
			}
	} else if (blnIE) {
		if (intBrowserW != document.body.clientWidth || intBrowserH != document.body.clientHeight) {
			location.href = location;
		}
	}
	return;
}

// ******************************************************************************************

function pad(num) {
	return (num < 10) ? "0" + num : num;
}

// ******************************************************************************************

function slidesinewave(dx, xt, dxt, dy, yt, dyt, rate, funcduring, funcatend) {
	this.sliding = true;
	var xover = true;
	var yover = true;
	if (dx != 0) {
		xover = false;
		if (xt >= 1.5708) {
			xt = 1.5708;
			xover = true;
		}
		this.css.left = this.x = Math.round(this.x + (dx * Math.cos(xt)));
		xt += dxt;
	}
	if (dy != 0) {
		yover = false;
		if (yt >= 1.5708) {
			yt = 1.5708;
			yover = true;
		}
		this.css.top = this.y = Math.round(this.y + (dy * Math.cos(yt)));
		yt += dyt;
	}
	if (("" + funcduring != "undefined") && (funcduring != null)) {
		eval(funcduring);
	}
	if (!xover || !yover) {
		this.slidingTID = setTimeout(this.self + ".slidesinewave(" + dx + ", " + xt + ", " + dxt + ", " + dy + ", " + yt + ", " + dyt + ", " + rate + ", '" + funcduring + "', '" + funcatend + "')", rate);  
	} else { 
		// alert("funcatend is " + funcatend);
		if ("" + funcatend != "undefined") {
			eval(funcatend);
		}
	}
}

// ******************************************************************************************

function slidesineamount(xbeg, xamt, xt, xdt, ybeg, yamt, yt, ydt, rate, funcduring, funcatend) {
	this.sliding = true;
	var xover = true;
	var yover = true;
	if (xamt != 0) {
		xover = false;
		if (xt >= 1.5708) {
			xt = 1.5708;
			xover = true;
		}
		this.css.left = this.x = Math.round(xbeg + Math.sin(xt) * xamt);
		xt += xdt;
	}
	if (yamt != 0) {
		/*
		alert("ybeg is " + ybeg + 
			"\nyamt is " + yamt +
			"\nyt is " + yt +
			"\nydt is " + ydt);
		*/
		yover = false;
		if (yt >= 1.5708) {
			yt = 1.5708;
			yover = true;
		}
		this.css.top = this.y = Math.round(ybeg + Math.sin(yt) * yamt);
		yt += ydt;
	}
	if (("" + funcduring != "undefined") && (funcduring != null)) {
		eval(funcduring);
	}
	if (!xover || !yover) {
		this.slidingTID = setTimeout(this.self + ".slidesineamount(" + xbeg + ", " + xamt + ", " + xt + ", " + xdt + ", " + ybeg + ", " + yamt + ", " + yt + ", " + ydt + ", " + rate + ", '" + funcduring + "', '" + funcatend + "')", rate);  
	} else { 
		if ("" + funcatend != "undefined") {
			eval(funcatend);
		}
	}
}

// ******************************************************************************************

function dragmousemove(e) {
	//if (!blnLoaded) {
	//	return;
	//}
	x = event.x + document.body.scrollLeft;
	y = event.y + document.body.scrollTop; 
	//window.status = 'x=' + x + ' ' + 'y=' + y;
	return;
}

// ******************************************************************************************

function cleanup() {
	writeNavCookie();
	
	if (blnNS) {
		document.releaseEvents(Event.MOUSEMOVE);
	}
	return;
}

// ******************************************************************************************

var popwin;
var blnNewPopwin = true;
function popwindow(site, w, h, num) {
	sb = "yes";
  rs = "yes";
  st = "no";
  lc = "no";
  mb = "no";
  tb = "no";
	if (blnNS) {
		if (dblVer < 4) {
			w += 20;
			h += 20;
		}
	} else if (blnIE) {
		w += 17;
	}
	windowparams = "width=" + w + ",height=" + h + ",toolbar=" + tb + ",menubar=" + mb + ",resizable=" + rs +  ",status=" + st + ",location=" + lc + ",scrollbars=" + sb;
		
	if (dblVer >= 4) {
		x = (screen.width - w) >> 1;
		y = (screen.height - h) >> 1;
	} else {
		x = (648 - w) >> 1;
		y = (324 - h) >> 1;
	}
	if (blnIE) {
		windowparams += ",top=" + y + ",left=" + x;
	} else {
		windowparams += ",screenX=" + x + ",screenY=" + y;
	}
	/*
	alert("windowparams is " + windowparams);
	if (("" + popwin != "undefined") && (!popwin.closed)) {
		popwin.close();
	}
	*/
	w += 12;
	h += 34;
	if (site.indexOf("?") == -1) {
		site += "?";
	} else {
		site += "&";
	}
	popwin = window.open(site + "w=" + w + "&h=" + h, "popwindow" + num, windowparams);
	// popwin = window.open(site, "popwindow" + num, windowparams);
	// setTimeout("popwin.resizeTo(" + w + ", " + h + ")", 70);
	setTimeout("popwin.focus()", 140);
	return;
}

// ******************************************************************************************

function rollOn(imgObjName){
if (!blnLoaded || !document.images) 
	{
		return;
	}
	imgObjName.img.src = imgObjName.imgon.src;
	return;
}

// ******************************************************************************************

function rollOff(imgObjName){
if (!blnLoaded || !document.images) 
	{
		return;
	}
	imgObjName.img.src = imgObjName.imgoff.src;
	return;
}

// ******************************************************************************************

function changeCssTop(obj, value){
	obj.css.top  = value;
	return;
}

// ******************************************************************************************

function changeCssVis(args) {
	var arg = changeCssVis.arguments;
	for (var i = 0; i < arg.length; i += 2) {
		arg[i].css.visibility = (arg[i+1] == 1) ? "visible" : "hidden";
		return;
	}
}

function changeCssBgGN(layer) {
	if (!(blnNS && (dblVer < 5))) {
		document.getElementById(layer).style.backgroundColor = '#FF0000';
	}
}


function changeCssBgGNOff(layer){
	if (!(blnNS && (dblVer < 5)))  {
		document.getElementById(layer).style.backgroundColor = '#FFFFFF';
	}
}

// ******************************************************************************************

function validateZipCode(zipCode){
	var zipRegexAll = '^[0-9]{5}$';
	 var regexZip = new RegExp(zipRegexAll);
	 blnZip = (regexZip.test(zipCode))?1:0;
	 return blnZip;
}

// ******************************************************************************************

function goToTop(page){
	top.location = page;
}




