function focusField(target)
{
	// The form elements that will be tested. Anything with a dot indicates the "type" attribute of the element
	var formElements = ["input.text", "input.checkbox", "input.radio", "select", "textarea"];
	var selectedNode = null;

	// IE's selection method
	if (typeof document.selection != "undefined" && document.selection != null && typeof window.opera == "undefined")
	{
		var theSelection = document.selection;
		var textRange = document.selection.createRange();

		selectedNode = textRange.parentElement();
	}
	// W3 selection method. Currently only Mozilla & Safari support it. However, neither of them support ranges inside form objects, so this part is redundant. Merely included in case they decide to include support in the future
	else if (typeof window.getSelection != "undefined")
	{
		var theSelection = window.getSelection();

		// The Safari way to get the node that a selection starts in
		if (typeof theSelection.baseNode != "undefined")
		{
			selectedNode = theSelection.baseNode;
		}
		// The Mozilla way to get the node that a selection starts in
		else if (typeof theSelection.getRangeAt != "undefined" && theSelection.rangeCount > 0)
		{
			selectedNode = theSelection.getRangeAt(0).startContainer;
		}
	}

	// If a selected node was found above, check whether it's a selection inside one of the specified form element types
	if (selectedNode != null)
	{
		for (var i = 0; i < formElements.length; i++)
		{
			if (selectedNode.nodeName.toLowerCase() == formElements[i].replace(/([^.]*)\..*/, "$1"))
			{
				return false;
			}
		}
	}

	var forms = document.forms;

	// Do a check of each form element on the page. If one of them has a value, do not focus
	for (var i = 0; i < forms.length; i++)
	{
		var formElements = forms[i];

		for (var j = 0; j < formElements.length; j++)
		{
			if (formElements[j].getAttribute("type") == "checkbox" || formElements[j].getAttribute("type") == "radio")
			{
				if (formElements[j].checked != formElements[j].defaultChecked)
				{
					return false;
				}
			}
			else
			{
				if (typeof formElements[j].defaultValue != "undefined" && formElements[j].value != formElements[j].defaultValue)
				{
					return false;
				}
			}
		}
	}

	// If no form elements were found to be focused -- or with values -- go ahead and focus
	target.focus();

	return false;
}

function CheckForm(theform, del)
{
			 if (!theform.section_name.value && del!=1) 
			 {
			  	alert('Please be sure to include a name for your section.');
				return false;
			 }
			 else return true;
}
function newWindow(file,window,options) {
    msgWindow=open(file,window,options);
    if (msgWindow.opener == null) msgWindow.opener = self;
}
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=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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var now = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number)	{
	return (number < 1000) ? number + 1900 : number;
}
var today =  days[now.getDay()] + ", " +
         months[now.getMonth()] + " " +
         date + ", " +
         (fourdigits(now.getYear())) ;
function launch(newURL, newName, newFeatures, orgName) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}
function OpenWindow(sURL, nw,nh, sOptions) {
   if (nw<1) {nw=500;}
   if (nh<1) {nh=300;}
   if (sOptions == '') { sOptions='screenX=125,left=125,screenY=125,top=125,channelmode=0,dependent=0,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no,left=0,top=0,screenX=0,screenY=0';}

   myRemote2 = launch(sURL, "myRemote2", "height=" + nh + ",width=" + nw + "," + sOptions, "HAMweather_Popup");

   return false;
}
var hex=153 // Initial color value.
function fadetext(elemID) {
	if(hex>55) { //If color is not black yet
		hex-=11; // increase color darkness
		document.getElementById(elemID).style.color="rgb("+hex+","+hex+","+hex+")";
		setTimeout("fadetext('"+elemID+"')",20);
	}
	else
	hex=153 //reset hex value
}

function swapblocks(newBlock,oldBlock)
{
        if (newBlock  && oldBlock)
        {
        	if (newBlock.style.display=='none')
        	{
		    	oldBlock.style.display='none';
		    	newBlock.style.display='block';
		    }
    	}
}

