// ============================
// ro - Rollover script	2002-08-16	v1.5	danieln	(C) The Web Ltd



////////////////////////////////////////
// ro START CONFIG


// N.B. Change this to the name of the directory you are building the site in, on the dev server
// it must be unique within the path
var devServerDir = "doc_biodiversity";



// This is the number of directories away from the root on the current path (without devServerDir) 
// that the swap images live. e.g. /sectionA, /sectionB, /sectionC could have different rollovers
var roDirOffset = 0;

function ro_init() {
	if (!imgSwp) { return true; }

	// Set up images - ro_setup("[image NAME attribute from HTML]", "[off image path]", "[on image path]" .. ) 
	// NB. no ',' after last one
	ro_setup(
"picture", "picture.gif", "mo_picture.gif", 
"land", "land.gif", "mo_land.gif", 
"seas", "seas.gif", "mo_seas.gif", 
"resources", "resources.gif", "mo_resources.gif",
"involved", "involved.gif", "mo_involved.gif",
"news", "news.gif", "mo_news.gif"
	);

	ro_ready = true;
	return true;
}

var path = window.location.pathname;

// find the path delimiter tortuously because IE prepends '/' to a path when proto is file with '\' as delimiters, 
var pathDlim = (path.indexOf("\\")!=-1) ? "\\" : "/"; 

// find dev server dir and strip path up to it
if ((devServerDir!=null) && (devServerDir!="")) {
	var foundPos = path.indexOf(devServerDir + pathDlim);
	if (foundPos > -1) {
		path = path.substring(foundPos + devServerDir.length);
	}
}

// Count how many directories deep we are
function depthFind(dirOffset) {
	var depth = "";
	var iterations = path.split(pathDlim).length - 2;
	if (dirOffset!=null) { iterations -= dirOffset };
	for(i=0;i<iterations;i++) {	depth += "../"; }
	return depth;
}


// Path to image files - remove the following line if you have included the paths in the 'ro_setup(..)'
ro_swPath = "" + depthFind(roDirOffset) + imagesDir;

// ro END CONFIG
////////////////////////////////////////

var imgSwp = (document.images!=null), NS4 = (document.layers!=null), NS404_ = (NS4 && (parseFloat(navigator.appVersion)<4.04)), ro_ready = false, ro_sw = new Object(), ro_ld = new Object();

function ro_setup() {
	if (ro_swPath==null) { ro_swPath = ""; }
	var j=0;
	while (j<arguments.length) {
		var a = Array(arguments[j++], arguments[j++], arguments[j++]);
		ro_sw[a[0]] = new Array(2);
		for (var i=0; i<2; i++) {
			ro_sw[a[0]][i] = new Image();
			ro_sw[a[0]][i].src = ro_swPath + a[i+1];
			ro_ld[a[0]] = false;
		}
	}
}

function ro(imgN,onOff) {
	if ((document[imgN]!=null) && imgSwp && ro_ready ) {
		if (ro_ld[imgN]) { document[imgN].src = ro_sw[imgN][onOff].src; }
		else if ((((ro_sw[imgN][onOff].complete) && (document[imgN].complete)) || NS404_ ) && (ro_ld[imgN]!=null)) {
			ro_ld[imgN] = true;
			document[imgN].src = ro_sw[imgN][onOff].src;
		}
	}
	return true;
}
function ro_on(imgN) { ro(imgN,1); }
function ro_off(imgN) { ro(imgN,0); }

// remove this line and add 'onload="ro_init()"' to the BODY tag to make the rollovers activate only after the page loads
ro_init();
