// ============================
// openScript - popup window


function openScript(url, width, height) {
        var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',top=20,left=20,resizable=1,scrollbars=yes,menubar=no,status=no' );
		return Win;
}


// ============================
// ro - Rollover script	2001-05-24	v1.2	danieln	(C) The Web Ltd

// ro START CONFIG

////////////////////
//FUNCTION depthFind()
//count how many directories deep we are


var devServerDir = "ChildrensDaySite";
var path = window.location.pathname;

// find the path delimiter tortuously because IE prepends '/' to a path when proto is file with '\' as delimiters, *doh*
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() {
	var depth = "";
	var iterations = path.split(pathDlim).length - 2;
	for(i=0;i<iterations;i++) {	depth += "../"; }

	// exception for htsearch
	if (path.indexOf('cgi-bin') != -1) { depth = "" ;}
	return depth;
}


// Path to image files - remove the following line if you have included the paths in the 'ro_setup(..)'
ro_swPath = "" + depthFind() + "images/nav/";

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(
"about", "about.gif", "about_s.gif", 
"activities", "activities.gif", "activities_s.gif", 
"athome", "athome.gif", "athome_s.gif", 
"atschool", "atschool.gif", "atschool_s.gif", 
"what", "whatson.gif", "whatson_s.gif", 
"events", "events.gif", "events_s.gif",
"ourlinks", "ourlinks.gif", "ourlinks_s.gif",
"haveyoursay", "haveyoursay.gif", "haveyoursay_s.gif", 
"newsflash", "newsflash.gif", "newsflash_s.gif",
"feedback", "feedback.gif", "feedback_s.gif", 
"important", "important.gif", "important_s.gif", 
"search", "search.gif", "search_s.gif", 
"home", "home.gif", "home_s.gif"
  );

// ro END CONFIG

	ro_ready = true;
	return true;
}

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();

// ============================
// ro_hiMe - Rollover script	2001-05-22	v1.0	danieln	(C) The Web Ltd
// Attempt to match this page or directory name to the section we are in from the path to this page

function ro_hiMe() {

	if (!imgSwp) { return true; }

	// ro_hiMe CONFIG - These set the limits of path 'depth' ('(1)/(2)/(3).html') between which we will search
	var depthMin = 1;
	var depthMax = 100;
	// ro_hiMe END CONFIG

	var locStr = location.pathname.substring(1), p_slash = -1, depth = 0, last = false;

	while (!last) {
		var n_slash = locStr.indexOf('/',p_slash+1);
		if (n_slash == -1) { n_slash = locStr.indexOf('\\',p_slash+1); } // to handle IE using '\' in the pathname *sigh*
		if (n_slash != -1) {
			var pathPart = locStr.substring(p_slash+1,n_slash);
			p_slash = n_slash;
			depth++;
		}
		else {
			var pathPart = locStr.substring(p_slash+1);
			last = true;
		}
		if (depth<depthMin) { continue; }
		if (depth>depthMax) { break; }
		ro_hiFind(pathPart);
	}
	return true;
}

function ro_hiFind(pathPart) {
	var tryImgSwapInterval = 500; // in milliseconds - set this higher if trials are slowing page down
	var tryImgSwapFor = 10000; // set this higher if page is slow to load
	var dotPos = pathPart.indexOf('.');
	if (dotPos!=-1) { pathPart = pathPart.substring(0,dotPos); } // discard any filename extension
	for (var imgN in ro_sw) {
		if (pathPart==imgN) {	ro_hiTry(imgN,tryImgSwapInterval,tryImgSwapFor); }
	}
}

function ro_hiTry(imgN,intv,tryFor) {
	var failed = false;
	if (document[imgN]!=null) {
		ro_ld[imgN] = true;
		ro(imgN,1);
		if (document[imgN].src != ro_sw[imgN][1].src) {	failed=true; }
		else { ro_ld[imgN] = null;	}
	}
	else { failed=true; }
	if (failed) { // it failed, try again later
		tryFor = tryFor - intv;
		if (tryFor > 0) { setTimeout("ro_hiTry('"+imgN+"',"+intv+","+tryFor+")",intv); }
	}
}

ro_hiMe(); if (NS4){window.onresize=ro_hiMe};
// -->

