var x="";var aW=Object();var aMap=Object();var aZ=Object();var aVC=Object();var elAct=null;var sLog="";var elToHide=null;var iClose=10;var taf=null;var tafShow=new TAFFY([]);var aWList=Object();var evLast=null;var sLang="english";var aLangs=Object();aLangs["Places to go in"]="Lleoedd i fynd";aLangs["Walking in"]="Cerdded yng";aLangs["Cycling in"]="Beicio yng";aLangs["Horse riding in"]="Marchogaeth yng";aLangs["Events in"]="Beth sy\u2019 \u2018mlaen yng";aLangs["Other activities in"]="Gweithgareddau eraill yng";function i18n(s){	el=document.getElementById("lang");	if (el!=null)		sLang=el.value;			if (sLang=="english")	{		return s;	}	if (aLangs[s]!==undefined)		return aLangs[s];			return s;}function doScale(){ 	el=document.getElementById("scale");	if (el!=null)	{		el.style.left=iScaleLeft;		el.style.top=iScaleTop;		f=fLen/fPx;		el.style.width=f+"px";		el.style.display="block";	}}function getNextTag(el,sTag){	while (el!=null && el.tagName!=sTag)	{		el=el.nextSibling;	}			return el;}function getNextDD(el){	while (el!=null && el.tagName!="DD")	{		el=el.nextSibling;	}			return el;}var aClose=Object();	function getCloseWoods(wood){	try	{		for (wd=0;wd<aWList[wood]["j"].length;wd++)		{			if (aClose[aWList[wood]["j"][wd]]==null)			{				aClose[aWList[wood]["j"][wd]]=aWList[wood]["j"][wd];				getCloseWoods(aWList[wood]["j"][wd]);			}		}	}	catch(e)	{	}}var aElToHide=Array();var curDD=null;function showDT(ev){	el=Event.element(ev);	elBox=document.getElementById("fortext");	elDD=getNextDD(el);	sHTML="";			aClose=Object();	aClose[aMap[el.id]]=aMap[el.id];	//aClose[el.id.toLowerCase()]=el.id.toLowerCase();	//getCloseWoods(el.id.toLowerCase(),aClose);	getCloseWoods(aMap[el.id],aClose);		if (elToHide!=null)		hideDT(elToHide);			elToHide=elDD;	if (elDD==null)		return;		curTop=0;	aCloseSort=new Array();	for (x in aClose)	{		aCloseSort[aCloseSort.length]=x;	}	hideTT();	aCloseSort.sort();	for (x=0;x<aCloseSort.length;x++)	{		s=aCloseSort[x];		if (aZ[aCloseSort[x]]!=1)		{			elWIP=document.getElementById("WoodIconPath");					elX=document.getElementById(aCloseSort[x].toLowerCase());			if (aVC[s]>0)			{				elX.style.background="url('"+elWIP.value+"/visiconz.gif') no-repeat";				sImg="<img src='"+elWIP.value+"/visiconx.gif'>&nbsp;";			}			else			{				elX.style.background="url('"+elWIP.value+"/woodiconz.gif') no-repeat";				sImg="";			}			elDD=getNextDD(elX);			sHTML+="<div style='width:172px;position:relative'>"+sImg+elDD.innerHTML+"</div>";			//if (aVC[s]==1)			//	sHTML+="There is no "+curAct+" at "+s+".  However, there's lots to do so please come";			//aElToHide[aElToHide.length]=elDD;			aElToHide.push(elDD);					curTop+=elDD.offsetHeight-2;		}	}	elBox.innerHTML=sHTML;}function hideDTarr(){	for (el=0;el<aElToHide.length;el++)	{		hideDT(aElToHide[el]);	}}function hideDT(elDD){	elDD.style.display="none";	elWIP=document.getElementById("WoodIconPath");	for (el=0;el<aElToHide.length;el++)	{		elDT=aElToHide[el].previousSibling;		while (elDT!=null && elDT.nodeType!=1)			elDT=elDT.previousSibling;		if (aVC[elDT.id]>0)			elDT.style.background="url('"+elWIP.value+"/visiconx.gif') no-repeat";		else			elDT.style.background="url('"+elWIP.value+"/woodiconx.gif') no-repeat";				aElToHide[el].style.display="none";	}}function hideDDForce(){	return;	if (curDD!=null)	{		curDD.style.display="none";		curDD=null;	}	for (el=0;el<aElToHide.length;el++)		aElToHide[el].style.display="none";}function positionWoods(idWood,x,y,img){	idWoodUL=idWood;	ar=taf.get({w:idWoodUL});	if (ar.length==0) // this stops any woods being displayed that don't have parameters	{		return;	}	idWood=idWood.toLowerCase();	aMap[idWood]=idWoodUL; // map lower and upper case wood names for use in get close woods.	//el=document.getElementById(idWoodUL);	el=document.getElementById(idWood);	if (el==null)	{		return;	}	el.style.cursor="pointer";	//el.onmouseover=function anonymous(){showDTAlt(this)};	el.onmouseout=function anonymous(){hideTT()};	//el.onfocus=function anonymous(){showDTAlt(this)};	el.onblur=function anonymous(){hideTT()};	el.tabIndex=0;			if (x<=0)	{		el.parentNode.removeChild(el);		return;	}	el.style.position="absolute";	var left=(x-xOrg)/fPx-ffX;	var top=imgHt-(y-yOrg)/fPx-ffY;	el.style.left=left+"px";	el.style.top=top+"px";	taf.update({x:left,y:top},{w:idWoodUL});	if (!(left==0 && top==0))	{			aWList[idWoodUL]=new Object();		aWList[idWoodUL]["x"]=left;		aWList[idWoodUL]["y"]=top;		/*aWList[idWood]=new Object();		aWList[idWood]["x"]=left;		aWList[idWood]["y"]=top;*/	}	if ((x>0 && y>0) && (top<imgHt && left<imgWidth-16) && (left>0 && top>0))	{		//el.onmousedown=function anonymous(){showDT(this)};		//el.onkeydown=function anonymous(){showDT(this)};		////el.onmouseover=function anonymous(){showWoodName(this)};		////el.style.display="inline";		el.style.display="block";		if (img!="")		{			elImg=document.getElementById(idWoodUL+"image");			if (elImg==null)			{				return;			}			elImg.style.display="block";						elImg.src="/images/"+img+"/$file/"+img;			if (elImg.width>elImg.height)				elImg.style.width="50%";			else				elImg.style.width="30%";		}	}	else	{		el.parentNode.removeChild(el);	}}var lastAct=getCookie("lastact");var curAct="ptg"function showWood(wood,bShow){	elWood=document.getElementById(wood);	if (elWood==null)	{		return;	}	if (bShow)	{		elWood.previousSibling.style.display="none";		if (elWood.style.left!=0 || elWood.style.top!=0)		{			elWood.style.display="block";		}	}	else	{		aZ[elWood.id]=1;		// why previous sibling? not sure this is right		if (elWood.previousSibling!=null && elWood.previousSibling.style!=null)		{			//elWood.previousSibling.style.display="none";		}		elWood.style.display="none";	}}function hideshow(id,sD){	el=document.getElementById("ah"+id);	if (el!=null)	{		el.style.display=sD;	}}function sh(){	var iCntTot=0;	var iCntThisWood=0;	aZ=Object();	taf.forEach(function (f,n) {hideshow(f.id,"none")});	tafShow.forEach(function (f,n) {hideshow(f.id,"none")});	tafShow=new TAFFY([]);	// This is called in response to a change in the criteria used.	// It goes through each wood in turn seeing if any meet the criteria	// If none do then the wood is hidden otherwise it is displayed	//alert("current activity "+curAct);	for (woodUL in aWList)	{		if (curAct=="ptg")		{					ar=taf.get({w:woodUL,t:{"has":curAct}});			}		else if (curAct=="event")		{				o=new Object();				o.w=woodUL;				o.t={"has":curAct};				gs=Array();				if (document.getElementById("e1").checked)					gs.push("nw");				if (document.getElementById("e2").checked)					gs.push("'nm");				if (document.getElementById("e3").checked)					gs.push("n3m");				if (document.getElementById("e4").checked)					gs.push("n6m");				o.whn=gs;				ar=taf.get(o);			}		else if (curAct=="othact")		{				o=new Object();				o.w=woodUL;				o.t={"has":curAct};				gs=Array();				if (document.getElementById("o1").checked)					gs.push("forestdrive.gif");				if (document.getElementById("o2").checked)					gs.push("fishing.gif");				if (document.getElementById("o3").checked)					gs.push("camping.gif");				if (document.getElementById("o4").checked)					gs.push("orienteering.gif");				if (document.getElementById("o5").checked)					gs.push("wildlifeactivities.gif");				if (document.getElementById("o6").checked)					gs.push("arts.gif");				if (document.getElementById("o7").checked)					gs.push("playarea.gif");				if (document.getElementById("o8").checked)					gs.push("watersports.gif");				if (document.getElementById("o9").checked)					gs.push("educational.gif");				if (document.getElementById("o10").checked)					gs.push("arboretum.gif");				if (document.getElementById("o11").checked)					gs.push("otheractivities.gif");				o.oa={"has":gs};				ar=taf.get(o);			}		else if (curAct=="horseriding")		{			ar=taf.get({w:woodUL,t:{"has":curAct}});			}		else if (curAct=="walking")		{					if (document.getElementById("graded").checked)				ar=taf.get({w:woodUL,t:{"has":curAct}});				else			{				o=new Object();				o.w=woodUL;				o.t={"has":curAct};				gs=Array();				if (document.getElementById("g1").checked)					gs.push("easyaccess.gif");				if (document.getElementById("g2").checked)					gs.push("gradienteasy.gif");				if (document.getElementById("g3").checked)					gs.push("gradientmoderate.gif");				if (document.getElementById("g4").checked)					gs.push("gradientdemanding.gif");				o.g=gs;				ar=taf.get(o);				}		}		else if (curAct=="cycling")				{			if (document.getElementById("cgraded").checked)				ar=taf.get({w:woodUL,t:{"has":curAct}});				else			{				o=new Object();				o.w=woodUL;				o.t={"has":curAct};				gs=Array();				if (document.getElementById("c1").checked)					gs.push("cyclingeasy.gif");				if (document.getElementById("c2").checked)					gs.push("cyclingmoderate.gif");				if (document.getElementById("c3").checked)					gs.push("cyclingdifficult.gif");				if (document.getElementById("c4").checked)					gs.push("cyclingsevere.gif");				if (document.getElementById("c5").checked)					gs.push("cyclingextreme.gif");				o.g=gs;				ar=taf.get(o);				}		}		wood=woodUL.toLowerCase();		//wood=woodUL;		if (ar.length==0)		{			// if its a vc then we still want to show it			/*if (aVC[woodUL]>0)			{				showWood(wood,true,woodUL);				aVC[woodUL]=ar.length+1;			}			else*/				showWood(wood,false);		}		else		{			showWood(wood,true,woodUL);			if (aVC[woodUL]>0)				aVC[woodUL]=ar.length+1;		}		for (i=0;i<ar.length;i++)		{			hideshow(ar[i].id,"block");			sId=ar[i].id;			tafShow.insert([{id:sId}]);		}	}}function shOld(){	var iCntTot=0;	var iCntThisWood=0;		// This is called in response to a change in the criteria used.	// It goes through each wood in turn seeing if any meet the criteria	// If none do then the wood is hidden otherwise it is displayed	//alert("current activity "+curAct);	for (woodUL in aW)	{		wood=woodUL.toLowerCase();		if (aW[wood]!=null)		{			if (aW[wood][curAct]==null)			{				showWood(wood,false);			}			else			{				iCntThisWood=checkWood(wood);				iCntTot+=iCntThisWood;				if (iCntThisWood==0)					showWood(wood,false);				else				{					showWood(wood,true);				}			}		}	}	//window.status="Total number of places shown: "+iCntTot;}function changeAct(s){	var sNew="";	el=document.getElementById("act"+curAct);	if (el!=null)		el.style.display="none";	curAct=s;	setCookie("lastact",s);	el=document.getElementById("act"+curAct);	if (el!=null)	{		el.style.display="block";		el.style.height=el.offsetHeight;	}	if (s=="othact")		sNew=i18n("Other activities in");	else if (s=="ptg")		sNew=i18n("Places to go in");	else if (s=="horseriding")		sNew=i18n("Horse riding in");	else if (s=="event")		sNew=i18n("Events in");	else if (s=="walking")		sNew=i18n("Walking in");	else if (s=="cycling")		sNew=i18n("Cycling in");			sNew="<span>"+sNew+" </span>";	el=document.getElementById("curact");	if (el!=null)	{		el.removeChild(el.lastChild);		el.innerHTML=sNew;	}	if (elAct!=null)	{		elAct.style.display="block";	}		el=document.getElementById(s+"hide");	if (el!=null)	{		el.style.display="none";		elAct=el;	}	el=document.getElementById("ptitle");	if (el!=null)		el.innerHTML=sNew;		sh();}function setParam(a){	// This is called when each link is added.  It notes the activities and gradient	// together with the wood (for categorisation) and the id (to show/hide)	if (a["t"]=="")	{		el=document.getElementById("ah"+a["id"]);		if (el!=null)			el.style.display="none";		return;	}	idx=a["w"].toLowerCase();	if (idx=="")	{		return;	}	if (aW[idx]==null)	{		aW[idx]=Object();	}	recordActivity(a,idx);}/*function spx(id){	a=Object();	el=document.getElementById("ah"+id);	if (el!=null)	{		if (el.getAttribute("w")!=undefined)		{			a["w"]=el.getAttribute("w");		}		if (el.getAttribute("ptg")!=undefined)		{			a["ptg"]=el.getAttribute("ptg");		}		if (el.getAttribute("g")!=undefined)		{			a["g"]=el.getAttribute("g");		}		if (el.getAttribute("eag")!=undefined)		{			a["eag"]=el.getAttribute("eag");		}		if (el.getAttribute("fd")!=undefined)		{			a["fd"]=el.getAttribute("fd");		}		if (el.getAttribute("fsh")!=undefined)		{			a["fsh"]=el.getAttribute("fsh");		}		if (el.getAttribute("cmp")!=undefined)		{			a["cmp"]=el.getAttribute("cmp");		}		if (el.getAttribute("ori")!=undefined)		{			a["ori"]=el.getAttribute("ori");		}		if (el.getAttribute("wld")!=undefined)		{			a["wld"]=el.getAttribute("wld");		}		if (el.getAttribute("art")!=undefined)		{			a["art"]=el.getAttribute("art");		}		if (el.getAttribute("pas")!=undefined)		{			a["pas"]=el.getAttribute("pas");		}		if (el.getAttribute("wat")!=undefined)		{			a["wat"]=el.getAttribute("wat");		}		if (el.getAttribute("edu")!=undefined)		{			a["edu"]=el.getAttribute("edu");		}		if (el.getAttribute("arb")!=undefined)		{			a["arb"]=el.getAttribute("arb");		}		if (el.getAttribute("oact")!=undefined)		{			a["oact"]=el.getAttribute("oact");		}		if (el.getAttribute("whn")!=undefined)		{			a["whn"]=el.getAttribute("whn");		}		if (el.getAttribute("sp")!=undefined)		{			a["sp"]=el.getAttribute("sp");		}		if (el.getAttribute("t")!=undefined)		{			a["t"]=el.getAttribute("t");		}		if (el.getAttribute("fd")!=undefined)		{			a["fd"]=el.getAttribute("fd");		}	}	sp(a);}*/function sp(a){	if (taf==null)	{		//taf=new TAFFY({t:'ptg',ptg:'',id:'6.1.1',w:'Abbeyford'});		//ar=taf.get({t:"ptg"});		//alert(ar.length);		taf = new TAFFY([a]);		//aWList[a.w]=a.w	}	else	{		taf.insert([a]);		//aWList[a.w]=a.w;	}}function recordEvent(a,idx){}function recordActivity(a,idx){}function recordActivityOld(a,idx){	aTypes=a["t"].split(";");	for (actTypeIdx in aTypes)	{		actType=aTypes[actTypeIdx];		if (aW[idx][actType]==null)		{			aW[idx][actType]=Object();		}		l=aW[idx][actType].length		aW[idx][actType][l]=a;	}}function checkLink(wood,link){	var bHide=true; // show or hide this link	aF=aCfg[curAct]["fs"];	for (i=0;i<aF.length;i++)	{		// get the id of the checkboxes from the config (also define the things to look for)		id=aF[i];		el=document.getElementById(id);		// only worry about criteria checked		if (el!=null && el.checked)		{						// Get the criteria from the config			aCri=aCfg[curAct][id];						// get the field that we're looking at			fld=aCri["f"];			// now get the value that we're after 			for (val in aCri["v"])			{				//alert(aW[wood][curAct][link]["t"]+" - "+aW[wood][curAct][link][fld]+" - "+fld+" - "+aCri["v"][val]);				if (aW[wood][curAct][link][fld]==aCri["v"][val])				{					bHide=false;				}			}		}	}	//alert(aW[wood][link]["id"]);	elLnk=document.getElementById("ah"+aW[wood][curAct][link]["id"]);	if (elLnk!=null)	{		if (bHide)		{			elLnk.style.display="none";			return 0;		}		else		{			//elLnk.style.display="inline";			elLnk.style.display="block";			return 1;		}	}	return 0;}function checkWood(wood){	// This function counts all of the links within the wood that should be shown.	// It does this by working out whether each link should be shown	i=0;	for (acts in aW[wood])	{		for (link in aW[wood][acts])		{				elLnk=document.getElementById("ah"+aW[wood][acts][link]["id"]);			if (elLnk!=null)				elLnk.style.display="none";		}	}	for (link in aW[wood][curAct])	{		i+=checkLink(wood,link);	}	//debug(wood+" "+i);	return i;}function removeDudWoods(){	for (wood in aWList)	{		el=document.getElementById(wood);		if (el==null)		{			aWList[wood]=null;		}		else		{			if ((el.style.left==0 && el.style.top==0) || (parseInt(el.style.left)>imgWidth || parseInt(el.style.top)>imgHt))			{				aWList[wood]=null;			}		}			}}function coaleseWoods(){	for (wood in aWList)	{		try		{			bStarted=false;			for (woodCmp in aWList)			{				if (aWList[woodCmp]!=null && woodCmp!=wood)				{					// 12 pixel gaps between woods means they're shown together					if (Math.abs(aWList[woodCmp]["x"]-aWList[wood]["x"])<iClose && 						Math.abs(aWList[woodCmp]["y"]-aWList[wood]["y"])<iClose)					{						if (aWList[wood]["j"]==null)							aWList[wood]["j"]=Array();						aWList[wood]["j"].push(woodCmp);						//l=aW[wood]["j"].length;						//aW[wood]["j"][l]=woodCmp;					}				}			}		}		catch(e)		{		}	}}function showWoodName(el){	return;	elName=document.getElementById("forname");	elName.innerHTML=el.id;	}function showDTAlt(ev){	el=Event.element(ev);	if (el.tagName=="DT")	{		elMap=document.getElementById("mapdiv");		// emulate tool tips		elTT=document.getElementById("ToolTip");		elTT.innerHTML=el.id;		elTT.style.display="block";		elTT.style.visibility="visible";		elTT.style.left=Event.pointerX(ev)+10+"px";		elTT.style.top=Event.pointerY(ev)+6+"px";		//elTT.style.left=parseInt(el.style.left)+20+elMap.offsetLeft;		//elTT.style.top=parseInt(el.style.top)+12+elMap.offsetTop;	}	}function hideEl(el){	el.style.display="none";}function hideTT(){	elTT=document.getElementById("ToolTip");	elTT.style.display="none";}function doEnable(){	el=document.getElementById("graded");	if (el.checked)		el.onclick();	el=document.getElementById("marked");	if (el.checked)		el.onclick();}function doVC(){	ar=taf.get({vc:1});	for (i=0;i<ar.length;i++)	{		elWIP=document.getElementById("WoodIconPath");				elX=document.getElementById(ar[i].w);		elX.style.background="url('"+elWIP.value+"/visiconx.gif') no-repeat";				aVC[ar[i].w]=1;	}}function onloadfuncs(){	//doVC();	doScale();	//removeDudWoods();	//sh();	doEnable();	sh();}
