<!--
var opera = navigator.userAgent.indexOf('Opera')>=0 ? true : false;
var ie4 = document.all;
var ns6 = document.getElementById&&!document.all;
var ns4 = document.layers&&!document.getElementById;
var off = '#395f0b', on = '#a6d56e', grey='#808080'; // colours
var theWindow, theFrames, theDocument, menuWindow, menuobj;	

function getFrames(){
  	// get the correct window/document in which to display menu
	theWindow = window.parent;
	//if (theWindow.parent) theWindow = theWindow.parent;
	theFrames = (theWindow == window) ? false : true ;
	theDocument = theFrames ? theWindow.frames['mainframe'].document : window.document;
	menuWindow = theFrames ? theWindow.frames['mainframe'].window : window;
}

function showmenu(e, menuno){
  	//if (opera) return;
  	getFrames();  
  	// get the menu content
  	var divobj= ie4? eval('document.all.menu'+menuno) : ns6? document.getElementById("menu"+menuno) : ns4? eval('document.menu'+menuno) : "";
  	var which = divobj.innerHTML;

  	//var posleft = new Array(10, 140, 270, 390, 520, 650);
  	var posleft = new Array(10, 166, 322, 460, 500, 630);
  	var widths = new Array(120, 120, 120, 150, 150, 130);  
  
	if (!theDocument.all&&!theDocument.getElementById&&!theDocument.layers)
	return;

	clearhidemenu();
	
	// find the menu object
	menuobj=ie4? theDocument.all.popmenu : ns6 ? theDocument.getElementById("popmenu") : ns4? theDocument.popmenu : "";
	//alert(menuobj.id+' '+theDocument.title);
	menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj;

	if (ie4||ns6)		
		menuobj.innerHTML=which;
	else{
		menuobj.write('<layer name=gui bgColor='+off+' onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>');
		menuobj.close();
	}
	menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width;
	menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height;
	eventX=ie4? event.clientX - event.srcElement.style.width/2 : ns6? e.clientX - e.target.style.width/2 : e.x;
	eventY=ie4? event.clientY : ns6? e.clientY : e.y;

	if (theFrames) {
	 	menuobj.thestyle.top = ie4 ? menuWindow.document.body.scrollTop + 2 : ns6 ? menuWindow.pageYOffset + 2 + 'px' :  2 ;
	}
	else {
		menuobj.thestyle.top =  155; // e.pageX + 10;
	}
	
	menuobj.thestyle.left = ie4 ? (document.body.clientWidth - 780)/2 + posleft[menuno-1] + 10 : (window.innerWidth - 780)/2 +posleft[menuno-1] - 10;
	menuobj.thestyle.width = ns6 ? widths[menuno-1] + 'px' : widths[menuno-1];
	menuobj.contentwidth = ns6 ? widths[menuno-1] + 'px' : widths[menuno-1];
	menuobj.thestyle.visibility="visible";
	return false
}

function contains_ns6(a, b) {
	//Determines if 1 element in contained in another- by Brainjar.com
	while (b && b.parentNode)
		if ((b = b.parentNode) == a)	return true;
	return false;
}

function hidemenu(){
	menuobj=ie4? theDocument.all.popmenu : ns6? theDocument.getElementById("popmenu") : ns4? theDocument.popmenu : "";
	menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj;
	if (menuobj)
		menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide";
}

function dynamichide(e){
	menuobj=ie4? theDocument.all.popmenu : ns6? theDocument.getElementById("popmenu") : ns4? theDocument.popmenu : "";
	menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj;
	if (ie4&&!menuobj.contains(e.toElement))
		 hidemenu();
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	  	hidemenu();
}

function delayhidemenu(){
	if (ie4||ns6||ns4||opera)
		delayhide=setTimeout("hidemenu()",200);
}

function clearhidemenu(){
	if (theWindow.delayhide)
		clearTimeout(delayhide);
}

function highlightmenu(e,state){
	if (ie4) {
		source_el=e.srcElement;
		source_el.style.background=eval(state);
 	}
	else if (ns6) {
		source_el=e.target;
		source_el.background=eval(state);
	}
	if (source_el.className=="menuitems" || source_el.className=="menubar"){
		source_el.style.background=eval(state);
		//source_el.id=(state=="on")? "mouseoverstyle" : "mouseoutstyle";
	}
	else{
		while(source_el.id != "popmenu"){
			source_el=theDocument.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className=="menuitems" || source_el.className=="menubar"){
				source_el.style.background=eval(state);
				//source_el.id=(state=="on")? "mouseoverstyle" : "mouseoutstyle";
			}
		}
	}
	if (state == 'off') clearhidemenu();
}


getFrames();
if (ie4||ns6||opera)
theDocument.onclick=hidemenu;
//menuobj=ie4? theDocument.all.popmenu : ns6 ? theDocument.getElementById("popmenu") : ns4? theDocument.popmenu : "";
	
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];}}
}

