var theRules = new Array();
var menuArray, submenuArray;
var currentMenu="location";
var currentSubmenu="location";
var activeMenu="location";
var activeSubmenu="location";


menuArray=new Array(10);
submenuArray=new Array(10);
var path=document.location.toString();
if (path.indexOf("jhweb1:2186")){
menuArray[0]="253";
menuArray[1]="location";
menuArray[2]="254";
menuArray[3]="openingtimes";
menuArray[4]="255";
menuArray[5]="directory";
menuArray[6]="256";
menuArray[7]="newsevents";
menuArray[8]="257";
menuArray[9]="contact";

submenuArray[0]="1198";
submenuArray[1]="location";
submenuArray[2]="1199";
submenuArray[3]="openingtimes";
submenuArray[4]="1200";
submenuArray[5]="directory";
submenuArray[6]="1201";
submenuArray[7]="newsevents";
submenuArray[8]="1202";
submenuArray[9]="contact";
}
else{
menuArray[0]="279";
menuArray[1]="location";
menuArray[2]="280";
menuArray[3]="openingtimes";
menuArray[4]="281";
menuArray[5]="directory";
menuArray[6]="282";
menuArray[7]="newsevents";
menuArray[8]="283";
menuArray[9]="contact";

submenuArray[0]="1282";
submenuArray[1]="location";
submenuArray[2]="1283";
submenuArray[3]="openingtimes";
submenuArray[4]="1284";
submenuArray[5]="directory";
submenuArray[6]="1285";
submenuArray[7]="newsevents";
submenuArray[8]="1286";
submenuArray[9]="contact";
}
getRules();

function setColor(color){
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#leftcolumn" || theRules[i].selectorText=='*[ID"leftcolumn"]'){
			theRules[i].style.setProperty('background', color, null);
			}
			if(theRules[i].selectorText=="#content" || theRules[i].selectorText=='*[ID"content"]'){
			theRules[i].style.setProperty('color', color, null);
			}
			if(theRules[i].selectorText=="#content .pagetab .standfirst" || theRules[i].selectorText=='*[ID"content"] .pagetab .standfirst'){
			theRules[i].style.setProperty('color', color, null);
			}
			if(theRules[i].selectorText==".pagetitle" || theRules[i].selectorText=='.pagetitle'){
			theRules[i].style.setProperty('color', color, null);
			}

			if(theRules[i].selectorText=="#subpagelinks a" || theRules[i].selectorText=='[ID"subpagelinks"] A'){
			theRules[i].style.setProperty('color', color, null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#leftcolumn"){
				theRules[i].style.background=color;
			}
			if(theRules[i].selectorText=="#content"){
				theRules[i].style.color=color;
			}
			if(theRules[i].selectorText=="#content .pagetab .standfirst"){
				theRules[i].style.color=color;
			}
			if(theRules[i].selectorText==".pagetitle"){
				theRules[i].style.color=color;
			}
			if(theRules[i].selectorText=="#subpagelinks A"){
				theRules[i].style.color=color;
			}
		}
	}
}

function setBg(color){
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#bodycontent" || theRules[i].selectorText=='*[ID"bodycontent"]'){
			theRules[i].style.setProperty('background', 'url(/images/bg-'+color.substring(1)+'.gif) top left repeat-y', null);
			}
			
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#bodycontent"){
			theRules[i].style.background='url(/images/bg-'+color.substring(1)+'.gif) top left repeat-y';
			}
		}
	}
}

function setMainBg(color){
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#bodycontent" || theRules[i].selectorText=='*[ID"bodycontent"]'){
			theRules[i].style.setProperty('background', 'url(/images/bg-'+color.substring(1)+'-main.gif) top left repeat-y', null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#bodycontent"){
			theRules[i].style.background='url(/images/bg-'+color.substring(1)+'-main.gif) top left repeat-y';
			}
		}
	}
}

function setFontSize(){
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#content h2" || theRules[i].selectorText=='*[ID"content"] H2'){
			theRules[i].style.setProperty('font-size', '2.5em', null);
			theRules[i].style.setProperty('color', '#FFFFFF', null);
			}
			if(theRules[i].selectorText=="#content .pagetab" || theRules[i].selectorText=='*[ID"content"] .pagetab'){
			theRules[i].style.setProperty('color', '#FFFFFF', null);
			theRules[i].style.setProperty('font-weight', 'bold', null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#content H2"){
			theRules[i].style.fontSize='2.5em';
			theRules[i].style.color='#FFFFFF';
			}
			if(theRules[i].selectorText=="#content .pagetab"){
			theRules[i].style.color='#FFFFFF';
			theRules[i].style.fontWeight='bold';
			}
		}
	}
}


function setHeight(){
		var height=document.getElementById('maincontent').offsetHeight;
		var rightHeight=document.getElementById('rightcolumn').offsetHeight;
		var leftHeight=document.getElementById('leftcolumn').offsetHeight;
		var offHeight;
		offHeight=Math.max(rightHeight, leftHeight);
		offHeight=Math.max(height, offHeight);
		if (offHeight<437) offHeight=437;
		setHeight0(offHeight);
		
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#bodycontent" || theRules[i].selectorText=='*[ID"bodycontent"]'){
				theRules[i].style.setProperty('height', offHeight+'px', null);
			}
			/*
			if(theRules[i].selectorText=="#bgopacity"){
				theRules[i].style.setProperty('height', offHeight+'px', null);
			}
			*/
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#bodycontent"){
			theRules[i].style.height=offHeight;
			}
			/*
			if(theRules[i].selectorText=="#bgopacity"){
			theRules[i].style.height=offHeight;
			}
			*/
		}
	}
		
}

