SiteMeta1.deriveFrom(GenMeta1)
function SiteMeta1(){
	this.GenMeta1()
}
SiteMeta1.prototype._init=function (){
	this.__GenMeta1_init()
	this.canvas.ondblclick=this.associateObjWithEvent(
this,"canvasDblClick")
	switch(bd.browser){
	case "IE":
	case "Opera":
this.initResetMenu="canvasMouseover"
break
	default:
c=new Cookie()
this.c_resetMenu=c.get("menuPref2")
if(!this.c_resetMenu)this.initResetMenu="bodyClick"	
	}
	this.myBody=document.getElementById("body")
	this.myForm=document.getElementById("myForm")
	this.canvasPos=new MyElement(this.canvas).findPos()
	this.FACOutDiv=document.getElementById("FACOutDiv")
	this.FAC_On_Color="#000000"
	this.FAC_On_BackgroundColor="#00b000"
	this.FAC_On_ColorLight="#000000"
	this.FAC_On_BackgroundColorLight="#00b000"
	this.FAC_Off_Color1="#000000"
	this.FAC_Off_BackgroundColor1="#ffffff"
	this.FAC_Off_Color2="#000000"
	this.FAC_Off_BackgroundColor2="#f0f0f0"
	this.FACOutDiv.style.position="absolute"
	this.FACOutDiv.style.width="120px"
	this.setFACDivPos()
	this.FACNum=-1
	this.setMainMenu()
	this.setCastlesMenu()
	this.handleFAC()
	this.mapTagBackgroundColor="#e6eba9"
	switch(pageId){
	case "Home":this.setHomeMap();break
	case "Map":this.setMainMap();break
	default:
		if(castleId){
			this.setCastleMenu()
			if(castlePage=="Map")this.setMapPlaces()
		}
	}		
}
SiteMeta1.prototype.bodyClick=
function (e,obj){
	myDoc.removeChildren(this.FACOutDiv)
	for(var x=0;x<this.resetMenus.length;x++){
		if((this.resetMenus[x])
		&&( this.resetMenus[x].parms.isResetMenu=="bodyClick")){
			this.resetMenus[x].resetMenu()
			this.resetMenu[x]=0
		}
	}
}
SiteMeta1.prototype.canvasDblClick=
function(e,obj){
	switch(bd.browser){
	case "IE":
	case "Opera":
alert("Sorry, double-click menu preference setting is "
+"\nnot currenty available with "+bd.browser)
return
	}
	c=new Cookie()
	if(this.CastlesMenu.parms.isResetMenu=="bodyClick"){
s="canvasMouseover"
alert("Javascript menus set to Auto")		
	}else{
s="bodyClick"
alert("Javascript menus set to Click")
	}
	this.CastlesMenu.parms.isResetMenu=s
	this.CastlesMenu.resetMenu(s)
	if(this.CastleMenu){
this.CastleMenu.parms.isResetMenu=s
this.CastleMenu.resetMenu(s)
	}
	this.MainMenu.parms.isResetMenu=s
	this.MainMenu.resetMenu(s)
	c.set("menuPref2",s,7)
}
SiteMeta1.prototype.DDCastles=function(){
	myDoc.removeChildren(this.FACOutDiv)
	var tbl=new HtmlTable(this.FACOutDiv)
	tbl.element.style.cursor="pointer"
	tbl.element.style.width="100%"	
	tbl.element.style.backgroundColor="#ffffff"
	tbl.element.style.border="1px #c0c0c0 solid"
	tbl.element.style.borderTop="0px"
	var thead=new HtmlThead(tbl.element)
	this.FACNum=0
	this.numOfFACs=0
	for(var x=0;x<16;x++){
		if( this.strXml.xmlDom.documentElement.childNodes.length>x){	
			var recNode=this.strXml.selectNodes(
				"/castles/rec["+(x+1)+"]")[0]
			var tr=this.FACOutRow(thead,x,recNode)
			tr.element.pageId= this.strXml.getFieldData(recNode,"homePageId")
			if(!x){
	tr.element.style.backgroundColor=this.FAC_On_BackgroundColorLight
	tr.element.style.color=this.FAC_On_ColorLight
			}
			this.numOfFACs++
		}else{
			continue
		}
	}
}
SiteMeta1.prototype.doMarkerClicked=function(placeKey){
	this.FAC_HTTP=new MyHttp(VPath+"/lib2/ss/http/sites/british-castle/getMarkerLink.php")
	this.FAC_HTTP.appendParm("placeKey",placeKey)
	this.HTTPSend(this.FAC_HTTP,"doMarkerHTTPReq")
}
SiteMeta1.prototype.doMarkerHTTPReq=function(){
	var varss=this.HTTPReq(this.FAC_HTTP)
	if(!varss)return
	if(varss["homePageId"])
		window.location.assign( this.getHrefBase(varss["homePageId"]))
	if(varss["link"])
		window.location.assign(varss["link"])
}
SiteMeta1.prototype.FACKeyup=function (event,element){
	if(event.keyCode==13){
		if(this.FACNum==-1)return
		var el=document.getElementById("FAC:"+this.FACNum)		
		this.myForm.action= this.getHrefBase()+"pageId="+el.pageId
		this.myForm.submit()
		return
	}else if(event.keyCode==38){
		if(this.FACNum<1)return
		var el=document.getElementById("FAC:"+this.FACNum)
		this.FACOutRowHighlightOff(el,this.FACNum--)
		var el=document.getElementById("FAC:"+this.FACNum)
		this.FACOutRowHighlightOn(el,this.FACNum)
		return
	}else if(event.keyCode==40){
		var numOfFACsLess2=this.numOfFACs-2
		if(this.FACNum<0||this.FACNum>numOfFACsLess2)return
		var el=document.getElementById("FAC:"+this.FACNum)
		this.FACOutRowHighlightOff(el,this.FACNum++)
		var el=document.getElementById("FAC:"+this.FACNum)
		this.FACOutRowHighlightOn(el,this.FACNum)
		return
	}
	if(!element.value){
		myDoc.removeChildren(this.FACOutDiv)
		return
	}
	this.FAC_HTTP=new MyHttp(VPath+"/lib2/ss/http/sites/british-castle/findACastle.php")
	this.FAC_HTTP.appendParm("str",element.value)
	this.HTTPSend(this.FAC_HTTP,"FACReq")
}
SiteMeta1.prototype.FACReq=function(){
	var varss=this.HTTPReq(this.FAC_HTTP)
	if(!varss)return
	this.strXml=new MyXml()
	this.strXml.loadStr(varss["xmlstring"])
	this.DDCastles()
}
SiteMeta1.prototype.FACOutRow=function (thead,x,recNode){
	var tr=new HtmlTr(thead.element)
	tr.element.id="FAC:"+x
	this.FACOutRowBC(tr.element,x)
	tr.element.onclick= this.associateObjWithEvent(this,"FACOutRowClick")
	tr.element.onmouseover= this.associateObjWithEvent(this,"FACOutRowMouseover")
	tr.element.onmouseout= this.associateObjWithEvent(this,"FACOutRowMouseout")
	var node=this.strXml.selectNodes("title",recNode)[0]
	var td=new HtmlTd(tr.element,node.firstChild.data)
	return tr
}
SiteMeta1.prototype.FACOutRowBC=function(el,rowNo){
	if(!el)return
	this.FACOutRowHighlightOff(el,rowNo)	
}
SiteMeta1.prototype.FACOutRowClick=
function FACOutRowClick(event,element){
	var recNo=parseInt(element.id.split(":")[1])+1
	var recNode=this.strXml.selectNodes(
				"/castles/rec["+recNo+"]")[0]
	var pageId=this.strXml.getFieldData(recNode,"homePageId")
	this.myForm.action=this.getHrefBase()+"pageId="+pageId
	this.myForm.submit()
}
SiteMeta1.prototype.FACOutRowMouseover=
function FACOutRowMouseover(event,element){
	this.FACOutRowHighlightOn(element)
	this.FACNum=element.id.split(":")[1]
}
SiteMeta1.prototype.FACOutRowMouseout=
function FACOutRowMouseout(event,element){
	this.FACOutRowHighlightOff(element,element.id.split(":")[1])
}
SiteMeta1.prototype.FACOutRowHighlightOff=
function (element,x){
	if(x%2){
		element.style.color= this.FAC_Off_Color1
		element.style.backgroundColor= this.FAC_Off_BackgroundColor1
	}else{
		element.style.color= this.FAC_Off_Color2
		element.style.backgroundColor= this.FAC_Off_BackgroundColor2
	}
}
SiteMeta1.prototype.FACOutRowHighlightOn=
function (element){
	element.style.color=this.FAC_On_Color
	element.style.backgroundColor=this.FAC_On_BackgroundColor
}
SiteMeta1.prototype.handleFAC=function (){
	this.FACInput=document.getElementById("FACInput")
	this.FACInput.focus()
	this.FACInput.onkeyup=this.associateObjWithEvent(this,"FACKeyup")
}
SiteMeta1.prototype.MainMap_Moveend=
function(){
	this.MainMap_getCastleRecs()	
}
SiteMeta1.prototype.MainMap_getCastleRecs=function(){
	pathname=VPath+"lib2/ss/http/sites/british-castle/getCastlesMapAndLink.php"
//alert(pathname)
	this.MM_HTTP=new MyHttp(pathname)
	this.boundsArr=this.MMap.getBoundsArr()
	this.MM_HTTP.appendParm("neLat",this.boundsArr["neLat"])
	this.MM_HTTP.appendParm("neLng",this.boundsArr["neLng"])
	this.MM_HTTP.appendParm("swLat",this.boundsArr["swLat"])
	this.MM_HTTP.appendParm("swLng",this.boundsArr["swLng"])
	this.HTTPSend(this.MM_HTTP,"MainMap_HTTPReturn")
}
SiteMeta1.prototype.MainMap_HTTPReturn=function(){
	var varss=this.HTTPReq(this.MM_HTTP)
	if(!varss)return
//alert(varss["xmlstring"])	
	this.castlesXml=new MyXml()
	this.castlesXml.loadStr(varss["xmlstring"])
	this.MainMap_setMarkers()
}
SiteMeta1.prototype.MainMap_MarkerClick=function(homePageId){
	this.MMap.MouseoverMarkerBox_remove()
	window.location.assign("index.php?pageId="+homePageId)
}
SiteMeta1.prototype.MainMap_MarkerMouseover=function(name){
	this.MMap.MouseoverMarkerBox_set(name,this.mapTagBackgroundColor)
}
SiteMeta1.prototype.MainMap_MarkerMouseout=function (){
	this.MMap.MouseoverMarkerBox_remove()
}

