

// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     a >> lib api
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o





// New library object for dynamic layers 
//Global document object
d = window.document
loaded = false;

// repeated below
//if(d.layers){
//	origWidth=innerWidth;
//	origHeight=innerHeight;
//}

// Browser detection object

function lib_bwCheck(){
	this.ver = navigator.appVersion
	this.agent = navigator.userAgent
	this.dom = document.getElementById?1:0
	this.opera5 = this.agent.indexOf("Opera 5")>-1
	this.ie5 = (this.agent.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0
	this.ie6 = (this.agent.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0
	this.ie4 = (document.all && !this.dom && !this.opera5)?1:0
	this.ie = this.ie4||this.ie5||this.ie6
	this.mac = this.agent.indexOf("Mac")>-1
	this.ns6 = (this.dom && parseInt(this.ver)>=5)?1:0
	this.ns4 = (document.layers && !this.dom)?1:0
	this.bw = (this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
	return this
}
bw = new lib_bwCheck() // Browser object

function lib_obj(obj){
	this.el = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval('document.' + obj):0;
	this.css = bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
	this.moveIt = lib_moveIt;
	this.showIt = lib_showIt;
	this.hideIt = lib_hideIt;
	return this;
}


function lib_moveIt(x,y){
	if (x){this.x=x; this.css.left = x;}
	if (y){this.y=y; this.css.top = y;}
}

function lib_showIt(){this.css.visibility = "visible"}
function lib_hideIt(){this.css.visibility = "hidden"}

// DHTML fix detection for Netscape browser resize
if (d.layers) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	onresize=DHTMLfix;
}
		
// DHTML fix for Netscape browser resize
function DHTMLfix() {
	if (origWidth != innerWidth || origHeight != innerHeight) {
		location.reload();
	}
}

function fixNav(){
	if(d.all)history.go(0)
	if (d.layers) {
		DHTMLfix();
	}
}


// X Position Layer relative to anchor image
function get_xPos(object,offset){
	if(d.layers && !d.dom){
		xPos = d.images[object].x
	} else {
		xPos = d.images[object].offsetLeft;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) xPos = xPos + offset;
	return xPos;
}


// Y Position Layer relative to anchor image 
function get_yPos(object,offset){
	if(d.layers && !d.dom){
		yPos = d.images[object].y
	} else {
		yPos = d.images[object].offsetTop;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) yPos = yPos + offset;
	return yPos
}





// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     b >> onload placement functions
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o




// function called onload to initialize dynamic elements
 
function init(){
	place_logo();
	place_menus();
	loaded = true;
}


// logo placement


function place_logo(){
	oDiv = new Array();
	oDiv[0] = new lib_obj('logoa');
	oDiv[1] = new lib_obj('logob');
	oDiv[2] = new lib_obj('logoc');
	oDiv[3] = new lib_obj('logod');
	oDiv[4] = new lib_obj('logoe');
	oDiv[5] = new lib_obj('logof');
	oDiv[6] = new lib_obj('logog');
	oDiv[7] = new lib_obj('logoh');
	oDiv[8] = new lib_obj('logoi');
	for(n=0; n<oDiv.length; n++){
		oDiv[n].moveIt(get_xPos("lnk0",-3),false);
		oDiv[n].showIt();
	}
}


// menu placement


function place_menus(){
	mDiv = new Array();
	for (var i=0;i<menu_ar.length;i++){
		mDiv[menu_ar[i]] = new lib_obj('m' + menu_ar[i]);
		mDiv[menu_ar[i]].moveIt(get_xPos(menu_ar[i]),false);
	}
	mDiv[rightmost_menu].moveIt(get_xPos(rightmost_menu,-67),false);
	mDiv['loc'].moveIt(get_xPos('loc',2),false);
	loaded=true;
}

// product placement for 3rd level product pages
// first arg is prefix ("hpr", "cpr", etc.), all following args are product/layer identifiers (efx533, efx521i, etc.). last arg is default layer, e.g. 'efx0'
// passed from onload in page body

function place_prod(prefix){
	pDiv = new Array();
	for (var i=1;i<arguments.length;i++){
		prod_ar[i-1] = prefix + arguments[i];
		pDiv[prefix + arguments[i]] = new lib_obj('d' + prefix + arguments[i]);
		pDiv[prefix + arguments[i]].moveIt(get_xPos("lnk0",273),false);
	}
	load_p_rollovers();

	pDiv[prefix + arguments[arguments.length-1]].showIt();
	pactive = prefix + arguments[arguments.length-1];
	pactive_d = pactive;
}


// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     c >> drop down menus
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o




// put the name of the images that trigger the dropdowns in this array
menu_ar = new Array();
menu_ar[0] = 'hpr';
menu_ar[1] = 'cpr';
menu_ar[2] = 'int';
menu_ar[3] = 'cus';
menu_ar[4] = 'fit';
menu_ar[5] = 'com';
menu_ar[6] = 'loc';

// menu variables

rightmost_menu = menu_ar[5];

delay=300;
active = menu_ar[0];
timer = null;


// rollover functions

function load_menu_rollovers(){
	mro_ar = new Array();
	for (var i=0;i<menu_ar.length;i++){
		mro_ar[menu_ar[i]] = new Array();
		mro_ar[menu_ar[i]]['off']=new Image();
		mro_ar[menu_ar[i]]['on']=new Image();
		mro_ar[menu_ar[i]]['off'].src="/images/all_nav-"+menu_ar[i]+".gif";
		mro_ar[menu_ar[i]]['on'].src="/images/all_nav-"+menu_ar[i]+"_on.gif";
	}
}

load_menu_rollovers();

function m_rollover(which){
	document.images[which].src = mro_ar[which]['on'].src;
}

function m_rollout(which){
	document.images[which].src = mro_ar[which]['off'].src;
}



// menu functions 

function changeActive(which){
	if (loaded){
		clearTimeout(timer);
		mDiv[active].hideIt();
		m_rollout(active);
		active=which;
		mDiv[active].showIt();
		m_rollover(active);
	}
}

function killIt(){
	if (loaded){
		mDiv[active].hideIt();
		m_rollout(active);
	}
}

function killMenu(){
	if (loaded){
		timer = setTimeout("killIt()",delay);
	}
}

function sleep(){
	clearTimeout(timer);
}



// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     d >> page specific functions
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o

//
// Pop-up windows
//

function popUpNav(newURL,sizeW,sizeH,tools,scroll) { 
	var features = 
		'"width=' + sizeW +
        ',height=' + sizeH +
        ',menubar=no' +    
		',toolbar=' + tools +
        ',scrollbars=' + scroll +
        ',resizable=yes' +
       	',screenX=20,screenY=20,top=20,left=20"';
	eval('window.open("'+newURL+'","popUp",' +features+')');
}	

function popUpNav2(newURL,sizeW,sizeH,tools,scroll,posX,posY) { 
	var features = 
		'"width=' + sizeW +
        ',height=' + sizeH +
        ',menubar=no' +    
		',toolbar=' + tools +
        ',scrollbars=' + scroll +
        ',resizable=yes' +
       	',screenX=' + posX + ',screenY=' + posY + ',top=' + posY + ',left=' + posX + '"';
	eval('window.open("'+newURL+'","popUp",' +features+')');
}	

//
// 2nd level product page rollovers
//

function load_all_ar(){
	all_ar = new Array();
	for (var i=0;i<arguments.length;i++){
		all_ar[arguments[i]] = new Image();
		all_ar[arguments[i]].src = "/images/all-"+arguments[i]+"_on.gif";
	}
}

load_all_ar("efx","tre","str","cyc","cli","stt","stm");

function second_rollover(which){
	document.images["prd"].src = all_ar[which].src;
}

function second_rollout(){
	document.images["prd"].src = "/images/all_space.gif";
}

//
// 3rd level product layer rollovers
//

function load_third_level(){
	third_ar = new Array();
	for (var i=0;i<arguments.length;i++){
		third_ar[arguments[i]] = new Array();
		third_ar[arguments[i]]['off'] = new Image();
		third_ar[arguments[i]]['on'] = new Image();
		third_ar[arguments[i]]['prod'] = new Image();
		third_ar[arguments[i]]['off'].src = "/images/"+arguments[i]+".gif";
		third_ar[arguments[i]]['on'].src = "/images/"+arguments[i]+"_on.gif";
		third_ar[arguments[i]]['prod'].src = "/images/"+arguments[i]+".jpg";
	}
}

function third_rollover(which){
	document.images[which].src = third_ar[which]['on'].src;
	document.images["prd3"].src = third_ar[which]['prod'].src;
}

function third_rollout(which){
	document.images[which].src = third_ar[which]['off'].src;
}


//
// product comparison rollovers
//

function load_compare_ar(){
	compare_ar = new Array();
	for (var i=0;i<arguments.length;i++){
		compare_ar[arguments[i]] = new Array();
		compare_ar[arguments[i]]['off'] = new Image();
		compare_ar[arguments[i]]['on'] = new Image();
		compare_ar[arguments[i]]['off'].src = "/images/all_compare_"+arguments[i]+"-but.gif";
		compare_ar[arguments[i]]['on'].src = "/images/all_compare_"+arguments[i]+"-but_on.gif";
	}
}

function compare_rollover(which){
	document.images[which].src = compare_ar[which]['on'].src;
}

function compare_rollout(which){
	document.images[which].src = compare_ar[which]['off'].src;
}


//
// Product Detail layer rollovers
// 

//variables 
PD_active = 0;
PD_delay=600;
PD_timer = null;


// ## Move and place prod. detail layers

function PDActive(pdnum,x1,y1){
		clearTimeout(PD_timer);
		pdDiv[PD_active].hideIt()
		mshDiv[PD_active].hideIt()
        PD_active=pdnum
	    pdDiv[PD_active].showIt()
		mshDiv[pdnum].moveIt(PDxPos+x1,PDyPos+y1) //position mesh layers based on passed coords.
	    mshDiv[PD_active].showIt()
}

// ## kill prod. detail layers / show default

function PDkillIt(){
	pdDiv[PD_active].hideIt()
	mshDiv[PD_active].hideIt()
	pdDiv[0].showIt() //make the default layer visible again
    PD_active=0; // set the active layer to default #
}

function PDkill(){
	PD_timer = setTimeout("PDkillIt()",PD_delay)
}

// Get the prod. detail X and Y

function PDget_xPos(n){
	if(d.layers && !d.dom){
		PDxPos = d.images["detailmap"].x
	} else {
		PDxPos = d.images["detailmap"].offsetLeft;
		PDtempEl = d.images["detailmap"].offsetParent;
		while (PDtempEl != null) {
			PDxPos += PDtempEl.offsetLeft;
		    PDtempEl = PDtempEl.offsetParent;
		}
	}
	return PDxPos
}


// Get the prod. detail X and Y

function PDget_yPos(n){
	if(d.layers && !d.dom){
		PDyPos = d.images["detailmap"].y
	} else {
		PDyPos = d.images["detailmap"].offsetTop;
		PDtempEl = d.images["detailmap"].offsetParent;
		while (PDtempEl != null) {
			PDyPos += PDtempEl.offsetTop;
		    PDtempEl = PDtempEl.offsetParent;
		}
	}
	return PDyPos
}

// Initialize for product detail layers

function PDinit(){
//	bw = new lib_bwCheck() // Browser object
	pdDiv = new Array()
	pdDiv[0] = new lib_obj('pd0') //this is the default/visible layer
	pdDiv[1] = new lib_obj('pd1')
	pdDiv[2] = new lib_obj('pd2')
	pdDiv[3] = new lib_obj('pd3')
	pdDiv[4] = new lib_obj('pd4')
	pdDiv[5] = new lib_obj('pd4')

	for(n=0; n<pdDiv.length; n++){
		pdDiv[n].moveIt(PDget_xPos(n)+document.images["detailmap"].width,PDget_yPos(n))
	}

// show default layer
    pdDiv[0].showIt()
	
// load MESH-MO layers
	mshDiv = new Array()
	mshDiv[0] = new lib_obj('mesh0') //this layer is a space holder
	mshDiv[1] = new lib_obj('mesh1')
	mshDiv[2] = new lib_obj('mesh2')
	mshDiv[3] = new lib_obj('mesh3')
	mshDiv[4] = new lib_obj('mesh4')
	mshDiv[5] = new lib_obj('mesh5')
	
}

// print function for specs charts
function printIt(){
	window.print();
}






