
function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}

// --------------------------------------------------------------------------------------------------

//	"searchSite()" added on 22/11/05 by Lee McIvor.
//	This function is called by the WebDisplayPublished Form, and enables the Search functionality
//	on every page.
/*
function searchSite() {
	var frm = window.document.forms[0];
	var query = frm.query.value;
	window.location = "searchresults?ReadForm&query=" + query;
}
*/
// --------------------------------------------------------------------------------------------------
//	"doSearch()" added on 26/03/06 by Keiron Convery.
//	This function is called by the search box on all pages and enables the Search functionality
//	
function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}

//THis function is only called from the YHN snippets! - JM
function yhndoSearch () {
s=document.forms[0].query
//alert(s)
var regExp1 = /\bfield\b/;
var regExp2 = /[(,),<,>,\[,\]]/;
var str = s.value;
//alert(s.value); 
if (( str == "" ) || ( str == "Enter text here" ))
{ 
alert("Please be sure to enter something to search for.");
s.focus();
} 
else 
{ 
if ( typeof regExp1.source != 'undefined' ) //supports regular expression testing 
if ( regExp1.test( str ) || regExp2.test( str ) ){
var alrt = "Please note that you can not include:"; 
alrt += "\n\nThe reserved word 'field'\nthe characters [, ], (, ), < or >";
alrt += "\n\nin your search query!"
s.focus();
return alert( alrt );
}
window.location.href="/core.nsf/yhnsearch?OpenAgent&query=" + escape( str ); 
}
}

function doSearch () {
s=document.forms[0].query
//alert(s)
var regExp1 = /\bfield\b/;
var regExp2 = /[(,),<,>,\[,\]]/;
var str = s.value;
//alert(s.value); 
if (( str == "" ) || ( str == "Enter text here" ))
{ 
alert("Please be sure to enter something to search for.");
s.focus();
} 
else 
{ 
if ( typeof regExp1.source != 'undefined' ) //supports regular expression testing 
if ( regExp1.test( str ) || regExp2.test( str ) ){
var alrt = "Please note that you can not include:"; 
alrt += "\n\nThe reserved word 'field'\nthe characters [, ], (, ), < or >";
alrt += "\n\nin your search query!"
s.focus();
return alert( alrt );
}
window.location.href="http://search.newcastle.gov.uk/search?q="+escape( str )+"&btnG=Search&site=just_newcastle_gov&client=ncc_livery&output=xml_no_dtd&proxystylesheet=ncc_livery";
//window.location.href="https://community.newcastle.gov.uk/search/search.php?query=" + escape( str )+"&search=1"; 
}
}

function doTWRISearch () {
s=document.search.query
//alert(s)
var regExp1 = /\bfield\b/;
var regExp2 = /[(,),<,>,\[,\]]/;
var str = s.value;
//alert(s.value); 
if (( str == "" ) || ( str == "Enter text here" ))
{ 
alert("Please be sure to enter something to search for.");
s.focus();
} 
else 
{ 
if ( typeof regExp1.source != 'undefined' ) //supports regular expression testing 
if ( regExp1.test( str ) || regExp2.test( str ) ){
var alrt = "Please note that you can not include:"; 
alrt += "\n\nThe reserved word 'field'\nthe characters [, ], (, ), < or >";
alrt += "\n\nin your search query!"
s.focus();
return alert( alrt );
}
window.location.href="https://community.newcastle.gov.uk/twri/search/search.php?query=" + escape( str )+"&search=1";
}
}

function doSuppPeopleSearch () {
s=document.forms[0].query
//alert(s)
var regExp1 = /\bfield\b/;
var regExp2 = /[(,),<,>,\[,\]]/;
var str = s.value;
//alert(s.value); 
if (( str == "" ) || ( str == "Enter text here" ))
{ 
alert("Please be sure to enter something to search for.");
s.focus();
} 
else 
{ 
if ( typeof regExp1.source != 'undefined' ) //supports regular expression testing 
if ( regExp1.test( str ) || regExp2.test( str ) ){
var alrt = "Please note that you can not include:"; 
alrt += "\n\nThe reserved word 'field'\nthe characters [, ], (, ), < or >";
alrt += "\n\nin your search query!"
s.focus();
return alert( alrt );
}
window.location.href="https://community.newcastle.gov.uk/supportingpeople/search.php?query=" + escape( str )+"&search=1";
//window.location.href="/cgi-bin/htsearch?restrict=%2fmsp_&config=htdig_msp&words=" + escape( str ); 
}
}


