
var sImagesPath = "gallery/images/";

var earth = new Array("anim_earth_b.jpg", "anim_earth_c.jpg", 820, 430);
var greeble = new Array("img_greeble_b.jpg", "img_greeble_c.jpg", 820, 430);
var microvideo = new Array("img_microvideo_b.jpg", "img_microvideo_c.jpg", 820, 430);
var sceau = new Array("img_sceau_b.jpg", "img_sceau_c.jpg", 820, 820);

//window.onload = init;
addListener(window, "load", "initImages");

function addListener(e, ev, fn){
	//alert("add listener");
	if (e.addEventListener){ 
		//try w3c model (false = bubbling)
		//alert("w3c");
		e.addEventListener(ev, eval(fn), false);
		//element.removeEventListener('click','fn',false)
   		return true; 
 	} else if (e.attachEvent){ 
		//try microsoft
		//alert("ms");
   		var r = e.attachEvent("on" + ev, eval(fn));
		//element.detachEvent('onclick','fn')
   		//return r; 
		return true;
 	} else { 
   		return false; 
 	} 
}

//////////////////////////////////////////////////////////////
function initImages(){
	//alert("init");
	//document.createTextNode is only required because of earlier versions of Opera, who claimed to support the DOM but!
	if(document.getElementById && document.createTextNode)
	{
		AddEvents();
	}
}

//////////////////////////////////////////////////////////////
function AddEvents() {
	var cnt = document.getElementById("contentmain");
	
	//title is first child		
	var imgs = cnt.getElementsByTagName("img");
	//alert(imgs.length);
	//return false;
	for(var i=0; i<=imgs.length-1;i++){
		imgs[i].onmouseover = function() {mover(this);};
		imgs[i].onmouseout = function() {mout(this);};
		//imgs[i].onclick = function() {nav(this);};
		//assign the onclick handler to the parent node <a>
		imgs[i].parentNode.onclick = function() {nav(this); return false;};
	}
}

//////////////////////////////////////////////////////////////
function mover(e){
	//alert(e.getAttribute("id"));
	//get the array name from the image id
	e.src = sImagesPath + eval(e.getAttribute("id"))[1];
	//e.src = e.src_on;
}

//////////////////////////////////////////////////////////////
function mout(e){
	//alert(e.getAttribute("id"));
	//get the array name from the image id
	e.src = sImagesPath + eval(e.getAttribute("id"))[0];
	//e.src = e.src_off;
}

//////////////////////////////////////////////////////////////
function nav(e){
	//this is the anchor element surrounding the image
	var href = e.getAttribute("href");
	//get the array name from the image id
	var img = e.getElementsByTagName("img")[0];
	var array = eval(img.getAttribute("id"));
	var width = array[2];
	var height = array[3];

	//alert(href + ", " + width + ", " + height);
	openwindow(href, width, height);
}

//////////////////////////////////////////////////////////////
//unused 

//custom image object constructor
function image(off, on, width, height)
{
	this.off = new Image();
	this.off.src = off
	this.on = new Image();
	this.on.src = on
	this.width = width;
	this.height = height;
}

