//-------------------------------------------------------------------------------------------
// HTML5 shim (for IE < 9) Needs to run before document.ready()
//-------------------------------------------------------------------------------------------

if($.browser.msie && parseFloat($.browser.version) <= 8){
// html5shiv MIT @rem remysharp.com/html5-enabling-script
// iepp v1.5.1 MIT @jon_neal iecss.com/print-protector
/*@cc_on(function(p,e){var q=e.createElement("div");q.innerHTML="<z>i</z>";q.childNodes.length!==1&&function(){function r(a,b){if(g[a])g[a].styleSheet.cssText+=b;else{var c=s[l],d=e[j]("style");d.media=a;c.insertBefore(d,c[l]);g[a]=d;r(a,b)}}function t(a,b){for(var c=new RegExp("\\b("+m+")\\b(?!.*[;}])","gi"),d=function(k){return".iepp_"+k},h=-1;++h<a.length;){b=a[h].media||b;t(a[h].imports,b);r(b,a[h].cssText.replace(c,d))}}for(var s=e.documentElement,i=e.createDocumentFragment(),g={},m="abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".replace(/ /g, '|'),
n=m.split("|"),f=[],o=-1,l="firstChild",j="createElement";++o<n.length;){e[j](n[o]);i[j](n[o])}i=i.appendChild(e[j]("div"));p.attachEvent("onbeforeprint",function(){for(var a,b=e.getElementsByTagName("*"),c,d,h=new RegExp("^"+m+"$","i"),k=-1;++k<b.length;)if((a=b[k])&&(d=a.nodeName.match(h))){c=new RegExp("^\\s*<"+d+"(.*)\\/"+d+">\\s*$","i");i.innerHTML=a.outerHTML.replace(/\r|\n/g," ").replace(c,a.currentStyle.display=="block"?"<div$1/div>":"<span$1/span>");c=i.childNodes[0];c.className+=" iepp_"+
d;c=f[f.length]=[a,c];a.parentNode.replaceChild(c[1],c[0])}t(e.styleSheets,"all")});p.attachEvent("onafterprint",function(){for(var a=-1,b;++a<f.length;)f[a][1].parentNode.replaceChild(f[a][0],f[a][1]);for(b in g)s[l].removeChild(g[b]);g={};f=[]})}()})(this,document);@*/
}



//-------------------------------------------------------------------------------------------
// Global Document Ready
//-------------------------------------------------------------------------------------------

$(document).ready(function(){
	if(!window.Prototype) {
		$('#ddMenu').dropdownMenu({displayMode: "slide"});
	}
	initBase64()
})







//-------------------------------------------------------------------------------------------
//Scripts and plugins
//-------------------------------------------------------------------------------------------

		// Google Analytics
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
		
		try {
		var pageTracker = _gat._getTracker("UA-7537426-2");
		pageTracker._trackPageview();
		} catch(err) {}



	   	// parsing the querystring
		function getParameterByName( name, fromWhere ) { 
		  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
		  var regexS = "[\\?&]"+name+"=([^&#]*)"; 
		  var regex = new RegExp( regexS ); 
		  var results
		  if (fromWhere == "url") {
		  	results = regex.exec( window.location.href ); 
		  } else {
		  	results = regex.exec( fromWhere ); 
		  }
		  
		  if( results == null ) 
			return ""; 
		  else 
			return decodeURIComponent(results[1].replace(/\+/g, " ")); 
		}	


/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/

