//var baseUrl = "http://localhost/";									// change this to the root site folder

var t = top.location.toString().toLowerCase();
if (t.indexOf("http://masterplan.co.za/") > -1) {
	var baseUrl = "http://masterplan.co.za/";									// change this to the root site folder
} else {
	var baseUrl = "http://www.masterplan.co.za/";									// change this to the root site folder
	//var baseUrl = "";		// localhost
}

var fileType = ".gif";												// your nav images type
var outId = 1;														// out state
var overId = 2;														// over state
var downId;															// down state
//var downId = 3;													// down state - uncomment this if you have a third button state

arrImages = ["about","services","products","clients","resources","contact","home"];					// these are your site top folders structure, plus home for the home images
//alert(arrImages)
function navSetter () {
	var pressedId = downId == undefined ? overId : downId;			// check for third state
	var suffix = pressedId + fileType;								// the file fuffix
	var t = top.location.toString();
	var u = t.slice(baseUrl.length);								// the url excluding the baseUrl
	var subfolderEnd = u.indexOf("/");								// the index of the first /
	if (subfolderEnd == -1) subfolderEnd = "";						// make nothing if not found
	var folder = u.slice(0, subfolderEnd);							// the parent folder
	folder.length == 0 ? folder = "home" : null;
	if (u.toLowerCase() == "products/order.php") {
		//alert(u)
		document.images["nav_otherproducts"].src = baseUrl + "images/nav_order_" + suffix;
	} else {
		if (validImage(folder)) document.images["nav_"+folder].src = baseUrl + "images/nav_"+folder+"_" + suffix;
	}
	preloadImages();
};

/*
	check for a valid image
*/
function validImage (folderStr) {
	for (var i=0;i<arrImages.length;i++) {if (folderStr.toLowerCase() == arrImages[i].toLowerCase()) return true;};
	return false;
};

/*
	preload over state images in arrImages
*/
function preloadImages () {
	var str = "";
	for (var i=0;i<arrImages.length;i++) {str += baseUrl + " 'images/nav_"+arrImages[i]+"_"+overId+fileType+"', ";};
	MM_preloadImages(str);
};