// JavaScript Document

$(document).ready(function(){

	/* ************************************ */
	/*			MENU OVER                       */
	/* ************************************ */
	
	$('li').mouseover(function(){
		$(this).children('.item_left').css("background-position","0 -33px");
		$(this).children('.item').css("background-position","0 -33px");
		$(this).children('.item_right').css("background-position","0 -33px");
	});
	
	$('li').mouseout(function(){
		$(this).children('.item_left').css("background-position","0 0");
		$(this).children('.item').css("background-position","0 0");
		$(this).children('.item_right').css("background-position","0 0");
	});

	
	
	/* ************************************ */
	/*			CONNECTION COMPTE               */
	/* ************************************ */
	
	$('#connexion_compte').click(function(){
		if($("#connexion_display").css("display")=="none"){
			$('#connectez_vous').animate({height:'87'},600, function(){$('#connexion_display').fadeIn(250);});
		}else{
			$('#connexion_display').fadeOut(250, function(){$('#connectez_vous').animate({height:'0'},600)});
		}
	});

	
	
	/* ************************************ */
	/*			RADIO BUTTON                    */
	/* ************************************ */
	
	$('.choix_profondeur > span > .bg_btn_radio').click(function(){ RadioProfondeur(this) });
	$('.choix_profondeur > span > label').click(function(){ RadioProfondeur($(this).parent().children(".bg_btn_radio")) });
	$('.choix_pietement > span > .bg_btn_radio').click(function(){ RadioUnique(this) });
	$('.choix_pietement > span > label').click(function(){ RadioUnique($(this).parent().children(".bg_btn_radio")) });
	$('.choix_penderie > span > .bg_btn_radio').click(function(){RadioUnique(this) });
	$('.choix_penderie > span > label').click(function(){ RadioUnique($(this).parent().children(".bg_btn_radio")) });
	$('.choix_montage > span > .bg_btn_radio').click(function(){ RadioUnique(this) });
	$('.choix_montage > span > label').click(function(){ RadioUnique($(this).parent().children(".bg_btn_radio")) });
	$('.choix_civilite > span > .bg_btn_radio').click(function(){ RadioCivilite(this) });
	$('.choix_civilite > span > label').click(function(){ RadioCivilite($(this).parent().children(".bg_btn_radio")) });
	$('.choix_group > span > .bg_btn_radio').click(function(){ RadioGroup(this) });
	$('.choix_group > span > label').click(function(){ RadioGroup($(this).parent().children(".bg_btn_radio")) });
	
	$('.bg_btn_radio_frais_port').click(function(){
		$(".bg_btn_radio_frais_port > .btn_radio").fadeOut(500);
		$(this).children(".btn_radio").fadeIn(500);
		$(this).children("input[type='radio']").attr('checked',true);
	});
	
	/* ************************************ */
	/*			CHECKBOX BUTTON                 */
	/* ************************************ */
	
	$('.bg_btn_checkbox').click(function(){
		if($(this).children("input[type='checkbox']").attr('checked')==false){
			$(this).children(".btn_checkbox").fadeIn(500);
			$(this).children("input[type='checkbox']").attr('checked',true);
		}else{
			$(this).children(".btn_checkbox").fadeOut(500);
			$(this).children("input[type='checkbox']").attr('checked',false);
		}	
		if($('#checkbox_order_adresse') && typeof(updateAddressesDisplay) != 'undefined') updateAddressesDisplay();
	});
	
		
	
	/* ************************************ */
	/*			SELECT                          */
	/* ************************************ */
	$('#select_panneau').SelectCustomizer();
	$('#select_traitement').SelectCustomizer();
	$('#select_epaisseur').SelectCustomizer();
	$('#select_contact').SelectCustomizerPropre();
	$('#select_days').SelectCustomizerPropre();
	$('#select_months').SelectCustomizerPropre();
	$('#select_years').SelectCustomizerPropre();
	$('#select_country').SelectCustomizerPropre();
	$('#id_country').SelectCustomizerPropre();
	$('#select_pagination').SelectCustomizerPropre();
	$('#selectPrductSort').SelectCustomizerPropre();
	$('#select_address_delivery').SelectCustomizerPropre();
	$('#select_address_invoice').SelectCustomizerPropre();

});


/* ************************************ */
/*			RADIO BUTTON                    */
/* ************************************ */

function RadioProfondeur(id){
	$(".choix_profondeur > span > .bg_btn_radio > .btn_radio").fadeOut(500);
	$(id).children(".btn_radio").fadeIn(500);
	$(id).children("input[type='radio']").attr('checked',true);
}

function RadioUnique(id){
	if($(id).children("input[type='radio']").attr('checked')==false){
		$(id).children(".btn_radio").fadeIn(500);
		$(id).children("input[type='radio']").attr('checked',true);
	}else{
		$(id).children(".btn_radio").fadeOut(500);
		$(id).children("input[type='radio']").attr('checked',false);
	}
}

function RadioCivilite(id){
	$(".choix_civilite > span > .bg_btn_radio > .btn_radio").fadeOut(500);
	$(id).children(".btn_radio").fadeIn(500);
	$(id).children("input[type='radio']").attr('checked',true);
}

function RadioGroup(id){
	$(".choix_group > span > .bg_btn_radio > .btn_radio").fadeOut(500);
	$(id).children(".btn_radio").fadeIn(500);
	$(id).children("input[type='radio']").attr('checked',true);
}



/* ************************************ */
/*			LIGHTBOX                        */
/* ************************************ */
	
function showBox( page,param, height , width){
	
	tb_init('a.thickbox, area.thickbox, input.thickbox');
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;
	tb_showIframe();
	tb_show('', page+"?height="+height+"&width="+width+"&"+param, false);
}
