/*=============================================================================

			 	 TITLE:		NetMediaOne - Core Library
		  MODIFIED:		2007.09.12
		 AUTHOR(S): 	Graham Wheeler - NetMediaOne - www.netmediaone.com
		  REQUIRES:		jQuery 1.2

=============================================================================*/

jQuery.fn.hoverClass = function(c) {
	return this.each(function(){
		jQuery(this).hover(
			function() { jQuery(this).addClass(c); },
			function() { jQuery(this).removeClass(c); }
		);
	});
};


var NMO = {
	
	version: "1.2.0",
	rootPath: "",
	documentMouseX: 0,
	documentMouseY: 0,
	windowMouseX: 0,
	windowMouseY: 0,
 
	newInstance: function(obj) {
		function F() {};
		F.prototype = obj;
		return new F();
	},
	
	stripeTable: function(selector) {
		jQuery(selector + " tr:visible:even").addClass("AltRow");
		jQuery(selector + " tr:visible:odd").removeClass("AltRow");
	},
	
	//
	// getPageScroll()
	// Returns array with x,y page scroll values.
	// Core code from - quirksmode.org
	//
	getPageScroll: function() {
	
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		arrayPageScroll = new Array('',yScroll) 
		return arrayPageScroll;
	},
	
	init: function() {

		jQuery("body *:first-child:not(:only-child)").addClass("FirstChild");
		jQuery("body *:last-child:not(:only-child)").addClass("LastChild");

		NMO.stripeTable(".Chart tbody");
		
		jQuery("body").addClass("HasJS");

		jQuery(".DropDownMenu").after('<div class="DropDownMenuShadow"></div>');

		jQuery(".HasMenu").hover(
			function() {
				var m = jQuery(".DropDownMenu", this);
				var mS = jQuery(".DropDownMenuShadow", this);
				var h = m.height();
				mS.height(h).show().fadeTo("fast", .75);
				m.fadeIn("fast");
			},
			function() {
				jQuery(".DropDownMenu, .DropDownMenuShadow", this).hide();
			}
		);

		jQuery(".HasMenu > a > img").hover(
			function() {	this.src = this.src.replace(/_(off|on)\./, "_hover.");	},
			function() {	this.src = this.src.replace( "_hover.", (jQuery(this.parentNode).hasClass("Active"))?"_on.":"_off.");	}
		);

		jQuery(".NavButton:not(.HasMenu) a:not(.Active) img").hover(
			function() { this.src = this.src.replace("_off.", "_on."); },
			function() { this.src = this.src.replace("_on.", "_off."); }
		);
		
		jQuery(document).mousemove( function(e) {
			NMO.documentMouseX = e.pageX;
			NMO.documentMouseY = e.pageY;
			NMO.windowMouseX = e.clientX;
			NMO.windowMouseY = e.clientY;
		} );
		
		if (document.all) {
			jQuery("#navButtons li").hoverClass("MenuHovered");
		}
		
		// Disable right click
		$(document).bind( "contextmenu", function(e) {
			return false;
		});
		
		$(".TabBar a").click( function(el) {
		
			var tabBar = this.parentNode;
			var tabContents = $(tabBar).next(".TabbedContentBox").children("div");
			var index = jQuery.inArray( this, jQuery.makeArray( $(tabBar).children("a") ) );

			$(tabBar).children("a").removeClass("Active");
			$(tabContents).addClass("Hidden");
			
			$(this).addClass("Active").removeClass("Hidden");
			$( tabContents[index] ).removeClass("Hidden");
		
		} );
		
	}
	
};


// Simple StringBuffer Class
function StringBuffer(str) {
	this.buffer = [];
	this.buffer.push(str);
	return this;
};
StringBuffer.prototype = {

	append: function(str) {
		this.buffer.push(str);
		return this;
	},
	
	clear: function() {
		this.buffer.clear();
		return this;
	},
	
	toString: function() {
		return this.buffer.join("");
	}

};

jQuery( function() { NMO.init(); } );