function returnFalse(s){
//guess the field if not supplied
s = (s == null) ? document.forms[0].query : s;
//if you want to do the search, use this line
//alert(document.forms[0].interfacetemplate.substring(0,3))
if (document.forms[0].interfacetemplate == undefined){
	doSearch();
} else if (document.forms[0].interfacetemplate.value.substring(0,3)== "YHN" )	{
	yhndoSearch();
} else if (document.forms[0].interfacetemplate.value.substring(0,4)== "TWRI" )	{
	doTWRISearch();
} else if (document.forms[0].interfacetemplate.value.substring(0,8)== "micro_sp" )	{
	doSuppPeopleSearch();
} else{
	doSearch();
}
	
//if you want to alert the user, use this line
//alert('Please use the \'Search\' button to activate a search');

//this line should always be here!!
//return false;
}
// --------------------------------------------------------------------------------

function resetStyleSheet(){
	
	var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
}

function setActiveStyleSheetPrint(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}


function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}


function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  //alert("got stylesheet");
  return null;
}

function getPreferredStyleSheet() {
	
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) 
       return a.getAttribute("title");
  }
  return null;
}

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 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;
}

window.onload = function(e) {
	
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  if (title != "print" ){
  	setActiveStyleSheet(title);
  }
}

window.onunload = function(e) {
 
  var title = getActiveStyleSheet();
	if (title != "print" ){
		createCookie("style", title, 365);
 	}
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
//alert(title);
setActiveStyleSheet(title);

//************ Next section added by KC on 24/03/06 as we need this code to provide
//************ the menu to NEMO (code sent to web team by Ray Kennedy - see CMS page called NEMOhome)

  // setup test for Nav 4.0
  var isIE = false;
  var isNav = (navigator.appName.indexOf("Netscape")>=0);
  var isNav4 = false;
  var isIE4 = false;
  var is5up = false;
  //alert(navigator.appVersion);
  if (isNav) {

  	if (parseFloat(navigator.appVersion)<5) {
  		isNav4=true;
  		//alert("Netscape 4.x or older");
  	} else {
  		is5up = true;
  	}
  } else {
  	isIE4=true;
  	isIE=true;
  	if (navigator.appVersion.indexOf("MSIE 5")>0) {
  		isIE4 = false;
  		is5up = true;
  		//alert("IE5");
  	}
  }

  // get the layer object called "name"
  function getLayer(name) {
 	  if (isNav4)
 	    return(document.layers[name]);
 	  else if (isIE4) {
 	    layer = eval('document.all.' + name + '.style');
 	    return(layer);
 	  } else if (is5up) {
 		var theObj = document.getElementById(name);
 		return theObj.style
 	  }
 	  else
 	    return(null);
  }

  function openHelp() {
  window.open('help.html');
  }

  function openTerms() {
  window.open('disclaimer.html');
  }

  function openNews() {
  layer = getLayer("Layer3");
  layer.visibility = "hidden";
  layer1 = getLayer("Layer4");
  layer1.visibility = "visible";
  }
  
  function openParking() {
  var wid;
  var hgt;
    if(navigator.appName == "Netscape"){

    wid = window.screen.availWidth;
 	hgt = window.screen.availHeight;
 	browsertype = "ns"

    }else if(navigator.appName == "Microsoft Internet Explorer"){

    wid = window.screen.availWidth;
    hgt = window.screen.availHeight;
    browsertype = "ie"

    }else{

    wid = 1024;
	hgt = 623;
	browsertype = "ns"

  	}
  	if(wid>1280){
  	wid = 1280;
  	}
  	if (wid<800){
  	wid = 800;
  	}
  	if (wid>801 && wid <1024){
  	wid = 1024;
  	}
  	if (wid>1025 && wid <1151){
  	wid = 1152;
  	}
  	if (wid>1153 && wid <1279){
  	wid = 1280;
  	}

	var winwid = wid * 0.98;
	var winhgt = hgt * 0.95;

	Stamp = new Date();
	var Hours;
	var Mins;
	var Secs;
	var Time;
	Hours = Stamp.getHours();
 	Mins = Stamp.getMinutes();
 	Secs = Stamp.getSeconds();
 	Time = Hours + Mins + Secs;
 	
	var winwid = wid + 8;
	var winhgt = hgt + 8;
	window.moveTo(-4, -4);
	window.resizeTo(winwid, winhgt);
	
	window.location = "http://gis.newcastle.gov.uk/ray_map/ray_map.asp?wid=" + wid + "&browsertype=" + browsertype;

  }

  function openNemo(call_type) {
  var wid;
  var hgt;
    if(navigator.appName == "Netscape"){

    wid = window.screen.availWidth;
 	hgt = window.screen.availHeight;
 	browsertype = "ns"

    }else if(navigator.appName == "Microsoft Internet Explorer"){

    wid = window.screen.availWidth;
    hgt = window.screen.availHeight;
    browsertype = "ie"

    }else{

    wid = 1024;
	hgt = 623;
	browsertype = "ns"

  	}
  	if(wid>1280){
  	wid = 1280;
  	}
  	if (wid<800){
  	wid = 800;
  	}
  	if (wid>801 && wid <1024){
  	wid = 1024;
  	}
  	if (wid>1025 && wid <1151){
  	wid = 1152;
  	}
  	if (wid>1153 && wid <1279){
  	wid = 1280;
  	}

	var winwid = wid * 0.98;
	var winhgt = hgt * 0.95;

	Stamp = new Date();
	var Hours;
	var Mins;
	var Secs;
	var Time;
	Hours = Stamp.getHours();
 	Mins = Stamp.getMinutes();
 	Secs = Stamp.getSeconds();
 	Time = Hours + Mins + Secs;
 	
	var winwid = wid + 8;
	var winhgt = hgt + 8;
	window.moveTo(-4, -4);
	window.resizeTo(winwid, winhgt);
	
if (call_type=="NNIS")
	{
	//window.open("http://gis.newcastle.gov.uk/nemow3c/Map.asp?wid=" + wid + "&amp;browsertype=" + browsertype + "&amp;WinHeight=" + hgt + "&amp;Wheight=" + winhgt + "&amp;Wwidth=" + winwid  + "&amp;nnisvitality=true&amp;SCI=true&amp;CGD=true&amp;nnis=Vitality - Ranked Position_04","Nemo" + Time + "Map","height=" + winhgt + ",width=" + winwid + ",scrollbars=no,status=yes,toolbar=no,menubar=no,location=no,resizable=no,top=0,left=0");
	window.location = "http://gis.newcastle.gov.uk/mapsonline/map.asp?wid=" + wid + "&browsertype=" + browsertype + "&ID=100004" + "&amp;nnis=Vitality - Ranked Position_04";
	} else 
	{
  	//window.open("http://gis.newcastle.gov.uk/nemow3c/map.asp?wid=" + wid + "&amp;browsertype=" + browsertype + "&amp;WinHeight=" + hgt + "&amp;Wheight=" + winhgt + "&amp;Wwidth=" + winwid ,"Nemo" + Time + "Map","height=" + winhgt + ",width=" + winwid + ",scrollbars=no,status=yes,toolbar=no,menubar=no,location=no,resizable=no,top=0,left=0");
  	window.location = "http://gis.newcastle.gov.uk/mapsonline/map.asp?wid=" + wid + "&browsertype=" + browsertype;
	}
}
  
function launch() {

	if (document.forms[0].TandC_Check.checked) {
		openNemo();
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}


function launchparkingmap() {

	if (document.forms[0].TandC_Check.checked) {
		openParking();
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}

function launchPlanningv2() {

	if (document.planning.TandC_Check.checked) {
		window.open("http://planningapplications.newcastle.gov.uk/online-applications/")
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}



function launchPlanning() {

	if (document.forms[0].TandC_Check.checked) {
		window.open("http://www.newcastle.gov.uk/publicaccess/")
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}

function launchGambleViewer() {

	if (document.forms[0].TandC_Check.checked) {
		window.location.href="http://gis.newcastle.gov.uk/olga/"
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}

function launchLicViewer() {

	if (document.forms[0].TandC_Check.checked) {
		window.location.href="http://gis.newcastle.gov.uk/Licensing/home.aspx"
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}

function launchRoadWorksMap() {

	if (document.forms[0].TandC_Check.checked) {
		window.open("http://gis.newcastle.gov.uk/iframemap/getmap.html")
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}

function launchNNIS() {

	if (document.forms[0].TandC_Check.checked) {
		openNemo("NNIS");	
	} else {
		alert("You must accept the License agreement Terms and Conditions before continuing.")
	}

}

function launchLibNemo(library) {

  var wid;
  var hgt;
    if(navigator.appName == "Netscape"){

    wid = window.screen.availWidth;
 	hgt = window.screen.availHeight;
 	browsertype = "ns"

    }else if(navigator.appName == "Microsoft Internet Explorer"){

    wid = window.screen.availWidth;
    hgt = window.screen.availHeight;
    browsertype = "ie"

    }else{

    wid = 1024;
	hgt = 623;
	browsertype = "ns"

  	}
  	if(wid>1280){
  	wid = 1280;
  	}
  	if (wid<800){
  	wid = 800;
  	}
  	if (wid>801 && wid <1024){
  	wid = 1024;
  	}
  	if (wid>1025 && wid <1151){
  	wid = 1152;
  	}
  	if (wid>1153 && wid <1279){
  	wid = 1280;
  	}

	var winwid = wid * 0.98;
	var winhgt = hgt * 0.95;

	Stamp = new Date();
	var Hours;
	var Mins;
	var Secs;
	var Time;
	Hours = Stamp.getHours();
 	Mins = Stamp.getMinutes();
 	Secs = Stamp.getSeconds();
 	Time = Hours + Mins + Secs;
 	
	var winwid = wid + 8;
	var winhgt = hgt + 8;
	window.moveTo(-4, -4);
	window.resizeTo(winwid, winhgt);
	
window.location = "http://gis.newcastle.gov.uk/mapsonline/map.asp?wid=" + wid + "&browsertype=" + browsertype + "&ZTL=true&Lib_Name=" + library;

}


function launchRecyclingRouteSearch() {

	if (document.forms[0].PostCode.value=="") 
	{
		alert("Please enter a Post Code");
		document.forms[0].PostCode.focus();
		return false;
	}
	
	if (document.forms[0].HouseNumber.value=="") 
	{
		alert("Please enter a House Number");
		document.forms[0].HouseNumber.focus();
		return false;
	}
	
	window.location="/wsapp.nsf/soapweb/RecyclingRoutes?opendocument=1&ct=RecyclingRoutes&PC=" + document.forms[0].PostCode.value + "&HN=" + document.forms[0].HouseNumber.value;

}

function newlaunchRecyclingRouteSearch() {

	if (document.forms[0].PostCode.value=="") 
	{
		alert("Please enter a Post Code");
		document.forms[0].PostCode.focus();
		return false;
	}
	
	if (document.forms[0].HouseNumber.value=="") 
	{
		alert("Please enter a House Number");
		document.forms[0].HouseNumber.focus();
		return false;
	}
	
	window.location="/wsapp.nsf/soapweb/newRecyclingRoutes?opendocument=1&ct=newRecyclingRoutes&PC=" + document.forms[0].PostCode.value + "&HN=" + document.forms[0].HouseNumber.value;

}


//************ End of NEMO code *********************

function validatebsifrm(){

	var x = document.forms[0].txtLibNo.value;
	
	var xarray = x.split("");
	var chk="false";
	var len=x.length;

	if(len<11 && len>8){
		for (i=0;i<len;i++){
				if(xarray[0]=="D" || xarray[0]=="d")	{chk="OK";}else{chk="false"; break;}
				if(i>0){
					if(xarray[i]=="0" || xarray[i]=="1" || xarray[i]=="2" || xarray[i]=="3" || xarray[i]=="4" || xarray[i]=="5" || xarray[i]=="6" || xarray[i]=="7" || xarray[i]=="8" || xarray[i]=="9")
					{chk="OK";}else{chk="false"; break;}
				}
		}

	} else if(len==8) {
			for (i=0;i<len;i++){
					if(xarray[i]=="0" || xarray[i]=="1" || xarray[i]=="2" || xarray[i]=="3" || xarray[i]=="4" || xarray[i]=="5" || xarray[i]=="6" || xarray[i]=="7" || xarray[i]=="8" || xarray[i]=="9")
					{chk="OK";}else{chk="false"; break;}
		}
	}

	if(chk=="OK"){
	window.location="/apps002.nsf/bsigoto?openform";
	//document.forms[0].submit();
	}else{
	alert("Invalid Library Card Number. Please try again.");
	}

}