
////////////////////
// XSWAP
////////////////////
xSwap = function(name){
	this.name = name;
	this.images = {};
	this.restoresrc = null;
	this.nest = "undefined";
};
xSwap.prototype.add = function(state,src){
	this.images[state] = new Image();
	this.images[state].src = src;
};
xSwap.prototype.swap = function(state){
	var img = this.getImage();
	this.restoresrc = img.src;
	img.src = this.images[state].src;
};
xSwap.prototype.restore = function(){
	if(this.restoresrc){
		this.getImage().src = this.restoresrc;
		this.restoresrc = null;
	}
};
xSwap.prototype.getImage = function(){// Private
	if(document.layers && this.nest == "undefined") this.nest = this.getLayer();
	if(document.layers && this.nest != false){
		return this.nest.document.images[this.name];
	}else{
		return document.images[this.name];
	}
};
xSwap.prototype.getLayer = function(root){// Private
	var i, k, layer, found = false;
	if(!root) root = window;
	for(i = 0; i < root.document.layers.length; i++){
		layer = root.document.layers[i];
		for(k = 0; k < layer.document.images.length; k++){
			if(layer.document.images[k].name == this.name){
				return layer;
			}
		}
		if(layer.document.layers.length) found = this.getLayer(layer);
		if(found) return found;
	}
	return false;
};


function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

var menutimer;
	
function showMenu(who,sub){
	closeall();
	omt();
	
	var ns = document.getElementById(sub);
	var nxpos = findPosX(who)+"px";
	ns.style.left = nxpos;
	var nypos = (findPosY(who)+30)+"px";
	ns.style.top = nypos;
	ns.style.display = "block";
}

function cmt(){
	omt();
	menutimer = setTimeout("closeall()",1000);
}

function closeall(){
	var ns = document.getElementById("sub_mag");
	ns.style.display = "none";
	
	var ns = document.getElementById("sub_inc");
	ns.style.display = "none";
	
	var ns = document.getElementById("sub_be");
	ns.style.display = "none";
	
	var ns = document.getElementById("sub_five");
	ns.style.display = "none";
}


function omt(){
	clearTimeout(menutimer);
}


mag_obj = new xSwap ("bnt_mag");
mag_obj.add ("over","http://www.inc.com/mediakit/images/nav_incmag_o.gif");

inc_obj = new xSwap ("btn_inc");
inc_obj.add ("over","http://www.inc.com/mediakit/images/nav_inc_o.gif");

be_obj = new xSwap ("btn_be");
be_obj.add ("over","http://www.inc.com/mediakit/images/nav_incbe_o.gif");

five_obj = new xSwap ("btn_five");
five_obj.add ("over","http://www.inc.com/mediakit/images/nav_inc500_o.gif");
