//*** Place any JavaScript to be loaded in the <head> area here. ***
$(document).ready(function() {

	//Append the InputFocus() and InputBlur() functions to any elements with the class "clearfocus"
	$(".clearfocus").focus(function() { InputFocus(this); });
	$(".clearfocus").blur(function() { InputBlur(this); });
	
	//preload CSS images
	$.preloadCssImages();
	
});


//*** Functions ***

function InputFocus(element) {
	if (element.value == element.defaultValue) {
		element.value = "";
	}
}

function InputBlur(element) {
	if (element.value == "") {
		element.value = element.defaultValue;
	}
}

//Function to make an element, e.g. content area, fill the visible space so a footer appears at the bottom. Wrapper can be a container or body element.
function MakeElementFillVisibleSpace(element_to_adjust, wrapper_element) {
	if (wrapper_element == undefined) { wrapper_element = 'body'; }
	$(element_to_adjust).height('auto');
	if ( $(wrapper_element).height() < $(window).height() ) {
		height_difference = $(window).height() - $(wrapper_element).height();
		new_height = $(element_to_adjust).height() + height_difference;
		$(element_to_adjust).height(new_height);
	}
}

//Make single element the same height as another single element - good for having two columns the same height
function MatchHeight(elementToAdjust, elementToCompare, adjust_offset, compare_offset) {
	if (isNaN(adjust_offset)) {
		adjust_offset=$(elementToAdjust).outerHeight(true) - $(elementToAdjust).height();
	};
	if (isNaN(compare_offset)) {
		compare_offset=$(elementToCompare).outerHeight(true) - $(elementToCompare).height();
	};
	if ( $(elementToAdjust).height()+adjust_offset < $(elementToCompare).height()+compare_offset ) {
		$(elementToAdjust).height( $(elementToCompare).height()+compare_offset-adjust_offset );	//adjust the height of the adjust element to the compare element
	}
}

//get a querystring by name
function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}