function delconf (f_name,f_action) {
	var del_conf = confirm('Are you sure you want to remove this post from the system?\n');
	if (del_conf) {
		document.forms[f_name].action = f_action;
		return true;
	}
	else {
		return false;
	}
}

function open_window(link,w,h) //opens new window
{
        var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
        newWin = window.open(link,'newWin',win);
        newWin.focus();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Banner Rotate Opacity (09-12-2005)
// by Vic Phillips  http://www.vicsjavascripts.org.uk

// Banner Images Opacity Rotation
// As many applications on a page as required

// Application Notes

// The Banner Images are nested in a <DIV>
// The <DIV> must have a unique ID name
// and a style position of relative or absolute
// e.g.
// <div id="Dick" style="position:relative;top:150px;">
// <img class="SSImg" width="500" height="50" src="http://www.vicsjavascripts.org.uk/StdImages/Zero.gif">
// <img class="SSImg" width="500" height="50" src="http://www.vicsjavascripts.org.uk/StdImages/One.gif">
// <img class="SSImg" width="500" height="50" src="http://www.vicsjavascripts.org.uk/StdImages/Two.gif">
// <img class="SSImg" width="500" height="50" src="http://www.vicsjavascripts.org.uk/StdImages/Three.gif">
// <img class="SSImg" width="500" height="50" src="http://www.vicsjavascripts.org.uk/StdImages/Four.gif">
// <img class="SSImg" width="500" height="50" src="http://www.vicsjavascripts.org.uk/StdImages/Five.gif">
// </div>

// The images must have a style of
// position:absolute;visibility:hidden;top:0px;left:0px;
// The script would normally Initialised from a <BODY> or window onload event
// e.g.
// <body onload="zxcBannerRotateOpacity('Dick',5,1)">
// Where:
// parameter 0 = the unique id of the <DIV>                                  (string)
// The follow parameters are optional, if ommitted defaults will be applied
// parameter 1 = the start image                                             (digits interga)
// parameter 2 = the number of slide show cycles (1 to n)                    (digits intega or floating point)
// parameter 3 = the fade increment (minimum = 1 = slow )( max = 30 = fast ) (digits interga)
// parameter 4 = the fade speed  (minimum = 5 = fast )                       (digits interga)
// parameter 5 = the Image delay (minimum = 50 = fast )                      (digits interga)


// All variable, function etc. names are prefixed with 'zxc' to minimise conflicts with other JavaScripts
// These charactors are easily changed to charactors of choise using global find and replace.

// The Functional Code is best as an External JavaScript

// Tested with IE6 and Mozilla FireFox


// Defaults
var zxcIncrement=2;
var zxcFadeSpeed=20;
var zxcImgDelay=2000;

// Functional Code - No Need to Change

var zxcCnt=0;

function zxcBannerRotateOpacity(zxcid,zxcsi,zxccy,zxcinc,zxcspd,zxcdly){
 var zxcp=document.getElementById(zxcid);
 if (!zxcp){ return; }
 if (zxcp.obj){ return; }
 zxcp.obj=new zxcAddBannerFade();
 zxcp.obj.imgary=zxcp.getElementsByTagName('IMG');
 if (!zxccy){ zxcccy=1; }
 zxcp.obj.cy=zxccy*zxcp.obj.imgary.length-1;
 zxcp.obj.cnt=0;
 if (!zxcsi){ zxcsi=1; }
 if (zxcsi>=zxcp.obj.imgary.length||zxcsi<1){ zxcsi=1; }
 zxcp.obj.cntT=zxcsi-1;
 zxcp.obj.cntB=zxcsi;
 if (zxcp.obj.cntB==zxcp.obj.imgary.length){ zxcp.obj.cntB=0; }
 if (!zxcinc){ zxcinc=zxcIncrement; }
 if (zxcinc<1||zxcinc>30){ zxcinc=zxcIncrement; }
 zxcp.obj.inc=zxcinc;
 if (!zxcspd){ zxcspd=zxcFadeSpeed; }
 if (zxcspd<5||zxcspd>70){ zxcspd=zxcFadeSpeed; }
 zxcp.obj.spd=zxcspd;
 if (!zxcdly){ zxcdly=zxcImgDelay; }
 if (zxcdly<50){ zxcdly=zxcImgDelay; }
 zxcp.obj.dly=zxcdly;
 var zxc0;
 for (zxc0=0;zxc0<zxcp.obj.imgary.length;zxc0++){
  zxcOpacity(zxcp.obj.imgary[zxc0],0)
 }
 zxcp.obj.IT=zxcp.obj.imgary[zxcp.obj.cntT];
 zxcOpacity(zxcp.obj.IT.style,100);
 zxcp.obj.IT.style.zIndex=1;
 zxcp.obj.IT.style.visibility='visible';
 //zxcp.obj.IT.style.marginLeft=(200-zxcp.obj.IT.width)/2;
 //zxcp.obj.IT.style.marginTop=(200-zxcp.obj.IT.height)/2;
 zxcp.obj.setTimeOut0();
}

function zxcAddBannerFade(){
 this.ref0 = 'timeout0'+zxcCnt;
 window[this.ref0]=this;
 this.ref1 = 'timeout1'+zxcCnt;
 window[this.ref1]=this;

 this.setTimeOut0= function(zxcf,zxcd){
  setTimeout('window.'+this.ref0+'.rotate()',this.dly);
 }

 this.setTimeOut1= function(zxcf,zxcd){
  setTimeout('window.'+this.ref1+'.'+zxcf,zxcd);
 }

 this.rotate=function(){
 if (this.cnt>=this.cy){ return; }
  this.fcnt=0;
  this.cnt++;
  this.IT=this.imgary[this.cntT]
  this.IB=this.imgary[this.cntB]
  this.IT.style.zIndex=0;
  this.IB.style.zIndex=1;
  this.IB.style.visibility='visible';
  //this.IB.style.marginLeft=(200-this.IB.width)/2;
  //this.IB.style.marginTop=(200-this.IB.height)/2;
  this.fadebanner();
 }

 this.fadebanner=function(){
  this.fcnt+=this.inc;
  zxcOpacity(this.IT.style,100-this.fcnt);
  zxcOpacity(this.IB.style,this.fcnt);
  if (this.fcnt<100){ this.setTimeOut1('fadebanner()',this.spd); }
  else {
   zxcOpacity(this.IB.style,100);
   zxcOpacity(this.IT.style,0);
   this.cntT=(this.cntT+1)%this.imgary.length;
   this.cntB=(this.cntB+1)%this.imgary.length;
   this.setTimeOut1('rotate()',this.dly);
  }
 }
 zxcCnt++;
}

function zxcOpacity(zxcobj,zxcop) {
 if (zxcop>100||zxcop<0){ return }
 if (zxcobj.MozOpacity!=null){ zxcobj.MozOpacity=(zxcop/100)-.001; }
 else if (zxcobj.opacity!=null){ zxcobj.opacity=(zxcop/100)-.001; }
 else if (zxcobj.filter!=null){ zxcobj.filter = 'alpha(opacity='+zxcop+')';     }
 else if (zxcobj.KHTMLOpacity!=null){ zxcobj.KHTMLOpacity=(zxcop/100)-.001; }
}


function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


/***********************************************
* Chrome CSS Drop Down Menu- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//Chrome Drop Down Menu- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: June 14th, 06'

var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
disablemenuclick: true, //when user clicks on a menu item with a drop down menu, disable menu item's link?
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" //hide menu via clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden" //hide menu
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick} //disable main menu item link onclick?
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
}
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'",this.disappeardelay) //hide menu
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
}

}

