
/* global nav feature dropdown submenu script start here  */
function subPopup1(mId) {
	$('#' + mId).css("visibility", "visible");
}
function subPopup0(mId) {
	$('#' + mId).css("visibility", "hidden");
}
/* global nav feature dropdown submenu script ends here */

/* magazine menu script start here */
var timeout = 100;
var closetimer = 0;
var ddmenuitem = 0;
// open hidden layer
function mopen(id) {
	// cancel close timer
	mcancelclosetime();
	// close old layer
	if (ddmenuitem) {
		ddmenuitem.css( {
			"visibility" :"hidden",
			"display" :"none"
		});
	}
	// get new layer and show it
	ddmenuitem = $('#' + id);
	ddmenuitem.css( {
		"visibility" :"visible",
		"display" :"block"
	});
}
// close showed layer
function mclose() {
	if (ddmenuitem) {
		ddmenuitem.css( {
			"visibility" :"hidden",
			"display" :"none"
		});
	}
}
// go close timer
function mclosetime() {
	closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime() {
	if (closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
document.onclick = mclose;
/* magazine menu script ends here */


/* Show and hide div script */
function toggleBoxTab(prefix) {
	var links = document.getElementsByTagName('li');
	for (i = 0; i < links.length; i++) {
		if (links[i].id.indexOf(prefix) == 0) {
			if (links[i].id == prefix + c) {
			} else {

			}
		}
	}
}

function showBoxDiv(prefix, vid) {
	var divs = document.getElementsByTagName('div');

	for (i = 0; i < divs.length; i++) {
		if (divs[i].id.indexOf(prefix) == 0) {
			if (divs[i].id == vid) {
				if (1) { // DOM3 = IE5, NS6
					divs[i].style.display = 'block';
					divs[i].style.visibility = 'visible';
					divs[i].style.height = '';
				} else if (document.layers) { // Netscape 4
					document.layers[divs[i]].display = 'visible';
				} else { // IE 4
					document.all.divs[i].visibility = 'visible';
				}
			} else if (1) {
				divs[i].style.display = 'none';
				divs[i].style.visibility = 'hidden';
				divs[i].style.height = '0px';
			} else if (document.layers) {
				document.divs[i].visibility = 'hidden';
			} else { // IE 4
				document.all.divs[i].visibility = 'hidden';
			}
		}
	}
}
/* Show and hide div script ends */



function ciFixtutetooltip(curobj, widgets_hiddenobj) {
	$('.fixTooltip').hide();
	var curobj = $(curobj);
	var offset = curobj.offset();
	$("#" + widgets_hiddenobj).css( {
		left :(offset.left + (25)) + 'px',
		top :(offset.top + (8)) + 'px',
		"display" :"block"
	});
}

function ciFixtutetooltipclose(widgets_hiddenobj) {
	$("#" + widgets_hiddenobj).css("display", "none")
}

viewport = {
	getWinWidth : function() {
		this.width = 0;
		if (window.innerWidth)
			this.width = window.innerWidth - 18;
		else if (document.documentElement
				&& document.documentElement.clientWidth)
			this.width = document.documentElement.clientWidth;
		else if (document.body && document.body.clientWidth)
			this.width = document.body.clientWidth;
	},

	getWinHeight : function() {
		this.height = 0;
		if (window.innerHeight)
			this.height = window.innerHeight - 18;
		else if (document.documentElement
				&& document.documentElement.clientHeight)
			this.height = document.documentElement.clientHeight;
		else if (document.body && document.body.clientHeight)
			this.height = document.body.clientHeight;
	},

	getScrollX : function() {
		this.scrollX = 0;
		if (typeof window.pageXOffset == "number")
			this.scrollX = window.pageXOffset;
		else if (document.documentElement
				&& document.documentElement.scrollLeft)
			this.scrollX = document.documentElement.scrollLeft;
		else if (document.body && document.body.scrollLeft)
			this.scrollX = document.body.scrollLeft;
		else if (window.scrollX)
			this.scrollX = window.scrollX;
	},

	getScrollY : function() {
		this.scrollY = 0;
		if (typeof window.pageYOffset == "number")
			this.scrollY = window.pageYOffset;
		else if (document.documentElement && document.documentElement.scrollTop)
			this.scrollY = document.documentElement.scrollTop;
		else if (document.body && document.body.scrollTop)
			this.scrollY = document.body.scrollTop;
		else if (window.scrollY)
			this.scrollY = window.scrollY;
	},

	getAll : function() {
		this.getWinWidth();
		this.getWinHeight();
		this.getScrollX();
		this.getScrollY();
	}

}

var menuLayers = {
	timer :null,
	activeMenuID :null,
	offX :4, // horizontal offset
	offY :0, // vertical offset
	show : function(id, e) {
		var mnu = document.getElementById ? document.getElementById(id) : null;
		if (!mnu)
			return;
		this.activeMenuID = id;
		if (mnu.onmouseout == null)
			mnu.onmouseout = this.mouseoutCheck;
		if (mnu.onmouseover == null)
			mnu.onmouseover = this.clearTimer;
		viewport.getAll();
		this.position(mnu, e);
	},

	hide : function() {
		this.clearTimer();
		if (this.activeMenuID && document.getElementById)
			this.timer = setTimeout("$('#'+'" + menuLayers.activeMenuID
					+ "').css('visibility','hidden')", 200);
	},

	position : function(mnu, e) {
		var x = e.pageX ? e.pageX : e.clientX + viewport.scrollX;
		var y = e.pageY ? e.pageY : e.clientY + viewport.scrollY;

		if (x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX)
			x = x - mnu.offsetWidth - this.offX;
		else
			x = x + this.offX;

		if (y + mnu.offsetHeight + this.offY > viewport.height
				+ viewport.scrollY)
			y = (y - mnu.offsetHeight - this.offY > viewport.scrollY) ? y
					- mnu.offsetHeight - this.offY : viewport.height
					+ viewport.scrollY - mnu.offsetHeight;
		else
			y = y + this.offY;

		mnu.style.left = x + "px";
		mnu.style.top = y + "px";
		this.timer = setTimeout("$('#'+'" + menuLayers.activeMenuID
				+ "').css('visibility','visible')", 200);
	},

	mouseoutCheck : function(e) {
		e = e ? e : window.event;
		// is element moused into contained by menu? or is it menu (ul or li or
		// a to menu div)?
	var mnu = $("#" + menuLayers.activeMenuID);
	var toEl = e.relatedTarget ? e.relatedTarget : e.toElement;
	if (mnu != toEl && !menuLayers.contained(toEl, mnu))
		menuLayers.hide();
},

// returns true of oNode is contained by oCont (container)
	contained : function(oNode, oCont) {
		if (!oNode)
			return; // in case alt-tab away while hovering (prevent error)
		while (oNode = oNode.parentNode)
			if (oNode == oCont)
				return true;
		return false;
	},

	clearTimer : function() {
		if (menuLayers.timer)
			clearTimeout(menuLayers.timer);
	}

}

/* Global photo module */
first = 1;
galfirst = 1;
walfirst = 1;
scrsvrfirst = 1;

last = 10;
gallast = 10;
wallast = 10;
scrsvrlast = 10;

current = 1;
galcurrent = 1;
walcurrent = 1;
scrsvrcurrent = 1;
function nextPicture() {
	object = $('#ptsGalslide' + current);
	object.css("display", "none");
	if (current == last) {
		current = 1;
	} else {
		current++;
	}
	object = $('#ptsGalslide' + current);
	object.css("display", "block");
}
function previousPicture() {
	object = $('#ptsGalslide' + current);
	object.css("display", "none");
	if (current == first) {
		current = last;
	} else {
		current--;
	}
	object = $('#ptsGalslide' + current);
	object.css("display", "block");
}
// Wall Paper Galslide
function nextGalslide() {
	object = $('#Galslide' + galcurrent);
	object.css("display", "none");
	if (galcurrent == gallast) {
		galcurrent = 1;
	} else {
		galcurrent++;
	}
	object = $('#Galslide' + galcurrent);
	object.css("display", "block");
}
function previousGalslide() {
	object = $('#Galslide' + galcurrent);
	object.css("display", "none");
	if (galcurrent == galfirst) {
		galcurrent = gallast;
	} else {
		galcurrent--;
	}
	object = $('#Galslide' + galcurrent);
	object.css("display", "block");
}
function nextWalpaper() {
	object = $('#walPaperslide' + walcurrent);
	object.css("display", "none");
	if (walcurrent == wallast) {
		walcurrent = 1;
	} else {
		walcurrent++;
	}
	object = $('#walPaperslide' + walcurrent);
	object.css("display", "block");
}
function previousWalpaper() {
	object = $('#walPaperslide' + walcurrent);
	object.css("display", "none");
	if (walcurrent == walfirst) {
		walcurrent = wallast;
	} else {
		walcurrent--;
	}
	object = $('#walPaperslide' + walcurrent);
	object.css("display", "block");
}
function nextScreensvr() {
	scrobject = $('#screenSvrslide' + scrsvrcurrent);
	scrobject.css("display", "none");
	if (scrsvrcurrent == scrsvrlast) {
		scrsvrcurrent = 1;
	} else {
		scrsvrcurrent++;
	}
	scrobject = $('#screenSvrslide' + scrsvrcurrent);
	scrobject.css("display", "block");
}
function previousScreensvr() {
	scrobject = $('#screenSvrslide' + scrsvrcurrent);
	scrobject.css("display", "none");
	if (scrsvrcurrent == scrsvrfirst) {
		scrsvrcurrent = scrsvrlast;
	} else {
		scrsvrcurrent--;
	}
	scrobject = $('#screenSvrslide' + scrsvrcurrent);
	scrobject.css("display", "block");
}
/* Global photo module ends */

function hide_div(named) {
	var viral_divelement = document.getElementById(named);
	left = left;
	viral_divelement.style.display = "none";
	return;
}

