// Drop Down Javascript

var timeout        = 600;
var closetimer    = 0;
var subnav         = 0;
var prevObject;
 

// open hidden layer
function mopen(id){
            mcancelclosetime();
            mclose();
            subnav = document.getElementById(id);
            subnav.style.display = 'block';
            prevObject = id;

}

// close showed layer
function mclose(){
            if(subnav){
                        subnav.style.display = 'none';
                        prevObject = null;
            }
}

// go close timer
function mclosetime(){
            closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime(){
            if(closetimer){
                        window.clearTimeout(closetimer);
                        closetimer = null;
            }
}




var tcloseTimer	= 0;
var thirdLevel	= 0;
var prevThirdLevelObj;
// open hidden layer
function mtopen(id){
	mtcancelclosetime();
	if(thirdLevel){
		thirdLevel.style.borderTop = 'none';
		thirdLevel.style.display = 'none';	
	}
	thirdLevel = document.getElementById(id);
	thirdLevel.style.display = 'block';
	var howManyLinks = thirdLevel.getElementsByTagName('a');
	if(howManyLinks.length > 0) thirdLevel.style.borderTop = '1px solid #aaaaaa';
	prevThirdLevelObj = id;
	findPos(thirdLevel);
}
// close showed layer
function mtclose(){
	if(thirdLevel){
		thirdLevel.style.borderTop = 'none';
		thirdLevel.style.display = "none";
		prevThirdLevelObj = null;
	}
}
// go close timer
function mtclosetime(){
	tcloseTimer = window.setTimeout(mtclose, timeout);
}
// cancel close timer
function mtcancelclosetime(){
	if(tcloseTimer){
		window.clearTimeout(tcloseTimer);
		tcloseTimer = null;
	}
}

function findPos(obj) {
	var element = obj;
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		while (obj = obj.offsetParent) {
			if(obj.id == 'main'){
				isOverbounds(curleft, element);
				break;	
			}
			curleft += obj.offsetLeft
		}
	}
}
function isOverbounds(leftPos, element){
	if(leftPos > RIGHTMAX && element.className == "thirdLevel"){thirdLevel.style.left = -191 + "px";}
	if(leftPos > RIGHTMAX && element.className == "subnavItem"){subnav.style.left = RIGHTMAX + "px";}
}
function closeAll(){
	mclose();
	mtclose();
	checkToolsClose();
}










// show and reveal script

var prev = null;

function divShow(idShow){
	if (document.getElementById(idShow).style.display == "none"){	
	document.getElementById(idShow).style.display = "block"
	document.getElementById('emailUpdates').style.backgroundPosition = "bottom";
	}
	else
	{
	document.getElementById(idShow).style.display = "none";
	document.getElementById('emailUpdates').style.backgroundPosition = "top";
	}
}



 
function hidePopup(idPopup) {
	document.getElementById(idPopup).style.display = "none"
}
 
function showPopup(idPopup) {
	document.getElementById(idPopup).style.display = "block"
}

function uploadShow(idShow,idHide,tabShow,tabHide){
		document.getElementById(idShow).style.display = "block";
		document.getElementById(idHide).style.display = "none";	

	if(tabShow == "videoTabLink"){ 
		document.getElementById(tabShow).style.backgroundPosition = "top";
		document.getElementById(tabHide).style.backgroundPosition = "bottom";
	}
	else {
		document.getElementById(tabShow).style.backgroundPosition = "top";
		document.getElementById(tabHide).style.backgroundPosition = "bottom";

	}
}

function productsShow(tabShow){
	if(tabShow == "featuredTabLink"){ 
		document.getElementById("featuredProducts").style.display = "block";
		document.getElementById("featuredTabLink").style.backgroundPosition = "top";	
		document.getElementById("smallTabLink").style.backgroundPosition = "bottom";
		document.getElementById("mediumTabLink").style.backgroundPosition = "bottom";
		document.getElementById("largeTabLink").style.backgroundPosition = "bottom";
		document.getElementById("smallProducts").style.display = "none";
		document.getElementById("mediumProducts").style.display = "none";
		document.getElementById("largeProducts").style.display = "none";
	}
	
	if(tabShow == "smallTabLink"){ 
		document.getElementById("smallProducts").style.display = "block";
		document.getElementById("smallTabLink").style.backgroundPosition = "top";	
		document.getElementById("featuredTabLink").style.backgroundPosition = "bottom";
		document.getElementById("mediumTabLink").style.backgroundPosition = "bottom";
		document.getElementById("largeTabLink").style.backgroundPosition = "bottom";
		document.getElementById("featuredProducts").style.display = "none";
		document.getElementById("mediumProducts").style.display = "none";
		document.getElementById("largeProducts").style.display = "none";
	}
	if(tabShow == "mediumTabLink"){ 
		document.getElementById("mediumProducts").style.display = "block";
		document.getElementById("mediumTabLink").style.backgroundPosition = "top";		
		document.getElementById("smallTabLink").style.backgroundPosition = "bottom";
		document.getElementById("featuredTabLink").style.backgroundPosition = "bottom";
		document.getElementById("largeTabLink").style.backgroundPosition = "bottom";
		document.getElementById("smallProducts").style.display = "none";
		document.getElementById("featuredProducts").style.display = "none";
		document.getElementById("largeProducts").style.display = "none";

	}
	if(tabShow == "largeTabLink"){
		document.getElementById("largeProducts").style.display = "block";
		document.getElementById("largeTabLink").style.backgroundPosition = "top";				
		document.getElementById("smallTabLink").style.backgroundPosition = "bottom";
		document.getElementById("mediumTabLink").style.backgroundPosition = "bottom";
		document.getElementById("featuredTabLink").style.backgroundPosition = "bottom";
		document.getElementById("smallProducts").style.display = "none";
		document.getElementById("mediumProducts").style.display = "none";
		document.getElementById("featuredProducts").style.display = "none";

	}	
}
