// JavaScript Document
//
var loadArray = new Array("home_over","profile_over","technology_over","people_over","contact_us_over","careers_over","news_over","ispider_over","norwegian_flag_over","uae_flag_over","uk_flag_over","usa_flag_over",'ered_over.gif','building_news_over.gif','newsletter_over.gif');
var preload=new Array();
for (var i=0; i<loadArray.length; i++){
  preload[i]=new Image();
  preload[i].src="../images/nav/"+loadArray[i]+".gif";
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//
// by Paul@YellowPencil.com and Scott@YellowPencil.com
// feel free to delete all comments except for the above credit

function setTall() {
	if (document.getElementById) {
		// the divs array contains references to each column's div element.  
		// Replace 'center' 'right' and 'left' with your own.  
		// Or remove the last one entirely if you've got 2 columns.  Or add another if you've got 4!
		var divs = new Array(document.getElementById('left_column'), document.getElementById('centre_column'), document.getElementById('right_column'));
		//
		// Let's determine the maximum height out of all columns specified
		var maxHeight = 0;
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
		}
		// Let's set all columns to that maximum height
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.height = maxHeight + 'px';
			// save max height for menu collapse function
			originalMaxHeight = maxHeight;
			//
			// Now, if the browser's in standards-compliant mode, the height property
			// sets the height excluding padding, so we figure the padding out by subtracting the
			// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
			if (divs[i].offsetHeight > maxHeight) {
				divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
			}
		}
	}
}
//
window.onload = function() {
	setTall();
}
/*
window.onresize = function() {
	setTall();
}*/
//
// sub menu control
//
menu_status = new Array();

function showHide(target){
if (target == 'showAll'){
	//show all
	for (var i=1;i<=2;i++){
		var show_id = document.getElementById('submenu_'+i);
		show_id.className = 'show';
        menu_status['submenu_'+i] = 'show';
	}	
	//
}else if (target == 'hideAll'){
	 //hide all
	 for (var i=1;i<=3;i++){
		var show_id = document.getElementById('submenu_'+i);
		show_id.className = 'hide';
        menu_status['submenu_'+i] = 'hide';
	}	
	 }else{
    if (document.getElementById) {
    var switch_id = document.getElementById('submenu_'+target);
		if(document.getElementById('submenu_'+target).className == 'show') {
//        if(menu_status['submenu_'+target] == 'show') {
           switch_id.className = 'hide';
           menu_status['submenu_'+target] = 'hide';
//document.getElementById(main).className = 'menu_arrow_down';
        }else{
           switch_id.className = 'show';
           menu_status['submenu_'+target] = 'show';
		   //document.getElementById(main).className = 'menu_arrow_right';
      	  }
		}
    }
	getMenuHeight();
}
//
// START SHOW ALL
var ids=new Array('submenu_1','submenu_2');
//
function hideAll(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}
//
function showAll(){
	//loop through the array and show each element by id
	for (var i=0;i<ids.length;i++){
		showdiv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
	menu_status.id = 'hide';
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
	alert (menu_status.id);
	menu_status.id = 'show';
	alert (menu_status.id);
}

//
//
function getMenuHeight(){
	var menuHeight = document.getElementById('submenu').offsetHeight;
	//+40;
	//	alert (originalMaxHeight);
	//
	var divs = new Array(document.getElementById('left_column'), document.getElementById('centre_column'), document.getElementById('right_column'));
	//
	if (menuHeight > originalMaxHeight){
	//	alert ("true");
		newHeight = menuHeight+40;
	}else{
		newHeight = originalMaxHeight;
	//	alert ("false");
	}
	//
	for (var i = 0; i < divs.length; i++) {
		divs[i].style.height = newHeight + 'px';
	}
}
//
//
function showProducts(){
    if (document.getElementById) {
    var switch_id = document.getElementById('productsMenu');
        if(menu_status['productsMenu'] != 'show') {
			//alert ("working");
			switch_id.className = 'show';
			menu_status['productsMenu'] = 'show';
   		   //document.getElementById(main).className = 'menu_arrow_down';
        }else{
			switch_id.className = 'hide';
			menu_status['productsMenu'] = 'hide';
		   //document.getElementById(main).className = 'menu_arrow_right';
        }
    }
}
// Gallery script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
/*function LoadGallery(pictureName,imageFile,btn)
{
//  if (document.all)
	var browserName=navigator.appName;
	if (browserName=="Microsoft Internet Explorer")
  {
	document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
    document.getElementById(pictureName).filters.blendTrans.Apply();
  }
  document.getElementById(pictureName).src = imageFile;
  // change button status
		for (var i = 1; i < 6; i++) {
			document.getElementById('btn0'+i).className = 'normal_btn';
		}
	document.getElementById(btn).className = 'active_btn';
  //
//  if (document.all)
  	if (browserName=="Microsoft Internet Explorer")
  {
    document.getElementById(pictureName).filters.blendTrans.Play();
  }
//  document.getElementById(titleCaption).innerHTML=captionText;
}*/

var buttondown = "btn01";
var buttondownb = "btn01b";
//
function LoadGallery(pictureName,imageFile,titleCaption,btn,captionText) {
	var browserName=navigator.appName;
	if (browserName=="Microsoft Internet Explorer") {
		document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
    	document.getElementById(pictureName).filters.blendTrans.Apply();
  		}
	document.getElementById(pictureName).src = imageFile;
	// change button status
	if (pictureName == 'ImageGallery'){
		document.getElementById(buttondown).className = 'normal_btn';
		document.getElementById(btn).className = 'active_btn';
		buttondown = btn;	
		}else{
		document.getElementById(buttondownb).className = 'normal_btn';
		document.getElementById(btn).className = 'active_btn';
		buttondownb = btn;
	}
	//
	if (browserName=="Microsoft Internet Explorer") {
		document.getElementById(pictureName).filters.blendTrans.Play();
		}
	// new bit
	 document.getElementById(titleCaption).innerHTML=captionText;
}