var moz = (document.nodeName)? true:false;	// Check if browser is mozilla
var ie = (document.all)? true:false;		// Check if browser is ie

var BUTTONS_DIR = "graphics/";

// Preload the buttons
var buttons = new Array("blogButton",
						"studioButton",
						"disciplinesButton",
						"portfolioButton"
);

buttons['blogButton'] 			= new Array("blog-link.gif",30,"blog-hover.gif",44);
buttons['studioButton'] 		= new Array("studio-link.gif",44,"studio-hover.gif",62);
buttons['disciplinesButton']	= new Array("disciplines-link.gif",73,"disciplines-hover.gif",105);
buttons['portfolioButton']		= new Array("portfolio-link.gif",64,"portfolio-hover.gif",90);


function load_navigation () {
	

	for (i = 0; i < buttons.length; i++) {
		button = buttons[i];
		img = (ie)? document.all(button) : document.getElementById(button);
	
		if (img) {
			buttons[button][4] = new Image();
			buttons[button][4].src = BUTTONS_DIR + buttons[button][0];
			buttons[button][5] = new Image();
			buttons[button][5].src = BUTTONS_DIR + buttons[button][2];
				
			img.onmouseover = hover;
			img.onmouseout = normal;		
		}

	}

	img = (ie)? document.all(active) : document.getElementById(active);
    img.src = buttons[img.id][5].src
	img.width = buttons[img.id][3];
	img.height = 16;

}

function hover (e) {
    e = (e) ? e : ((window.event) ? window.event : "");
    
    if (e) {
    	img = get_button(e);
		img.src = buttons[img.id][5].src;
		img.width = buttons[img.id][3];
		img.height = 16;
	}

	if (img.id != active) {
		img = (ie)? document.all(active) : document.getElementById(active);
    	img.src = buttons[img.id][4].src
		img.width = buttons[img.id][1];
		img.height = 12;
	}


}

function normal (e) {
    e = (e) ? e : ((window.event) ? window.event : "");
  
    if (e) {
    	img = get_button(e);
    	img.src = buttons[img.id][4].src;
		img.width = buttons[img.id][1];
		img.height = 12;
    } 

	img = (ie)? document.all(active) : document.getElementById(active);
    img.src = buttons[img.id][5].src
	img.width = buttons[img.id][3];
	img.height = 16;


}

function get_button (e) {
	var button;
    if (e.target) {
        button = (e.target.nodeType == 3) ? e.target.parentNode : e.target;
    } else {
        button = e.srcElement;
    }
    return button;
}

window.onload = function () {
	load_navigation();
}