SiteMeta1.prototype.MainMap_setMarker=function(ind,iSize){
	var arr=new Array()
	var lat=this.castlesXml.getFieldData(
this.castlesXml.myChildNodes[ind],"lat")
	var lng=this.castlesXml.getFieldData(
this.castlesXml.myChildNodes[ind],"lng")
	var icon=this.MMap.getIcon(
UVPath+"content/images/_map/"+this.castlesXml.getFieldData(this.castlesXml.myChildNodes[ind],"placetype")+".gif",iSize)
	var name=this.castlesXml.getFieldData(
this.castlesXml.myChildNodes[ind],"place")
	var marker=this.MMap.getMarker(lat,lng,icon,name)
	this.MMap.map.addOverlay(marker)
	var homePageId= this.castlesXml.getFieldData(this.castlesXml.myChildNodes[ind],"homePageId")
	var eventlisteners=new Array()
	eventlisteners.push(
GEvent.bind(marker,"click",this,function(){this.MainMap_MarkerClick(homePageId)}))
	eventlisteners.push(
GEvent.bind(marker,"mouseover",this,function(){this.MainMap_MarkerMouseover(name)}))
	eventlisteners.push(
GEvent.bind(marker,"mouseout",this,function(){this.MainMap_MarkerMouseout()}))
	var arr=new Array()
	arr["marker"]=marker
	arr["eventlisteners"]=eventlisteners
	this.MMap.markers.push(arr)
}
SiteMeta1.prototype.MainMap_setMarkers=function(){
	this.MMap.removeOutOfBounds(this.boundsArr)
	var iSize=new GSize(16,16)
	for(var x=0;x<this.castlesXml.myChildNodes.length;x++){
		var name= this.castlesXml.getFieldData(this.castlesXml.myChildNodes[x],"place")
		if(!this.MMap.isMarker(name))
			this.MainMap_setMarker(x,iSize)
	}
}
SiteMeta1.prototype.onload=
function onload(){
	this.setCurvyCorners()
}
SiteMeta1.prototype.resizeIt=function (){
	this.__Meta1_resizeIt()
	this.canvasPos=new MyElement(this.canvas).findPos()
	this.setMainMenuPosParms(this.MainMenu.parms)
	if(this.MainMenu)this.MainMenu.reset()
	this.setCastlesMenuPosParms(this.CastlesMenu.parms)
	if(this.CastlesMenu)this.CastlesMenu.reset()
	if(this.CastleMenu){
		this.setCastleMenuPosParms(this.CastleMenu.parms)
		this.CastleMenu.reset()
	}
	this.setFACDivPos()
}
SiteMeta1.prototype.setCastleMenu=function (){
	var parent=document.getElementsByTagName("body")[0]
	var myXml=new MyXml()
	myXml.loadStr(CastleMenuXml,"castle")
	var parms=new Menu_parms()
	parms.menulayerVars["types"]=["horizontal"]
	parms.menulayerVars["xDispositions"]=["centring"]
	parms.menulayerVars["yDisposition"]="down"
	parms.positioning="absolute"
//	var canvasPos=new MyElement(this.canvas).findPos()
parms=this.setCastleMenuPosParms(parms)
//	parms.offsetLeft=canvasPos[0]+10
//	parms.offsetTop=canvasPos[1]+80
	parms=this.setStdMenuStyles(parms)
parms.styles["borderWidth"]="1px"
	this.CastleMenu=new Menu(parent,myXml,parms)
	this.CastleMenu.parent.element.style.fontSize="12px"	
	this.CastleMenu.build()

}
SiteMeta1.prototype.setCastleMenuPosParms=function(parms){
	parms.offsetLeft=this.canvasPos[0]+10
	parms.offsetTop=this.canvasPos[1]+75	
	return parms
}
SiteMeta1.prototype.setCastlesMenu=function (){
	var parent=document.getElementsByTagName("body")[0]
	var myXml=new MyXml()
	myXml.loadStr(CastlesMenuXml,"castles")
	var parms=new Menu_parms()
	parms=this.setCastlesMenuPosParms(parms)
	parms=this.setStdMenuStyles(parms)
	parms.menulayerVars["types"]=["vertical"]
	parms.menulayerVars["xDispositions"]=["left"]
	parms.menulayerVars["yDispositions"]=["down","down"]
	parms.positioning="absolute"
	parms.styles["borderRightColor"]="#c0c0c0"
	this.CastlesMenu=new Menu(parent,myXml,parms)
	this.CastlesMenu.parent.element.style.fontSize="12px"	
	this.CastlesMenu.build()
}
SiteMeta1.prototype.setCastlesMenuPosParms=
function(parms){
	parms.offsetRight= this.canvasPos[0]+this.canvas.offsetWidth-36
	parms.offsetTop=this.canvasPos[1]+11
	return parms
}
SiteMeta1.prototype.setFACDivPos=function(){
	var l=this.canvasPos[0]+771
	var t=this.canvasPos[1]+176
	switch(bd.browser){
	case "IE":break
	default:
		//t+=10
	}
	this.FACOutDiv.style.left=l+"px"
	this.FACOutDiv.style.top=t+"px"
}
SiteMeta1.prototype.setHomeMap=function(){
	var el=document.getElementById("GBSmallMapDiv")
	el.style.border="1px solid #c0c0c0"	
	var myGMap2=new MyGMap2(el)
	myGMap2.map.setMapType(G_PHYSICAL_MAP)
	var point=new GLatLng(55,-3.5)
	myGMap2.map.setCenter(point,4)
	myGMap2.map.disableDragging()
}
SiteMeta1.prototype.setMainMap=function(){
	this.MM_castles=new Array()
	var el=document.getElementById("GBMainMapDiv")
	el.style.border="1px solid #c0c0c0"
	el.style.marginBottom="20px"
	switch(bd.browser){
	case "IE":break;
	default:
		el.style.marginLeft="5px"
	}
	this.MMap=new MyGMap2(el)
	this.MMap.map.setMapType(G_PHYSICAL_MAP)
	GEvent.bind(this.MMap.map,"moveend",this,function(){
		this.MainMap_Moveend()
	})
/*
	GEvent.bind(this.MMap.map,"zoomend",this,
			function(oldLevel,newLevel){
		this.MainMap_Zoomend(oldLevel,newLevel)
	})
*/
	var point=new GLatLng(54.1,-3.5)
	this.MMap.map.setCenter(point,7)
	this.MMap.map.addMapType(G_PHYSICAL_MAP)
	this.MMap.map.addControl(new GMapTypeControl());
	this.MMap.map.addControl(new GLargeMapControl())
	this.MMap.map.addControl(new GScaleControl())	
	var gOverviewMapControl=new GOverviewMapControl()
/*
	GEvent.bind(gOverviewMapControl,"dragend",this,function(){
		this.MainMap_Dragend()
	})
*/
	this.MMap.map.addControl(gOverviewMapControl)
	this.MainMap_getCastleRecs()	
}
SiteMeta1.prototype.setMainMenu=function (){
	var parent=document.getElementsByTagName("body")[0]
	var myXml=new MyXml()
	myXml.loadStr(MainMenuXml,"MainMenu")
	var parms=new Menu_parms()
	parms=this.setMainMenuPosParms(parms)
	parms=this.setStdMenuStyles(parms)
	parms.menulayerVars["types"]=["vertical"]
	parms.menulayerVars["xDispositions"]=["leftedge"]
	parms.menulayerVars["yDispositions"]=["down","down"]
	parms.positioning="absolute"
	parms.styles["borderLeftColor"]="#c0c0c0"
	this.MainMenu=new Menu(parent,myXml,parms)
	this.MainMenu.parent.element.style.fontSize="12px"	
	this.MainMenu.build()
}
SiteMeta1.prototype.setMainMenuPosParms=function(parms){
	parms.offsetLeft=this.canvasPos[0]+28
	parms.offsetTop=this.canvasPos[1]+11
	return parms
}
SiteMeta1.prototype.setMapPlaces=function(){
	parms=new GoogleMapPlacesParms()
	parms.mapLinkOn="#0000ff"
	parms.mapLinkOff="#000080"
	parms.mapTagBackgroundColor=this.mapTagBackgroundColor
	parms.showPlace=place
	parms.zoom=zoom	
	this.__GenMeta1_setMapPlaces(parms)
}
SiteMeta1.prototype.setCurvyCorners=
function (){
	settings={
		tl:{radius:10},
		tr:{radius:10},
		bl:{radius:10},
		br:{radius:10},
		antiAlias:true,
		autoPad:false
	} 
	var cornersObj=new curvyCorners(settings,"rounded")
	cornersObj.applyCornersToAll()
}
SiteMeta1.prototype.setStdMenuStyles=function(parms){
	this.c_resetMenu
	?parms.isResetMenu=this.c_resetMenu
	:parms.isResetMenu=this.initResetMenu
	parms.styles["backgroundColor"]="#ffffff"
	parms.styles["color"]="#000000"
	parms.styles["fontWeight"]="normal"
	parms.styles["border"]="2px solid #000000"
	parms.styles["borderTopColor"]="#c0c0c0"
	parms.styles["backgroundColor"]="#c0c0c0"
	parms.buildStyles["backgroundColor"]="#008000"
	parms.buildStyles["color"]="#000000"
	parms.activeStyles["color"]="#008000"
	parms.activeStyles["backgroundColor"]="#e0e0e0"
parms.pointerColorPathRebuild="White"
	return parms
}