function initBase64() {
	Base64 = {
	
		// private property
		_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
	
		// public method for encoding
		encode : function (input) {
			var output = "";
			var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
			var i = 0;
	
			input = Base64._utf8_encode(input);
	
			while (i < input.length) {
	
				chr1 = input.charCodeAt(i++);
				chr2 = input.charCodeAt(i++);
				chr3 = input.charCodeAt(i++);
	
				enc1 = chr1 >> 2;
				enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
				enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
				enc4 = chr3 & 63;
	
				if (isNaN(chr2)) {
					enc3 = enc4 = 64;
				} else if (isNaN(chr3)) {
					enc4 = 64;
				}
	
				output = output +
				this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
				this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
	
			}
	
			return output;
		},
	
		// public method for decoding
		decode : function (input) {
			var output = "";
			var chr1, chr2, chr3;
			var enc1, enc2, enc3, enc4;
			var i = 0;
	
			input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
	
			while (i < input.length) {
	
				enc1 = this._keyStr.indexOf(input.charAt(i++));
				enc2 = this._keyStr.indexOf(input.charAt(i++));
				enc3 = this._keyStr.indexOf(input.charAt(i++));
				enc4 = this._keyStr.indexOf(input.charAt(i++));
	
				chr1 = (enc1 << 2) | (enc2 >> 4);
				chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
				chr3 = ((enc3 & 3) << 6) | enc4;
	
				output = output + String.fromCharCode(chr1);
	
				if (enc3 != 64) {
					output = output + String.fromCharCode(chr2);
				}
				if (enc4 != 64) {
					output = output + String.fromCharCode(chr3);
				}
	
			}
	
			output = Base64._utf8_decode(output);
	
			return output;
	
		},
	
		// private method for UTF-8 encoding
		_utf8_encode : function (string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";
	
			for (var n = 0; n < string.length; n++) {
	
				var c = string.charCodeAt(n);
	
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}
	
			}
	
			return utftext;
		},
	
		// private method for UTF-8 decoding
		_utf8_decode : function (utftext) {
			var string = "";
			var i = 0;
			var c = c1 = c2 = 0;
	
			while ( i < utftext.length ) {
	
				c = utftext.charCodeAt(i);
	
				if (c < 128) {
					string += String.fromCharCode(c);
					i++;
				}
				else if((c > 191) && (c < 224)) {
					c2 = utftext.charCodeAt(i+1);
					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
					i += 2;
				}
				else {
					c2 = utftext.charCodeAt(i+1);
					c3 = utftext.charCodeAt(i+2);
					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
					i += 3;
				}
	
			}
	
			return string;
		}
	
	}

}


// JQUERY Tab Navigation Plugin
// 2010 Dominion Digital, Inc.
//
// v1 - jhilowitz 1/12/2010
 
(function($) {
	$.fn.jTabs = function(options) {		
		var defaults = {
				tabFunction:"dynamic",	// "dynamic" = in-page tab switching; "static" = tabs do not switch
				tabSwitchCallback: null	// "null" = use default function; specified = calls function after opening tab
			};
		var options = $.extend(defaults, options);
		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		// Loop
		return this.each(function() {
		
			obj = $(this);
			
			tabID = '';
			contentID = '';
			
			///////////////////////////////////////////////////////////////////////////////////////////////////
			// Set default tab
			testCurrent = obj.find('.tab li').hasClass('current');
			
			if(testCurrent == true){
				tabID = obj.find('li.current').children('a').attr('href');
				$(tabID).show();
			} else {
				firstTab = obj.children('.tab').children('ul').children('li:first');
				firstTabContent = obj.children('.tab').children('ul').children('li:first').children('a').attr('href');
				$(firstTab).addClass('current');
				$(firstTabContent).show();
			};
		
			///////////////////////////////////////////////////////////////////////////////////////////////////
			// Select tabs & show content
			if (options.tabFunction == "dynamic") {
				obj.children('.tab').children('ul').children('li').click(function(event) {
					event.preventDefault();
					tabID = $(this).children('a').attr('href');
					
					$(tabID).show();
					$(this).addClass('current');
					$(tabID).siblings('.tabContentContainer').hide();
					$(this).siblings('li').removeClass('current');

					if (typeof options.tabSwitchCallback == 'function'){
						options.tabSwitchCallback.call(this);    
					};
				});
				
			};
			
		///////////////////////////////////////////////////////////////////////////////////////////////////
	 	});
	};
})(jQuery);

// A Rotating Banner Plugin
// Dominion Digital (c) 2009

