/// <reference path="jquery-1.3.2.min-vsdoc.js" />
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 InitSubmitOnEnter() {
	// 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], input[type=submit]").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){
	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); }
}

// Plugin to put tips into input boxes.
// author: http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
jQuery.fn.hint = function() {
    return this.each(function() {
        // get jQuery version of 'this'
        var t = jQuery(this);
        // get it once since it won't change
        var title = t.attr('title');
        // only apply logic if the element has the attribute
        if (title) {
            // on blur, set value to title attr if text is blank
            t.blur(function() {
                if (t.val() == '') {
                    t.val(title);
                    t.addClass('blur');
                }
            });
            // on focus, set value to blank if current value 
            // matches title attr
            t.focus(function() {
                if (t.val() == title) {
                    t.val('');
                    t.removeClass('blur');
                }
            });

            // clear the pre-defined text when form is submitted
            t.parents('form:first()').submit(function() {
                if (t.val() == title) {
                    t.val('');
                    t.removeClass('blur');
                }
            });

            // now change all inputs to title
            t.blur();
        }
    });
}