function showSafariSearchBox() {
	if (!document.getElementById) return;
	var theSearchField = document.getElementById('nav-search-box'); // Enter search box's id attribute here
	if (navigator.userAgent.indexOf("AppleWebKit") !=-1) {
        // Changing type to 'search' from 'text'
        // and inserting 'autosave,' 'results,' 'placeholder' values for Safari and WebKit-based browsers
		theSearchField.setAttribute('type', 'search');
		theSearchField.setAttribute('autosave', 'saved.data');
		theSearchField.setAttribute('results', '5');
		theSearchField.setAttribute('placeholder', 'Search site');
theSearchField.style.width = '150px';
document.getElementById('nav-search-button').style.display = 'none';
	}
}

function showElementHideOthers(elementId, parentElementId, showClassName) {

	var myElement = document.getElementById(elementId);
	var parentElement = document.getElementById(parentElementId);
	var parentDivs = parentElement.getElementsByTagName('div');
	for(var i=0;i<parentDivs.length; i++) {		
		parentDivs[i].className = 'hidden';
	}

	myElement.className = showClassName;

}

function toggleElement(elementId, showClassName, hideClassName) {

	var myElement = document.getElementById(elementId);

if (myElement.className == showClassName) {
	myElement.className = hideClassName;
} else {
	myElement.className = showClassName;
}

}

function revealMaster(masterDivId, articleDivId) {
var masterDiv = document.getElementById(masterDivId);
var articleDiv = document.getElementById(articleDivId);
var localNavDiv = document.getElementById('local-nav');
var extrasDiv = document.getElementById('extras');
localNavDiv.className = 'hidden';
articleDiv.className = 'hidden';
extrasDiv.className = 'hidden';
masterDiv.className = 'shown';
var contentDiv = document.getElementById('content');
contentDiv.style.marginLeft='15px';
contentDiv.style.marginRight='15px';
}

function hideMaster(masterDivId, articleDivId) {
var masterDiv = document.getElementById(masterDivId);
var articleDiv = document.getElementById(articleDivId);
var localNavDiv = document.getElementById('local-nav');
var extrasDiv = document.getElementById('extras');
localNavDiv.className = 'shown';
articleDiv.className = 'shown';
extrasDiv.className = 'shown';
masterDiv.className = 'hidden';
var contentDiv = document.getElementById('content');
contentDiv.style.marginLeft='190px';
contentDiv.style.marginRight='190px';
}

// FLASH EMBED FUNCTIONS

function createFlashObjectTag(objSrc, objHeight, objWidth, objType, objVars, objWMode) {

	var strFlashTag = '';

	if (objType = "flash") {
	// FLASH FILE
	
		strFlashTag += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + objWidth + '" height="' + objHeight + '" id="video_test" align="middle">\n';
		if (objVars != '') {
			strFlashTag += '<param name="FlashVars" value="' + objVars + '">\n';
		}
		if (objWMode != '') {
			strFlashTag += '<param name="wmode" value="' + objWMode + '">\n';
		}
		strFlashTag += '<param name="allowScriptAccess" value="sameDomain" />\n';
		strFlashTag += '<param name="movie" value="' + objSrc + '" />\n';
		strFlashTag += '<param name="quality" value="high" />\n';
		strFlashTag += '<param name="bgcolor" value="#ffffff" />\n';
		strFlashTag += '<embed src="' + objSrc + '"';
		if (objVars != '') {
			strFlashTag += ' FlashVars="' + objVars + '"';
		}
		if (objVars != '') {
			strFlashTag += ' wmode="' + objWMode + '"';
		}
		strFlashTag += ' quality="high" bgcolor="#ffffff" width="' + objWidth + '" height="' + objHeight + '" name="video_player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
		strFlashTag += '</ob' + 'ject>\n';

	}

	document.write(strFlashTag);

}

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);
}

// function to open new windows

