
// Javascript for DDL

	var active_ddl_id
	var active_ddl_anchor

	function DDL_HighlightRow(rowid) {
		//getObj(rowid).className = "RowSelected"
		document.getElementById(rowid).className = "RowSelected";
	}
	
	function DDL_DeHighlightRow(rowid) {
		//getObj(rowid).className = ""
		document.getElementById(rowid).className = "";
	}
	
	function DDL_ShowAtElement(ddl_id, elemid) {
		// find the position of 'elemid' and put the top-right corner there.
		
		var browseWidth = 0, browseHeight = 0;
		
		if ( document.layers || ( document.getElementById	&&	!document.all ) ){
		   browseWidth	=	window.outerWidth;
		   browseHeight	=	window.outerHeight;
		} else if ( document.all ) {
		   browseWidth	=	document.body.clientWidth;
		   browseHeight	=	document.body.clientHeight;
		}
		var left = findPosLeft(document.getElementById(elemid));
		var top  = findPosTop(document.getElementById(elemid));
		if (left + 440 > browseWidth  - 10) left = browseWidth  - 470
		if (top  + 200 > browseHeight - 10) top  = browseHeight - 210

		// show the container
		document.getElementById(ddl_id + "_Container").style.display = 'block';
		document.getElementById(ddl_id + "_Container").style.left    = left + "px";
		document.getElementById(ddl_id + "_Container").style.top     = top + "px";

		// show the root-pane, for off-menu click hiding
		document.getElementById(ddl_id + "_RootPane").style.height = document.body.clientHeight + "px";
		document.getElementById(ddl_id + "_RootPane").style.width = document.body.clientWidth + "px";
		document.getElementById(ddl_id + "_RootPane").style.display  = 'block';
		
		active_ddl_id = ddl_id;
		active_ddl_anchor_id = elemid;
	}
	
	function DDL_Reposition() {
		try {
			if (active_ddl_id != "" && active_ddl_anchor_id != "") {
				DDL_ShowAtElement(active_ddl_id, active_ddl_anchor_id);
			}
		} catch(err) {}
	}
	
	window.onresize = DDL_Reposition;
	
	function DDL_Hide(ddl_id) {
		// hide the dropdown
		
		document.getElementById(ddl_id + "_Container").style.display = '';
		document.getElementById(active_ddl_id + "_RootPane").style.display = '';
		
		active_ddl_id = "";
		active_ddl_anchor_id = "";
	}
	
	function getObj(name)
{
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	} else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else if (document.layers) {
		if (document.layers[name]) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
	}
}

function findPosLeft(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 findPosTop(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

/*********
    
    Tiny JS File for showing video Popups. Dont much like inline JS 
    
    16.06.06

 *********/

function popupURL(name, URL, theWidth, theHeight) {
	 window.open(URL,"popup_" + name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + theWidth + ",height=" + theHeight + ",top=20,left=20");
}

function AddCruiseToCookies(tourid, tourname) {
	createCookie("globus_" + tourid, tourname);
	window.location.reload();
}

function RemoveCruiseFromCookies(tourid) {
	eraseCookie("globus_" + tourid);
	document.getElementById('favtour_' + tourid).style.display = 'none';
}

function ShowEmailLinker() {
	document.getElementById('email_div').style.display = 'block';
}

function HideEmailLinker() {
	document.getElementById('email_div').style.display = 'none';
}

function createCookie(name,value,days)
{
	value = escape(value);
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}
