$(function() {
	SetRollOvers();
	SetSubmitOnEnter();
	SetExternalLinks();
	//$(".script-only").show();
	Equalise($(".multi-pod-holder .multi-pod"));
	Equalise($(".book-it-list .hot-deal p"));
	Equalise($(".book-it-list .hot-deal h3"));
});

function SetRollOvers(){
	// 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'));
	});
}


function SetSubmitOnEnter(){
	// usage: add the class 'submit-on-enter' to any element which contains a text input and a button.
	$(".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").find("input[type=image]:first, input[type=button]:first, input[type=submit]:first").trigger('click');
             return false;
        }
    });
}

function SetExternalLinks(){
	/*
	Purpose: checks all <a>'s in the doc, if it has a rel attribute of 'external', sets to open in new window
	usage: <a href="http://www.google.com" rel="external">Google</a>
	*/
	
	$('a[rel*=external]').click(function(){ window.open(this.href); return false; });
	
}

function Equalise(elms){
	// usage:
	// Equalise($(".list li"));
	// Equalise($("#nav, #content"));
	//alert("howdy");
	var highest = 0;
	for(i=0; i < elms.length; i++){ if($(elms[i]).height() > highest) highest = $(elms[i]).height(); }
	for(i=0; i < elms.length; i++){ if($(elms[i]).height() < highest) $(elms[i]).height(highest); }
}