/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
* Modified by Gareth Davies
* Guerrilla Digital Media (05/12/2005)
************************************************/


//var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
//var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){
	document.write('<style type="text/css">\n')
	document.write('.sub1, .sub2{display: none;}\n')
	document.write('</style>\n')
}

function index() {
	PAGE1 = "http://www.nrsp.org.uk/index.aspx"
	PAGE2 = "http://www.nrsp.org/index.aspx"
	PAGE3 = "http://nrsp.org.uk/index.aspx";
	PAGE4 = "http://nrsp.org/index.aspx";
	PAGE = document.location;
	
	if (PAGE!=PAGE1 && PAGE!=PAGE2 && PAGE!=PAGE3 && PAGE!=PAGE4){
		goTo('index.aspx');
	} else {
		SwitchMenu('sub1');
	}
}
function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterWrap").getElementsByTagName("div");
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu")
				ar[i].style.display = "none";
			}
			el.style.display = "block";
			
			switch_areas(obj);
			switch_sub_areas(obj);
		}else{
			el.style.display = "none";
		}
	}
}
function hide_areas(subs,menu) {
	var inc=1
	if (subs=='0'){
		while (document.getElementById("sub"+inc)){
			document.getElementById("sub"+inc).style.display = "none";
		inc++
		}
	} else {
		while (document.getElementById("sub"+inc)){
			if (("sub"+inc)!=("sub"+subs)){
				document.getElementById("sub"+inc).style.display = "none";
			}else{
				document.getElementById("menu"+menu).style.background='url(images/menu4.gif)';
				document.getElementById("menu"+menu).style.color='#FFFFFF';
				//alert(menu);
			}
			inc++
		}
	}
	inc=1
	while (document.getElementById("menu"+inc)){
		if (("menu"+inc)!=("menu"+menu)){
			if ((("menu"+inc)==("menu"+"3"))|(("menu"+inc)==("menu"+"4"))|(("menu"+inc)==("menu"+"8"))|(("menu"+inc)==("menu"+"9"))|(("menu"+inc)==("menu"+"11"))){
				document.getElementById("menu"+inc).style.background='url(images/menu3.gif)';
			}else{
				document.getElementById("menu"+inc).style.background='url(images/menu2.gif)';
				document.getElementById("menu"+inc).style.color='#000000';
			}
		}else{
			if ((("menu"+inc)==("menu"+"3"))|(("menu"+inc)==("menu"+"4"))|(("menu"+inc)==("menu"+"8"))|(("menu"+inc)==("menu"+"9"))|(("menu"+inc)==("menu"+"11"))){
				document.getElementById("menu"+inc).style.background='url(images/menu4.gif)';
				document.getElementById("menu"+inc).style.color='#FFFFFF';
				//alert(inc);
			}else{
				document.getElementById("menu"+inc).style.background='url(images/menu1.gif)';
			}
		}
		inc++
	}
}
function hide_areas_OLD(subs,menu) {
	inc=1;
	while (document.getElementById("menu"+inc)){
		if (inc!=menu){
			if(!((inc=='3')|(inc=='4')|(inc=='8')|(inc=='9')|(inc=='11'))){
				document.getElementById("menu"+inc).style.background='url(images/menu2.gif)';
				document.getElementById("menu"+inc).style.color='#000000';
			}
		} else {
			if((inc=='3')|(inc=='4')|(inc=='8')|(inc=='9')|(inc=='11')){
				//document.getElementById("menu"+inc).style.background='url(images/menu4.gif)';
			} else {
				document.getElementById("menu"+inc).style.background='url(images/menu1.gif)';
				document.getElementById("menu"+inc).style.color='#FFFFFF';
			}
		}
		inc++
	}
}
function switch_areas(subs) {
	if (subs=="sub1"){
		hide_areas('1','1');
	}
	if (subs=="sub2"){
		hide_areas('2','2');
	}
	if (subs=="sub3"){
		hide_areas('3','5');
	}
	if (subs=="sub4"){
		hide_areas('4','6');
	}
	if (subs=="sub5"){
		hide_areas('5','7');
	}
	if (subs=="sub6"){
		hide_areas('6','10');
	}
}
function sub_menu_change(smenu){
	inc=1
	while (document.getElementById("smenu"+inc)){
		if (("smenu"+inc)!=("smenu"+smenu)){
			document.getElementById("smenu"+inc).style.color='#000000';
			document.getElementById("ssub"+inc).style.display = "none";
		} else {
			document.getElementById("smenu"+inc).style.color='#00A1B1';
		}
		inc++
	}
}
function switch_sub_areas(subs) {
	if (subs=="ssub1"){
		sub_menu_change('1');
	}else if (subs=="ssub2"){
		sub_menu_change('2');
	}else if (subs=="ssub3"){
		sub_menu_change('3');
	}else if (subs=="ssub4"){
		sub_menu_change('4');
	}else if (subs=="ssub5"){
		sub_menu_change('5');
	}else if (subs=="ssub6"){
		sub_menu_change('6');
	}else if (subs=="ssub7"){
		sub_menu_change('7');
	}else if (subs=="ssub8"){
		sub_menu_change('8');
	}else if (subs=="ssub9"){
		sub_menu_change('9');
	}else if (subs=="ssub10"){
		sub_menu_change('10');
	}else if (subs=="ssub11"){
		sub_menu_change('11');
	}else if (subs=="ssub12"){
		sub_menu_change('12');
	}
}

function toggleBG(div,state,subdiv){
	if(state=="1"){
		if (subdiv=="null"){
			document.getElementById(div).style.background='url(images/menu4.gif)';
			document.getElementById(div).style.color='#FFFFFF';
		}else{
			document.getElementById(div).style.background='url(images/menu1.gif)';
			document.getElementById(div).style.color='#FFFFFF';
		}
	} else {
		if (subdiv=="null"){
			document.getElementById(div).style.background='url(images/menu3.gif)';
			document.getElementById(div).style.color='#000000';
		}else if(document.getElementById(subdiv).style.display != "block"){
			document.getElementById(div).style.background='url(images/menu2.gif)';
			document.getElementById(div).style.color='#000000';
		}
	}
}
function toggleCLR(div,state,subdiv){
	if(state=="1"){
		document.getElementById(div).style.color='#00A1B1';
	} else {
		if(document.getElementById(subdiv).style.display != "block"){
			document.getElementById(div).style.color='#000000';
		}else{
			document.getElementById(div).style.color='#00A1B1';
		}
	}
}

function goTo(screen)
{
	window.location=screen;
}

function displayArea(menuid,subid,smenuid,ssubid,itemid) {
	MM_preloadImages('images/menu1.gif','images/menu2.gif','images/menu3.gif','images/menu4.gif');
	hide_areas(subid, menuid)
	if (subid!='0'){
		SwitchMenu("sub"+subid)
	}
	if (itemid!='0'){
		toggleCLR("item"+itemid,'1','0')
	}
	if (ssubid!='0'){
		SwitchMenu("ssub"+ssubid)
	}
	if (smenuid!='0'){
		document.getElementById("smenu"+smenuid).style.color='#00A1B1';
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}