//copyright 2000; Gravity Media Group.
//this code may be used only for the purposes for which
//it was purchased. Unauthorized duplication or usage is
//prohibited.
//contact scott@gravitymedia.com with any questions.

if (typeof(is) == "undefined") {
	alert("You need to load browsercheck.js before using the two-image-rollovers.");
}

fInit = false;
relight = null;
reposFlag = true;
arPopups = new Object();

if (is.dom==1) {
	if (typeof(window.gravity) != "object") {
		window.gravity = new Object();
	}
	window.gravity.reloadCheck = function() { if(window.gravity.reloadCheck.x != window.innerWidth || window.gravity.reloadCheck.y != window.innerHeight) document.location = document.location; }
	window.gravity.reloadCheck.x = window.innerWidth;
	window.gravity.reloadCheck.y = window.innerHeight;
	window.onresize = window.gravity.reloadCheck;
} else if ( is.dom >= 2 ) {
	window.onresize = function() { InitRollovers(); }
}

function setCoords(which, top, right, bottom, left) {

	arPopups[which] = new Object();
	arPopups[which].coords = new Array();
	arPopups[which].coords[0] = top;
	arPopups[which].coords[1] = right;
	arPopups[which].coords[2] = bottom;
	arPopups[which].coords[3] = left;
	arPopups[which].timer = null;
}

function mapOver(el, which, on, showmenu) {
	showmenu = false;
	if (typeof(showmenu) == "undefined") {
		showmenu = true;
	}
	else if (showmenu == null) {
		showmenu = true;
	}
	
	if (which == null) return;
	
	if ((is.dom == 3) && (reposFlag)) {
		reposFlag = false;
		InitRollovers();
	}

	if (!fInit) return;
	clearTimeout(relight);

	topclip = arPopups[which].coords[0];
	rightclip = arPopups[which].coords[1];
	bottomclip = arPopups[which].coords[2];
	leftclip = arPopups[which].coords[3];


	eval("whichEl = el" + el + ";");
	if (on) {
		whichEl.clipTo(topclip, rightclip, bottomclip, leftclip);
		whichEl.show();
		
		if ((showmenu) && (arPopups[which].menu != null)) {
			clearTimeout(arPopups[which].timer);
			arPopups[which].menu.show();
		}
	}
	else {
		whichEl.hide(); 
		if ((pageBase != null) && (imDefault != null)) eval("relight = setTimeout(\"mapOver('" + imDefault + "', '" + pageBase + "', true, false)\", 1000);");

		if ((showmenu) && (arPopups[which].menu != null)) {
			arPopups[which].timer = setTimeout("arPopups['" + which + "'].menu.takeShowDuty();",100);
		}
	}
}


function InitRollovers() {
	var i;
	for (i = 0; i < ar2imr.length; i++) {
		if (!fInit) {
			eval("el" + ar2imr[i].name + " = new dEl('el" + ar2imr[i].name + "', " + document.images['im' + ar2imr[i].name].width + ")");
			eval("el" + ar2imr[i].name + ".write(\"" + ar2imr[i].imstr + "\");");
			eval("el" + ar2imr[i].name + ".moveToImage('im" + ar2imr[i].name + "', 0, 0);");
		} else{
			eval("el" + ar2imr[i].name + ".moveToImage('im" + ar2imr[i].name + "', 0, 0);");
		}
	}
	fInit = true;
}

function clipObject(name, imstr) {
	this.name = name;	
	this.imstr = imstr;
}

function rollElementStyles() {
	loadStr = "InitRollovers(";
	sStr = "<STYLE TYPE=\"text/css\">\n<!--\n";
	var i;
	for (i = 0; i < ar2imr.length; i++) {
		sStr += "#el" + ar2imr[i].name + "{position:absolute; visibility:hidden;}\n";
		sStr += "#im" + ar2imr[i].name + "{position:relative;}\n";
		loadStr += "'" + ar2imr[i].name + "'";
		if ( (i+1) < ar2imr.length ) loadStr += ",";
	}
	loadStr += ");";
	if ((pageBase != null) && (imDefault != null)) {
		loadStr += " mapOver('" + imDefault + "', '" + pageBase + "', true, false);";
	}
	sStr += "-->\n</STYLE>\n\n";
	
	addToOnload(loadStr);
	return sStr;
}