function showPop(thisurl){
	
		win2=window.open(thisurl, '', 'scrollbars=no, status=yes, left=0, top=0, width=800, height=1')
	}


document.write('<style>.incidents .detailbox {display: none;}</style>')
document.write('<style>.gallery {display: none;}</style>')

if (top.frames.length > 0)
    {
        top.location.href = location.href;
    }
	
//detect flash
var flashversion = 0;
if (navigator.plugins && navigator.mimeTypes.length) {
	var x = navigator.plugins["Shockwave Flash"];
	if(x && x.description) {
		var y = x.description;
		flashversion = parseInt(y.substr(y.indexOf(".") - 2, 2), 10);
	}
} else {
	result = false;
	for(var i = 30; i >= 3 && result != true; i--){
		execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
		flashversion = i;
	}
}

if (flashversion >= 8) {
	// remove flicker of non flash
    document.getElementsByTagName('html')[0].className = 'flashInstalled';

}
	

function getFlash(what, movie, query, width, height) {

	new_txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">\n';
	new_txt += '<param name="movie" value="'+movie+query+'">\n';
	new_txt += '<param name="quality" value="high" />\n';
	new_txt += '<param name="menu" value="false">\n';
	new_txt += '<param name="wmode" value="transparent">\n';
	new_txt += '<param name="scale" value="noscale" />\n';
	new_txt += '<param name="salign" value="lt" />\n';
	new_txt += '<embed src="'+movie+query+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" scale="noscale" salign="lt" wmode="transparent"></embed>\n';
	new_txt += '</object>';
	what.innerHTML = new_txt;
	what.style.visibility= 'visible';
	
}

function flashRewrite(x, movie, query, type){

	if (flashversion >= 8){
		
	if (type == '1'){
	
	xArea = x.split('>'); //if TagName in a id
	if (xArea[1]){
		
	var x = $(xArea[0]).getElementsByTagName(xArea[1]);	
	} else {	
	var x = document.getElementsByTagName(x);	
	}
	
	for (var i=0;i<x.length;i++){
	
		width = x[i].offsetWidth;
		height = x[i].offsetHeight;
		title = x[i].innerHTML;
		if (title) {title = title.replace("&", "%26")}
		
			if (!query){
				q= "?title="+ title;
			}else{
				q= query +"&title="+ title;
			}

			getFlash(x[i], movie, q, width, height)
			q = '';
	}
	} else {
	
	var x = $(x);
	
		width = x.offsetWidth;
		height = x.offsetHeight;
		getFlash(x, movie, query, width, height)
	}
}	
}

function openWindow(){
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
	if (x[i].getAttribute('title') >'') {
		
		if (x[i].getAttribute('title').indexOf("Link opens in a new window") >= 0)
		{
		x[i].onclick = function () {window.open(this.href); return false}
		}	
	}	
	}
}

function formStyle(){
	var formRoot = document.getElementsByTagName("form"); 
	for (var f=0;f<formRoot.length;f++)
	{
		var r = formRoot[f].elements;
		var rlen = r.length;

		for (var h = 0; h < rlen; h++) {
		 var node = r[h];
				
					node.onfocus=function() {
					if(this.type !=='checkbox' && this.type !=='radio' && (this.tagName =='INPUT' || this.tagName =='TEXTAREA')) {
							this.className="textformfocus";
							if (this.value.charAt(0) == '-') { this.value='' } 
					}
			}
												
					node.onblur=function() {
					if(this.type !=='checkbox' && this.type !=='radio' && (this.tagName =='INPUT' || this.tagName =='TEXTAREA')) {
							this.className="textform";
					}
			}
			
		}
	}
}	


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");
  }
  return null;
}



function boxLinks() {
		
		linkNode = $A(document.getElementsByClassName("box")); 
		linkNode.each(function(node, i) {
		
				node.className+=" hand";
				node.onclick=function() {
					
						window.location = node.childNodes[1].childNodes[2].href;
					
				}	
		
		})
	}


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

/*
function addMarker(map, point, html) {
 var marker = new GMarker(point, icon);

 map.addOverlay(marker);
 GEvent.addListener(marker, "click", function() {
											  
   map.centerAndZoom(point, 2);

$('address').innerHTML = html;
flashRewrite('address>h3','../images/layup1/title2.swf', '', '1')
 });
} 
 
function resetMap() {
   map.centerAndZoom(new GPoint(0.722351, 51.903613), 9);

} 
*/

addEvent(window, 'load', boxLinks);
addEvent(window, 'load', openWindow);
addEvent(window, 'load', formStyle);
addEvent(window, 'load', function() {
					  
	$("Fprint").onclick = function() {window.print();}
	if ($("office-example")) flashRewrite('office-example','../images/layup1/office.swf', '', '0');
	if ($("boxnavi")){accordion = new Accordion("boxnavi", 3)};

});

