// JavaScript Document

/* ********************************************************
*
*  customizations to product nav menu
*
*  all customizations should remain in this file
*
* ******************************************************** */

function P7_centerTag(t){ //v1.0 by Project Seven Development (www.projectseven.com)
 var w=0,tP,tL,lp,pp,ow;t=(t)?t:document.p7cme;tP=document.getElementById(t);
 if(tP){tL=tP.childNodes;for(i=0;i<tL.length;i++){
 w+=(tL[i].offsetWidth)?tL[i].offsetWidth:0;}pp=tP.parentNode;
 ow=pp.offsetWidth;if(ow<w){w=ow;}lp=parseInt(ow-w)/2;
 tP.style.marginLeft=lp+"px";document.p7cme=t;}
 document.p7cmh=document.body.offsetHeight;document.p7cmw=document.body.offsetWidth;
 setInterval("P7_cmPM()",10);onresize=P7_cmPM;}function P7_cmPM(){
 if(document.p7cmh!=document.body.offsetHeight||document.p7cmw!=document.body.offsetWidth){
 P7_centerTag();}
}

/* this is the new body onLoad handler */
function bodyLoad() {
  // CSScriptInit();
  P7_centerTag('p7PMnav');
  P7_initPM(1,0,0,-20,10);
}

function bodyUnload() {
	P7_PMclr();
}

// The right way to add load events. By Simon Willison
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function addUnloadEvent(func) {
	var oldunload = window.onunload;
	if (typeof window.onunload != 'function') {
		window.onunload = func;
	}
	else {
		window.onunload = function() {
			oldunload();
			func();
		}
	}
}

/* **********************************************************
   this appends our onload handler to existing handlers.
   there is an issue though... this function has to be 
	 run from AFTER the body tag, otherwise if the body
	 tag has an onload handler assigned it will overwrite
	 our handler.  The other option is to move the body 
	 onload function calls into our bodyLoad function. 
* ********************************************************** */
// var old = (window.onload) ? window.onload : function () {};
// window.onload = function () { old(); bodyLoad(); };
addLoadEvent(bodyLoad);
//var old = (window.onunload) ? window.onunload : function () {};
//window.onunload = function () { old(); bodyUnload(); };
addUnloadEvent(bodyUnload);