/*global $, document, location*/
$(document).ready(function () {

	//navigation
	$("#nav li").hover(
	  	function () {//over
			$(this).addClass('over');
			$(this).find('ul').addClass('shown-sub');
	  	}, 
	  	function () {//out
	    	$(this).removeClass('over');
	    	$(this).find('ul').removeClass('shown-sub');
	  	}
	);

    //Make external urls target _blank.
    $('a').filter(function() {
        //Compare the anchor tag's host name with location's host name
        return this.hostname && this.hostname !== location.hostname;
    }).addClass("external").attr("target", "_blank");
    
    
    //Validate like Magento
	$.validator.setDefaults({
		errorElement: "div",
   		errorClass: "validation-advice",
   		
		highlight: function(element, errorClass, validClass) {
			$(element).addClass('validation-failed');
		},
		unhighlight: function(element, errorClass, validClass) {
			$(element).removeClass('validation-failed');
		},
		ignoreTitle: true
	});

	$.validator.addMethod("required-entry", function(value, element) { 
		return value != ''; 
	});
	

    
});

// setLocation function
function setLocation(url){
	window.location.href = url;
};


