var moz = (document.nodeName)? true:false;	// Check if browser is mozilla
var ie = (document.all)? true:false;		// Check if browser is ie

var dloc = "design";
var dbuttons_DIR = "graphics/disciplines/";

// Preload the dbuttons
var dbuttons = new Array("designButton",
						 "identityButton",
						 "programmingButton",
						 "databasesButton"
);

dbuttons['designButton'] 		= new Array("design-link.gif","design-hover.gif","design-active.gif");
dbuttons['identityButton'] 		= new Array("identity-link.gif","identity-hover.gif","identity-active.gif");
dbuttons['programmingButton']	= new Array("programming-link.gif","programming-hover.gif","programming-active.gif");
dbuttons['databasesButton']		= new Array("databases-link.gif","databases-hover.gif","databases-active.gif");


function load_rollovers () {
	var button;

	for (i = 0; i < dbuttons.length; i++) {
		button = dbuttons[i];
		img = (ie)? document.all(button) : document.getElementById(button);
	
		if (img) {

			dbuttons[button][3] = new Image();
			dbuttons[button][3].src = dbuttons_DIR + dbuttons[button][0];
			dbuttons[button][4] = new Image();
			dbuttons[button][4].src = dbuttons_DIR + dbuttons[button][1];
			dbuttons[button][5] = new Image();
			dbuttons[button][5].src = dbuttons_DIR + dbuttons[button][2];
				
			img.onmouseover = hover2;
			img.onmouseout = normal2;
		}
						
	}
}

function hover2 (e) {
    e = (e) ? e : ((window.event) ? window.event : "");
    
    if (e) {
    	img = get_button(e);
    	if (img.id != dloc + "Button")
			img.src = dbuttons[img.id][4].src;
	}

}

function normal2 (e) {
    e = (e) ? e : ((window.event) ? window.event : "");
 
    if (e) {
    	img = get_button(e);
    	if (img.id != dloc + "Button")
	    	img.src = dbuttons[img.id][3].src;
    } 
}

function activate (e) {
	var bodyCopy;
	var button;
	
	for (i = 0; i < dbuttons.length; i++) {
		button = dbuttons[i];
		img = (ie)? document.all(button) : document.getElementById(button);
   		img.src = dbuttons[img.id][3].src;
	
		bodyCopy = dbuttons[i].substr(0,dbuttons[i].length - 6) + "Copy";
		current = (ie)? document.all(bodyCopy) : document.getElementById(bodyCopy);
		current.style.visibility = 'hidden';
	}

	button = e + "Button";
	img = (ie)? document.all(button) : document.getElementById(button);
   	img.src = dbuttons[img.id][5].src;

	bodyCopy = e + "Copy";
	current = (ie)? document.all(bodyCopy) : document.getElementById(bodyCopy);
	current.style.visibility = 'visible';
	
	dloc = e;
}


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;
}


