// AREANAMES must be in the correct order as in the flash and the form
var areanames = new Array("area1","area2","area3","area4","area5","area6","area7","area8","area9","area10","area11","area12","area13","area14","area15","area16","area17");

// pathtoclip is the path to the movieclip in the flash with the buttons and areas in
var pathtoclip = "/map/";
var rolloffFrame = "up";
var rolloverFrame = "over";
var selectedFrame = "selected";
var boxname_start = "box";
var textname_start = "text";

// selected rollover styles
function areaon(areaname) {
	window.document.getElementById(areaname).style.color = "#68B07D";
	window.document.getElementById(areaname).style.textDecorationUnderline = true;
}

//normal styles to change them back
function areaoff(areaname) {
	window.document.getElementById(areaname).style.color = "#000";
	window.document.getElementById(areaname).style.textDecorationUnderline = false;
}

function checkHiddenBoxes(){
	if (document.searchform.box6.checked == true){
	document.searchform.aloNNewbald.checked=true;
	//alert ("the box is selected");
	}else{
	document.searchform.aloNNewbald.checked=false;
	}
	
	if (document.searchform.box9.checked == true){
	document.searchform.aloAnlabyCommon.checked=true;
	//alert ("the box is selected");
	}else{
	document.searchform.aloAnlabyCommon.checked=false;
	}
 }

function SubmitForm(){
        window.document.forms.searchform.submit();
}
function ResetForm(){
        window.document.forms.searchform.reset();
        checkwhatson();
}

//DONT TOUCH THE STUFF BELOW HERE
//---------------------------------------------------------------------------------------------

 function getareaname(i) {
	var areaname = areanames[i];
	return areaname;
 }
 function doPassVar(variablename,thevalue){
	window.document.flashMap.SetVariable(variablename, thevalue);
}
function checkwhatson() {
	for (i = 0; i < areanames.length; i++) {	
		var whichbox = boxname_start + i;
		if (window.document.getElementById(whichbox).checked == true) {
			areaname = getareaname(i);
			areaon(textname_start + i);
			var areaselected = areanames[i] + "selected";
			doPassVar(areaselected,1)
			document.flashMap.TGotoLabel(pathtoclip + areanames[i],selectedFrame);
		} else {
			var areaselected = areanames[i] + "selected";
			doPassVar(areaselected,0)
			document.flashMap.TGotoLabel(pathtoclip + areanames[i],rolloffFrame);
			areaoff(textname_start + i);
		}
	}
}
function clicktext(thearea) {
	var areaname = getareaname(thearea);
	var whichbox = boxname_start +  thearea;
	
	if(window.document.getElementById(whichbox).checked == true) {
		window.document.getElementById(whichbox).checked = false;
		var areaselected = areaname + "selected";
		doPassVar(areaselected,0)
		document.flashMap.TGotoLabel(pathtoclip + areaname,rolloverFrame);
		areaoff(textname_start + thearea);
	} else {
		window.document.getElementById(whichbox).checked = true;
		var areaselected = areaname + "selected";
		doPassVar(areaselected,1)
		var movieclip = pathtoclip + areaname + boxname_start;
		document.flashMap.TGotoLabel(pathtoclip + areaname,selectedFrame);
		areaon(textname_start + thearea);
	}
}
function clickcheckbox(thearea) {
	var areaname = getareaname(thearea);
	var whichbox = boxname_start +  thearea;
	if(window.document.getElementById(whichbox).checked == true) {
		areaon(textname_start + thearea);
		var areaselected = areaname + "selected";
		doPassVar(areaselected,1)
		document.flashMap.TGotoLabel(pathtoclip + areaname,selectedFrame);	
	} else {
		//window.document.getElementById(areaname).style.fontWeight = "normal";
		var areaselected = areaname + "selected";
		doPassVar(areaselected,0);
		document.flashMap.TGotoLabel(pathtoclip + areaname,rolloverFrame);
		areaoff(textname_start + thearea);
	}
}
function spanhover(thearea) {
	var areaname = getareaname(thearea);
	var txtname = textname_start + thearea;
	var whichbox = boxname_start +  thearea;
	if(window.document.getElementById(whichbox).checked != true) {
		document.flashMap.TGotoLabel(pathtoclip + areaname,rolloverFrame);
	}
	areaon(txtname);
}
function spanhoveroff(thearea) {
	var areaname = getareaname(thearea);
	var txtname = textname_start + thearea;
	var whichbox = boxname_start +  thearea;
	if(window.document.getElementById(whichbox).checked != true) {
		document.flashMap.TGotoLabel(pathtoclip + areaname,rolloffFrame);
		areaoff(txtname);
	}
	
}
function maphover(thearea) {		
	for (i = 0; i < areanames.length; i++) {	
		if (thearea == areanames[i]) {
				areaon(textname_start + i);
		} else {
			var whichbox = boxname_start +  i;
			if(window.document.getElementById(whichbox).checked == true) {
				areaon(textname_start + i);
			} else {
				areaoff(textname_start + i);
			}
		}
	}
}
function maphoveroff(thearea) {		
	for (i = 0; i < areanames.length; i++) {	
		var whichbox = boxname_start +  i;
		if(window.document.getElementById(whichbox).checked == true) {
			areaon(textname_start + i);
		} else {
			areaoff(textname_start + i);
		}
	}
}
function swapSearch(thearea) {
	for (i = 0; i < areanames.length; i++) {	
		if (thearea == areanames[i]) {
			var whichbox = boxname_start +  i;
			//alert(whichbox);
			if(window.document.getElementById(whichbox).checked == true) {
				window.document.getElementById(whichbox).checked = false;
			} else {
				window.document.getElementById(whichbox).checked = true;
				areaon(textname_start + i);
			}		
		}
	}
}