function popup(path, myWidth, myHeight) {

var attributes = "width=" + myWidth + ",height=" + myHeight + ",resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no";

window.open(path, '', attributes);

}

function popupBasic(path, myWidth, myHeight) {

var attributes = "width=" + myWidth + ",height=" + myHeight + ",resizable=no,scrollbars=no,menubar=no,toolbar=no,status=no,location=no";

window.open(path, '', attributes);

}

// DIDNT USE THIS IN THE END
function ns_flashcounter(ns_flashn){
var ns_flash="http://uk.sitestat.com/rspb/website/s?"+ns_flashn+"&amp;ns_type=flash"+"&amp;ns__t="+(new Date()).getTime();
document.ns_flashp.src=ns_flash;
}


// FUNCTION TO RESIZE SCREEN FOR IE6 AND UNDER
function expandLayout() {

// CHECK FOR IE SCREEN SIZE
var screenCookie = readCookie('wide');
if (screenCookie == null) {
	// COOKIE NOT THERE - DOES THE VERSION OF IE KNOW ABOUT SCREEN WIDTH
	if (screen.width) {
			// IF SO, IS SCREEN OVER 800 WIDE?
			if (screen.width > 800) {
				createCookie('wide', 'true', 90);
				largeScreen = true;
			} else {
				largeScreen = false;
			}
	} else {
		// IF NOT, ASSUME SMALL SCREEN
		largeScreen = false;
	}
} else {
	// COOKIE THERE
	if (screenCookie == 'true') {
		largeScreen = true;
	} else {
		if (screen.width > 800) {
			createCookie('wide', 'true', 90);
			largeScreen = true;
		} else {
			largeScreen = false;
		}
	}

}

// ADJUST LAYOUT
if (largeScreen == true) {
	document.write('<style type="text/css">#wrapper {width: 900px};#content {width:514px;}#content-wide{width: 694px;}</style>');
	//document.getElementById('wrapper').style.width='900px';
	//if (document.getElementById('content')) {
	//	document.getElementById('content').style.width='514px';
	//}
	//if (document.getElementById('content-wide')) {
	//		document.getElementById('content-wide').style.width='694px';
	//}
} else {
	document.write('<style type="text/css">#nav-search-box {display:none;}</style>');
	//document.getElementById('nav-search-box').style.display='none';
}

}

// FUNCTION TO ADD MULTIPLE ONLOAD EVENTS
function addLoadEvent(func) {

	var oldunload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldunload();
			func();
		}
	}

}

//SOCIAL BOOKMARKS HOVER WINDOW
function showElement(elementId) {

	var myElement = document.getElementById(elementId);

	//myElement.className = 'shown';
	myElement.style.position = 'absolute';
	myElement.style.display = 'block';

}

function hideElement(elementId) {

	var myElement = document.getElementById(elementId);

	//myElement.className = 'hidden';
	myElement.style.display = 'none';

}// two functions - checkForm() and isBlank()
// checkForm returns every blank field in a form unless it is marked optional
// checkForm calls isBlank
// mark fields optional by saying: this.myField.optional=true; in the onSubmit
// call using: onSubmit="return checkForm(this);"

function checkForm(f) {

var msg;
var empty_fields = "";

for (var i = 0; i < f.length; i++) {

var e = f.elements[i];
if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {

if ((e.value == null) || (e.value == "") || isBlank(e.value)) {
empty_fields += "\n" + e.name;
continue;
}

}

}

if (!empty_fields) {
return true;
}

if (empty_fields) {
msg = "One or more required fields are empty.\n";
msg += "Please complete the following fields before you submit the form:\n";
msg += empty_fields;
}

alert(msg);
return false;

}