function menuSwitch(cell, mode) {
  	if (ie4) {
  		val = document.all[cell];
  	}
  	else if (ns6){
		val = document.getElementById(cell);
  	}	
  	else return;
  	if (mode=='on' || mode=='off') val.style.background=eval(mode);
}

		
function start(page) {
if(navigator.appVersion < "3.0") return; 	
	if (self != parent.frames[1]) 
	{
		window.location = page;
	 }
	
}

function switchweek(z, on, off){
	var i,j,val; // checks or unchecks a whole week
    	var btype = (navigator.appName == 'Netscape')? 'NS':'IE';
	if (btype == 'IE') {
	  if (document.all['Cweek'+z].checked==true) {
		document.all['Bweek'+z].style.background= on;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.all['Cday'+j]) document.all['Cday'+j].checked = true;
			if (document.all['Bday'+j]) document.all['Bday'+j].style.background= on;

		}
	  }
	  else {
		document.all['Bweek'+z].style.background= off;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.all['Cday'+j]) document.all['Cday'+j].checked = false;
			if (document.all['Bday'+j]) document.all['Bday'+j].style.background= off;
		}

	  } 
        }
	else {
	  if (document.forms['update'].elements['Cweek'+z].checked == true){
		val = document.getElementById('Bweek'+z);
         	val.style.background=on;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.forms['update'].elements['Cday'+j]) document.forms['update'].elements['Cday'+j].checked = true;
			val=document.getElementById('Bday'+j);
			if (val) val.style.background=on;
		}

	  }
	  else {
		val = document.getElementById('Bweek'+z);
         	val.style.background=off;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.forms['update'].elements['Cday'+j]) document.forms['update'].elements['Cday'+j].checked = false;
			val=document.getElementById('Bday'+j);
			if (val) val.style.background=off;
		}
	  } 
	}
}

function scswitch(d, on, off) {
	var w, val, c, i; // the week
    	var btype = (navigator.appName == 'Netscape')? 'NS':'IE';
	if (btype == 'IE') {
	  if (document.all['Cday'+d].checked==true) {
		document.all['Bday'+d].style.background=on;   // on
		w = (d - (d%7));
		c = 1;
		for (i=w; i < w+7; i++) {
			if (document.all['Cday'+i] && document.all['Cday'+i].checked==false) c = 0;
		}
		w = w / 7;
		if (c == 1) {
			document.all['Cweek'+w].checked = true;
			document.all['Bweek'+w].style.background=on;
		}		
	  }
	  else {
		w = (d - (d%7)) / 7;
		document.all['Bday'+d].style.background=off;	// off
		document.all['Bweek'+w].style.background=off;
		document.all['Cweek'+w].checked = false;
	  }
	}
	else {
	  if (document.forms['update'].elements['Cday'+d].checked==true) {
		val=document.getElementById('Bday'+d);
		val.style.background=on;
		w = (d - (d%7));
		c = 1;
		for (i=w; i < w+7; i++) {
			if (document.forms['update'].elements['Cday'+i] && document.forms['update'].elements['Cday'+i].checked==false) c=0;
		}
		w = w / 7;
		if (c == 1) {
			document.forms['update'].elements['Cweek'+w].checked = true;
			val=document.getElementById('Bweek'+w);
			val.style.background=on;
		}
	  }
	  else {
		w = (d - (d%7)) / 7;
		val=document.getElementById('Bday'+d);
		val.style.background=off;
		document.forms['update'].elements['Cweek'+w].checked=false;
		val=document.getElementById('Bweek'+w);
		val.style.background=off;
	  }
	}		
}

