var isIE501 = navigator.userAgent.indexOf("MSIE 5.01") > 0 ? true : false;
var isNN6 = navigator.userAgent.indexOf("Netscape6") > 0 ? true : false;



function openBrWindow() {
  
  //variables
  var theURL = "http://webgis.islington.gov.uk/website/internet/Interactive_Islington_public/";
  var theWinName = "intIslingtonWin";

  if (navigator.appName.indexOf("Netscape")!=-1){
   	var features = 'status=yes,scrollbars=yes,resizable=yes,height=' + (((screen.availHeight)-46)-screen.availTop) + ',width=' + (((screen.availWidth)-7)-screen.availLeft) + ',left=' + screen.availLeft + ',top=' + screen.availTop;
    	window.open(theURL,theWinName,features); 	
  } else {
  	var features = 'status=yes,scrollbars=yes,resizable=yes,height=' + ((screen.availHeight)-49) + ',width=' + ((screen.availWidth)-10) + ',left=0,top=0';
  		window.open(theURL,theWinName,features);
  }
}

//
// 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 setCookie(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 getCookie(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));
}


function hideSections()
{
	switchDisplay("none", "block", true);
/*	document.getElementById("balance-top").style.background = "url(../images/show-balance.gif) no-repeat";*/
}

function showSections()
{
	switchDisplay("block", "none", true);
/*	document.getElementById("balance-top").style.background = "url(../images/hide-balance-top.gif) no-repeat";*/
}

//
// switchAccountDisplay(string state1,string state2)
// restore show/hide account details from cookie
//
function switchDisplay(state1, state2, browserReload)
{
	if(document.getElementById("section-navigation"))
	{
		document.getElementById("section-navigation").style.display = state1;
		document.getElementById("hide-switch").style.display = state1;
		document.getElementById("show-switch").style.display = state2;
		setCookie("state1", state1, "", "/");
		setCookie("state2", state2, "", "/");
		if((browserReload == true) && ((isIE501 == true) || (isNN6==true)))
		{
			location.reload();
		}
	}
}



//
// restoreAccountDisplay
// restore show/hide account details from cookie
//
function restoreDisplay()
{
	state1 = getCookie("state1") == null ? "none" : getCookie("state1");
	state2 = getCookie("state2") == null ? "block" : getCookie("state2");
	switchDisplay(state1, state2, false);
}


//
// trigger onLoad function (do_onload)
//
if (window.addEventListener)
{
	window.addEventListener("load", restoreDisplay, false);
}
else
{
	if (window.attachEvent)
	{
		window.attachEvent("onload", restoreDisplay);
	}
	else
	{
	if (document.getElementById)
		{
			window.onload = restoreDisplay;
		}
	}
}

function printpage() {
 window.print();  
}