var dfltID = "main";
var currID = dfltID;

function showImage(newID) {

// 20090802: To prevent swapping with non-existent main# objects,
//           check first if newID exists


    if (document.getElementById(newID)) {
	newImg = document.getElementById(newID);
	oldImg = document.getElementById(currID);

    // 20090802: Turn off old image first before turning on new,
    //           to prevent DIV overlaps or displacements

	oldImg.style.visibility = "hidden";
	oldImg.style.display = "none";
	newImg.style.visibility = "visible";
	newImg.style.display = "inline";
	currID = newID;
    }
}

function showDefault() {
	showImage("dfltID");
}


//	alert(document.cookie);
//	alert("Category: " + projectCategory + "\n" + "Location: " + location.href + "\n" + "Referrer: " + location.referrer);

if (window.parent == window && document.location.href.indexOf("#project") < 0) {
    if (projectCategory != "") {

// Get project file name offset

	var allCookies = document.cookie;
	var cookieCategory = allCookies.substr(allCookies.indexOf("category=") + 9); 
	var pName = document.location.pathname.substr(1);
	var subsStart = (pName.lastIndexOf("/") >= 0) ? (pName.lastIndexOf("/") + 1) : ( (pName.lastIndexOf("\\") >= 0) ? (pName.lastIndexOf("\\") + 1) : 0 );
	if (cookieCategory.indexOf(";") >= 0) cookieCategory = cookieCategory.substring(0, cookieCategory.indexOf(";"));

// Check if referrer category is different from default
//	alert(pName + "\n" + pName.lastIndexOf("/") + " " + pName.lastIndexOf("\\"));

//	alert("Referrer Path: " + referrer.pathname);

//	alert ("Category: " + projectCategory + "\nCookie: " + cookieCategory);

	if (projectCategory != cookieCategory && cookieCategory.indexOf("html") > 0) projectCategory = cookieCategory;

// Combine category and project files

	document.location.href = projectCategory + "#" + pName.substr(subsStart);
    }
}
