//<![CDATA[
var tick=1000;
var deltaTime="";
var timer = null; 
jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.07
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 1;
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar and Fabien Volpi
				});
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.width(stripWidth);			
				var totalTravel = stripWidth+containerWidth;
				var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye		
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
function setCookie (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function deleteCookie (name,path,domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
function setCookieDays(name,value,days)
{
	var date_exp = new Date();
	date_exp.setTime(date_exp.getTime()+(days*24*3600*1000));
	setCookie(name,value,date_exp);
}
function EmailValide(email)
{
  var re = /([a-z0-9]+([-_]?[a-z0-9]+)*.)*[a-z0-9]+([-_]?[a-z0-9]+)*@([a-z0-9]+([-_]?[a-z0-9]+)*.)+[a-z]{2,4}/gi;  
  return (email.value.match(re) == email.value);  
}
function horloge() 
{ 	
	var nJour, nMois, nAnnee, nHeures , nMinutes, nSecondes;
	var dtJour;
	if (deltaTime=="")
	{
		serverTime=$("#cd_timer").text();
		var currentDate = new Date();
		var clientTime=currentDate.getTime();
		clientTime=clientTime/1000;
		clientTime=Math.floor(clientTime);			
		deltaTime=serverTime-clientTime;
	}	
	dtJour = new Date();
	dtJour.setTime(dtJour.getTime() + deltaTime*1000);
	nHeures = dtJour.getHours();
	if (nHeures < 10) nHeures = "0"+nHeures;
	$("#horloge_heure").text(nHeures);
	nMinutes = dtJour.getMinutes();
	if (nMinutes < 10) nMinutes = "0"+nMinutes;
	$("#horloge_minute").text(nMinutes);
	nSecondes = dtJour.getSeconds();
	if (nSecondes < 10) nSecondes = "0"+nSecondes;
	$("#horloge_seconde").text(nSecondes);
	timer = setTimeout(horloge, tick); 
}
$(document).ready(function() {
	timer = setTimeout(horloge, tick);
	jQuery.extend(jQuery.validator.messages, 
	{
required: ''
	});
	$("#email_form").validate
	(
	{
invalidHandler: function(form, validator) 
		{
			var errors = validator.numberOfInvalids();			
			if (errors) { 
				$("#email_abo").val("Email non valide !");				
			} 
		}	  
		, 
	rules: 
		{	
			"email_abo":{"required": true,"email":true}
		},
messages: {        
email_abo:""
		},
submitHandler: function(form)
		{
			email=$("#email_abo").val();
			window.location="abonnement_email_"+email+".html";
		}
		
	}
	);	 
	  



	
	//if (!(($("#page_name").text()=="index.php")))
	if ($(".categories").length)
	{
		$('.categories').click(function()
		{
			if( $(this).next('.categ').is(':hidden') ) 
			{ 
				$(".categ").slideUp(500);
				$(this).next('.categ').slideDown(500); 	
			}
			else
			{
				$(this).next('.categ').slideUp(500); 	
			}		
		});
		$('#sidebar_recherche_bouton').click(function()
		{
			var filtre=$('#sidebar_recherche_champ').val();
			if (filtre=='')
			{
				filtre='***';
			}
			window.location="../listing-lots_motscles_"+filtre+"_page_1.html";
		});
	}
	return false; //Prevent the browser jump to the link anchor
});
$(function(){ $("ul#ticker").liScroll({travelocity: 0.15}); });
//  IE 6
var browser = navigator.appName
var ver = navigator.appVersion
var thestart = parseFloat(ver.indexOf("MSIE"))+1
var brow_ver = parseFloat(ver.substring(thestart+4,thestart+7))
if ((browser=="Microsoft Internet Explorer") && (brow_ver < 7))
{
	//alert(this.location);
	window.location="forabetterweb.html";
}
//]]>
