/*
	Drop down script
*/

var isDom = document.getElementById;

var focusElem = null;
function dropdown( obj )
{
	if( focusElem != null )
	{
		focusElem.className = focusElem.className.replace(" over", "");
	}
	focusElem = obj.parentElement;
	focusElem.className += ' over';
}

swDropMenu = function() {
	if (document.getElementById) {
		navRoot = document.getElementById("swDropMenu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.className == "swDrop") 
				node.firstChild.onfocus = function() {dropdown(this)}; // JWJ
			{
				node.onmouseover = function() 
				{
					this.className += " over";
					this.firstChild.className += " expanded";
				}
				node.onmouseout = function()
				{
					this.className = this.className.replace(" over", "");
					if (this.firstChild.className == "selected expanded") this.firstChild.className = "selected";
					if (this.firstChild.className == " expanded" || this.firstChild.className == "expanded") this.firstChild.className = "";
				}
			}
		}
	}
}

/*
	Global menu mouseover
*/
if (document.images) { 

  img1_on = new Image(); 
  img1_on.src = "graphics/Frontend/Global-nav/global-hkp-sel.gif"; 
  img1_off = new Image(); 
  img1_off.src = "graphics/Frontend/Global-nav/global-hkp.gif"; 
} 

function ms( imagename, action ) { 
  if ( document.images ) { 
eval('document.images.' +imagename + '.src=' + imagename + '_' + action +'.src'); 
  } 
} 


/*
	PopUp window
*/
function PopWin(url,h,w,css) {
	popupWin = window.open(url+'?sendlink='+escape(document.location.href)+'&sCss='+css, 'popup', 'height=' + h + ',width=' + w + ',top=50,left=25')
}

/*
	Combobox selector

	mode 1 = Open in new window
*/
function LinkSelect(form, sel, mode) 
{
	c = sel.selectedIndex;
    adrs = sel.options[c].value;
    if (adrs != "-" && mode == 1)
    {
		window.open(adrs, 'New')
	 }
		else {
			parent.location.href = adrs;
		}
}
/* 

	Show/Hide function

*/
function fncToggleShow(pDiv) {
	if (isDom) { document.getElementById(pDiv).style.visibility=(document.getElementById(pDiv).style.visibility=='hidden')? 'visible':'hidden'; }
}


function $() {
	var elements = new Array();
	for (var i=0;i<arguments.length;i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);
		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}

var BoxHeights = {
	maxh: 0,
	boxes: Array(),
	num: 0,
	op_test: false,
	equalise: function() {
		this.num = arguments.length;
		for (var i=0;i<this.num;i++) if (!$(arguments[i])) return;
		this.boxes = arguments;
		this.maxheight();
		for (var i=0;i<this.num;i++) $(arguments[i]).style.height = this.maxh+"px";
	},
	maxheight: function() {
		var heights = new Array();
		for (var i=0;i<this.num;i++) {
			if (navigator.userAgent.toLowerCase().indexOf('opera') == -1) {
				heights.push($(this.boxes[i]).scrollHeight);
			} else {
				heights.push($(this.boxes[i]).offsetHeight);
			}
		}
		heights.sort(this.sortNumeric);
		this.maxh = heights[this.num-1];
	},
	sortNumeric: function(f,s) {
		return f-s;
	}
}

function showLinks(n){
	document.getElementById(n).style.display='block';
}

function dontShowLinks(n){
	document.getElementById(n).style.display='none';
}