function getRules(){
	if (document.styleSheets[0].cssRules){
		theRules = document.styleSheets[0].cssRules;
	}
	// IE
	else if (document.styleSheets[0].rules){
		theRules = document.styleSheets[0].rules;
	}
}

function setHeight0(height){
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if (theRules[i].selectorText=="#bodycontent" || theRules[i].selectorText=='*[ID"bodycontent"]'){
			theRules[i].style.setProperty('height', height+'px', null);
			}
			else if(theRules[i].selectorText=="#leftcolumn" || theRules[i].selectorText=='*[ID"leftcolumn"]'){
			theRules[i].style.setProperty('height', (height-20)+'px', null);
			}
			else if(theRules[i].selectorText=="#rightcolumn" || theRules[i].selectorText=='*[ID"rightcolumn"]'){
			theRules[i].style.setProperty('height', (height-20)+'px', null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if (theRules[i].selectorText=="#bodycontent"){
			theRules[i].style.height=height;
			}
			else if(theRules[i].selectorText=="#leftcolumn"){
			theRules[i].style.height=(height-20);
			}
			else if(theRules[i].selectorText=="#rightcolumn"){
			theRules[i].style.height=(height-20);
			}
		}
	}
}

function setMenuOff(menu){
	document.getElementById(currentMenu).src="/images/"+currentMenu+".gif";
	if(activeMenu==menu) document.getElementById(menu).src="/images/"+menu+"-on.gif";
	activeMenu=menu;
}

function setSubmenuOff(menu){
	document.getElementById(currentSubmenu).src="/images/"+currentSubmenu+".gif";
	if(activeSubmenu==menu) document.getElementById(menu).src="/images/"+menu+"-on.gif";
	activeSubmenu=menu;
}


function setMenuActive(menu){
	document.getElementById(currentMenu).src="/images/"+currentMenu+".gif";
	document.getElementById(menu).src="/images/"+menu+"-on.gif";
	currentMenu=menu;
}

function setSubmenuActive(menu){
	document.getElementById(currentSubmenu).src="/images/"+currentSubmenu+".gif";
	document.getElementById(menu).src="/images/"+menu+"-on.gif";
	currentSubmenu=menu;
}


function setMenuOn(menuid){
	for(var i=0; i<menuArray.length; i+=2){
			if (menuid==menuArray[i]) menu=menuArray[i+1];
	}
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#rightcolumn #leftnav li.on a" || theRules[i].selectorText=='*[ID"rightcolumn"] *[ID"leftnav"] LI.on[CLASS~="on"] A'){
			theRules[i].style.setProperty('background', 'url(/images/'+menu+'.gif) top left no-repeat', null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#rightcolumn #leftnav LI.on A"){
			theRules[i].style.background='url(/images/'+menu+'.gif) top left no-repeat';
			}
		}
	}
}

function setSubmenuOn(menuid){
	for(var i=0; i<submenuArray.length; i+=2){
			if (menuid==submenuArray[i]) menu=submenuArray[i+1];
	}
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#leftcolumn #pagelinks li.on a" || theRules[i].selectorText=='*[ID"leftcolumn"] *[ID"pagelinks"] LI.on[CLASS~="on"] A'){
			theRules[i].style.setProperty('background', 'url(/images/'+menu+'-sub.gif) top left no-repeat', null);
			}
			if(theRules[i].selectorText=="#leftcolumn #pagelinks li a" || theRules[i].selectorText=='*[ID"leftcolumn"] *[ID"pagelinks"] LI A'){
			theRules[i].style.setProperty('background', 'url(/images/'+menu+'.gif) top left no-repeat', null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#leftcolumn #pagelinks li.on a"){
			theRules[i].style.background='url(/images/'+menu+'-sub.gif) top left no-repeat';
			}
			if(theRules[i].selectorText=="#leftcolumn #pagelinks li a"){
			theRules[i].style.background='url(/images/'+menu+'.gif) top left no-repeat';
			}
		}
	}
}

function setSublinkPosition(){
		var height=document.getElementById('content').offsetHeight;
		var linkHeight=document.getElementById('lowerlinks').offsetHeight;
		var offHeight=0;
		if (height<=437) offHeight=437-height;
		
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#lowerlinks" || theRules[i].selectorText=='*[ID"lowerlinks"]'){
			theRules[i].style.setProperty('padding-top', offHeight+'px', null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText=="#lowerlinks"){
			theRules[i].style.paddingTop= offHeight+'px';
			}
		}
	}
		
}

function setTurnOverPos(){
		var offHeight=0
		if(document.getElementById('lowerlinks')!=null)
			offHeight=document.getElementById('lowerlinks').offsetHeight-10;
		
	// firefox
	if (document.styleSheets[0].cssRules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText==".turnover"){
				theRules[i].style.setProperty('bottom', offHeight+'px', null);
			}
		}
	}
	// IE
	else if (document.styleSheets[0].rules){
		for (i=0; i<theRules.length; i++){
			if(theRules[i].selectorText==".turnover"){
			theRules[i].style.bottom=offHeight;
			}
		}
	}

}