var chosenDL = null;
if(navigator.userAgent.match(/msie/i)){ var IE = true; } 

function positionPopOver()
{
	var wHeight = document.viewport.getHeight();
	var wWidth = document.viewport.getWidth();
	var pHeight = $('container').getStyle('height');
	var poLeft = 65;
	pHeight = pHeight.replace("px","");
	if (wWidth > 719)
	{
		poLeft = ((parseInt(wWidth) - 719) / 2) + 65;
	}
	pHeight = parseInt(pHeight);
	if (wHeight > pHeight){pHeight = wHeight;}
	$('dl_popOverScreen').setStyle({ height:pHeight+'px' });
}

function showPopOver(e)
{
	Event.stop(e);
	var elt = Event.element(e);
	chosenDL = elt.href;
	positionPopOver();
	if (!IE) { $('dl_popOverScreen').show(); }
	$('dl_popOver').show();
	new Effect.ScrollTo('container');  
}

function loadSelectedDownload(e)
{
	Event.stop(e);
	window.location=chosenDL;
	if (!IE) { $('dl_popOverScreen').hide(); }
	$('dl_popOver').hide();
}

function hidePopOver(e)
{
	Event.stop(e);
	if (!IE) { $('dl_popOverScreen').hide(); }
	$('dl_popOver').hide();
}

function initialize()
{
	if($('download_ok') != null){Event.observe('download_ok', 'click', loadSelectedDownload, false);}
	if($('download_cancel') != null){Event.observe('download_cancel', 'click', hidePopOver, false);}
	$$('.download_trig').each(function (elem) { Event.observe(elem, 'click', showPopOver, false); });
}

Event.observe(window, 'load', initialize, false);


//suckerfish dropdowns//
sfHover = function() {
	
	var sfEls = document.getElementById("headerNavUL").getElementsByTagName("LI");
	var sfPLs = document.getElementById("headerNavUL").getElementsByTagName("a");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			$$('.selectSorter').each(function (sel) { sel.hide(); });
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			$$('.selectSorter').each(function (sel) { sel.show(); });
		}
	}
	
	var sfEl2s = document.getElementById("languageDropUp").getElementsByTagName("LI");
	var sfPL2s = document.getElementById("languageDropUp").getElementsByTagName("a");
	for (var j=0; j<sfEl2s.length; j++) {
		sfEl2s[j].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEl2s[j].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	
	var sfEl3s = document.getElementById("otherSitesDropUp").getElementsByTagName("LI");
	var sfPL3s = document.getElementById("otherSitesDropUp").getElementsByTagName("a");
	for (var k=0; k<sfEl3s.length; k++) {
		sfEl3s[k].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEl3s[k].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
		
}
if (window.attachEvent){window.attachEvent("onload", sfHover);}

