
/*
Page Load Event Handeler
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
function pageLoadHandeler() {
	Hover("header", "div");
	Hover("wrapper", "button");
	Hover("subMenu", "li");
	Hover("*", "dl");
	
	addShippingMenuImageToolTip();
}



/*
Adds the pageload handeler
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
if ( window.addEventListener )
	window.addEventListener("load", pageLoadHandeler, false);
else if ( window.attachEvent )
	window.attachEvent("onload", pageLoadHandeler);




/*
Resolves IE CSS background flickering
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
try {
 document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}





/*
If the textfield is empty, resets the contents to its default value (also removes leading/trailing spaces)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
function checkIfEmptyTextField(inputField) {
	var inputValue = inputField.value;
	
	// Removes leading spaces
	while (inputValue.charAt(0) == " ")
		inputValue = inputValue.substring(1);
		
	// Removes trailing spaces
	while (inputValue.charAt(inputValue.length - 1) == " ")
		inputValue = inputValue.substring(0, inputValue.length - 1);
	
	if ( inputValue.length > 0 )
		inputField.value = inputValue;
	else
		inputField.value = inputField.defaultValue;
}




function addShippingMenuImageToolTip() {
	if ( document.getElementById("freeShippingMenuImage") && document.getElementById("freeShippingMenuImageLightbox") ) {
		var linkElement     = document.getElementById("freeShippingMenuImage");
		var lightboxElement = document.getElementById("freeShippingMenuImageLightbox");
		
		new ToolTip(linkElement, lightboxElement.innerHTML, { marginX: 0, marginY: 12, snapToMouse: true, cssClass: "tooltip-right" });
	}
}
