function initWindowLoad(){
}


/* ************************************************************** checkbox et radio custom */	

function setupLabel() {
	if ($('.label_checkbox input').length) {
		$('.label_checkbox').each(function(){
			$(this).removeClass('c_on');
		});
		$('.label_checkbox input:checked').each(function(){
			$(this).parent('label').addClass('c_on');
		});
	};
	
	if ($('.label_radio input').length) {
		$('.label_radio').each(function(){
			$(this).removeClass('r_on');
		});
		$('.label_radio input:checked').each(function(){
			$(this).parent('label').addClass('r_on');
		});
	};
	
};

$(document).ready(function(){
	$('body').addClass('nq_custom');
	$('.label_checkbox, .label_radio').click(function(){
	setupLabel();
});
setupLabel();
}); 
	
/* ************************************************************************************* */

function initDomReady()
{
    /**
    * Cufon
    */
    Cufon.replace('.eblastTypo');

    /**
    * Préchargement d'images
    */
    var preloadImages = new Array(
        imgDir + 'sprite_eblast.png',
        imgDir + 'sprite_navigation.png',
        imgDir + 'sprite_960.png',
        imgDir + 'sprite_footer.png'
    );

    $( preloadImages ).each( function( index, value ) {
        var img = new Image();
        $(img).load( function() {
            //  Couleur Header
            if( $(this).attr('src').indexOf('sprite_960') != -1 ) {
                $('#header').css( 'backgroundColor', 'transparent' );
            }
            //  Couleur Navigation
            if( $(this).attr('src').indexOf('sprite_navigation') != -1 ) {
                $('#nq_navigation').css( 'backgroundColor', 'transparent' );
            }
        }).attr('src', value );
    });

    /**
    * Product sort
    */
    //  Valeur Défaut
    $('.selectPrductSort').each( function() {
        var _list = $(this);
        var _selected = _list.find('.selectPrductSort_result').text();
        $(this).find('span.value').each( function() {
            if( $(this).text() == _selected ) {
                $(_list).find('.selectPrductSort_text .list_text').html( $(this).prev().prev().text() );
            }
        });
    });
    $('.selectPrductSort_opt').click( function() {
        var _value = $(this).find('span.value').text();
        var _result = $(this).find('span.result').text();
        $(this).parent().parent().find('.selectPrductSort_text .list_text').html( _result );
        $(this).parent().parent().find('.selectPrductSort_result').html( _value );
        productSort( _value );
    });


    /**
    * Tailles Produits
    */
    //  Hover
    $('.size').click( function() {
        //  Replace all
        $(this).parent().find('.size').each( function() {
            $(this).attr('class', $(this).attr('class').replace('on', 'off'));
        });
        //  Select
        $(this).parent().find('select').val($(this).find('span.value').text());
        //  Class
        $(this).attr('class', $(this).attr('class').replace('off', 'on'));
        //  Event
        if( $(this).parent().attr('id') == 'attributes' ) {
            findCombination();
        }
    });


    /**
    * Description longue Produits
    */
    //  Ouverture
    $('#show_more').click( function() {
        $('#product_long_desc').slideDown(300, function() {
            $(this).fadeIn(150);
        });
    });
    //  Fermeture
    $('#hide_more').click( function() {
        $('#product_long_desc').fadeIn(100, function() {
            $(this).slideUp(150);
        });
    });

    
    /**
    * Newsletter
    */
    if( $('#result_newsletter').length > 0 ) {
        var content = $('#result_newsletter').html();
        $('#result_newsletter').remove();
        alert(content);
    }
	
	
	/**
    * BLOCKLAYERED - HACK IE7
    ***************************/
    if( $('.filter_content').length > 0 ) {
        var i = 0;
        $('.filter_content').each( function() {
            var _h = parseInt( $(this).height() );
            if( _h > 350 ) {
                _h = 350;
            }
            $(this).css('height', _h);
            $(this).css('z-index', i);
            i++;
        });
    }
	
	
	
	
	
	
	
}

// Retour prod

function returnIsOk(e){
	var ok_input = 0;
	var ok_textarea = 0;
	if($(e).parent().parent().find('textarea[name=returnText]').val() != ''){
		ok_textarea = 1;
		$(e).parent().parent().find(".order_cb input").each(function(){
			if($(this).attr('checked')){
				ok_input = 1;
			}
		});
	}
	if(ok_textarea == 0){
		alert('Merci de spécifier le motif du retour');
	} 
	else if(ok_input == 0){
		alert('Merci de cocher le ou les produits à retourner');
	}else{
		e.submit();
	}
}

//partie shopping cart



function gestionCheckboxGift(){
	$("#total_price").html($("#total_price").html()+" ");
		
}

var mon_total = "";
function initEvent(){
	
}



$(window).load(function(){ initWindowLoad(); });
$(document).ready(function(){ initDomReady();initEvent(); });
