var menu = null;
function checkHover() {
	if (menu) {
		menu.find('div').hide();	
	}
}
jQuery(document).ready(function() {
	// Global - Navigation
	jQuery('.sub-nav-list a', jQuery('.header-nav')).mouseover(function() {
		if (jQuery(this).children('img:first').length) {
			jQuery('.nav-image img').attr('src', jQuery(this).children('img:first').attr('src')).fadeIn();
		}
		else {
			jQuery('.nav-image img').hide();
		}
	});
	// IE7 - Navigation
	if ($.browser.msie && $.browser.version.substr(0,1) == 7) {
		$('.header-nav > li').hover(function() {
			if (menu) {
				menu.find('div').hide();
				menu = null;
			}
			$(this).find('div').show();
		}, function() {
			menu = $(this);
			setTimeout("checkHover()", 10);
		});
	}
	// Global - Newsletter - placeholder
	var fieldNlEmail = jQuery('#newsletter-field-email');
	fieldNlEmail.each(function() {
		var elInitVal = 'Entrez votre e-mail';
		jQuery(this).focus(function() {
			if (jQuery(this).val() == elInitVal) {
				jQuery(this).val('');
			}
		}).blur(function() {
			if (jQuery(this).val() == '') {
				jQuery(this).val(elInitVal);
			}
		});
	});
	// Global - Newsletter - check form
	jQuery('#newsletter-form').submit(function() {
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if (!emailPattern.test(fieldNlEmail.val())) {
			alert('Votre adresse e-mail est incorrecte.');
			return false;
		}
	});
	// Global - Breadcrumbs (compatibility)
	jQuery('#page-breadcrumbs ul li:last').addClass('last');
	
	jQuery('.input_error').keypress(function(){
		jQuery(this).removeClass('input_error');
	});

    jQuery('.linkoption').hover(function(){
       jQuery('#attribute_'+jQuery(this).attr('id')).show();
	}, function(){
		jQuery('#attribute_'+jQuery(this).attr('id')).hide();
	});

	jQuery('.sizeGuide').click(function() {
		var html = '<iframe id="sizeGuideFrame" src="' + this.href + '?content_only=1" class="iframe-sizeguide"></iframe>';
		$('#page-content').append(html);
		$('#bodywhite').append(html);
		return false;
	});
	
	var h = jQuery('.left-side').height();
	if(h>460){
		jQuery('#page-footer').css('top', h+170+'px');
	}
	if(jQuery('#completlook').length==1){
		jQuery('#page-footer').css('top', h+320+'px');
	}
});

function closeSizeGuide() {
	jQuery('#sizeGuideFrame').remove();
}
