var currLoc=-1;
var bObj = new ple_Browser();
//var imgNameArr = new Array("B1","B2","B3","B4","B5","B6","B7","B8");
//var imgNameArr = new Array("B1","B2","B3","B4","B5","B6","B7","B8","T1","T2","T3","T4");
var imgNameArr = new Array("NavMenu_r1_c1a","NavMenu_r1_c2a","NavMenu_r1_c3a","NavMenu_r1_c4a","NavMenu_r1_c5a","NavMenu_r1_c6a","NavMenu_r1_c7a","NavMenu_r1_c8a","NavMenu_r1_c9a","T2","T3","T4");

//********************************************************************************************************

if (document.images) {
	nav_on = new MakeArray(imgNameArr.length);
	nav_off = new MakeArray(imgNameArr.length);
	for (x=0;x<imgNameArr.length;x++){
		nav_off[x] = new Image(); 
		//nav_off[x].src = "images/" + imgNameArr[x] + ".jpg";
		nav_off[x].src = "../NavMenu/" + imgNameArr[x] + ".gif";
		nav_on[x] = new Image();
		//nav_on[x].src = "images/" +imgNameArr[x] + "over.jpg";
		nav_on[x].src = "../NavMenu/" +imgNameArr[x] + "_f2.gif";
	}
}
//********************************************************************************************************
function MakeArray(n){ this.length = n;for (var i = 1; i<=n; i++) {this[i] = new Image();}return this;}
//********************************************************************************************************	
function navOn(num){eval ("document." + imgNameArr[num] + ".src ='" + nav_on[num].src +"'");}
//********************************************************************************************************
function navOff(num){ if ((num != currLoc)) {eval ("document." + imgNameArr[num] + ".src ='" + nav_off[num].src +"'");}}
//********************************************************************************************************
var NS = (navigator.appName == "Netscape");
mac = navigator.appVersion.indexOf("Mac");
if (mac>=0) {mac=1} else {mac=0}
IE = (document.all) ? true : false; 
NS4 = (document.layers) ?  true : false;
eID = document.getElementById;
if(eID && NS) {NS6=true} else {NS6=false}
if ((IE) || (NS4) || (NS6)) {dhtml=1;}
//******************************************************************************************************** 
function makeRef(refElement) {
	if (bObj.ns6) {var prefix = "document.getElementById('" + refElement + "')"}
	if (bObj.ie) {var prefix = "document.all." + refElement}
	if (bObj.ns) {var prefix = "document." + refElement}
	//alert(prefix);
	return prefix;
}
//********************************************************************************************************
/*
 | Browser object
 */
function ple_Browser() {
	 d=document;
	 this.agt=navigator.userAgent.toLowerCase();
	 this.major = parseInt(navigator.appVersion);
	 this.dom=(d.getElementById)?1:0; // true for ie6, ns6
	 this.ns=(d.layers);
	 this.ns4up=(this.ns && this.major >=4);
	 this.ns6=(this.dom&&navigator.appName=="Netscape");
	 this.op=(window.opera? 1:0);
	 this.ie=(d.all);
	 this.ie4=(d.all&&!this.dom)?1:0;
	 this.ie4up=(this.ie && this.major >= 4);
	 this.ie5=(d.all&&this.dom);
	 this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
	 this.mac=(this.agt.indexOf("mac")!=-1);
}
//********************************************************************************************************
// like to optimize this further
function ple_getObj(id,d) {
  	var i, x;  
  	if(!d) {
  		d=document;
  	}
	if(!(x=d[id]) && d.all) { 
		x=d.all[id];
	}
	for (i=0; !x && i<d.forms.length; i++) { 
		x=d.forms[i][id];
	}
	for(i=0; !x && d.layers && i < d.layers.length; i++) { 
		//alert(d.layers.length + ":" + i);
		x=ple_getObj(id,d.layers[i].document);
	}
	if(!x && document.getElementById) {
		 x=document.getElementById(id);
	}
	return x;
}
//********************************************************************************************************
function ple_getH(o) { var h=0; if (bObj.ns) { h=(o.height)? o.height:o.clip.height; return h; } h=(bObj.op)? o.style.pixelHeight:o.offsetHeight; return h; }
function ple_setH(o,h) { if(bObj.ns) {if(o.clip) o.clip.bottom=h;}else if(bObj.op)o.style.pixelHeight=h;else o.style.height=h; }

