<!-- HIDE FROM INCOMPATIBLE BROWSERS

/*
*	BEST Arts Conference JavaScript Code Snippets
*
*	By: Tammy C. Wilson, Agile Web Development
*	12/6/07
*/

/* These two functions are courtsey of "DOM Scripting: Web Design with JavaScript and the
Document Object Model" by Jeremy Keith. It improves the use of default values in forms by
clearing out the default value when you enter an input field and replacing it when you leave
the input field without entering a value
Modified to ignore the reset button as well as commented items below
Using default values caused too many problems. If JavaScript isn't available, no error checking
is done and we can be left with the default values--no easy way I know of to check for that, would
have to do each one individually. Not sure this addes enough. Will keep the functions with modifications
as I have added error checking... */

function prepareForms() {
	for (var i=0; i<document.forms.length; i++) {
		var thisform = document.forms[i];
		resetFields(thisform);
	}
}

function resetFields(whichForm) {
	for (var i=0; i<whichForm.elements.length; i++) {
		var element = whichForm.elements[i];

// When submitting the form, check that all required fields have been filled in
		if (element.type == "submit") {
			submitProcessing(element);
			continue;
		}

		if (element.type == "reset" ) continue;
		if (!element.defaultValue) continue;

// If there is a valid working default value, don't clear it
		var thisClass = element.getAttribute("class");
		if (thisClass !== null) {
			if (thisClass.indexOf("defaultOk") > -1) continue;
		}

/*		element.onfocus = function() {
			if (this.value == this.defaultValue) {
				this.value = "";
			}
		}
*/
// Don't assign the onblur function if this is not a required field and CAN be left blank
/*		if (thisClass == null) continue;
		
		if (thisClass.indexOf("required") < 0) continue;
		
		element.onblur = function() {
			if (this.value == "") {
				this.value = this.defaultValue;
			}
		}
*/	}
}

/* When submitting the form, first verify all the required fields have been completed and are not left with the default values */
function submitProcessing(submitButton) {
	if (submitButton.getAttribute("name") == "register") {
		submitButton.onclick = function() {
			var reqFields = [];
			reqFields = getElementsByClassName(document, "*","required");
			
			for (var j=0; j < reqFields.length; j++) {
				// Don't need to check the labels, just check the text fields (type is undefined)
	
				if (reqFields[j].type == "text") {
					if (reqFields[j].value == "" || reqFields[j].value == "REQUIRED") {
	
						// Don't touch a valid working default value
						var thisClass = reqFields[j].getAttribute("class");
						if (thisClass !== null) {
							if (thisClass.indexOf("defaultOk") == -1) {
								var newClass = reqFields[j].getAttribute("class") + " notBlank";
								reqFields[j].setAttribute("class", newClass);
								reqFields[j].value = "REQUIRED";
							}
						}
					}
				}
				
				// Check the list value to be sure one was actually selected
				if (reqFields[j].type == "select-one") {
					if (reqFields[j].value == 0) {
						var newClass = reqFields[j].getAttribute("class") + " notBlank";
						reqFields[j].setAttribute("class", newClass);			
					}
				}
			}
			
			if (newClass !== undefined && newClass !== null) {
				var message = document.getElementById("required");
				var txt = document.createTextNode("--Please fill in the required fields before Submitting the form.");
				message.appendChild(txt);
				message.setAttribute("class", "notBlank");
	
				return false;
			}
		}
	}
}

/*
	Written by Jonathan Snook, http://www.snook.ca/jonathan
	Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements);
}

/* This function is courtsey of: Simon Willison http://simon.incutio.com, via Pro JavaScript Techniques by John Resig */
function hasClass(name, type) {
	var r = [];

	// Locate the class name (allows for multiple class names)
	var re = new RegExp("(^|\\s)" + name + "(\\s|$)");
alert("re = "+re);
	// Limit search by type, or look through all elements
	var e = document.getElementsByTagName(type || "*");

	for ( var j=0; j < e.length; j++ )
		// If the element has the class, add it for return
		if ( re.test(e[j]) ) r.push( e[j] );

alert("r.length = " + r.length);
// Return the list of matched elements
	return r;
}

/* This function is courtsey of: http://www.sitepoint.com/article/standards-compliant-world
It opens links marked external in a new Window. Use with PDF's and external websites */

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
		}
}

/************************************************************************************************************************/


// xGetElementById r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetElementById(e) {
  if(typeof(e)=='string') {
    if(document.getElementById) e=document.getElementById(e);
    else if(document.all) e=document.all[e];
    else e=null;
  }
  return e;
}

// xNum r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xNum() {
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}

// xDef r1, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

// xStr r1, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xStr(s) {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

// xCamelize r1, Copyright 2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xCamelize(cssPropStr)
{
  var i, c, a = cssPropStr.split('-');
  var s = a[0];
  for (i=1; i<a.length; ++i) {
    c = a[i].charAt(0);
    s += a[i].replace(c, c.toUpperCase());
  }
  return s;
}
// xGetComputedStyle r7, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetComputedStyle(e, p, i) {
  if(!(e=xGetElementById(e))) return null;
  var s, v = 'undefined', dv = document.defaultView;		
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(e,'');
    if (s) v = s.getPropertyValue(p);
  }
  else if(e.currentStyle) {
    v = e.currentStyle[xCamelize(p)];
  }
  else return null;
  return i ? (parseInt(v) || 0) : v;
}

// xHeight r6, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xHeight(e,h) {	
  var s = e;
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(h)) {
    if (h<0) h = 0;
    else h=Math.round(h);
  }
  else h=-1;
  var css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    h = xClientHeight();
  }
  else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
   if(h>=0) {
      var pt=0,pb=0,bt=0,bb=0;
      if (document.compatMode=='CSS1Compat') {
        var gcs = xGetComputedStyle;		
        pt=gcs(e,'padding-top',1);		  
        if (pt !== null) {
          pb=gcs(e,'padding-bottom',1);
          bt=gcs(e,'border-top-width',1);
          bb=gcs(e,'border-bottom-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetHeight,e.style.height)){ 			
          e.style.height=h+'px';
          pt=e.offsetHeight-h;			
        }
      }
      h-=(pt+pb+bt+bb);
      if(isNaN(h)||h<0) return;
	   	  else e.style.height=h+'px';
    }
    h=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {			
    if(h>=0) e.style.pixelHeight=h;
    h=e.style.pixelHeight;
  }
  return h;
}

/* This function is courtsey of http://www.sitepoint.com/newsletter/viewissue.php?id=3&issue=70#4
It adjusts the height of the columns so they are identical. That way the background goes all the way
to the bottom of the column
It has been adjusted for two columns from the original three
It uses the X JavaScript library, see routines above */

function adjustLayout() {
  // Get natural heights
  var cHeight = xHeight("main");
  var lHeight = xHeight("sidebar");

  // Find the maximum height
  var maxHeight =
    Math.max(cHeight, lHeight);

/* Have a problem with one of the pages, not sure what the exact problem is, but calculated height is 225px
but the actual height is 240px. It might have something to do with the image making the height taller than the 
rest of the content? Anyway, set a minimum height of 240px to avoid this for now... */

  if( maxHeight < 250 ) maxHeight = 250;

  // Assign maximum height to all columns
  xHeight("main", maxHeight);
  xHeight("sidebar", maxHeight);
}

/************************************************************************************************************************/


/* This function is courtsey of: http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/ */
/* It adds functions to the onload event, without screwing up any previous onload events */

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(prepareForms);
addLoadEvent(externalLinks);
addLoadEvent(adjustLayout);

// STOP HIDING FROM INCOMPATIBLE BROWSERS -->