// javascript functions to be inserted into HTML documents
// home level

//Browsercheck:
ie=document.all?1:0
n=document.layers?1:0
var stop_hide = false;
var timeout_id;
var isnav, isIE;
var coll = "";
var styleObj = "";
var obj ="";
var ns_refresh = "first load";

function preload(path){
	MM_preloadImages(path + 'imgs/ico_solutions_on.gif');
	MM_preloadImages(path + 'imgs/ico_news_on.gif');
	MM_preloadImages(path + 'imgs/ico_careers_on.gif');
	MM_preloadImages(path + 'imgs/ico_investor_on.gif');
	MM_preloadImages(path + 'imgs/ico_about_on.gif');
	//alert("test1");
}

function go(submenu,amount_subs, brake, heigth){
	//This function builds the content of the menu layer
	//submenu is the submenu number
	//amount_subs: is the amount of links in the submenu (this many TD have to be generated)
	//brake: is '<BR>' or '' when black layer it is at the top it has to be smaller. (on the home it is bigger) 
	//heigth: is height of table
	//alert("test");
	if (document){
		//alert("test2");
		obj = eval("document"+coll);
		if (obj.popup || obj.nspopup){
			if (isIE!=true){
				//alert("Yeah! i'm in this NS if!"); //for testing!
				if (obj.nspopup.src){
					obj.nspopup.src = "ns_menu" + submenu + ".html";
					//alert(obj.nspopup.src);
				}
			}else{
				//build HTML content for layer. This is the menu-navigation
				varHTML = "<table width='100%' height='" + heigth + "' border='0' cellspacing='0' cellpadding='0'>";
				varHTML += "<tr><td width='100%' bgcolor='#221919' align='center' onmouseover='' onmouseout=''>" + brake + "<p class='menutable'>"; 
				for (i=1;i<=amount_subs;i++){
					varHTML += "<a class='menusub' onmouseover='over_it(this); hide_off()' onmouseout='out_of(this); hide_on(); hide_timeout()' href='" + go_menu(submenu, i, "href") + "'>" + go_menu(submenu, i, "desc") + "</a>";
					if (i!=amount_subs){
						varHTML += " | ";
					}
				}
				varHTML +=  "</p></td></tr>";
				varHTML += "</table>";
				//document.write(varHTML); //for getting HTML
				//initialize obj (this is not the same for NS and IE !! fools!
				//actually: document.all.popup.innerHTML = varHTML; for IE and document.popup.innerHTML = varHTML; for NS
				obj.popup.innerHTML = varHTML;
			}
		}else{
			//do nothing
			//alert("object not yet loaded in document"); //for testing!
		}
	}
}

function what(ref ,desc , which){
	//alert(which);
	if (which=="href"){
		return ref;
	}else if (which=="desc"){
		return desc;
	}
}

function over_it(a) {
	a.style.color = "white";
	a.style.cursor = 'hand';
}

function out_of(a){
	a.style.color = "#999999";
	a.style.fontWeight ="normal";
}

function underline(icon){
	var obj = which_obj(icon);
	if (obj){
		obj.textDecoration = "underline";
	}
	//alert(obj.textDecoration);
}

function no_underline(icon){
	var obj = which_obj(icon);
	if (obj){
		obj.textDecoration = "";
	}
	//alert(obj.textDecoration);
}

function which_obj(icon_no){
	if (n==0){
		var element="";
		switch (icon_no){
			case 1: element="solutions"; break;
			case 2: element="news"; break;
			case 3: element="investors"; break;
			case 4: element="careers"; break;
			case 5: element="about"; break;
			default: break;
		}
		strBuild="document" + coll + "." + element + styleObj;
		obj = eval(strBuild);
		//alert(strBuild + "=" + obj);
		return obj;
	}
}

function hide_off(){
	//stop the hiding process
	stop_hide = true;
	window.clearTimeout(timeout_id);
}

function hide_on(){
	//turn on the hiding process
	stop_hide = false;
	window.clearTimeout(timeout_id);
}

function hide_timeout(){
	//binnen een bepaalde tijd wordt hide aangeroepen
	//in de tussentijd kan hide_off() aangeroepen worden,
	//waardoor stop_hide op true gezet kan worden,
	//waardoor de layer niet leeg (hide) wordt.
	timeout_id = window.setTimeout("hide()", 750);
}

function hide(){
	//for explorer the div for Netscape the layer
	if (isIE!=true){
		//alert("Yeah! i'm in this NS if!"); //for testing!
		if (obj.nspopup){
			obj.nspopup.src = "ns_menu_empty.html";
		}
	}else{
		//hide (=make empty) or not?
		if (stop_hide==false){
			//initialize obj (this is not the same for NS and IE !! Idiots!
			obj = eval("document"+coll);
			document.all.popup.innerHTML = "";
		}
	}
}

function browser_ref_initialize(){
	if (parseInt(navigator.appVersion)>=4){
		//alert(navigator.appName);
		if (navigator.appName == "Microsoft Internet Explorer"){
			//alert(navigator.appName); //for testing
			isIE=true;
			coll=".all";
			styleObj=".style";
		}else{
			//alert(navigator.appName); //for testing
			isNav = true;
		}
	}
	//alert("help! " + document.popup.innerHTML);
}

//functions for roll over buttons 
//automatically generated by Macromedia 
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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  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); 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];}
}