function ple_getW(o) { var w=0; if(bObj.ns) { w=(o.width)? o.width:o.clip.width; return w; } w=(bObj.op)? o.style.pixelWidth:o.offsetWidth; return w; }
function ple_setW(o,w) { if(bObj.ns) {if(o.clip) o.clip.right=w;}else if(bObj.op)o.style.pixelWidth=w;else o.style.width=w; }

function ple_getX(o) { var x=(bObj.ns)? o.left:(bObj.op)? o.style.pixelLeft:o.offsetLeft; return x;}
function ple_setX(o,x) { (bObj.ns)? o.left=x:(bObj.op)? o.style.pixelLeft=x:o.style.left=x; }

function ple_getY(o) {  var y=(bObj.ns)? o.top:(bObj.op)? o.style.pixelTop:o.offsetTop; return y;}
function ple_setY(o,y) { (bObj.ie||bObj.dom)? o.style.top=y:(bObj.ns)? o.top=y:o.style.pixelTop=y; }

function ple_setClip(o) { }

function ple_getPageX(o) { if(bObj.ns) { var x=(o.pageX)? o.pageX:o.x; return x; } else if (bObj.op) {  var x=0; while(eval(o)) { x+=o.style.pixelLeft; o=o.offsetParent; } return x; } else { var x=0; while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; } return x; } }

function ple_getPageY(o) { if(bObj.ns) { var y=(o.pageY)? o.pageY:o.y; return y; } else if (bObj.op) {  var y=0; while(eval(o)) { y+=o.style.pixelTop; o=o.offsetParent; } return y; }  else { var y=0; while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } return y; } }

function ple_moveTo(o,x,y) { ple_setX(o,x);ple_setY(o,y); }
function ple_moveBy(o,x,y) { ple_setX(o,ple_getPageX(o)+x);ple_setY(o,ple_getPageY(o)+y); }

function ple_setZ(o,z) { if(bObj.ns)o.zIndex=z;else o.style.zIndex=z; }

function ple_show(o,disp) { 
 (bObj.ns)? '':(!disp)? o.style.display="inline":o.style.display=disp;
 (bObj.ns)? o.visibility='show':o.style.visibility='visible';  
}
function ple_hide(o,disp) {
 if(o!=null){ 
 (bObj.ns)? '':(arguments.length!=2)? o.style.display="none":'';
 (bObj.ns)? o.visibility='hide':o.style.visibility='hidden';  
 }
}

function ple_setStyle(o,s,v) { if(bObj.ie5||bObj.dom) eval("o.style."+s+" = '" + v +"'"); }
function ple_getStyle(o,s) { if(bObj.ie5||bObj.dom) return eval("o.style."+s); }

function ple_getDocW() { }
function ple_getDocH() { }

function ple_addEvt(o,e,f,c){ if(o.addEventListener)o.addEventListener(e,f,c);else if(o.attachEvent)o.attachEvent("on"+e,f);else eval("o.on"+e+"="+f)}