function bbswitch(d, r, on, off) {
	var j=d, val, check, box; // the week
	var offset = 5; // number of elements at start of 'update' form - before calendar itself
    	var btype = (navigator.appName == 'Netscape')? 'NS':'IE';
	if (btype == 'IE') {
	  if (document.all['Cday'+d+'room'+r].checked==true) {
		document.all['Bday'+d+'room'+r].style.background=on;   // on
		w = (d - (d%7));
		c = 1;
		for (i=w; i < w+7; i++) {
			if (document.all['Cday'+i+'room'+r] && document.all['Cday'+i+'room'+r].checked==false) c = 0;
		}
		w = w / 7;
		if (c == 1) {
			document.all['Cweek'+w+'room'+r].checked = true;
			document.all['Bweek'+w+'room'+r].style.background=on;
		}	
	  }
	  else {
		document.all['Bday'+d+'room'+r].style.background=off;	// off
		w = (d - (d%7)) / 7;
		document.all['Bweek'+w+'room'+r].style.background=off;
		document.all['Cweek'+w+'room'+r].checked = false;
	  }
	}
	else {
	  if (document.forms['update'].elements['Cday'+d+'room'+r].checked==true) {
		val=document.getElementById('Bday'+d+'room'+r);
		val.style.background=on;
		w = (d - (d%7));
		c = 1;
		for (i=w; i < w+7; i++) {
			if (document.forms['update'].elements['Cday'+i+'room'+r] && document.forms['update'].elements['Cday'+i+'room'+r].checked==false) c=0;
		}
		w = w / 7;
		if (c == 1) {
			document.forms['update'].elements['Cweek'+w+'room'+r].checked = true;
			val=document.getElementById('Bweek'+w+'room'+r);
			val.style.background=on;
		}
	  }
	  else {
		val=document.getElementById('Bday'+d+'room'+r);
		val.style.background=off;
		w = (d - (d%7)) / 7;
		document.forms['update'].elements['Cweek'+w+'room'+r].checked=false;
		val=document.getElementById('Bweek'+w+'room'+r);
		val.style.background=off;
	  }
	}		
}
function bbswitchweek(z, r, on, off){
	var i,j,val; // checks or unchecks a whole week for a given room
	var btype = (navigator.appName == 'Netscape')? 'NS':'IE';
	if (btype == 'IE') {
	  if (document.all['Cweek'+z+'room'+r].checked==true) {
		document.all['Bweek'+z+'room'+r].style.background= on;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.all['Cday'+j+'room'+r]) document.all['Cday'+j+'room'+r].checked = true;
			if (document.all['Bday'+j+'room'+r]) document.all['Bday'+j+'room'+r].style.background= on;

		}
	  }
	  else {
		document.all['Bweek'+z+'room'+r].style.background= off;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.all['Cday'+j+'room'+r]) document.all['Cday'+j+'room'+r].checked = false;
			if (document.all['Bday'+j+'room'+r]) document.all['Bday'+j+'room'+r].style.background= off;
		}

	  } 
        }
	else {
	  if (document.forms['update'].elements['Cweek'+z+'room'+r].checked == true){
		val = document.getElementById('Bweek'+z+'room'+r);
         	val.style.background=on;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.forms['update'].elements['Cday'+j+'room'+r]) document.forms['update'].elements['Cday'+j+'room'+r].checked = true;
			val=document.getElementById('Bday'+j+'room'+r);
			if (val) val.style.background=on;
		}

	  }
	  else {
		val = document.getElementById('Bweek'+z+'room'+r);
         	val.style.background=off;
		for (i=0; i<7; i++) {
			j = z*7 + i;
			if (document.forms['update'].elements['Cday'+j+'room'+r]) document.forms['update'].elements['Cday'+j+'room'+r].checked = false;
			val=document.getElementById('Bday'+j+'room'+r);
			if (val) val.style.background=off;
		}
	  } 
	}
}
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];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function popup(myUrl) {
   var topBars= 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,dependent=yes';
   var myOptions = 'scrollbars=yes,width=640,height=640,resizeable=yes,top=50,left=0';
   var myFeatures = topBars+','+myOptions;
   var newWin = open(myUrl,'',myFeatures);
   //newWin.document.close();
   newWin.focus();
}

function farmpop(myUrl) {
   var topBars= 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,dependent=yes';
   var myOptions = 'scrollbars=yes,width=800,height=600,resizeable=yes,top=0,left=0';
   var myFeatures = topBars+','+myOptions;
   var newWin = open(myUrl,'',myFeatures);
   //newWin.document.close();
   newWin.focus();
}

function viewImage(picpath, element) {
	// designed to work with the 'p' type of Event field
	// which type of browser?
	var ie = document.all;
	var ns = document.getElementById;
	if (!ie && !ns) return;
	var obj = ie ? eval('document.all.'+element) : document.getElementById(element);
	var file = obj.options[obj.selectedIndex].value;
	if (file == 'none') return;
	var uri = document.domain;
	uri = "http://"+uri;
	file = uri + picpath + file;
	popup(file);
}

function swapImg() { //
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.swapImgData;
  for (i=0; i < (swapImg.arguments.length-2); i+=3) {
    objStr = swapImg.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
//alert(objStr);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = swapImg.arguments[i+2];
  } }
  document.swapImgData = swapArray; //used for restore
}

function restoreImg() { //v1.2
  if (document.swapImgData != null)
    for (var i=0; i<(document.swapImgData.length-1); i+=2)
      document.swapImgData[i].src = document.swapImgData[i+1];
}

function locationmap() {
window.open('location.htm','location','directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=no,width=300,height=500');
}

function slideshow() {
	var b, f, v;
	b = ie4 ? document.all.buildings : document.getElementById('buildings');
	f = ie4 ? document.all.farming : document.getElementById('farming');
	v = ie4 ? document.all.views : document.getElementById('views');
	var p;
	if (document.position) p = document.position;
	else p = 1;
	p++;
	if (p > 20) p = 1;
	b.src = 'slideshow/buildings/img_'+p+'.jpg';
	f.src = 'slideshow/farming/img_'+p+'.jpg';
	v.src = 'slideshow/views/img_'+p+'.jpg';
 	document.position = p;
}
//-->

