
// Constants
var DROP_ITEM_OFF_CLASS = "item-off";
var DROP_ITEM_ON_CLASS = "item-on";
var DROP_DISAPPEAR_MS = 4000;

var initDone = false;

// A Stack to keep track of window timeouts
var timeoutIDs = [];

// Array of objects describing the drop menus and their parent images
var drop = [
	[ 'drop_services', 'nav_services', new Image(), new Image() ],
	[ 'drop_company', 'nav_company', new Image(), new Image() ]
];

//drop[0][2].src = '/Media/Images/nav-services3.gif';
//drop[0][3].src = '/Media/Images/nav-services3.gif';
//drop[1][2].src = '/Media/Images/nav-services3.gif';
//drop[1][3].src = '/Media/Images/nav-services3.gif';

function Point(x, y) {
	this.x = x;
	this.y = y;
}

function getObj(id) {
	if(document.layers) {
		return document.layers[id];
	} else if(document.all) {
		return document.all[id];
	} else if(document.getElementById) {
		return document.getElementById(id);
	}
}

function getPosition(el) {
	if(document.all) {
		return getPositionIE(el);
	} else if(document.getElementById) {
		return getPositionNS(el);
	}
}

function getPositionNS(el) {
	return new Point(el.x, el.y);
}

function getPositionIE(el) {
	var r = new Point(el.offsetLeft, el.offsetTop);
	
	if(el.offsetParent) {
		var tmp = getPositionIE(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}

	return r;
}

function dropItemOver(obj) {
	obj.className = DROP_ITEM_ON_CLASS;
}

function dropItemOut(obj) {
	obj.className = DROP_ITEM_OFF_CLASS;
}

function dropItemClick(obj) {
	document.location.href = obj.href;
}

function navOver(obj, index) {
	if(!initDone) return;
	
	dropHideAll();
	var target = getObj(drop[index][0]);
	target.style.display = 'block';
	timeoutIDs.push([ window.setTimeout('dropHideAll();', DROP_DISAPPEAR_MS), obj, index ]);
	obj.src = obj.src; //drop[index][3].src;
}

function navOut(obj, index) {
	// Noop
}

function dropHide(index) {
	var target = getObj(drop[index][0]);
	target.style.display = 'none';
}

function dropHideAll() {
	for(var i = 0; i < drop.length; i++) {
		var target = getObj(drop[i][0]);
		target.style.display = 'none';
	}
	while(timeoutIDs.length > 0) {
		var timeout = timeoutIDs.pop();
		window.clearTimeout(timeout[0]);
		//timeout[1].src = drop[timeout[2]][2].src;
	}
}

function putObj(theParent, theTarget, offsetX, offsetY) {
    var pt = getPosition(theParent);
    theTarget.style.top = new String(pt.y + offsetY) + 'px';
    theTarget.style.left = new String(pt.x + offsetX) + 'px';
    return pt;
}


function initDrops() {
	for(var i = 0; i < drop.length; i++) {
		var el = getObj(drop[i][1]);
		var target = getObj(drop[i][0]);
		var pt;
		
		pt = putObj(el, target, 0, el.offsetHeight + 1);
	}
	initDone = true;
}

function init() {
	initDrops();
	dropHideAll();
}

function leaveSite() {
     return confirm('You are now being redirected to the European web site. \nIf you are a U.S. citizen access is not allowed. \nPress OK if you are not U.S. citizen.');
}

function leaveSite2() {
	return confirm('Clicking Ok confirms your understanding that Eurofins\nis not publicly traded in any US Markets.');
}

function showEmergency(){
	var div = getObj('EmergencyDiv');
	div.style.display = 'block';
}

function hideEmergency(){
	var div = getObj('EmergencyDiv');
	div.style.display = 'none';
}

function showFund(){
	var div = getObj('FundDiv');
	div.style.display = 'block';
}

function hideFund(){
	var div = getObj('FundDiv');
	div.style.display = 'none';
}