function ple_writeHTML(o,h) { 
	if(bObj.ns){var doc=o.document;doc.write(h);doc.close();return false;}
	if(o.innerHTML)o.innerHTML=h; 
}
// The number of pixels the document has scrolled horizontally.
function ple_getScrollX() {  var offset;  if (bObj.ns4up || bObj.opera) {   offset = window.pageXOffset;  }  else if (bObj.ie4up) {    offset = document.body.scrollLeft;  }  return offset;}
// The number of pixels the document has scrolled vertically.
function ple_getScrollY(){  var offset;  if (bObj.ns4up || bObj.opera) {    offset = window.pageYOffset;  }  else if (bObj.ie4up) {    offset = document.body.scrollTop;  }  return offset;}
//********************************************************************************************************
//********************************************************************************************************
var maxMouseX;
var maxMouseY;
var minMouseX;
var minMouseY;
var currDd = null;
var db = "";
var currDdID = -1;
function createDropdown($idx) {
	//var imgObj = ple_getObj($imgID);
	var imgObj = ple_getObj(imgNameArr[$idx]);
	//alert(imgObj);
	//alert(imgID.id);
	if(currDdID != -1 && currDdID != $idx && currDd!=null) {
		ple_hide(currDd);
		currDd=null;
		navOff(currDdID);
	}
	currDdID = $idx;
	navOn($idx);
	//currDd = eval(makeRef("menu" + $idx));
	currDd = ple_getObj("menu" + $idx);
	//currDd = ple_getObj("menu2");
	//alert(currDd);
	var x = ple_getPageX(imgObj);
	//alert("1");
	var sx = ple_getScrollX();
	if(isNaN(sx)){sx=0;}
	var y = ple_getPageY(imgObj);
	var sy = ple_getScrollY();
	if(isNaN(sy)){sy=0;}
	//
	var h = ple_getH(imgObj);
	//alert("111");
	var w = ple_getW(imgObj);
	//alert("2");
	ple_moveTo(currDd,x,y+h);
	//alert("22");
	ple_show(currDd);
	//
	var hh = ple_getH(currDd);
	var ww = ple_getW(currDd);
	//
	minMouseX = x - sx;
	minMouseY = y - sy;
	maxMouseY = y + h + hh;
	if(ww <= 0) {
		maxMouseX = x + w;
	} else {
		maxMouseX = x + ww;
	}
	//alert("3");
	//
	db = "minMouseX: " + minMouseX + "/" + maxMouseX + " minMouseY: " + minMouseY + "/" + maxMouseY;
	//
	if(document.layers) {
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = detectMousePos;
	if (bObj.ie) { 
		document.onmouseover = null;
	} else { 
	 	document.releaseEvents(Event.MOUSEOVER);
	};
	//03/22
	var anIfr = ple_getObj("content_iframe");
	if(anIfr!=null) {		
		//anIfr.test(); //document.onmousemove = "alert('test');"; //"anIfr.whocare()";
		//parent.content_iframe.test();
		//parent.frames["content_iframe"].document.attachEvent('onmousemove', whocarex);
		if(bObj.ie) {
			parent.frames["content_iframe"].document.attachEvent('onmousemove', whocarex);
		}else {
			document.getElementById("content_iframe").addEventListener('onmousemove', whocarex, true);
		}
		//document.getElementById("content_iframe").document.onmousemove = "alert('test');";
	}
}
//********************************************************************************************************
function whocarex() {
	//alert("here");
	//window.status="here_ok" + new Date;
	ple_hide(currDd);
	navOff(currDdID)
	currDd=null;
	if (bObj.ie || bObj.ns6) { 
 		parent.frames["content_iframe"].document.detachEvent('onmousemove', whocarex);
 	} else {
 		//alert("test"); 
 		parent.frames["content_iframe"].document.releaseEvents(Event.MOUSEMOVE);
 	}
}
//********************************************************************************************************
function detectMousePos(e) {
	//window.status = "detectMousePos ";
	mouseY  =	(bObj.ie) ? event.y : e.pageY;
	mouseX  =	(bObj.ie) ? event.x : e.pageX;
	
	if(mouseY < minMouseY || mouseY > maxMouseY || mouseX < minMouseX || mouseX > maxMouseX) {
		//alert("here: " + currDd);
		ple_hide(currDd);
		currDd=null;
		navOff(currDdID);
		if (bObj.ie || bObj.ns6) { 
 			document.onmousemove = null;
 		 } else { 
 		 	document.releaseEvents(Event.MOUSEMOVE);
 		}
	}
	//window.status = db + " current:  " + mouseX + "/ " + mouseY;
}
//********************************************************************************************************
function mouseOverStyle($obj) {
	//divObj = ple_getObj($divID);
	if(bObj.ns) {
		//$obj.bgColor = "#99FFFF";
		$obj.bgColor = "#009999";
		//$obj.style.color="000000";
		$obj.style.color="white";
	} else {
		//alert("here" + $obj);
		//$obj.style.backgroundColor='#99FFFF';
		$obj.style.backgroundColor='#009999';
		//$obj.style.color="000000";
		$obj.style.color="white";
	}
}		
//********************************************************************************************************
function mouseOverStylex($divID) {
	divObj = ple_getObj($divID);
	//alert(divObj);
	if(bObj.ns) {
		//divObj.bgColor = "#66CCFF";
		divObj.bgColor = "#000000";
	} else {
		//divObj.style.backgroundColor="#66CCFF";
		divObj.style.backgroundColor="#000000";
	}
}	
//********************************************************************************************************
function mouseOutStyle($obj) {
	//divObj = ple_getObj($divID);
	$obj.style.backgroundColor="#000000";
	$obj.style.color="FFFFFF";
}
//********************************************************************************************************
var fullIFrame = "<iframe src=\"bott_isza_home.asp\" width=\"100%\" height=\"100%\" scrolling=\"yes\" frameborder=\"0\" id=\"content_iframe\">Your browser does not support iframe.</iframe>";
var subMenuIFrame = "<iframe src=\"#\" width=\"100%\" height=\"100%\" scrolling=\"no\" frameborder=\"0\" id=\"sub_iframe\">Your browser does not support iframe.</iframe>";
var halfIFrame = "<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"16%\">" + subMenuIFrame + "</td><td align=\"right\">" + fullIFrame + "</td></tr></table>";
function updateIFrame($1, $idx, $subMenu) {
	ifrDivObj = ple_getObj("iframe_div");
	if($subMenu!=null) {
		ifrDivObj.innerHTML =  halfIFrame;
		var subMenuObj = ple_getObj("sub_iframe");
		subMenuObj.src = $subMenu;
	}else {
		ifrDivObj.innerHTML =  fullIFrame;
	}
	//alert($1);
	//alert($idx);
	//var imgObj = ple_getObj(imgNameArr[$idx]);
	//if(currDdID != -1){
		//alert("here");
		ple_hide(currDd);
		currDd=null;
	//	navOff(currDdID);
	//}
	currDdID = $idx;
	//navOn($idx);
	currDd = ple_getObj("menu" + $idx);
	//
	currLoc=$idx;
	navOn(currLoc);
	for(i=0; i<imgNameArr.length; i++) {
		if(i!=currLoc) {
			navOff(i);
		}
	}
	//
	if (bObj.ie || bObj.ns6) { 
 		document.onmousemove = null;
 	} else { 
 	 	document.releaseEvents(Event.MOUSEMOVE);
 	}
	//
	var anIfr = document.getElementById("content_iframe");
	anIfr.src = $1;
	trackPage($1);
}
//********************************************************************************************************
function trackPage($1) {
	var trackPgIfr = ple_getObj("trackpg_iframe");
	if(trackPgIfr!=null) {
		//alert("here");
		trackPgIfr.src="trackpage.asp?currpg="+$1;
	}	
}	
//********************************************************************************************************
function updateIFrameFromSubMenu($1) {
	var anIfr = ple_getObj("content_iframe");
	anIfr.src = $1;
}
//********************************************************************************************************
function printIFrame() {
	//alert("here");
	var anIfr = null;
	if(bObj.ie) {
		anIfr = document.frames("content_iframe");
	} else {
		alert("not ie: " + window.frames.length);
		anIfr = window.frames["content_iframe"]; //
	}
	//alert(anIfr);
	anIfr.focus();
	anIfr.print();
	//content_iframe.print();
}
//********************************************************************************************************
function viewPrintFriendlyIFrame() {
	var anIfr = document.getElementById("content_iframe");
	var isrc = anIfr.src;
	window.open(isrc, 'CreditCardProcessing', 'toolbar=yes,scrollbars=yes,location=yes,status=yes,menubar=0,resizable=yes,width=800,height=500,left=100,top=100');
}
//********************************************************************************************************	
