$(document).ready(function() {

	// ie 6 hack
	if($.browser.msie && $.browser.version < 7) {
		ReplacePng2Gif('#logo img[@src$=.png]');
		ReplacePng2Gif('#user img[@src$=.png]');
	}
	
	// menu
	$('.produits_ul').superfish({ 
		delay:       500,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       'normal',                          // faster animation speed 
		autoArrows:  false,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows 
	});
	
	// marques
	$('.marques_ul').superfish({ 
		delay:       500,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       'normal',                          // faster animation speed 
		autoArrows:  false,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows 
	});
	
	// clear search field on click
	
	$(".search-submit").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	// animation form success
	try{
		window.setTimeout(function(){
			$('.formSuccess, .formError').animate({'opacity' : 0.75}, 1000);
		}, 1000);
	}catch(e){}
	
	// corners
	try{ $('a.button').corner("6px"); }catch(e){}
	
	// bordure droite des listings produits
	$('#produit_listing div.list-bloc-produit').each(function(i) {
		if (i%3 != 2) {
			$(this).css('border-right', '1px solid #4fa048');
		}
	});
	$('div.liste_produits div.liste_produit_item').each(function(i) {
		if (i%3 != 2) {
			$(this).css('border-right', '1px solid #4fa048');
		}
	});
	
	// pagination 
	if($('div > span.panier_page_num').parent().length > 1) {
		$('div > span.panier_page_num').parent().eq(1).css('text-align', 'right');
	}
	
	// etape 3 du paiement
	$('#cadeau_box input[type=checkbox]').css('cursor', 'pointer').click(function(){
		if(this.checked) {
			$('#cadeau_box .cadeau_box_field').css('display', 'block');
		}
		else {
			$('#cadeau_box .cadeau_box_field').css('display', 'none');
		}
	});
	$('#cadeau_box strong.t13').css('cursor', 'pointer').click(function(){
		var $input = $('#cadeau_box input[type=checkbox]');
		if($input.get(0).checked) {
			$input.get(0).checked = false;
			$('#cadeau_box .cadeau_box_field').css('display', 'none');
		}
		else {
			$input.get(0).checked = true;
			$('#cadeau_box .cadeau_box_field').css('display', 'block');
		}
	});
});

function ReplacePng2Gif(selector) {
	try{
		var img = $(selector);
		if(img.length == 1) {
			img.get(0).src = img.get(0).src.replace(/\.png$/i, '.gif');
		}
	}catch(e){}
}

function confirmLink(linkObj, question) {
	var is_confirmed = confirm(question);
	if(is_confirmed == true) {
		linkObj.href += '&is_js_confirmed=1';
	}
	else {
		linkObj.href += '&is_js_confirmed=0';
	}
}