addEvent(window, 'load', function() {

if (getActiveStyleSheet() == 'Default Screen Style'){
	flashRewrite('middle>h1','../images/layup1/title.swf', '', '1')	
	flashRewrite('topcontent>h2','../images/layup1/title2.swf', '', '1')
	if ($("address")) {flashRewrite('address>h3','../images/layup1/title2.swf', '', '1')}
	if ($("efabox")) {flashRewrite('efabox>h2','../images/layup1/title3.swf', '', '1')}
	if ($("vidbox")) {flashRewrite('vidbox>h2','../images/layup1/title2.swf', '', '1')}
	}
});

addEvent(window, 'load', function() {

	//safari search
	if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
		
		if ($('filter'))  {
			searchField = $('filter');
		    searchField.setAttribute('type', 'search');
			searchField.setAttribute('autosave', 'at.essexfire.search');
			searchField.setAttribute('results', '5');	
			searchField.style.width ='186px'
	}}


});


function display_details(what){
		if ($(what).style.display == 'block') {
			$(what).style.display = 'none';
		} else {
			$(what).style.display = 'block';
	}
}

function showGallery(what,showclass){
		if ($(what).style.display == 'block') {
			$(what).style.display = 'none';
			$(showclass).className='ask filesoff';
		} else {
			$(what).style.display = 'block';
			$(showclass).className='ask fileson';
		}
}

function popup(url) {
var w = 800;
var h = 600;
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;

var page = url;
windowprops = "height="+h+",width="+w+",top="+ wint +",left="+ winl +",location=no,"
+ "scrollbars=yes,menubars=no,toolbars=no,resizable=yes,status=yes";
window.open(page, "Popup", windowprops);

}

function feedbackform() {
	if ($("feedback")) {
			var title = $("Title").value;
			var initials = $("Initials").value;
			var surname = $("Surname").value;
			var telephone = $("Telephone").value;
			var house = $("House").value;
			var county = $("County").value;
			var postcode = $("Postcode").value;
			var err = '';
		if (((title !='') && (title.charAt(0)!='-')) || ((initials !='') && (initials.charAt(0)!='-')) || ((surname !='') && (surname.charAt(0)!='-')) || ((telephone !='') && (telephone.charAt(0)!='-')) || ((house !='') && (house.charAt(0)!='-')) || ((county !='') && (county.charAt(0)!='-')) || ((postcode !='') && (postcode.charAt(0)!='-'))) {
			if ((title =='') || (title.charAt(0)=='-')) { err = err + '\n Please enter your title';}
			if ((initials =='') || (initials.charAt(0)=='-')) { err = err + '\n Please enter your initials';}
			if ((surname =='') || (surname.charAt(0)=='-')) { err = err + '\n Please enter your surname';}
			if ((telephone =='') || (telephone.charAt(0)=='-')) { err = err + '\n Please enter your telephone';}
			if ((house =='') || (house.charAt(0)=='-')) { err = err + '\n Please enter your house number and street';}
			if ((county =='') || (county.charAt(0)=='-')) { err = err + '\n Please enter your county';}
			if ((postcode =='') || (postcode.charAt(0)=='-')) { err = err + '\n Please enter your postcode';}
		}
		if (err !='') {
			alert(err);
			return false;
		} else {
			$("feedback").submit();
		}
	}
}



var citrusCMS = {
		
	load : function() {
		citrusCMS.openWindow();
		citrusCMS.confirmBox();
		citrusCMS.boxLinks();
		citrusCMS.communicatedDocs();
	},
	
	openWindow : function(){
		
		allNodes = $A(document.getElementsByClassName("openWindow")); 
		allNodes.each(function(node, i) {
		allNodes[i].onclick = function() {window.open(this.href); return false};
		});
	},
	
	confirmBox : function() {
		var text = 'Are you sure?';
		allNodes = $A(document.getElementsByClassName('confirm'));
		allNodes.each(function(node, i) {
							   
			allNodes[i].onclick = function() {
				if (this.getAttribute('title')!=''){text = 'Are you sure you wish to ' + this.getAttribute('title') +'?';}
				return confirm(text)
			}; 
			
		});
	},
	
	boxLinks : function(){
		
		allNodes = $A(document.getElementsByClassName("box")); 
		allNodes.each(function(node, i) {
		allNodes[i].onclick = function() {
			if (this.id !='nolink') {	window.location = this.getElementsByTagName("a")[0].href };
			}
		});
		
	},
	
	communicatedDocs : function() {
		allNodes = $A(document.getElementsByClassName("communicated")); 
		allNodes.each(function(node, i) {
		allNodes[i].onclick = function() {
				var myAjax = new Ajax.Request(
					window.location,
					{
						method: 'post', 
						parameters: 'ajax=1&' + Form.serialize("cmsForm"),
						onComplete: this.style.display = 'none'
					});
			};
		});
		
	}
}
Event.observe(window, 'load', citrusCMS.load, false);