function isBlank(s) {

for (var i = 0; i < s.length; i++) {

var c = s.charAt(i);
if ((c != ' ') && (c != '\n') && (c != '')) {
return false;
}

}

return true;

}function showMenu(menuId, linkId) {

	var myMenu = document.getElementById(menuId);
	var myLink = document.getElementById(linkId);
	var menus = document.getElementById('menus');
	var menuDivs = menus.getElementsByTagName('div');
	for(var i=0;i<menuDivs.length; i++) {
			if (menuDivs[i].className == 'menu-shown') {
				menuDivs[i].className = 'menu-hidden';
			}
	}

	myMenu.className = 'menu-shown';
	myLink.style.backgroundColor = "#EEEEEE";

}

function hideMenus() {

	var menus = document.getElementById('menus');
	var menuDivs = menus.getElementsByTagName('div');
	for(var i=0;i<menuDivs.length; i++) {
		menuDivs[i].className = 'menu-hidden';
	}
	var nav = document.getElementById('nav');
	var navChildren = nav.childNodes;
	for(var i=0;i<navChildren.length; i++) {
		if (navChildren[i].tagName == "A") {
			navChildren[i].style.backgroundColor = '#FFFFFF';
		}
	}

}// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  //if (src.indexOf('?') != -1) {
    //return src.replace(/\?/, ext+'?'); 
  //}else {
    //return src + ext;
//}
return src;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}/*
addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
*/
function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

/*
createElement function found at http://simon.incutio.com/archive/2003/06/15/javascriptWithXML
*/
function createElement(element) {
	if (typeof document.createElementNS != 'undefined') {
		return document.createElementNS('http://www.w3.org/1999/xhtml', element);
	}
	if (typeof document.createElement != 'undefined') {
		return document.createElement(element);
	}
	return false;
}

function insertTop(obj) {
	// Create the two div elements needed for the top of the box
	d=createElement("div");
	d.className="bt"; // The outer div needs a class name
    d2=createElement("div");
    d.appendChild(d2);
	obj.insertBefore(d,obj.firstChild);
}

function insertBottom(obj) {
	// Create the two div elements needed for the bottom of the box
	d=createElement("div");
	d.className="bb"; // The outer div needs a class name
    d2=createElement("div");
    d.appendChild(d2);
	obj.appendChild(d);
}

function initCB()
{
	// Find all div elements
	var divs = document.getElementsByTagName('div');
	var cbDivs = [];
	for (var i = 0; i < divs.length; i++) {
	// Find all div elements with cbb in their class attribute while allowing for multiple class names
		if (/\bcbb\b/.test(divs[i].className))
			cbDivs[cbDivs.length] = divs[i];
	}
	// Loop through the found div elements
	var thediv, outer, i1, i2;
	for (var i = 0; i < cbDivs.length; i++) {
	// Save the original outer div for later
		thediv = cbDivs[i];
	// 	Create a new div, give it the original div's class attribute, and replace 'cbb' with 'cb'
		outer = createElement('div');
		outer.className = thediv.className;
		outer.className = thediv.className.replace('cbb', 'cb');
	// Change the original div's class name and replace it with the new div
		thediv.className = 'i3';
		thediv.parentNode.replaceChild(outer, thediv);
	// Create two new div elements and insert them into the outermost div
		i1 = createElement('div');
		i1.className = 'i1';
		outer.appendChild(i1);
		i2 = createElement('div');
		i2.className = 'i2';
		i1.appendChild(i2);
	// Insert the original div
		i2.appendChild(thediv);
	// Insert the top and bottom divs
		insertTop(outer);
		insertBottom(outer);
	}
}

if(document.getElementById && document.createTextNode)
{
	addEvent(window, 'load', initCB);
}function hideNearYouChooser() {

document.getElementById("near-you-counties").className = 'hidden';
return false;

}

function changeNearYou() {

	var countyBlock = document.getElementById("near-you-counties");
	if (countyBlock.className == "hidden") {
		document.getElementById("near-you-counties").className = 'shown';
	} else {
		document.getElementById("near-you-counties").className = 'hidden';
	}
	return false;
}