if (document.getElementById && document.images) {



// [ Config - editable ] ------------------------------------------

// Globals
var rootVirtual = '/_NEW';


// config:  pop-up defaults
	var popClass = "popup";
	var popName	= "popWin";
	var popPrefix = "pup-";
	var popW	= 400;
	var popH	= 300;
	
// config:  magic labels
	var magicLabelClass = 'dynLabel';
	var magicLabelHider = rootVirtual +'/_inc/css/hideLabel.css';
	


//	[ BEGIN NO EDIT ] ===============================================
	

// [ Utilities ] ------------------------------------------
	
	
	
	/**
	* addEvent
	*	Sample Usage:
	*	addEvent(window, 'load', function() {
	*		document.getElementById('myfield').focus()
	*	});
	*/
	if (typeof addEvent == 'undefined') {
		function addEvent(obj, evType, fn){
			if (obj.addEventListener){
				obj.addEventListener(evType, fn, true);
				return true;
			} else if (obj.attachEvent){
				var r = obj.attachEvent("on"+evType, fn);
				return r;
			} else {
				return false;
			}
		}
	}

	/**
	* isArray();
	* Returns true if submitted object is an array
	*/
	function isArray(obj) {
		if (isNaN(obj.length)) { return false; }
		else { return true; }
	}

	/**
	* inArray();
	* Searches array for specified value
	*/
	Array.prototype.inArray = function (value) {
		var i; 
		for (i=0; i < this.length; i++) {
			if (this[i] === value) { return true; } 
		}
		return false; 
	}; 
	
	/**
	* isNumeric();
	* Determines if specified value is numeric -- considers floats numeric
	*/
	function isNumeric(x) {
		var nums = "0123456789.";
		var IsNumber=true;
		var Char;
		for (i = 0; i < x.length && IsNumber == true; i++) {
			Char = x.charAt(i);
			if (nums.indexOf(Char) == -1) { IsNumber = false; }
		}
		return IsNumber;
	}
	

	/**
	* popUp();
	* Pop-up window launcher.  Automatically centers & sizes upon launch.  Req. by popupHandler
	* @params	winURL, target, width, height, {addlfeature[s]=1 [comma delim]}
	*/
	var _popWindow; // global var for accessing childwindow
	function popUp(winURL,t,w,h,s){
		var specs="width="+w+",height="+h +',resizable=1';
		if (s && s!='') {
			specs += ","+ s;
		}
		// resize & reposition if childwindow exists
		if (_popWindow == null) { // new
			_popWindow = t; 
		}
		else if (!_popWindow.closed) { // exists
				var Woff= (document.all) ? 11 : 9;
				var iw = parseInt(w) + Woff;
				var Hoff= (document.all) ? 60 : 57;
				var ih = parseInt(h) + Hoff
				
				var pos = getCentering(iw,ih);

				_popWindow.moveTo(pos[0],pos[1]);	
				_popWindow.resizeTo(iw,ih);
		}
		else { // failsafe
			_popWindow = t; 
		}
		// make sure we have positioning
		if (typeof pos == 'undefined') {
			var pos = getCentering(w,h);
			specs+=',left='+pos[0]+',top='+pos[1];
		}

		_popWindow = window.open(winURL,t,specs);	
		if (window.focus) { _popWindow.focus(); }
	}	

	function getCentering(w,h) {
		var scrX=Math.round((screen.width/2)-(w/2));
		var scrY=Math.round((screen.height/2)-(h/2));
		if (scrY>100){ scrY=scrY-40; }
		var ret = new Array(scrX,scrY);
		return ret;
	}




// [ Custom Handlers ] ------------------------------


/**
	* popupHandler();
	* Unobtrusive pop-up window launch handler, customizable. 
	* Keys off of 2 specified CSS classes in config [@top].
	* In HREF, pop-up class must be first but otherwise will concatenate. [TO DO: fix]
	* @author: Spencer Sundell <www.spencersundell.com>
	*/
	function popupHandler() { 
		var cl=popClass.length;
		var a=document.getElementsByTagName("a");
		for(var i=0; i<a.length; i++) { 
			var ca=document.getAttribute?a[i].getAttribute("class").split(" "):a[i].className.split(" ");
			if(ca[0]===popClass) { 
				a[i].onclick=function () { 
					var w = popW;  var h = popH; var s='';
					var ca2=document.getAttribute ? this.getAttribute("class").split(" ") : this.className.split(" ");
					for (var i=0; i<ca2.length; i++) {
						if (ca2[i].substring(0,popPrefix.length) === popPrefix) {
							var aaa = ca2[i].substring(popPrefix.length,ca2[1].length);
							c = aaa.split("_");
							for (var z=0; z<c.length; z++) {
								if (c[z].substring(0,1)=='w') { w = c[z].substring(1,c[z].length); }
								else if (c[z].substring(0,1)=='h') { h = c[z].substring(1,c[z].length); }
								else { s += c[z] +"=1,"; }
							}					
						}
					}
					var t= this.getAttribute("target") ? this.getAttribute("target") : popName;
					popUp(this.getAttribute("href"),t,w,h,s);
					return false;
				}
			}
		}
	}


/** doNav
*	Attaches designated CSS "here" class to either LI or A element when the current page's
* 	URL matches any in the designated navigation
*	@param		navID  		= ID of whatever container holds the target nav (div, ul)
* 	@param  	hereClass  	= any CSS class name, used to flag the "here" link (via elementSwitch)
*	@param  	elementSwitch  = 'li' or 'a' - attach hereClass to this (default = li)
*	@example: 	addEvent(window,'load',doNav);
*   @Note: 		There's a better-optimized version of this script.
*/

function doNav() {

 // configs
	var elementSwitch = 'li';  // 'a' or 'li'
	var hereClass = 'here';

//  ----
	var here = false;
	here= (typeof window.location != 'undefined') ? window.location.toString().toLowerCase() : false;
		if (here===false) { return false; }
	var navID = document.getElementById('nav');
	var navLinks = navID.getElementsByTagName(elementSwitch);
	//		hereLOC = navLinks[i];
		
	if (elementSwitch == 'a') {
			
			//// 'a' 
			for (var i=0; i<navLinks.length; i++) {
				switch (here == navLinks[i].href.toLowerCase()) {
					case true:
						var thisClass = navLinks[i].className.toString();
						navLinks[i].className = (thisClass=='' || thisClass==null) 
							? hereClass 
							: thisClass +' here';
						break;
					default:
						// Do Nothing	
				} // close switch
			} // end for
			////  end 'a'
	
	} else if (elementSwitch == 'li') {
	
			//// 'li'
				for (var i=0; i<navLinks.length; i++) {		
					var urls = navLinks[i].getElementsByTagName("a");
					var url = urls[0].href.toString().toLowerCase();
					switch (here == url) {
						case true:
							var thisClass = navLinks[i].className.toString();
							navLinks[i].className = (thisClass=='' || thisClass==null) 
								? hereClass 
								: thisClass +' here';
							break;
						default:
							// Do Nothing				
	
					} // close switch
				} // closer for
	
			//// end 'li'
	} // end IF		



} // close Function



// [ MAGIC LABELS ]===================================================
	/*  source -- http://www.sitepoint.com/article/behaved-dhtml-case-study/5   [example F]
		...with some modifications in labelTest()
	  
	  	labelTest() function modified by Spencer Sundell 2 AUG 2006:
			- fully unobtrusive implementation (vs. original document.writeln)
			- changed style ref from inline to a linkrel due to IE barfage on adding innerHTML to style element
	
	*/

function labelTest() {
	if (supportsDynamicLabels()) {
		var headRef = document.getElementsByTagName('head').item(0);
		var labelStyle = document.createElement('link');
			labelStyle.type = 'text/css';
			labelStyle.rel = 'stylesheet';
			labelStyle.href = rootVirtual +'/_inc/css/hideLabel.css';
			headRef.appendChild(labelStyle);
		setupLabels();
	}
}

function setupLabels() {
  var objLabels = document.getElementsByTagName("LABEL");
  var objField;

  for (var i = 0; i < objLabels.length; i++) {
    if (magicLabelClass == objLabels[i].className) {
      objField = document.getElementById(objLabels[i].htmlFor);
      addEvent(objField, "focus", focusDynamicLabel);
      addEvent(objField, "blur", blurDynamicLabel);
      objField._labelText = objLabels[i].firstChild.nodeValue;
      objField.value = objField._labelText;
    }
  }

  for (var i = 0; i < document.forms.length; i++) {
    addEvent(document.forms[i], "submit", resetLabels);
  }
}

function resetLabels(event) {
  var elm = getEventSrc(event);
  var objLabels = elm.getElementsByTagName("LABEL");
  var objField;

  for (var i = 0; i < objLabels.length; i++) {
    if (magicLabelClass == objLabels[i].className) {
      objField = document.getElementById(objLabels[i].htmlFor);
      if (objField._labelText == objField.value) {
        objField.value = "";
      }
    }
  }
}

function focusDynamicLabel(event) {
  var elm = getEventSrc(event);
  if (elm._labelText == elm.value) {
    elm.value = "";
  }
}

function blurDynamicLabel(event) {
  var elm = getEventSrc(event);
  if ("" == elm.value) {
    elm.value = elm._labelText;
  }
}

function getEventSrc(e) {
  if (!e) e = window.event;

  if (e.originalTarget)
    return e.originalTarget;
  else if (e.srcElement)
    return e.srcElement;
}

function supportsDynamicLabels() {
  return document.getElementById && 
    (window.attachEvent || window.addEventListener) && 
    null == navigator.appVersion.match(/Safari\/\d+$/);
}


// [end magic labels ] ---------------------------------------------------








// [[ ONLOAD inits ]] -------------------------------------
	addEvent(window,'load',labelTest);
	addEvent(window,'load',doNav);
	addEvent(window,'load',popupHandler);


} // close Test
