function CacheMontreOnglet(nom) {
	this.id.replace("top5_action_","");
}

function getTime(ts) {
	idmaj = document.getElementById(ts);

	now = new Date();
	y2k = new Date();
	y2k.setTime(countcar[ts]*1000);
	
	days = (y2k - now) / 1000 / 60 / 60 / 24;
	daysRound = Math.floor(days);
	hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
	hoursRound = Math.floor(hours);
	minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
	minutesRound = Math.floor(minutes);
	seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
	secondsRound = Math.round(seconds);

	if(now>y2k) {
		idmaj.innerHTML = "Délai dépassé !";
	}
	else {
		if(daysRound)
			idmaj.innerHTML = daysRound  + " j " + hoursRound + " h " + minutesRound + " mn " + secondsRound + " s";
		else
			idmaj.innerHTML = hoursRound + " h " + minutesRound + " mn " + secondsRound + " s";
		setTimeout('getTime(\''+ts+'\')', 1000); 
	}
}

function switchTop5(){   //function top5(){
	var visible = parseInt($('#top5_content div:visible').attr('id').replace("top5_vue_",""));
	$('#top5_action_'+visible).removeClass('num_on');
	if (visible >= 5)
		visible = 1;
	else
		visible += 1;
	$('#top5_content div:visible').fadeOut('normal', function(){
		$('div#top5_vue_'+visible).fadeIn('slow');
	});
	
	$('#top5_action_'+visible).addClass('num_on');
}



$(document).ready(function () {
	
	if($('.eventcounter').length)
	{
		$('.eventcounter').each(function(i) {
			getTime(this.id);
		});
	}
	
	/* SLIDE BAR */
	$("#slider").hide();
	
	$('#promo_suite a:not(.more-promo), #nouveaux_suite a:not(.more-nouveaux)').mouseover(function(){
		var req=anet_assistant_httpreq();
		select = $(this);
		var id = $(this).parent().attr("id");
		var prod = id.substr(6,id.length);
		
		//l.innerHTML=l.innerHTML+'<img src="'+l.value+'" alt="" class="loader" />';
		req.onreadystatechange=function(){
			if(req.readyState==4){
				if(req.status==200){
					$(select).after(req.responseText);
				}
			}
		}
		req.open("GET",'assistant-ajax.php?info='+prod,true);
		req.send(null);
	}); 
	$('#promo_suite tr, #promo_suite table, #nouveaux_suite tr, #nouveaux_suite table').mouseout(function(){$('#appear').remove();});
	
	/* Gestion de la navigation vers nouveautés page d'accueil */
	$('#anet_nouveau .miniature, #anet_nouveau .savoir_plus, #anet_nouveau table a ').click(function(){
		var req=anet_assistant_httpreq();		
		//l.innerHTML=l.innerHTML+'<img src="'+l.value+'" alt="" class="loader" />';
		req.onreadystatechange=function(){
			if(req.readyState==4){
				if(req.status==200){
					console.log(req.responseText);
				}
			}
		}
		req.open("GET",'assistant-ajax.php?liste=nouvo',false);
		req.send(null);
	}); 
	$('#anet_promo .miniature, #anet_promo .savoir_plus, #anet_promo table a ').click(function(){
		var req=anet_assistant_httpreq();		
		//l.innerHTML=l.innerHTML+'<img src="'+l.value+'" alt="" class="loader" />';
		req.onreadystatechange=function(){
			if(req.readyState==4){
				if(req.status==200){
					console.log(req.responseText);
				}
			}
		}
		req.open("GET",'assistant-ajax.php?liste=promo',false);
		req.send(null);
	}); 
	$('.box-vente a').click(function(){
		var req=anet_assistant_httpreq();		
		//l.innerHTML=l.innerHTML+'<img src="'+l.value+'" alt="" class="loader" />';
		req.onreadystatechange=function(){
			if(req.readyState==4){
				if(req.status==200){
					console.log(req.responseText);
				}
			}
		}
		req.open("GET",'assistant-ajax.php?liste',false);
		req.send(null);
	});
	$('#menu_left > ul > li > ul > li > a').click(function(){
		if ($(this).next('ul').length > 0) {
			if ($(this).next('ul:visible').length) {
				$(this).next('ul').hide();
			} else {
				$(this).next('ul').show();
			}
			return false;
		} 
	});
	$('select#id_contact').change(function() {
		if (parseInt($(this).val()) == 1) { 
			$('.hidden').show();
		} else {
			$('.hidden').hide();
		}
	});
	if (parseInt($('select#id_contact').val()) == 1) {
		$('.hidden').show();
	}
});
