//these functions are related to the dhtml portion of dcl in the network right nav
//see www/csjs/dcl/dcl.js for functions related to opening links

var mnuSelected = '';
var linkSelected = '';
var myCancel;
var status;

	function showMenu(num, difference) {
	
		//window.clearTimeout(myCancel);
		
		var menu = "menu" + num; 
		var linkID = "link" + num;
		
		hideMenu(mnuSelected, linkSelected);
		
		obj = document.getElementById(linkID)
			
		obj.style.color = '#C5920A';		
		
		oLeft = findPosX(obj);
		oTop = findPosY(obj);
		
		move (oTop, oLeft, menu, difference);
		
		document.getElementById(menu).style.visibility = 'visible';
   		
		mnuSelected = menu;
		linkSelected = linkID;
		
   	}
   	
	function hideMenu(menu, linkID) {
   		if (mnuSelected != '') {
      		document.getElementById(menu).style.visibility = 'hidden';
			document.getElementById(linkID).style.color = '#000099';
		}
   	}
	
	function move(top, left, id, diff) {	
		left = left - diff;
		document.getElementById(id).style.top = top + "px";		
		document.getElementById(id).style.left = left + "px";	
	}
	
	function findPosX(obj) {
		var curleft = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		return curleft;
	}

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

	
//this is to close all layers if they are open and user clicks somewhere else on the page
document.onclick = clickHandle;
function clickHandle() {
	hideMenu(mnuSelected, linkSelected);
}

	
	
function changeLayer (tab) {
	
	layerArray = new Array ("vacation", "air", "internatl", "last-minute");
	
	for (i = 0; i < layerArray.length; i++) {
		if (layerArray[i] == tab) {
			document.getElementById("worldWideLinks_" + tab).style.display = "block"
			document.getElementById(tab + "Img").src = "/images/dcl/footer_right_nav/worldwide-" + tab + "-on.gif";
		} else { 
			document.getElementById("worldWideLinks_" + layerArray[i]).style.display = "none"
			document.getElementById(layerArray[i] + "Img").src = "/images/dcl/footer_right_nav/worldwide-" + layerArray[i] + "-off.gif";
		}
	
	}
}