function getRandomBanner(module, isFlash)
{
	switch (module)
	{
		case "home":
			if (isFlash) 
				return Math.floor(Math.random() * 6) + 1;
			else
				return Math.floor(Math.random() * 22) + 1;
		case "aboutus":
			return Math.floor(Math.random() * 8) + 1;
		case "ouroperations":
			if (isFlash) 
				return Math.floor(Math.random() * 1) + 1;
			else
				return Math.floor(Math.random() * 5) + 1;
		case "currentprojects":
		case "newscentre":
		case "faq":
		case "sitemap":
		case "contactus":
		case "search":
			return Math.floor(Math.random() * 2) + 1;
		case "investorrelations":
		case "careers":
			return Math.floor(Math.random() * 3) + 1;
	}
}
	
function scrollToHash (hashName)
{
	if (navigator.userAgent.indexOf("Safari")!=-1) {	
		if (hashName = "#top") window.scrollTo(0,0);
	} else {
		location.hash=hashName;
	} 
}

function popUp(page, name, w, h, scroll) 
{	
	// need to round the value, Safari doesn't like non-integer value
	popLeft = Math.floor((screen.availWidth - w)/2);
	popTop = Math.floor((screen.availHeight - h)/2);

	if (navigator.appName == 'Netscape') {
		popWindow = window.open(page,name,'width='+w+',height='+h+',resizable=no,menubar=no,status=no,scrollbars='+scroll+',toolbar=no,directories=no,location=no,screenX='+popLeft+',screenY='+popTop);
		popWindow.focus();
	}	
	
    	else if (navigator.appName == 'Microsoft Internet Explorer') {
		popWindow = window.open(page,name,'width='+w+',height='+h+',resizable=no,menubar=no,status=no,scrollbars='+scroll+',toolbar=no,directories=no,location=no,top='+popTop+',left='+popLeft);
		popWindow.focus();
	}
 	
	else {
		popWindow = window.open(page,name,'width='+w+',height='+h+',resizable=no,menubar=no,status=no,scrollbars='+scroll+',toolbar=no,directories=no,location=no,top='+popTop+',left='+popLeft);
		popWindow.focus();
	}
 }


function displayDiv(id, array) {
	for (i=0; i<array.length; i++) {
		document.getElementById("div_list"+array[i]).style.display = "none";

		if (document.getElementById("div_img"+array[i]))
		{
			srcName = document.getElementById("div_img"+array[i]).src;
			document.getElementById("div_img"+array[i]).src = srcName.substring(0, srcName.lastIndexOf("_")) + "_off.gif";
		}

		if (document.getElementById("div_txt"+array[i]))
			document.getElementById("div_txt"+array[i]).childNodes[0].className = "";
	}
	document.getElementById("div_list"+id).style.display = "block";	
	
	if (document.getElementById("div_img"+id))
	{
		srcName = document.getElementById("div_img"+id).src;
		document.getElementById("div_img"+id).src = srcName.substring(0, srcName.lastIndexOf("_")) + "_on.gif";
	}

	if (document.getElementById("div_txt"+id))
		document.getElementById("div_txt"+id).childNodes[0].className = "selected";

	if (document.getElementsByName("list_nav_select"))
	{
		selectElements = document.getElementsByName("list_nav_select")

		for (i=0; i<selectElements.length; i++)
		{	
			for (j=0; j<selectElements.item(i).length; j++)
			{
				if (parseInt(selectElements.item(i).options[j].value) == parseInt(id))
				{
					// netscape 6.2 will have trouble setting selectedIndex if the combo box embedded in a div with display turned on/off not in focus
					if (navigator.appName=="Netscape")
						selectElements.item(i).focus();

					selectElements.item(i).selectedIndex = j;
				}
			}
		}
	}
}

function displayDataSet(id, array) {
	for (i=0; i<array.length; i++) {
		document.getElementById("dataSet"+array[i]).style.display = "none";
		if (document.getElementById("div_img"+array[i]))
		{
			srcName = document.getElementById("div_img"+array[i]).src;
			document.getElementById("div_img"+array[i]).src = srcName.substring(0, srcName.lastIndexOf("_")) + "_off.gif";
		}

		if (document.getElementById("div_txt"+array[i]))
			document.getElementById("div_txt"+array[i]).childNodes[0].className = "";
	}
	document.getElementById("dataSet"+id).style.display = "block";	
	
	if (document.getElementById("div_img"+id))
	{
		srcName = document.getElementById("div_img"+id).src;
		document.getElementById("div_img"+id).src = srcName.substring(0, srcName.lastIndexOf("_")) + "_on.gif";
	}
	
	if (document.getElementById("div_txt"+id))
		document.getElementById("div_txt"+id).childNodes[0].className = "selected";
}

function setTableAltColor(highlightCol, hasFirstColBorder) {
	tableElements = document.getElementsByName("alt_row_list");
	if (tableElements != null)
	{
		for (i=0; i<tableElements.length; i++)
		{
			for (j=0; j<tableElements.item(i).childNodes.length; j++)
			{
				if (tableElements.item(i).childNodes[j].tagName == "TBODY")
				{
					var count = 0;

					for (k=0; k<tableElements.item(i).childNodes[j].childNodes.length; k++)
					{
						if (count%2 == 0) {
							tableElements.item(i).childNodes[j].childNodes[k].className = "list_odd_row";
							if ((highlightCol > 0) && (tableElements.item(i).childNodes[j].childNodes[k].tagName == "TR")) 
							{
								if (tableElements.item(i).childNodes[j].childNodes[k].cells.length > 0)
									tableElements.item(i).childNodes[j].childNodes[k].cells[highlightCol-1].className = "list_odd_row_highlight";
								else {
									if (highlightCol == 1)
										tableElements.item(i).childNodes[j].childNodes[k].firstChild.className = "list_odd_row_highlight";
									else {
										tmpStr = "tableElements.item(i).childNodes[j].childNodes[k].firstChild";
										for (x=1; x<highlightCol; x++)
											tmpStr = tmpStr + ".nextSibling";
										eval(tmpStr).className = "list_odd_row_highlight";
									}
								}
							}
						}

						if (tableElements.item(i).childNodes[j].childNodes[k].tagName == "TR")
						{
							if (tableElements.item(i).childNodes[j].childNodes[k].cells.length > 0) { 
								if (!hasFirstColBorder) tableElements.item(i).childNodes[j].childNodes[k].cells[0].style.borderRight = "0px";
								tableElements.item(i).childNodes[j].childNodes[k].cells[tableElements.item(i).childNodes[j].childNodes[k].cells.length-1].style.borderRight = "0px";
							} else {
								if (!hasFirstColBorder) tableElements.item(i).childNodes[j].childNodes[k].firstChild.style.borderRight = "0px";
								tableElements.item(i).childNodes[j].childNodes[k].lastChild.style.borderRight = "0px";
							}
							count++;
						}
					}
				}
			}
		}
	}	
}
