function openWindow(strLocation,nbrWidth,nbrHeight) { 
	var strOptions = "location=yes,menubar=yes,toolbar=yes,scrollbars=yes,width=" + nbrWidth + ",height=" + nbrHeight;

	var nbrRandom=Math.floor(Math.random()*999);

	var objWindow = window.open(strLocation, String(nbrRandom), strOptions);
	objWindow.focus();

	return true;
}

function setPopUpLinks() {

	var hrefs = document.getElementsByTagName('A');

	for (i in hrefs) { 
		if (hrefs[i].className == 'pop_up') {
			hrefs[i].onclick = function() { window.open(this.href); return false; }
			hrefs[i].onkeypress = function() { window.open(this.href); return false; }
		}
	}
}



function changeIt(){
document.getElementById("amtdiv").innerHTML="<table id='amountdiv'><tr><td width='200'><strong>Amount:*$</strong>&nbsp;&nbsp;</td><td><input type='text' name='amount' size='10' value='' /></td></tr></table>"
return true;
}
function changeItBack(){
document.getElementById("amtdiv").innerHTML="&nbsp;"
return false;

}
function addFields(){
document.getElementById("abovediv").innerHTML="<p class='caption'>*Virginia law requires that we report the occupation and employer of those who give over $100</p><table id='newfieldsdiv'><tr><td width='200'><strong>Employer:*</strong>&nbsp;&nbsp;</td><td><input type='text' name='company' size='30' value='' /></td></tr><tr><td width='200'><strong>Occupation:*</strong>&nbsp;&nbsp;</td><td><input type='text' name='position' size='30' value='' /></td></tr></table>"
return true;
}
function removeFields(){
document.getElementById("abovediv").innerHTML="&nbsp;"
return false;
}


function registrationDonCheck() {
	
	if(document.getElementById("amountdiv")) {
		if(document.form_don.amount.value == "") {
		alert('Please enter an amount');
		document.form_don.amount.focus();
		return false;
		}
	}
	
	
	if(document.getElementById("amountdiv") && document.form_don.amount.value < 100) {


	} else if(document.getElementById("newfieldsdiv")) {
	
		if(document.form_don.company.value == "") {
		alert('Please enter your employer');
		document.form_don.company.focus();
		return false;
		}
		if(document.form_don.position.value == "") {
		alert('Please enter your position');
		document.form_don.position.focus();
		return false;
		}
	}
	
	if(document.form_don.first_name.value == "") {
		alert('Please enter your first name.');
		document.form_don.first_name.focus();
		return false;
	}

	if(document.form_don.last_name.value == "") {
		alert('Please enter your last name.');
		document.form_don.last_name.focus();
		return false;
	}

	if(document.form_don.address1.value == "") {
		alert('Please enter address one.');
		document.form_don.address1.focus();
		return false;
	}
	if(document.form_don.city.value == "") {
		alert('Please enter city.');
		document.form_don.city.focus();
		return false;
	}
	if(document.form_don.state.value == "") {
		alert('Please select state.');
		document.form_don.state.focus();
		return false;
	}

	if(document.form_don.country.value == "") {
		alert('Please select country.');
		document.form_don.country.focus();
		return false;
	}
	if(document.form_don.zip.value == "") {
		alert('Please enter zip code.');
		document.form_don.zip.focus();
		return false;
	}
	if(document.form_don.phone.value == "") {
		alert('Please enter your telephone number.');
		document.form_don.phone.focus();
		return false;
	}
	if(document.form_don.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert('Please enter a valid email value.');
		document.form_don.email.focus();
		return false;
	}
	if(document.form_don.email_confirm.value != document.form_don.email.value) {
		alert("The email your typed in doesn't match.");
		document.form_don.email_confirm.focus();
		return false;
	}

	if(!document.form_don.read_policy.checked) {
		alert('You must agree to the Right Change policies.');
		document.form_don.read_policy.focus();
		return false;
	}

	if(document.form_don.cc_num.value == "") {
			alert('Please enter your credit card #.');
			document.form_don.cc_num.focus();
			return false;
	}
			
		if(document.form_don.cc_ccv.value== "") {
			alert('Please enter the secure code.');
			document.form_don.cc_ccv.focus();
			return false;
		}
		if(document.form_don.cc_name.value== "") {
			alert('Please enter your name on card.');
			document.form_don.cc_name.focus();
			return false;
		}
		if(document.form_don.cc_type.value== "") {
			alert('Please select your credit card type.');
			document.form_don.cc_type.focus();
			return false;
		}

	return true;
}
function SubmitDonForm(cform) {
  if(registrationDonCheck()){cform.submit();}
}

var help_parent = window.location;
function help_popup() {window.open('/index.php/site/help','page','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=550,left=50,top=50,titlebar=yes')}






