

// Set up page to do multiple loads //
function addLoadEvent(func) {

	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} 
	else 
	{
		window.onload = function() {
		  if (oldonload) {
			oldonload();
		  }
		  func();
		}
	}
	
}

/*
addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() { 
	more code to run on page load 
	}
); 
*/ 

var prepareLinks = {
	"sites" : function(){
		var url=document.location.toString();
		var domain=url.split(".")[1];
		var siteName=document.getElementById("siteName");
		var h=document.getElementById("sites");
		var img=h.getElementsByTagName("img");
		var imgLength=img.length;
		for (x=0;x<imgLength;x++){
			if (img[x].getAttribute('rel')==domain){
				siteName.innerHTML=": "+img[x].alt;
				img[x].parentNode.className="selected";
			}
			img[x].onclick=function(){
				document.location="http://www."+this.getAttribute('rel')+".com";
			}
		}
	},
	"menu" : function(){
		var menuC=document.getElementById("menu");
		menuC.style.display="none";
		var menuBut=document.getElementById("menuBut");
		menuBut.onclick=function(){menuC.style.display = (menuC.style.display == 'none') ? '' : 'none';};
	}
};

// LOAD EVENTS //
addLoadEvent(function() 
	{ 
		if (document.getElementById("open"))
		{
			document.getElementById("open").onmouseover=function(){this.src="/images/close.png";}
			document.getElementById("open").onmouseout=function(){this.src="/images/open.png";}
		}
		if (document.getElementById("sites"))
		{
			prepareLinks.sites();
		}
		if (document.getElementById("menu"))
		{
			prepareLinks.menu();
		}
	}
); 
