$(document).ready(function(){
	$("a#popup_recrut_link").click(function (){$('.popup_recrut').show();});
	
	// FOOTER NEWSLETTER
	$('#footer_newsletter').submit(function(){
		$('#result').remove();
		$('<div>').attr('id','result').appendTo('#footer .newsletter').html($('<img>').attr('src','/themes/prestashop_new/img/ajax-loader.gif'));
		$('#result').load('/newsletter.php .news_msg>strong',{'email':$(this).find('#email_newsletter').val(), 'action':"0",'submitNewsletter':""});
		return false;
	});
	
	// POPUP RECRUTEMENT
	if( ($('.popup_recrut').size() > 0) && ( readCookie('popup_recrut') != 'displayed' ) ){
		
		$('.popup_recrut').show();
		createCookie('popup_recrut','displayed',99);
		
		$('<div>').addClass('layer_popup').fadeTo(50,0.6).appendTo('#container');
	}
		$('#recrut_email').focus(function(){
			if( $(this).val() == "Exemple : nom@hotmail.com" ) {
				$(this).val("")
			}
		});
		$('#recrut_email').blur(function(){
			if( $(this).val() == "" ) {
				$(this).val("Exemple : nom@hotmail.com")
			}
		});
		
		$('.close_popup').mouseenter(function(){
			$(this).addClass('close_hover');
		});
		$('.close_popup').mouseleave(function(){
			$(this).removeClass('close_hover');
		});
		$('#recrut_valid,.close_popup').mouseenter(function(){
			$(this).addClass('ok_hover');
		});
		$('#recrut_valid,.close_popup').mouseleave(function(){
			$(this).removeClass('ok_hover');
		});
		
		$('#popup_recrut').submit(function(){
			/*
			$('.recrut_result').empty().html($('<img>').attr('src','/themes/prestashop_new/img/ajax-loader2.gif'));
			$('.recrut_result').load('/newsletter.php .news_msg>strong',{'email':$(this).find('#recrut_email').val(), 'action':"0",'submitNewsletter':""},function(){
				$('.recrut_result').removeClass('recrut_error');
				if( $('.recrut_result').text().indexOf('invalide') != -1){
					$('.recrut_result').addClass('recrut_error');
				} 
				if( $('.recrut_result').text().indexOf('sol') != -1 ){
					$('.recrut_result').addClass('recrut_error');
				}
				if( $('.recrut_result').text().indexOf('licitation') != -1 ){
					setTimeout(function(){
						$('.popup_recrut .close_popup').trigger('click');
					},2000);
				}
			});*/
			$.post(baseDir+"ajaxnewsletter.php",
				$('#popup_recrut').serialize(),
				function(data){
					$('#recrut_result').html(data);	
			});
			return false;
		});
		
		$('.popup_recrut .close_popup').click(function(){
			$('.layer_popup, .popup_recrut').hide();
		});


	//RANDOM HP
	/*if ( $('#eshop,#index').size() > 0 ){
		 //indice = (Math.round(Math.random()))+5;
		 indice = 5;
		 $('.lien_hp').css('display','none');
		 $('.lien_hp.hp_'+indice).css('display','block');
		 $('body').css('background','url(/themes/prestashop_new/img/background/bg_hp_'+indice+'.jpg) no-repeat top center');
	}*/
	
	navigation();
	if ( $('#product').size() > 0 ){
		ZoomFiche();
		slideThumb();		
	}
	
	if ( $('.mozaic_look').size() > 0 ){
		look();		
	}
	
	if ( $(window).width() < 1200 ) {
		$('.mini_account').css({
		//	right: 'auto',
		//	left: ($(window).width()-185)
		});
		$('ul.liste_produit').css({
			width: 960,
			margin: '0 '+(($(window).width()-960)/2)
		});
		$('#logo, #categories_block_left, .encarts_hp, .breadcrumb').css({
			margin: '0 0 0 5px'
		});
	}
	
	
	var ssMenuToAgregate = null;
if( window.location.href.toString().indexOf('285-pret-a-porter') != -1 ) {
	ssMenuToAgregate = 0;
} else if( window.location.href.indexOf('235-accessoires-homme') != -1 ) {
	ssMenuToAgregate = 1;
} else if( window.location.href.indexOf('6-bons-plans-mode-homme') != -1 ) {
	ssMenuToAgregate = 2;
}

if(ssMenuToAgregate != null) {
	var _options = [];
	var _select = $('<select>').attr('id','switch_category');
	var _label = $('<label>').attr('for','switch_category').html('<strong>Cat&eacute;gorie</strong>');
	var _div = $('<div>').addClass('switch_category');
	
	$('#categories_block_left > li:eq('+ssMenuToAgregate+') ul li:not(.offre_du_moment) a').each(function(){
		_options.push($('<option>').attr('value',$(this).attr('href')).html($(this).html()))
	});

	_select.append($('<option>').html("Indiff&eacute;rent"));
	for(i=0;i<_options.length;i++) {
		_select.append(_options[i])
	}
	
	_select.bind('change',function(){
		if($(this).val() != ""){
			window.location  = $(this).val();	
		}
	});

	$('#header .block_content').prepend(_div.append(_label).append(_select));

	_div.css({
		position:'absolute',
		padding:5,
		left:$('#header .block_content form').position().left
	});
	_div.css({
		margin:'0 0 0 -'+_div.outerWidth()+'px'
	});
	
}
	
});



