
	/* *
	 *
	 *		@function			Base Javascript
	 *
	 *		@website			MyWyoming.org
	 *		@owner				TCT West, Inc.
	 *
	 *		@author				Alan Ferguson
	 *		@company			Vision West, Inc.
	 *		@date					July 15, 2010
	 *
	 *		@description	Basic javascript for generic tasks.
	 *
	 * */
 
	// Menu hover configuration
	
	var hoverConfig = {
		interval: 100,
		sensitivity: 20,
		over: addHover,
		timeout: 100,
		out: removeHover
	};
 
	// Menu hover configuration
	// without delay
	
	var hoverConfigNoDelay = {
		interval: 0,
		sensitivity: 100,
		over: addHover,
		timeout: 0,
		out: removeHover
	};

	/* *
	 * Load on DOM Ready
	 * */
	 
	$(document).ready(function() {

		// Equalize DIV heights for menus
		
		EqualizeMenuHeight();
		
		// Bind hover event to menu items.

		$("li.video-menu-item").hoverIntent(hoverConfig);
		$("li.video-menu-item-no-delay").hoverIntent(hoverConfigNoDelay);
		
		// Bind external links for XHTML compliance
		
		BindExternalLinks();
		
	});
	
	/* *
	 * Add Menu Hovering
	 * */
	
	function addHover(){
		$(this).addClass("hover");
	}
	
	/* *
	 * Remove Menu Hovering
	 * */
	
	function removeHover(){
		$(this).removeClass("hover");
	}

	/* *
	 * Equalize Menu Heights
	 *
	 *		Iterates through menu UL elements
	 *		and sets all to the same height.
	 *
	 * */
	
	function EqualizeMenuHeight()
	{
		
		var height = 0;
		
		$("div.video-menu-wrapper ul").each(function() {
			if ($(this).height() > height) height = $(this).height();
		});
		
		$("div.video-menu-wrapper ul").each(function() {
			$(this).height(height);
		});
		
	}
	
	/* *
	 * External Links
	 *
	 *		XHTML 1.0 Strict does not allow target
	 *		attribute in anchor tags.
	 *
	 *		This script will add target="_blank" to
	 *		all anchor tags that open links in
	 *		external URLs.
	 *
	 * */
	
	function BindExternalLinks()
	{
		
		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";
				
		}
		
	}
		
	/* *
	 * Add Commas to Number
	 * */
	
	function addCommas(nStr)
	{
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}
	
	/* *
	 * Disable Enter Key
	 * */

	function disableEnterKey(e)
	{
		
		var key;     
		
		if(window.event)
		{
			key = window.event.keyCode; //IE
		} else {
			key = e.which; //firefox
		}
		
		return (key != 13);
		
	}
