jQuery(document).ready(function()
{
	// make a '.clickable' element activate the first link it contains (when clicking anywhere on it)
	// $(".clickable").biggerlink(); // requires: jquery.biggerlink.pack.js

    // usage: add the class 'rollover' to image elements
	jQuery("input[type=image].rollover, a.rollover img, img.rollover").hover(function(){
		    $(this).attr("src",jQuery(this).attr("src").replace(/(\.[^.]+)$/, 'Hi$1'));
	    },function(){
		    $(this).attr("src",jQuery(this).attr("src").replace(/Hi(\.[^.]+)$/, '$1'));
	});
	
	// usage: add the class 'submit-on-enter' to any element
	$(".submit-on-enter input[type=text], .submit-on-enter textarea").keydown(function(ev){
        //$(".submit-on-enter").append(ev.keyCode);
        if(ev.keyCode == 13)
        {
            ev.preventDefault();
            ev.stopPropagation();
             //$(".submit-on-enter").append("==submitting");    
             $(this).parents(".submit-on-enter").children("input[type=image], input[type=button]").click();
             return false;
        }
    });
    
    	/*$(".showcase li a").each(
		function(index) {
			var index = index + 1;
			$(this).addClass(""+index);
			
			if(index == 1) {
				$("<img src=\"" + $(this).attr("href") +"\" class=\"highlight " + index +"\">").appendTo(".showcase .main-focus");
			} else {
				$("<img src=\"" + $(this).attr("href") +"\" class=\"" + index +"\">").appendTo(".showcase .main-focus");
			};
		});
	*/
	
	// Simple Gallery - Toggle between images
	$(".showcase li a").click(
		function() {
			$(".main-focus img").attr("src", $(this).attr("href"));
			$(".thumbnails li a.selected").removeClass("selected"); // Remove selected class
			$(this).toggleClass("selected"); // Add selected class
			return false;
		});
	
	// IE6 Fix: CSS Navigation Menu - To stop drop down nav from going under select tags
	// Check Browser type and version is IE6
	if ($.browser.msie & jQuery.browser.version == "6.0") {
	// On hover in the navigation, hide all select tags within #main
		$("#navigation li").hover(function() {
			$("#main select").css({visibility:"hidden"});
	// On hover off in the navigation, show all select tags within #main	
		},function() {
			$("#main select").css({visibility:"visible"});
		});
	}
	
	// Article Image/Caption resizer
	// Sets caption text to size of image minus padding
	if ($(".article .general-image p").length > 0) {
		var imgWidth = $(".article .general-image img").width() - 30;
		$(".article .general-image p").width(imgWidth);
	}

});

