
/** rollover function **/
jQuery.fn.rollOver = function(settings){
	settings = jQuery.extend({
			mouseOn:  "_on",
			mouseOff:  "_off"
	}, settings);
	/** preload rollover images **/
		$(function() {
		// preload first on window.load
		$(window).bind('load', function() {
		   var preload = new Array();
		   $(".rollover").each(function() {
			   //preimg = $(this).attr("src").replace(/\.(_off.+)$/i, settings.mouseOn+".$1");
			   preimg = $(this).attr("src").replace(settings.mouseOff, settings.mouseOn);
			   //alert(preimg);
			   preload.push(preimg)
		   });
		   var img = document.createElement('img');
		   $(img).bind('load', function() {
			   if(preload[0]) {
				   this.src = preload.shift();
			   }
		   }).trigger('load');
		});

		$('a img.rollover,input[type="image"].rollover').hover(function() {
				$(this).attr("src", $(this).attr("src").split(settings.mouseOff+".").join(settings.mouseOn+"."));
			}, function() {
				$(this).attr("src", $(this).attr("src").split(settings.mouseOn+".").join(settings.mouseOff+"."));
			});
		});
};

/** tabber function **/
jQuery.fn.tabber = function(settings){
	settings = jQuery.extend({
			activeClass:  "current"
	}, settings);
	
	$(function() {
		//When page loads...
		$(".tabcontent").hide(); //Hide all content
		$("ul.tabs li:first").addClass(settings.activeClass).show(); //Activate first tab
		$(".tabcontent:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.tabs li").click(function() {

			$("ul.tabs li").removeClass(settings.activeClass); //Remove any "active" class
			$(this).addClass(settings.activeClass); //Add "active" class to selected tab
			$(".tabcontent").hide(); //Hide all tab content

			var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
			//$(activeTab).fadeIn(); //Fade in the active ID content
			//$(activeTab).slideDown("fast"); //Fade in the active ID content
			$(activeTab).show(); //Fade in the active ID content
			return false;
		});
		
	});
};

/** double submit function : prevents forms from being submitted while form is processing **/
jQuery.fn.doubleSubmit = function(){
	$("form").each(function(){
		var $that = $(this);
		$that.submit(function(){
			//alert("foobar");
			$that.find("input[type='image'],input[type='submit'][nodisable!='true'],button[type='submit']").attr("disabled", "true");
		});
	});
};

$(document).ready(function() {
	/** rollover , including preload**/	
	$('a img.rollover,input[type="image"].rollover').rollOver({
		mouseOn: "_on",
		mouseOff:  "_off"
	})

	/** tabber **/
	$(this).tabber({
		activeClass:  "current"
	})

	/** doubleSubmit **/
	$(this).doubleSubmit({
	})
});

/** tootltip.jquery.js **/
//REQUIRES: "tooltip.jquery.min.js + dimensions.jquery.min.js"
$(function () {
	$('a.tooltip').tooltip({
		track: true,
		delay: 0,
		showBody: " :|: ",
		showURL: false,
		fade: 250
	});
});

$(function () {
	$('span.tooltip').tooltip({
		track: true,
		delay: 0,
		showBody: " :|: ",
		showURL: false,
		fade: 250
	});
});

$(function () {
	$("a.tipItem").tooltip({
		bodyHandler: function () {
			return $($(this).attr("href")).html();
		},
		track: true,
		showURL: false,
		delay: 0,
		fade: 250
	});
});

