
// Save window state to disable the use of multiple popups
var openWindowCache = null;

// Point default page form to location.href
if (location.href.substring(location.href.length - 1) == "/") {
    document.forms[0].action = location.href + "default.aspx";
}
else {
    document.forms[0].action = location.href;
}

function openWindow(uri, w, h)
{
    openWindow(uri, w, h, '', 'directories=no,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes');
}

function openWindow(uri, w, h, name, options)
{
    if (openWindowCache && !openWindowCache.closed) {
        openWindowCache.close();
    }

    openWindowCache = open(uri, '', 'width=' + w + ',height=' + h + ',' + options);
    openWindowCache.focus();
}


function showHide( id )
{
  if ( document.getElementById ) // DOM3 = IE5, NS6
  {
    if ( document.getElementById( id ).style.display == "none" )
    {
			document.getElementById( id ).style.display = 'block';
		}
		else
		{
			document.getElementById( id ).style.display = 'none';			
		}	
  }
  else
  {
    if ( document.layers )
    {	
			if ( document.id.display == "none" )
			{
				document.id.display = 'block';
			} 
			else 
			{
				document.id.display = 'none';
			}
		} 
		else 
		{
			if ( document.all.id.style.visibility == "none" )
			{
				document.all.id.style.display = 'block';
			} 
			else 
			{
				document.all.id.style.display = 'none';
			}
		}
  }

}

// Will redirect the current page if within a frame
function removeParentFrame()
{
  if ( top.location != location )
  {
    top.location.href = document.location.href;
  }
}

function addLoadListener( fn )
{
    if (typeof window.addEventListener != "undefined")
    {
        window.addEventListener("load", fn, false);
    }
    else if (typeof document.addEventListener != "undefined")
    {
        document.addEventListener("load", fn, false);
    }
    else if (typeof window.attachEvent != "undefined")
    {
        window.attachEvent("onload", fn);
    }
    else
    {
        var oldfn = window.onload; if (typeof window.onload != "function") window.onload = fn; else window.onload = function() { oldfn(); fn();}
    }
}

function addUnLoadListener( fn )
{
    if (typeof window.addEventListener != "undefined")
    {
        window.addEventListener("unload", fn, false);
    }
    else if (typeof document.addEventListener != "undefined")
    {
        document.addEventListener("unload", fn, false);
    }
    else if (typeof window.attachEvent != "undefined")
    {
        window.attachEvent("onunload", fn);
    }
    else
    {
        var oldfn = window.onunload; if (typeof window.onunload != "function") window.onunload = fn; else window.onunload = function() { oldfn(); fn();}
    }
}


function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}



