jQuery(function() {

	jQuery("span.separator:last-child").remove();
	jQuery(".dropmenudiv").wrap('<div class="submenu" />');

	var first = window.location.pathname;
	
	if ('http://'+window.location.host+'/' == window.location.href) {
		jQuery('div#menu ul li:first-child').addClass('nav');
	}

	/*
	 * This adds the class 'sub' to the <li> elements that
	 * have an <ul> within
	 */
	jQuery('div#menu ul li').has('ul').addClass('sub');
	jQuery("div#menu ul li a span:contains('Shop')").parent().attr("target", "_blank");

	/*
	 * This adds the class 'active' to the <a> elements
	 * whom 'href' attribute matches to the url path
	 */
	jQuery('div#menu ul li a').each(function(){
		if (first.match(jQuery(this).attr('href'))) {
			jQuery(this).addClass('active');
		}
	});

	/*
	 * This adds the class 'nav' to the <li> element that has
	 * the <a> with class 'active' within it
	 */
	jQuery('div#menu ul li').has('a.active').addClass('nav');

	if (jQuery("#wrapper").height() < 700) {
		jQuery("#wrapper").css("background-position", "50% 100%");
	}

	/*
	 * This sets the submenu position to the left of the wrapper
	 */
	/* Unfortunately it has errors on Chrome and Safari
	var wrapos = jQuery("#wrapper").offset().left;
	jQuery("#menu ul li.nav ul").css('left', wrapos+11); */

	jQuery("#menu ul li.nav ul").wrap("<div id='abs' />");
	
	/*
	 Page flip thingie
	*/
	jQuery("#pageflip").hover(function() { //On hover...
		jQuery("#pageflip img , .msg_block").stop()
			.animate({ //Animate and expand the image and the msg_block (Width + height)
				width: '307px',
				height: '319px'
			}, 500);
		} , function() {
		jQuery("#pageflip img").stop() //On hover out, go back to original size 50x52
			.animate({
				width: '50px',
				height: '52px'
			}, 220);
		jQuery(".msg_block").stop() //On hover out, go back to original size 50x50
			.animate({
				width: '50px',
				height: '50px'
			}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
	});

});