jQuery.fn.rotatingBanner = function(options) {
 
	var defaults = { 
		viewableHeight: 'auto',
		interruptDelay: 5000,
		autoplayDelay: 5000,
		transitionType: "slide", // "slide" = default; "fade" = dissolves images between each other
		transitionInDelay: 250,
		transitionOutDelay: 250		
	};
	
	var settings = $.extend({}, defaults, options);
 
	return this.each(function(){
						   
		var scrollableContainer = $(this);
		var $messageContainer = scrollableContainer.find('#sm-content');
		var messageList = scrollableContainer.find('#sm-content ul');
		messageList.css("left", 0);
		var $messageItems = messageList.find('li');
	
		if (messageList != null) {
		  var numberOfMessages = $messageItems.size();
	
		  if (numberOfMessages > 1) {
	
			messageWidth = parseInt($messageItems.width());

			if (settings.viewableHeight == 'auto') {
				messageHeight = parseInt($messageItems.height());
			} else {
				messageHeight = settings.viewableHeight;
			}

			var counter = 1;
			
	
			if (numberOfMessages >= 2) {
				// build navigation
				scrollableContainer.closest(".contentArea").prepend("<div id='scrollableNav'><ul></ul></div>");
				
				
				temp = $("#scrollableNav ul")
				
				for(i=1;i<=numberOfMessages;i++) {
					temp.append("<li id='item" + i + "'><a href='#'>" + i + "</a></li>");
				}
				
				temp.prepend("<li id='scrollPrevious'><a href='#'>&laquo</a></li>")
				temp.append("<li id='scrollNext'><a href='#'>&raquo;</a></li>")
				
				$scrollableNav = scrollableContainer.closest(".contentArea").find('#scrollableNav');
				
				$scrollableNav.find("#item1").toggleClass("selected")
				
				
				$("#scrollableNav ul li").each( function() {
					$(this).click(function(event) {
							event.preventDefault();
							manageTimer();
							moveToMessage($(this).attr('id'))
					}); 
				})
				
				if (settings.transitionType == "slide") {
					$messageContainer.width(messageWidth * numberOfMessages);
					$messageItems.css("float","left");
				}
				
				pauseDelay = null
				
				delayTimer()
			}
		  }
		}
		
		function manageTimer() {
			if (pauseDelay != null) {
				clearTimeout(pauseDelay)
				pauseDelay = null
			}
			clearInterval(autoPlay);
			autoPlay = null
			pauseDelay = setTimeout(delayTimer, settings.interruptDelay);
		}
		
		function delayTimer() {
			autoPlay = setInterval(moveMessages, settings.autoplayDelay);
		}
		
		function moveMessages() {
			
			$scrollableNav.find("#item" + counter).toggleClass("selected");
			
			if (counter == numberOfMessages) {
				moveWhere = 0
				counter = 0;
			} else {
				if (settings.transitionType = "slide") {
					moveWhere = parseInt(messageList.css("left")) - messageWidth;
				} else {
					moveWhere = parseInt(messageList.css("top")) - messageHeight;
				}
			}
			transitionMessageOut()
			
			counter++;
			
			$scrollableNav.find("#item" + counter).toggleClass("selected");
		}
		
		function moveToMessage(whatAction) {
			$scrollableNav.find("#item" + counter).toggleClass("selected");
			if (whatAction == "scrollPrevious") {
				if (counter == 1) {
					counter = numberOfMessages
				} else {
					counter--
				}
			} else if (whatAction == "scrollNext") {
				if (counter == numberOfMessages) {
					counter = 1
				} else {
					counter++
				}
			} else if (whatAction.indexOf("item") == 0) {
				var whichMessage = parseInt(whatAction.substr(4, whatAction.length ))
				counter = whichMessage
			}
			
			if (settings.transitionType = "slide") {
				moveWhere = (messageWidth * -counter) + messageWidth;
			} else {
				moveWhere = (messageHeight * -counter) + messageHeight;
			}
			
			transitionMessageOut()
			
			$scrollableNav.find("#item" + counter).toggleClass("selected");
		}
		
		function transitionMessageOut() {
			if (settings.transitionType = "slide") {
				messageList.animate({"left": moveWhere}, (settings.transitionInDelay + settings.transitionOutDelay));
			} else {
				messageList.fadeOut(settings.transitionOutDelay, transitionMessageIn);
			}

		}
		function transitionMessageIn() {
			if (settings.transitionType = "slide") {

			} else {
				messageList.css("top",moveWhere);
				messageList.fadeIn(settings.transitionInDelay);
			}
		}
		
	});
	
};