function registrationVolCheck() {
	
	
	if(document.form_vol.first_name.value == "") {
		alert('Please enter your first name.');
		document.form_vol.first_name.focus();
		return false;
	}

	if(document.form_vol.last_name.value == "") {
		alert('Please enter your last name.');
		document.form_vol.last_name.focus();
		return false;
	}

	if(document.form_vol.address1.value == "") {
		alert('Please enter address one.');
		document.form_vol.address1.focus();
		return false;
	}
	if(document.form_vol.city.value == "") {
		alert('Please enter city.');
		document.form_vol.city.focus();
		return false;
	}
	if(document.form_vol.state.value == "") {
		alert('Please select state.');
		document.form_vol.state.focus();
		return false;
	}

	if(document.form_vol.zip.value == "") {
		alert('Please enter zip code.');
		document.form_vol.zip.focus();
		return false;
	}
	if(document.form_vol.phone.value == "") {
		alert('Please enter your telephone number.');
		document.form_vol.phone.focus();
		return false;
	}
	if(document.form_vol.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert('Please enter a valid email value.');
		document.form_vol.email.focus();
		return false;
	}
	if(document.form_vol.email_confirm.value != document.form_vol.email.value) {
		alert("The email your typed in doesn't match.");
		document.form_vol.email_confirm.focus();
		return false;
	}

	return true;
}
function SubmitVolForm(cform) {
  if(registrationVolCheck()){cform.submit();}
}






//Flash Detect Variables
var flashinstalled = 0;
var flashversion = 0;

function checkFlash(nbrFlashversion) {

	if (nbrFlashversion < 1) {
		/* This Flash detection code was originally written by Peter-Paul Koch at http://www.quirksmode.org/.  He has allowed for this to be freely distributed per his copyright located at http://www.quirksmode.org/about/copyright.html. */

		if (navigator.plugins && navigator.plugins.length) {
			x = navigator.plugins["Shockwave Flash"];
			if (x) {

				flashinstalled = 2;
				if (x.description) {
					y = x.description;
					nbrFlashversion = y.charAt(y.indexOf('.')-1);
				}
			} else {
				flashinstalled = 1;
			}

			if (navigator.plugins["Shockwave Flash 2.0"]) {
				flashinstalled = 2;
				nbrFlashversion = 2;
			}

		} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
			x = navigator.mimeTypes['application/x-shockwave-flash'];
			if (x && x.enabledPlugin) {
				flashinstalled = 2;
			} else {
				flashinstalled = 1;
			}
		}
	}

	if(nbrFlashversion < 8) {

		switch(document.body.id) {
			case "homepage":
				removeFlashElement("homepage_video","content_center");
				document.getElementById("content_center").className="homepage_image";
				break;
		}

		if(getCookie("oldflash") != 1){
			box = confirm("To view the video content on this site, please click \"OK\" to download the latest Flash plugin.  To view the site without video, click \"Cancel\"."); 
			
			if(box == true){window.location="http://www.macromedia.com/go/getflashplayer";}
			
			setCookie("oldflash","1",7,setCookieDomain(),"/");
			setCookie("dialup","1",7,setCookieDomain(),"/");
		}
	}
}

function noVideo(nbrVideo) {

	if(getCookie("dialup") != 1 || getCookie("oldflash") != 1) {	
		var arrVideo = new Array();

		//SWF Names
		arrVideo[0] = "bobm_hm";
		if (getCookie(arrVideo[nbrVideo]) == 1) {
			if (document.getElementById(arrVideo[nbrVideo])) {getFlashMovieObject(arrVideo[nbrVideo]).SetVariable("makeItStop","1");}
		} else {setCookie(arrVideo[nbrVideo],"1",0,setCookieDomain(),"/");}
	}
}

function getFlashMovieObject(menu) {
  	if (window.document[menu]) {
      		return window.document[menu];
  	}
  	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    		if (document.embeds && document.embeds[menu]){
      			return document.embeds[menu]; 
		}
  	}
  	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) 
	{
    		return document.getElementById(menu);
  	}
}

function removeFlashElement(childDiv,parentDiv) {
  
  	if(document.getElementById(childDiv)){
		
		var objParent = document.getElementById(parentDiv);

		var objChild = document.getElementById(childDiv);
  
		objParent.removeChild(objChild);
	}
}


function CurrentTime() {
	time = new Date();
	return time.getTime();
}

function returnKBPS(kbps){
	return kbps;
}

