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_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) { //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];}
}




// browser detection
var w3c=(document.getElementById)?true:false;
var ns4=(document.layers)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;

// DHTML functions
var DHTML = (document.getElementById || document.all || document.layers);

function lightup(imgName)
 {
   if (document.images)
    {
      imgOn=eval(imgName + "_on.src");
      document[imgName].src= imgOn;
    }
 }

function turnoff(imgName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + "_off.src");
      document[imgName].src= imgOff;
    }
 }

function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	} else
	if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else
	if (document.layers) {
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}

// return document object by id;
function getobject(obj){
if (document.getElementById)
	return document.getElementById(obj)
else if (document.all)
	return document.all[obj]
}

// set obj class style
function setStyle(obj, className) {
	if(getobject(obj).className != className) {
	getobject(obj).className = className;
	}
}

/// popup window function
function popup(URL,w,h) {

day = new Date();
id = day.getTime();

var width = w;
var height = h;

var left = ((screen.width-width)/2);
var top = ((screen.height-height)/2);

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + '');");
}

/// popup window function with name
function wpopup(URL,n,w,h) {

var day = new Date();

var name = n;
var width = w;
var height = h;

var left = 50;
var top =20;


var features = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;

//eval("page" + name + " = window.open(URL, '" + name + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + '');");

window.open(URL, name, features);
//popWin.focus();

}


function popWindow(url, name, features)
{
    var host = location.hostname;
	window.top.name = "opener";
	var popupWin = window.open( url, name, features );

	if ( popupWin && popupWin.opener ) {
		if ( openerUrl )
		{
			popupWin.opener.location = openerUrl;
			popupWin.focus();
		}
	}
}


/////
///onKeyPress="return numbersonly(this, event)";
/////

function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;
	if (window.event){
		key = window.event.keyCode;
	}else if (e){
		key = e.which;
	}else{
		return true;
	}
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ){
		return true;
	}else if ((("+1234567890").indexOf(keychar) > -1)){
		return true;
	}else if (dec && (keychar == ".")){
		myfield.form.elements[dec].focus();
		return false;
	}else{
		return false;
	}
}

///// onKeyUp="numTyped(this.value,p3,'3')"
/// jump phone number fields
function numTyped(current, next,maxlen) {
  var len = current.length;
  if (len==maxlen) {
    next.focus();
  }
}

//// form validation

/// form validation starts here

var new_fieldname = ""

//this is the onclick that calls this function
//
// onClick="return check(form,form.elements.length)"
//


function checkEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{
		return (true)
	}
	else
	{
		return (false)
	}
}


/// functions for form validation script

function count_checkboxes(element_name)
{
	box_checked = 0;
	with (document.form) {
		for (var i=0; i < elements.length; i++) {
			if (elements[i].name == element_name)
				if (  elements[i].checked )
				{
						box_checked += 1;
				}
		}
	}
	return box_checked;
}

function chkAll(frm, arr, mark) {
  for (i = 0; i <= frm.elements.length; i++) {
   try{
     if(frm.elements[i].name == arr) {
       frm.elements[i].checked = mark;
     }
   } catch(er) {}
  }
}



//######################################################################################
// Author: ricocheting.com
// For: public release (freeware)
// Date: 4/24/2003 (update: 5/15/2009)
// Description: displays the amount of time until the "dateFuture" entered below.


// NOTE: the month entered must be one less than current month. ie; 0=January, 11=December
// NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc
// format: dateFuture = new Date(year,month-1,day,hour,min,sec)
// example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm

dateFuture = new Date(2011,0,26,9,00,00);

// TESTING: comment out the line below to print out the "dateFuture" for testing purposes
//document.write(dateFuture +"<br />");