// Set local nav to highlight
			
			$(document).ready(function(){
              var thisPageName = location.pathname;
              thisPageName = thisPageName.substr(thisPageName.lastIndexOf('/')+1, thisPageName.length);
              $('.secondary a').each(function(){
                     if ($(this).attr('href') == thisPageName) {
                           $(this).parents('li:last').addClass('selected');
                     };
              });
			});

// A Dropdown Menu System Plugin
// Dominion Digital (c) 2010

(function($) {
	$.fn.dropdownMenu = function(options) {		
		var defaults = {
				dropdownTopOffset: 0, // 0 = default; units in pixels, accepts negative numbers
				dropdownLeftOffset: 0, // 0 = default; units in pixels, accepts negative numbers
				displayMode: "appear", // "appear" = default; just show/hide // "slide" = animate reveal down
				slideSpeed: "fast", // "fast" = default; // "slow"
				fitLinksToWidth: false // false = default; // true = fits the links in the dropdowns to the dropdown width
			};
		var options = $.extend(defaults, options);
		
		return this.each(function() {

			var $menuContainer = $(this);
			var mainMenuOffset = $menuContainer.position();
			var dropdownFit = false;
			

			$menuContainer.find("ul:first").addClass("menu");
			$menuContainer.find("ul:first").children().each(function(index) {
				
				$(this).addClass("mainItem").addClass("item" + index).hover(
						function() {
							displayDropdown($(this));
						},
						function() {
							hideDropdown($(this));
				 })
				 

				$(this).find("a:first").addClass("topItem");
			})
			
			function displayDropdown($whichObject) {
				var $theDropdown = $whichObject.find(".dropdownContainer");
							
				if (options.displayMode == "appear") {
					$theDropdown.css({"display":"block"});
				} else {
					$theDropdown.slideToggle(options.slideSpeed)
				}
				if (!dropdownFit && options.fitLinksToWidth){
					$dropdownItems = $whichObject.find(".dropdownContainer li")
					var dropdownWidth = $dropdownItems.width()
					$dropdownItems.each(function(){
						$whichObject.find("a").width(dropdownWidth);
					})
					dropdownFit = true;
				}
			}

			function hideDropdown($whichObject) {
				var $theDropdown = $whichObject.find(".dropdownContainer");
				
				if ($theDropdown.css("display") == "block" ) {
					if (options.displayMode == "appear") {
						$theDropdown.css({"display":"none"});
					} else {
						$theDropdown.slideToggle(options.slideSpeed)
					}
				}
			}
			
			
			$menuContainer.css({"visibility":"visible"});

			$menuContainer.find("ul:first").children().last().addClass("lastItem");
			
			$menuContainer.find("ul:first").children().each(function(index) {
				
				$(this).find('ul:first').wrap("<div class='dropdownContainer' />");
				
				var localDropdown = $(this).find('.dropdownContainer');
				var localMenuOffset = $(this).find(".topItem").position();

				var newLeft = localMenuOffset.left + options.dropdownLeftOffset// - mainMenuOffset.left;
				var newTop = (localMenuOffset.top + $(this).height()) + options.dropdownTopOffset // - mainMenuOffset.top;
				
				$(localDropdown).css('left', newLeft+'px');	
				$(localDropdown).css('top', newTop+'px');	
				
			})
			
	 	});
	};
})(jQuery);

