/***********************************************************************
*	MAIN.JS
*  
*	(c) 2005 Walker Art Center - Brent Gustafson
***********************************************************************/

var pageTotal = 0;

function searchGo(url,val) {
	if ((val > 0) && (val <= pageTotal)) document.location = url + val;
	else return false;
}

function popup(url,width,height) {
	var properties = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height;
	var myPopup = window.open(url, "myPopup", properties);
	myPopup.focus();
}

function loadContent(nID, nType){
	//alert(nID);
	//alert(nType);
	document.location = "details.wac?id="+nID+"&title="+nType;
}

function flashReshow(){
	document.getElementById("flashOn").style.display = "block";
	document.getElementById("flashOff").style.display = "none";
}

function flashRehide(){
	document.getElementById("flashOn").style.display = "none";
	setTimeout("flashReshow()",2);
}

function pHideButton() {
	document.getElementById("hideButton").style.display = "none";
}
function pHideFlash() {
	setTimeout("pHideButton()",2);
	document.getElementById("flashOff").style.display = "block";
	document.getElementById("flashOn").style.display = "none";	
}

function hideFlash() {
	if (document.getElementById("flashOn").style.display == "none") {
		// show it:
		deleteCookiePing("hidePingFlash");
		
		// should just be this line
		document.getElementById("flashOn").style.display = "block";

		// work around for Safari
		setTimeout("flashReshow()",10);
		
		document.getElementById("hideButton").style.zIndex = "100";
		document.getElementById("flashOff").style.display = "none";

		document.getElementById("hideButton").style.display = "block";
	}
	else {
		// hide it:
		setCookiePing("hidePingFlash","true");
		document.getElementById("flashOff").style.display = "block";
		document.getElementById("flashOn").style.display = "none";
		document.getElementById("hideButton").style.display = "none";
	}
}

function preHideFlash() {
	hideFlashCookie = getCookiePing("hidePingFlash");
	if (hideFlashCookie == "true") return true;
	return false;
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookiePing(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookiePing(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookiePing(name, path, domain)
{
    if (getCookiePing(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}