//###################################
//nothing beyond this point
function GetCount(){

	dateNow = new Date();									//grab current date
	localtime = dateNow.getTime();
	localOffset = dateNow.getTimezoneOffset() * 60000;
	dt=localtime+localOffset;
	pst = dt + (3600000*(-8.0));
	amount = dateFuture.getTime() - pst;			//calc milliseconds between dates
	delete dateNow;

	// time is already past
	if(amount < 0){
		document.getElementById('countbox').innerHTML="Now!";
	}
	// date is still good
	else{
		days=0;hours=0;mins=0;secs=0;out="";

		amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

		days=Math.floor(amount/86400);//days
		amount=amount%86400;

		hours=Math.floor(amount/3600);//hours
		amount=amount%3600;

		mins=Math.floor(amount/60);//minutes
		amount=amount%60;

		secs=Math.floor(amount);//seconds

		if(days >= 30) { out += Math.floor(days/30.5) + " month" + ((Math.floor(days/30.5) > 1) ? "s, " : ", "); days = days%30.5; }
		if(days != 0){out += Math.floor(days) +" day"+((days!=1)?"s":"")+" ";}
		if(days != 0 || hours != 0){out += hours +":";}
		if(days != 0 || hours != 0 || mins != 0){out += ((mins > 9) ? mins:"0"+mins) +":";}
		out += (secs > 9)?secs:"0"+secs;
		document.getElementById('countbox').innerHTML=out;

		setTimeout("GetCount()", 1000);
	}
}

//subtract 0.5 from (days), above, in out += (days) to toggle .5 days on/off

window.onload = GetCount; //call when everything has loaded


var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

var active_region = 0;

$(document).ready(function()
{
  $('#jsddm > li').bind('mouseover', jsddm_open);
  $('#jsddm > li').bind('mouseout',  jsddm_timer);
  $(".equal").equalizeCols();
  $(".equal2").equalizeCols();

  var height = $("#equal3_left").height() - 12;
  $("#getreadywrapper_long").height(height);

  var this_height;
  var max_height = 0;

  $('.equal_top').each(function () {
	this_height = $(this).height();
	if ($(this).attr('id') == 'left_nav') {
		this_height = this_height - 6;
	}
	max_height = Math.max(this_height, max_height);
  });
  $('.equal_top').height(max_height);
  
  $('.equal_top_long').each(function () {
	this_height = $(this).height();
	this_height = this_height - 8;
	max_height = Math.max(this_height, max_height);
  });

  var get_ready_height = $('#getready_content').height();
  
  if (get_ready_height > max_height) {
	  $('.equal_top_long').height(get_ready_height);
	  var one_short_height = get_ready_height - max_height + $('#oneshort').height();
	  $('#oneshort').height(one_short_height);
  } else {
	  $('.equal_top_long').height(max_height);
  }

  //bcbluemap code
	$('.map_mouseover').mouseover(function () {
		var id = $(this).attr('id').substr(10);
		map_hide(id);
		map_show(id);
	}).mouseout(function () {
		var id = $(this).attr('id').substr(10);
		map_hide(id);
	}).click(function () {
		var id = $(this).attr('id').substr(10);
		map_info_show(id);
		$('#map_overlay'+active_region).hide();
		active_region = id;
		return false;
	});
/*	
	$('.map_overlay_info').mouseover(function () {
		var id = $(this).attr('id').substr(16);
		map_show(id);
	}).click(function () {
		var id = $(this).attr('id').substr(16);
		map_info_show(id);
		return false;
	});
	
	$('#bcbluemap').mouseout(function () {
		map_hide();						 
	});
	*/
});

function map_show(id) {
	$('#map_overlay'+id).show();
	//$('.map_overlay_info').attr('id', 'map_overlay_info'+id);
	//$('.map_overlay_info').html(rdData[id].regionaldistrict);
	//$('.map_overlay_info').show();
}

function map_info_show(id) {
	$('#bcbluemap_default_copy').hide();
	$('#bcbluemap_overlay_copy').show();
	
	populate_overlay_data(id);
}

function map_hide(id) {
	if (id != active_region) {
		$('#map_overlay'+id).hide();
	}
	//$('.map_overlay_info').hide();
}

function populate_overlay_data(id) {
	$('#bcbluemap_overlay_copy').attr('map_id', id);
	
	$('#county').html(rdData[id].regionaldistrict);
	$('#registrants').html(rdData[id].total);
	//$('#sponsors').html(rdData[id].sponsors);
	//$('#online').html(rdData[id].online);	
	$('#members').html(rdData[id].members);
	$('#urldir').html(rdData[id].urldir);
	//$('.map_overlay_info').show();
}

document.onclick = jsddm_close;