function GetKBPS(ST,section) {
	ET = CurrentTime();
	Factor	= 1000;
	DT = ((ET - ST)/Factor);
	DataSize = 29;
	kbps1    = (DataSize/DT);
	kbpsA    = ((kbps1*8)*10*1.02);
	kbyteA   = ((DataSize*10)/DT);
	kbps     = (Math.round(kbpsA)/10);
	kbyte    = (Math.round(kbyteA)/10);

	if (getCookie("dialup") == 1 || kbps <= 80) {

		switch(section) {
			case 1:
				removeFlashElement("homepage_video","content_center");
				document.getElementById("content_center").className="homepage_image";
			break;
		} 
		setCookie("dialup","1",7,setCookieDomain(),"/");
	}
}



function getCookie(strName) {
	var nbrStart = document.cookie.indexOf(strName + "=");
	var nbrLength = nbrStart + strName.length + 1;
	if ((!nbrStart) && (strName != document.cookie.substring(0, strName.length))) {
		return null;
	}
	if (nbrStart == -1) return null;
	var nbrEnd = document.cookie.indexOf(';', nbrLength);
	if (nbrEnd == -1) nbrEnd = document.cookie.length;
	return unescape(document.cookie.substring(nbrLength, nbrEnd));
}

function setCookie(strName,strValue,strDuration,strDomain,strPath) {

	var strCookie="";

	if (strDuration == 0) {strCookie=strName+"="+escape(strValue)+";DOMAIN="+strDomain+";PATH="+strPath;} else {strCookie=strName+"="+escape(strValue)+";EXPIRES="+getExpiryDate(strDuration)+";DOMAIN="+strDomain+";PATH="+strPath;}

	document.cookie=strCookie;

	if(!getCookie(strName)){
		return false;
	}
	else{
		return true;
	}
}

function deleteCookie(strName) {setCookie(strName,"",-1,setCookieDomain(),"/");}

function getExpiryDate(intDays) {

	var strUTC; //This will hold the UTC value

	strToday = new Date(); //Get the current date.
	strToday.setTime(strToday.getTime() + 3600000*24*intDays); //Add the number of days to keep alive
	strUTC = strToday.toUTCString(); //Convert the UTC back to a string.

	return strUTC; //Return the date.
}

function setCookieDomain() {
	var strDomain = document.domain;
	
	strDomain.replace('www.','');

	return '.'+strDomain;
}



//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "wmode":
	ret.params[args[i]] = args[i+1];
	break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function contactCheck() {
	if(document.contactform.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1){
		alert('Please enter a valid email value.');
		return false;
	}
	if(document.contactform.first.value == "") {
		alert('Please enter your name.');
		return false;
	}
	if(document.contactform.last.value == "") {
		alert('Please enter your name.');
		return false;
	}

	if(document.contactform.zip.value == "") {
		alert('Please enter your zip code.');
		return false;
	}

	if(document.contactform.phone.value == "") {
		alert('Please enter a phone number.');
		return false;
	}

	return true;
}

function SubmitStartForm(cform) {cform.submit();}

function clearForm() {
	document.mailstart.email.value = "";
}
function clearFormZip() {
	document.mailstart.zip.value = "";
}
function initHomepage() {
	window.setTimeout("noVideo(0)", 250);

}
/* END CONTACT FORM VALIDATOR */

function registrationJoinCheck() {

	
	if(document.form_join.zip.value == "") {
		alert('Please enter zip code.');
		document.form_join.zip.focus();
		return false;
	}

	if(document.form_join.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert('Please enter a valid email value.');
		document.form_join.email.focus();
		return false;
	}
	if(document.form_join.email2.value != document.form_join.email.value) {
		alert("The email you typed in doesn't match.");
		document.form_join.email_confirm.focus();
		return false;
	}
	

	return true;
}


function SubmitJoinForm(cform) {
  if(registrationJoinCheck()){cform.submit();}
}

function checkEventSignup() {

	if(document.form_event_signup.schedule.value == "") {
		alert('Please select the event you like to attend.');
		document.form_event_signup.schedule.focus();
		return false;
	}	
	if(document.form_event_signup.fname.value == "") {
		alert('Please enter your first name.');
		document.form_event_signup.fname.focus();
		return false;
	}
	if(document.form_event_signup.lname.value == "") {
		alert('Please enter your last name.');
		document.form_event_signup.lname.focus();
		return false;
	}
	if(document.form_event_signup.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert('Please enter a valid email value.');
		document.form_event_signup.email.focus();
		return false;
	}

	if(document.form_event_signup.phone.value == "") {
		alert('Please enter your phone number.');
		document.form_event_signup.phone.focus();
		return false;
	}	
	if(document.form_event_signup.numAttendees.value == "") {
		alert('Please enter number of attendees coming to the event.');
		document.form_event_signup.phone.focus();
		return false;
	}
	return true;
}

//
//
//

sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i = 0; i < sfEls.length; i++) {
        sfEls[i].onmouseover = function() {
            this.className += " sfhover";
        }
        sfEls[i].onmouseout = function() {
            this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);