function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}




// script from: http://adamv.com/dev/javascript/rollovers

function Rollovers_swap(id){ // id to swap in an image, null to swap out
	if (id != null)
	{	
		var image = document.images[id]
		if (image == null) return
	
		var newimage = this.images[id]
		if (newimage == null) return
		
		this.temp_img = image
		this.temp_src = image.src
		
		image.src = newimage.src
	}
	else
	{
		if ((this.temp_img != null) && (this.temp_src != null))
			this.temp_img.src = this.temp_src
			
		this.temp_img = null
		this.temp_src = null
	}
}
	
function Rollovers(image_list){
	this.images = new Object()		// Storage for swap-in images
	this.Install = Rollovers_Install
	this.swap = Rollovers_swap
	
	// Storage for the current swap-out image
	this.temp_img = null
	this.temp_src = null

	for (var i=0; i < image_list.length; i++) {
		var id = image_list[i][0]
		var src = image_list[i][1]
		
		var image = new Image()
		image.src = src
		this.images[id] = image
	}
}

function Rollovers_Install() {	// Should be called after page is loaded
	init_Text();
	var _this = this
	var swap_out = function(){_this.swap(null);}

	var set = function (id){
		var image = document.images[id]
		if (image == null) return
		image.onmouseover = function(){_this.swap(id);showhide_Text(id)}
		image.onmouseout = function(){_this.swap(null);showhide_Text('default-home')};
	}
	
	for(var id in this.images) set(id);
	
}

function init_Text() {
	var p = document.getElementById('producttext');
	
	var divs = p.getElementsByTagName('div');
	
	for(var i = 0; i< divs.length; i++) {
		var h4 = divs[i].getElementsByTagName('h4')[0];
		h4.parentNode.removeChild(h4);
		if(i> 0) divs[i].style.display = 'none';
	}
}

function showhide_Text(id) {
	var p = document.getElementById('producttext');
	
	var divs = p.getElementsByTagName('div');
	
	for(var i = 0; i< divs.length; i++) {
		divs[i].style.display = 'none';
	}
	
	document.getElementById(id+'-text').style.display = 'block';
}

rollovers = new Rollovers([
	
	["eA-home", "assets/btns/btn_eA_hover.jpg"],
	["pE-home", "assets/btns/btn_pE_hover.jpg"],
	["cS-home", "assets/btns/btn_cS_hover.jpg"],
	["cT-home", "assets/btns/btn_cT_hover.jpg"]
	
	]);

/* drop down menus (just for IE to make it act like it supports :hover  */
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}




if (window.attachEvent) window.attachEvent("onload", sfHover);

