/*=============================================================================

			 	 TITLE:		NetMediaOne - Core Library
		  MODIFIED:		2008.03.27
		 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: "",
	resizeTimer: null,
	documentMouseX: 0,
	documentMouseY: 0,
	windowMouseX: 0,
	windowMouseY: 0,
 
	stripeTable: function(selector) {
		jQuery(selector + " tr:visible")
		.filter(":even").removeClass("Odd").addClass("Even")
		.end().filter(":odd").removeClass("Even").addClass("Odd");
	},	
	
	showStatusMessages: function() {
	
		$(".StatusMessage").show().fadeIn( "slow", function() {
			setTimeout( function() { $(".StatusMessage:not(.Sticky)").fadeOut("slow"); }, 4000 );
		} );
	
	},

	init: function() {

		jQuery("body").addClass("HasJS");

		jQuery("body *:first-child").not("a, em, strong, span, thead, tbody").addClass("FirstChild");
		jQuery("body *:last-child").not("a, em, strong, span, thead, tbody").addClass("LastChild");

		NMO.stripeTable(".Striped tbody");
		
		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();
				var w = m.width();
				mS.height(h).width(w).show().fadeTo("fast", .40);
				m.fadeIn("fast");
			},
			function() {
				jQuery(".DropDownMenu, .DropDownMenuShadow", this).hide();
			}
		);

		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");
		}

		NMO.showStatusMessages();
		
	}
	
};


// 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 = [];
		return this;
	},
	
	toString: function() {
		return this.buffer.join("");
	}

};

jQuery( function() { NMO.init(); } );
