/*---- BarScroll.js ----*/

var move = 1;
var nomCarrousselAntiRebond = undefined;

window.onscroll = function() {
	var ObjPJPASousRubrique = $("#DivPositionMenu").offset();
	var ObjPJPABarLinkFD = $("#DivPositionMenuLien").offset();
	var position = $(document).scrollTop();

	var	diff = position - ObjPJPASousRubrique.top;
	MoveBarHeader(diff);

	if (ObjPJPABarLinkFD != undefined) {
		var	diffForBarLinkFD = position - ObjPJPABarLinkFD.top + 47;
		MoveBarLinkFD(diffForBarLinkFD);
	}
}

function MoveBarHeader(diff) {

	if (diff > 0) {
		if ($("#MenuHeader").css("position") != "fixed") {
			$("#MenuHeader").css("position", "fixed");
			$("#MenuHeader").css("top", "0px");
			$(".SsMenuBardG").css("top", "0px");
			$(".SsMenuBardD").css("top", "0px");
		}
	}
	else {
		if ($("#MenuHeader").css("position") == "fixed") {
			$("#MenuHeader").css("position", "static");
			$("#MenuHeader").css("top", "auto");
			$(".SsMenuBardG").css("top", "10px");
			$(".SsMenuBardD").css("top", "10px");
		}
	}
}


function MoveBarLinkFD(diff) {
	var url = document.location.pathname;
	
	if (url != "/DepotAnnonce/AnnonceRecapitulatif.aspx") {

		if (diff > 0) {
			if ($("#PJPABarScrollMenuLien").css("position") != "fixed") {
				$("#PJPABarScrollMenuLien").css("position", "fixed");
				$("#PJPABarScrollMenuLien").css("top", "24px");
				$("#PJPABarScrollMenuLien").css("margin-top", "11px");
				$("#PJPABarScrollMenuLien").css("border-left", "solid");
				$("#PJPABarScrollMenuLien").css("border-bottom", "solid");
				$("#PJPABarScrollMenuLien").css("border-right", "solid");
				$("#PJPABarScrollMenuLien").css("border-width", "thin");
				$("#PJPABarScrollMenuLien").css("border-color", "#CCCCCC");

				if (move == 1) {
					$("#PJPABarScrollMenuLien").animate({ width: "946px" }, 700, "linear", function() { ShowLinks(); });
				} else {
					$("#PJPABarScrollMenuLien").stop();
					$("#PJPABarScrollMenuLien").css("width", "946px");
				}
			}
		}
		else {
			if ($("#PJPABarScrollMenuLien").css("position") == "fixed") {
				$("#PJPABarScrollMenuLien").css("position", "relative");
				$("#PJPABarScrollMenuLien").css("top", "auto");
				$("#PJPABarScrollMenuLien").css("margin-top", "0px");
				$("#PJPABarScrollMenuLien").css("border", "none");

				if (move == 0) {
					//Changement d avis antoine on cache directement le bloc de lien
					//$("#PJPABarScrollMenuLien").animate({ width: "628px" }, 700, "linear", function() { HideLinks(); });

					HideLinks();
					$("#PJPABarScrollMenuLien").css("width", "628px");


				} else {
					$("#PJPABarScrollMenuLien").stop();
					$("#PJPABarScrollMenuLien").css("width", "628px");
				}
			}
		}
	}
}

function ShowLinks() {
	$("#ExtraButton").show();
	move = 0;
}

function HideLinks() {
	$("#ExtraButton").hide();
	move = 1;
}

function MoveCarrousselAntiRebond(position) {
	if (nomCarrousselAntiRebond != undefined) {
		var objCarroussel = eval(nomCarrousselAntiRebond);
		if (objCarroussel != undefined) {

			var HauteurDecl = 185;
			if (document.getElementById("LocalPublicityTop") != undefined && document.getElementById("ctl00_HeaderPartenaire_UC_BlocHeaderHtmlCont")) {
				var HauteurPub1 = $("#LocalPublicityTop").css("display") == "none" ? 0 : 80;
				var HauteurPub2 = parseInt($("#ctl00_HeaderPartenaire_UC_BlocHeaderHtmlCont").css("height").replace(/px/gi, ""));
				var HauteurDecl = HauteurPub1 + HauteurPub2 + 185;
			}

			var screeny = screen.availHeight - 200;
			var divToHide = $(objCarroussel.CadreThumbails).height() + 28 * 2 + 20 + 50;
			var topcalcule = divToHide - screeny; //-125
			if (objCarroussel.BlocToHide != undefined) {
				if (position >= HauteurDecl + topcalcule) {
					if ($(objCarroussel.BlocToHide).css("position") != "fixed") {

						if (topcalcule > 0) {
							$(objCarroussel.BlocToHide).css("position", "fixed");
							$(objCarroussel.BlocToHide).css("top", "-" + topcalcule + "px");
							$(objCarroussel.BlocToHide).css("left", "10px");
						}
					}
				}
				else {
					$(objCarroussel.BlocToHide).css("position", "absolute");
					$(objCarroussel.BlocToHide).css("top", "auto");
					$(objCarroussel.BlocToHide).css("left", "-140px");
				}
			}
		}
	}
}


/*---- Calendar.js ----*/

function Calendar() {}

Calendar.prototype.Display = function(idDateTextBox) {
	$('#' + idDateTextBox).focus();
}

Calendar.prototype.OnInputBlur = function(obj, defaultValue) {
    var value = obj.value;
    
    if (value == '') {
        obj.value = defaultValue;
    }
}

Calendar.prototype.SetPositionAlerte = function(leftMin, leftMax, leftMiddle, top, width, isFlechG) {
	this.LeftMin = leftMin;
	this.LeftMax = leftMax;
	this.LeftMiddle = leftMiddle;
	this.Top = top;
	if (width != undefined) {
		this.Width = width;
	}
	else {
		this.Width = 200;
	}
	
	if (width != undefined) {
		$("#" + this.DivAlerteTexte).css("width", width);
	}

	if (isFlechG == 1) {
		var $alerte = this.DivAlerte.find(".alerte_hg");
		if ($alerte != undefined) {
			$alerte.attr("class", "alerte_bd");
		}
	}
}

var _calendar = new Calendar();

/*---- CoteAuto.js ----*/

function ToutCacherOptionCoteAuto()
{
    SetClassName(getObj("DivAC"), "cacheOptions");
    SetClassName(getObj("DivDJ"), "cacheOptions");
    SetClassName(getObj("DivKP"), "cacheOptions");
    SetClassName(getObj("DivQS"), "cacheOptions");
    SetClassName(getObj("DivTZ"), "cacheOptions");

    SetClassName(getObj("AC"), "LettreFiltre");
    SetClassName(getObj("DJ"), "LettreFiltre");
    SetClassName(getObj("KP"), "LettreFiltre");
    SetClassName(getObj("QS"), "LettreFiltre");
    SetClassName(getObj("TZ"), "LettreFiltre");
}


function AfficheListeOption(objDiv, objOnglet) 
{
    ToutCacherOptionCoteAuto();
    SetClassName(getObj(objDiv), "afficheOptions");
    SetClassName(getObj(objOnglet), "LettreFiltre_Selected");
}


/*---- CryptLink.js ----*/

// Used in whole web site in CryptLink.cs (WebControl)
function CryptLink() {
	this.Host = '';
}

CryptLink.prototype.SetHref = function(obj) {
	if (obj != null) {
		var href = obj.href;

		if (href.charAt(href.length - 1) == '#') {
			args = this.SetHref.arguments;
			var urlTmp = this.GetUrl(args);
			obj.href = urlTmp;
		}
	}
}

CryptLink.prototype.Redirect = function(obj) {
	if (obj != null) {
		var args = this.Redirect.arguments;
		if (args.length > 1) {
			var link = args[0];
			var url = this.GetUrl(args);

			var target = $(link).attr('target');

			if (target == "" || target == null || target == undefined) {
				target = $(link).attr('Target');
			}

			if (target != undefined) {
				if (target.toLowerCase() == '_blank') {
					window.open(url);
				}
				else if (target.toLowerCase() == '_parent') {
					window.parent.location = url;
				}
				else {
					window.location = url;
				}
			}
			else {
				window.location = url;
			}
		}
	}
}

CryptLink.prototype.GetUrl = function(args) {
	var output = '';

	if (args.length > 1) {
		output += args[1].substr(1, args[1].length - 1);

		for (i = 2; i < args.length; i++) {
			output += args[i];
		}

		output = output.replace(/[\*]/gi, "/");
		output = output.replace(/\[123\]/, ".html");

		if (this.Host != '' && output.charAt(0) == '/') {
			output = 'http://' + this.Host + output;
		}
	}
	
	return output;
}

CryptLink.prototype.DecryptLink = function() {
	if (IsIE6()) {
		window.setTimeout('_cryptLink.DecryptLinkIE6()', 5);
	}
}

CryptLink.prototype.DecryptLinkIE6 = function() {	
	
	$('span[crypted="1"]').each(	
		function () {	
			var elt = $(this);
			var html = '<a href="#" ';
			html += GetStrAttrHtml(elt, 'id');
			html += GetStrAttrHtml(elt, 'class');
			html += GetStrAttrHtml(elt, 'style');
			html += GetStrAttrHtml(elt, 'target');
			html += GetStrAttrHtml(elt, 'title');
			html += GetStrAttrHtml(elt, 'crypted');
			html += GetEventAttrHtml(elt, 'onclick');
			html += GetEventAttrHtml(elt, 'onmouseover');
			html += GetEventAttrHtml(elt, 'onmouseout');
			html += GetEventAttrHtml(elt, 'onmouseup');
			html += GetEventAttrHtml(elt, 'onmousedown');
			html += '>'
			html += elt.html();
			html += '</a>';

			elt.replaceWith(html);
		}
	);
}

function GetStrAttrHtml(elt, name) {
	return GetCoreAttrHtml(elt, name, false);
}

function GetEventAttrHtml(elt, name) {
	return GetCoreAttrHtml(elt, name, true);
}

function GetCoreAttrHtml(elt, name, isEvent) {
	var attribute = elt.attr(name);

	if (attribute != undefined && attribute != '') {		
		var value = GetCleanAttribute(elt, attribute, name, isEvent);
		return name + '="' + value + '" ';
	}
	
	return '';
}

function GetCleanAttribute(elt, attribute, name, isEvent) {
	var value =	attribute.toString();

	if (isEvent) {
		var isOnclick = name == 'onclick';
	
		if (IsIE6() && isOnclick) {
			value = value.replace('function anonymous() { ', '');
		}
		else {
			value = value.replace('function ' + name + '(event) {     ', '');
		}

		value = value.replace('};', '');

		if (isOnclick) {
			value = value.replace('.Redirect', '.SetHref');
		}
		
		var reg = new RegExp('"', 'g');
		value = value.replace(reg, "'");
	}
	
	return value;
}

function IsIE6(){
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if (version >= 5.5 && version < 7)
	{
		return true;
	}
	
	return false;
}

var _cryptLink = new CryptLink();

/*---- DateUtility.js ----*/

// Return a date or undefined if input string is not a valid date
function GetDate(date) {	
	var pos1 = date.indexOf(dateSeparator);
	var pos2 = date.indexOf(dateSeparator, pos1 + 1);
	
	if (pos1 == -1 || pos2 == -1) {
		return undefined;
	}
	
	var strDay = date.substring(0, pos1);
	var strMonth = date.substring(pos1 + 1, pos2);
	var strYear = date.substring(pos2 + 1);
	
	if (!IsInteger(strDay) || !IsInteger(strMonth) || !IsInteger(strYear)) {
		return undefined;
	}

	var day = parseInt(strDay, 10);
	var month = parseInt(strMonth, 10);
	var year = parseInt(strYear, 10);

	if (!IsValidYear(year) || !IsValidMonth(month) || !IsValidDay(day, month, year)) {
		return undefined;
	}
	
	return new Date(year, month - 1, day); // in JS months begin to 0. ie : March = 2
}

var min = "|min";
var middle = "|middle";
var max = "|max";

// Return position to set alert
function GetMessageDateValidator(type, isValidMin, isValidMax, dateValidator) {
	var messageArray = GetMessageArray();
	var top = dateValidator.TopMax;
	var left = dateValidator.LeftMax;
	var message = messageArray[type + max];

	if (!isValidMin && !isValidMax) {
		top = dateValidator.TopMiddle;
		left = dateValidator.LeftMiddle;
		message = messageArray[type + middle];
	} else if (isValidMax) {
		top = dateValidator.TopMin;
		left = dateValidator.LeftMin;
		message = messageArray[type + min];
	}
	
	return new MessageDateValidator(message, top, left);
}

function GetMessageArray() {
	this["empty" + min] = "Veuillez saisir la date de début de séjour souhaitée";
	this["empty" + middle] = "Veuillez saisir les dates de séjour souhaitées";
	this["empty" + max] = "Veuillez saisir la date de fin de séjour souhaitée";
	this["unvalid" + min] = "Veuillez saisir une date dans un format valide. Ex: 30/07/2011";
	this["unvalid" + middle] = "Veuillez saisir des dates dans un format valide. Ex: 30/07/2011";
	this["unvalid" + max] = "Veuillez saisir une date dans un format valide. Ex: 30/07/2011";
	this["futur" + min] = "Veuillez saisir une date future";
	this["futur" + middle] = "Veuillez saisir des dates futures";
	this["futur" + max] = "Veuillez saisir une date future";
	
	return this;
}

// "jj/mm/aaaa" => ""
function FormatDate(s, emptyDate) {
	var reg = new RegExp(emptyDate);
	return s.replace(reg, "");
}

// Check if input string is empty
function IsEmpty(s, emptyDate) {
	s = FormatDate(s, emptyDate);

	if (jQuery.trim(s) != "") {
		return false;
	}
	return true;
}

// Check if input string is an integer
function IsInteger(s) {
	var i;

    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        
        if (((c < "0") || (c > "9"))) {
			return false;
        }
    }

    return true;
}

// Check if input string is a valid year
function IsValidYear(year) {
	if (year < minYear || year > maxYear) {
		return false;
    }
    return true;
}

// Check if input string is a valid month
function IsValidMonth(month) {
	if (month < 1 || month > 12) {
		return false;
    }
    return true;
}

// Check if input string is a valid day
function IsValidDay(day, month, year) {
	var daysInMonth = DaysArray(year);
	
	if (day < 1 || day > daysInMonth[month]) {
		return false;
    }
    return true;
}

// Return array with days per month
// ie : this[1] = 31 (31 days in January)
function DaysArray(year) {
	for (var i = 1; i <= 12; i++) {
		this[i] = 31;
		
		if (i == 4 || i == 6 || i == 9 || i == 11) {
			this[i] = 30;
		}
		
		if (i == 2) {
			this[i] = DaysInFebruary(year);
		}
   } 
   return this
}

// Return the day's number in February
// Bissextile year if divible by 4 but not by 100
// Or disible by 400
function DaysInFebruary(year) {
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
		return 29;
	}
	return 28;
}

// Compare 2 dates
// date1 > date2 => return -1
// date1 = date2 => return 0
// date1 < date2 => return 1
function CompareDate(date1, date2) {
	var result = 1;

	if (date1 > date2) {
		result = -1;
	} else if (date1 == date2) {
		result = 0;
	}
	
	return result;
}

// Check if date is greater or equal than today
function IsGreaterOrEqualThanToday(date) {
	var today = GetToday();
	var result = CompareDate(today, date);
	
	if (result > 0) {
		return true;
	}
	return false;
}

// Return today whitout timte
function GetToday() {
	var today = new Date();
	return new Date(today.getFullYear(), today.getMonth(), today.getDate());
 }
 

/*---- DateValidator.js ----*/

var dateSeparator = "/";
var minYear = 1900;
var maxYear = 2100;

function DateValidator(nameVarGlobal, startDateId, startEmptyDate, endDateId, endEmptyDate, divAlerte) {
	this.ID = nameVarGlobal;
    this.StartDateElem = document.getElementById(startDateId);
    this.StartEmptyDate = startEmptyDate;
    this.EndDateElem = document.getElementById(endDateId);
    this.EndEmptyDate = endEmptyDate;

    this.DivAlerteTexte = "id" + divAlerte + "_texte";
    this.DivAlerte = PJPAPopinAlerte.ErreurFormulaire(divAlerte, "id" + divAlerte, "id" + divAlerte + "_texte", "", 50, 35, 185);
    this.ObjAlerteTexte = document.getElementById(this.DivAlerteTexte);
}

DateValidator.prototype.ClickOk = function() {
	var okVal = false;
	var strStartDate = this.StartDateElem.value;
	var strEndDate = this.EndDateElem.value;

	var isEmptyStartDate = IsEmpty(strStartDate, this.StartEmptyDate);
    var isEmptyEndDate = IsEmpty(strEndDate, this.EndEmptyDate);

	if (isEmptyStartDate && isEmptyEndDate) {
		okVal = true;
	} else if (isEmptyStartDate || isEmptyEndDate) {
		okVal = false;
		var messageDateValidator = GetMessageDateValidator("empty", !isEmptyStartDate, !isEmptyEndDate, this);
		this.ShowAlerte(messageDateValidator);
	} else {
		var startDate = GetDate(strStartDate);
		var endDate = GetDate(strEndDate);
		var isValidStartDate = (startDate != undefined);
		var isValidEndDate = (endDate != undefined);

		if (!isValidStartDate || !isValidEndDate) {
			okVal = false;
			var messageDateValidator = GetMessageDateValidator("unvalid", isValidStartDate, isValidEndDate, this);
			this.ShowAlerte(messageDateValidator);
		} else {
			var isGtorEqStartDate = IsGreaterOrEqualThanToday(startDate);
			var isGtorEqEndDate = IsGreaterOrEqualThanToday(endDate);
			
			if (isGtorEqStartDate && isGtorEqEndDate) {
				okVal = true;
			} else {
				okVal = false;
				var messageDateValidator = GetMessageDateValidator("futur", isGtorEqStartDate, isGtorEqEndDate, this);
				this.ShowAlerte(messageDateValidator);
			}
		}
	}
	
	return okVal;
}

DateValidator.prototype.SetPositionAlerte = function(leftMin, leftMax, leftMiddle, topMin, topMax, topMiddle, width, isFlechG) {
	this.LeftMin = leftMin;
	this.LeftMax = leftMax;
	this.LeftMiddle = leftMiddle;
	this.TopMin = topMin;
	this.TopMax = topMax;
	this.TopMiddle = topMiddle;

	if (width != undefined) {
		this.Width = width;
	}
	else {
		this.Width = 200;
	}
	
	if (width != undefined) {
		$("#" + this.DivAlerteTexte).css("width", width);
	}

	if (isFlechG == 1) {
		var $alerte = this.DivAlerte.find(".alerte_hg");
		if ($alerte != undefined) {
			$alerte.attr("class", "alerte_bd");
		}
	}
}

DateValidator.prototype.MovePositionAlerte = function(left, top, width) {
	this.DivAlerte.css("left", left);
	this.DivAlerte.css("top", top);
	$("#" + this.DivAlerteTexte).css("width", width);
}

DateValidator.prototype.ShowAlerte = function(messageValidator) {
	this.ObjAlerteTexte.innerHTML = messageValidator.Message;
	this.MovePositionAlerte(messageValidator.Left, messageValidator.Top, this.Width);
	setTimeout("ShowAlerteDate('" + this.ID + "');", 100);
}

function ShowAlerteDate(idObj) {
	var objetId = eval(idObj + ".DivAlerte");
	$(objetId).show();
}

DateValidator.prototype.OnInputFocus = function() {
	$(this.DivAlerte).hide();
}

// Message and position of alert
function MessageDateValidator(message, top, left) {
	this.Message = message;
	this.Top = top;
	this.Left = left;
}

/*---- DebuggerJavascript.js ----*/

/***********************
* DebuggerJavascriptOn 
***********************/

var DebuggerJavascriptOn = false;
var DebuggerModeAbsolute = false;
var DebuggerNbLoggedLine;
var DebuggerMaxNbLoggedLine;
var TimerDebuggerScrollSet = "";
var TimerDebuggerDragSet = "";
var DebuggerVersion;
var Debugger_x;
var Debugger_y;
var UserIsDraggingDebugger = false;
function InitDebuggerJavascript()
{
    DebuggerJavascriptOn = true;
    DebuggerModeAbsolute = false;
    Debugger_x = 0;
    Debugger_y = 0;
    DebuggerNbLoggedLine = 0;
    DebuggerMaxNbLoggedLine = 500;
    TimerDebuggerScrollSet = "";
    DebuggerVersion = "Version 0.2.0.1";
    
    document.write('<div id="debugger_javascript" class="debugger_javascript" onclick="DebuggerDragOff()" onmouseup="DebuggerDragOff()">');
    document.write('<strong id="Debugger_title" onmousedown="DebuggerDragOn()">' + GetTile() + '</strong>');
    document.write(' ( ');
    document.write('<a id="linkModeDebuggerJavascript" href="#" onclick="ChangeModeDebuggerJavascript();">Change to Mode Absolute</a> ');
    document.write('<a id="linkChangeHeight" href="#" onclick="ChangeHeight(true);">Increase Height</a> ');
    document.write('<a id="linkChangeHeight" href="#" onclick="ChangeHeight(false);">Lower Height</a> ');
    document.write('<a id="linkChangeHeight" href="#" onclick="DebuggerOnOff(true);">On</a> ');
    document.write('<a id="linkChangeHeight" href="#" onclick="DebuggerOnOff(false);">Off</a> ');
    document.write(' )');
    
    document.write('<div id="debugger_content" class="content"></div>');
    document.write('</div>');
}

function DebuggerOnOff(OnOff) {
    DebuggerJavascriptOn = OnOff;
}

function DebuggerDragOn()
{
    if (DebuggerModeAbsolute)
    {
        UserIsDraggingDebugger = true;
        TimerDebuggerDragSet = setTimeout("StartSetPositionDebuggerToMousePos()",tjs_delai);
        document.onmousemove = getMousePos;
    }
}

function DebuggerDragOff()
{
    UserIsDraggingDebugger = false;
    clearTimeout(TimerDebuggerDragSet);
}

function GetTile()
{
    var title = 'PJPA Javascript Debugger -- ' + DebuggerVersion + ' -- ';
    if (DebuggerModeAbsolute)
        title += "Mode Absolue";
    else
        title += "Mode Relatif";
    return title;
}

function ChangeModeDebuggerJavascript()
{
    var debugger_javascript = document.getElementById("debugger_javascript")
    var link = document.getElementById('linkModeDebuggerJavascript');
    var title = document.getElementById('Debugger_title');
    if (DebuggerModeAbsolute) {
        link.innerHTML = "Change to Mode Absolue";
        debugger_javascript.style.top = "0px";
        debugger_javascript.style.left = "0px";
        debugger_javascript.classname = "debugger_javascript";
        DebuggerModeAbsolute = false;
        
        clearTimeout(TimerDebuggerScrollSet);
    }
    else {
        title.innerHTML = GetTile();
        link.innerHTML = "Change to Mode Relatif";
        debugger_javascript.className = "debugger_javascript mode_absolute";
        DebuggerModeAbsolute = true;
        
        TimerDebuggerScrollSet = setTimeout("StartSetPositionDebuggerToScrollTop()",tjs_delai);
    }
    title.innerHTML = GetTile();
}

function ChangeHeight(increase) {
    var debugger_content = $('#debugger_content');
    var height = debugger_content.height();
    if (increase) {
        debugger_content.height(height + 25);
    } else {
        if (height > 75) {
            debugger_content.height(height - 25);
        }
    }
}

var tjs_delai=100;
function StartSetPositionDebuggerToScrollTop() {
    SetPositionDebuggerToScrollTop();
    TimerDebuggerScrollSet = setTimeout("StartSetPositionDebuggerToScrollTop()",tjs_delai);
}

function SetPositionDebuggerToScrollTop() {
    var debugger_javascript = document.getElementById("debugger_javascript");
    debugger_javascript.style.top = Number(GetScrollTop() + Debugger_y) + "px";
    debugger_javascript.style.left = Number(Debugger_x) + "px";
}

function StartSetPositionDebuggerToMousePos() {
    
    SetPositionDebuggerToMousePos();
    TimerDebuggerDragSet = setTimeout("StartSetPositionDebuggerToMousePos()",tjs_delai);
}

function SetPositionDebuggerToMousePos() {
    var debugger_javascript = document.getElementById("debugger_javascript");
    
    var Debugger_title = document.getElementById("Debugger_title");
    
    Debugger_x = MousePosX - Debugger_title.offsetLeft - Debugger_title.offsetWidth / 2;
    Debugger_y = MousePosY - GetScrollTop() - Debugger_title.offsetHeight / 2;
}

function ScrollToBottomOfElement(objDiv)
{
    objDiv.scrollTop = objDiv.scrollHeight;
}

function FormatNumberToString(nb, nbcharmin)
{
    if (nbcharmin == 2) {
        if (nb < 10) return "0" + nb;
    }
    if (nbcharmin == 3) {
        if (nb < 10) return "00" + nb;
        if (nb < 100) return "0" + nb;
    }
    return nb;
}

function GetCurrentTime()
{
    var date = new Date();
    var hours = FormatNumberToString(date.getHours(), 2);
    var minutes = FormatNumberToString(date.getMinutes(), 2);
    var seconds = FormatNumberToString(date.getSeconds(), 2);
    var milliseconds = FormatNumberToString(date.getMilliseconds(),3);
        
    return hours + ":" + minutes + ":" + seconds + ":" + milliseconds;
}

function WriteDebugText(text)
{
    if (DebuggerJavascriptOn)
    {
        DebuggerNbLoggedLine++;
        if (DebuggerNbLoggedLine > DebuggerMaxNbLoggedLine) 
        {
            DebuggerNbLoggedLine = 0;
            debugger_content.innerHTML = "";
        }        
    
        var debugger_content = document.getElementById("debugger_content");
        var div_time = "<div class='prompt'>" + GetCurrentTime() + " > <span>" + FormatNumberToString(DebuggerNbLoggedLine,3) + "</span> >></div>";
        var div_text = "<div class='text'>" + text + "</div>";
        var div_breaker = "<div class='the_breaker'></div>";

        var contenttoadd = div_time + div_text + div_breaker;
        debugger_content.innerHTML += contenttoadd;
        
        ScrollToBottomOfElement(debugger_content);
    }
}

function ColorDebugText(text, color)
{
    if (DebuggerJavascriptOn)
    {
        return "<span style='color:" + color + "'>" + text + "</span>";
    } 
    else
    {
        return "";
    }
}

/*****************************/

/*---- Fiche_detail.js ----*/

////////////////////DEBUT SCRIPT FICHE DETAIL ET TECHNIQUE////////////////////
function RefrechCompteurSelection()
    {
    if(getObj('ContenerNbSelection')!=null)
        {    
        //getObj('ContenerNbSelection').innerHTML='('+getNbAnnoncesSelection(TypeSelection)+')';
        getObj('ContenerNbSelection').innerHTML='('+getNbAnnoncesSelectionTotal()+')';
        }
    }
    
 function getNbAnnoncesSelectionTotal()
    {
    Total = 0;
    if(getCookie('GetSelectionAutoMoto')!=null)
        {
        var ArrayLstSelectionAutoMoto=getCookie('GetSelectionAutoMoto').split("|");
        Total += ArrayLstSelectionAutoMoto.length;
        }
    if(getCookie('GetSelectionImmobilier')!=null)
        {
        var ArrayLstSelectionImmobilier=getCookie('GetSelectionImmobilier').split("|");
        Total += ArrayLstSelectionImmobilier.length;
        }
    return Total;
    }   

function WriteTotalNombreSelection()
    {
    TotalSelection=0;
    if(getCookie('GetSelectionImmobilier')!=null)
        {
        var ArrayLstSelection=getCookie('GetSelectionImmobilier').split("|");
        NbSelectionImmobilier=ArrayLstSelection.length;
        TotalSelection=TotalSelection+NbSelectionImmobilier
        }
    if(getCookie('GetSelectionAutoMoto')!=null)
        {
        var ArrayLstSelection=getCookie('GetSelectionAutoMoto').split("|");
        NbSelectionAutoMoto=ArrayLstSelection.length;
        TotalSelection=TotalSelection+NbSelectionAutoMoto
        }
    if(getObj('ContenerSelectionProfile')!=null)
        {    
        getObj('ContenerSelectionProfile').innerHTML='('+TotalSelection+')';
        }
    }

function getNbAnnoncesSelection(TypeSelection)
    {
    if(getCookie('GetSelection'+TypeSelection)!=null)
        {
        var ArrayLstSelection=getCookie('GetSelection'+TypeSelection).split("|");
        return ArrayLstSelection.length;
        }
    else
        {
        return '0';
        }
    }
   
// En attente de nettoyage
function VieweVisuProduct(Url)
    {
    getObj('ContenerVisu').src=Url; 
    
    // don't modify the following lines of code
    if(getObj('VisuPhoto') != null){
        if(Url.indexOf('_Detaillee') != -1){ // found
            getObj('VisuPhoto').src=Url.replace('_Detaillee', '_Zoom');            
        }else if(Url.indexOf('tpj') != -1){
            getObj('VisuPhoto').src=Url.replace('tpj', 'ppj');             
        }
    }
    }

// En attente de nettoyage
function VieweVisuProduct(Url, Title) {
// used in fiche det. only -> modify everything EXCEPT this!
    // visu moins grand
    getObj('ContenerVisu').src=Url; 
    getObj('ContenerVisu').title=Title; 
    // visu en grand
    getObj('VisuPhoto').title=Title;
    
    // don't modify the following lines of code
    if(getObj('VisuPhoto') != null){
        if(Url.indexOf('_Detaillee') != -1){ // found
            getObj('VisuPhoto').src=Url.replace('_Detaillee', '_Zoom');             
        }else if(Url.indexOf('tpj') != -1){
            getObj('VisuPhoto').src=Url.replace('tpj', 'ppj'); 
        }        
    }
    }   

// Used in whole web site
function OpenLelay(Id)
    {
    if(getObj(Id).style.display=='')
        {
        getObj(Id).style.display='none';
        }
    else
        {	
        getObj(Id).style.display='';
        }
    }

// Used in whole web site
function WindowOnResize() 
{
    if (getObj('ContenerAlertPjpa')&&getObj('ContenerAlertPjpa').style.visibility=='visible') 
    {
        if (document.body.clientWidth > 950) 
        {
            SetToXY('ContenerAlertPjpa',Math.floor((document.body.clientWidth - 930) / 2) + (650 - getWidth('ContenerAlertPjpa')), getTop(getObj('ContenerAlertPjpa')));
        } 
        else 
        { 
            if (document.body.clientWidth < 670) 
            {
                if (document.body.clientWidth < getWidth('ContenerAlertPjpa')) 
                {
                    SetToXY('ContenerAlertPjpa',0, getTop(getObj('ContenerAlertPjpa')));
                } 
                else 
                {
                    SetToXY('ContenerAlertPjpa',Math.floor((document.body.clientWidth - getWidth('ContenerAlertPjpa')) / 2), getTop(getObj('ContenerAlertPjpa')));
                }                
            } 
            else 
            {                
                SetToXY('ContenerAlertPjpa',660 - getWidth('ContenerAlertPjpa'), getTop(getObj('ContenerAlertPjpa')));
            }   
        }
    }
}


// Programme d'assistance JavaScript requis pour detecter les informations de version du plug-in Flash Player
function JSGetSwfVer(i){
    // Version NS/Opera >= 3 rechercher le plug-in Flash dans le tableau des plug-ins
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            descArray = flashDescription.split(" ");
            tempArrayMajor = descArray[2].split(".");
            versionMajor = tempArrayMajor[0];
            versionMinor = tempArrayMajor[1];
            if ( descArray[3] != "" ) {
	            tempArrayMinor = descArray[3].split("r");
            } else {
	            tempArrayMinor = descArray[4].split("r");
            }
            versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        } else {
            flashVer = -1;
        }
    }
    // MSN/WebTV 2.6 prend en charge Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 prend en charge Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // La version anterieure de WebTV prend Flash 2 en charge
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    // Detection impossible dans tous les autres cas
    else {
		
        flashVer = -1;
    }
    return flashVer;
} 
// Si elle est appelee sans parametres,
// cette fonction renvoie une valeur en virgule flottante indiquant la version Flash Player ou 0.0 
// ex : Flash Player 7r14 renvoie 7.14
// Si appele avec reqMajorVer, reqMinorVer, reqRevision renvoie true si cette version ou une version ulterieure est disponible
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
    var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
    var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
    var jsVersion = 1.1;

    reqVer = parseFloat(reqMajorVer + "." + reqRevision);
    // Examiner les versions pour detecter la plus recente	
    for (i=25;i>0;i--) {        
        if (isIE && isWin && !isOpera) {
            //GUBOI this function is not available when called by ajax, indeed it's a VBS function and can't loaded
            try{versionStr = VBGetSwfVer(i);}
            catch(e){versionStr=" 8.14";}            
        } else {
            versionStr = JSGetSwfVer(i);            
        }
        if (versionStr == -1 ) {             
            return false;
        } else if (versionStr != 0) {
            if(isIE && isWin && !isOpera) {
	            tempArray         = versionStr.split(" ");
	            tempString        = tempArray[1];
	            versionArray      = tempString .split(",");				
            } else {
	            versionArray      = versionStr.split(".");
            }
            versionMajor      = versionArray[0];
            versionMinor      = versionArray[1];
            versionRevision   = versionArray[2];
			
            versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
            versionNum        = parseFloat(versionString);
            // est la revision.principale >= revision.principale demandee ET la version mineure >= mineure demandee
            if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {            
	            return true;
            } else {        
	            return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
            }
        }
    }	    
    return (reqVer ? false : 0.0);
}

function AjoutezAuxFavoris() {
    if (document.all) { 
        window.external.AddFavorite('http://www.annoncesjaunes.fr','Petites annonces immo-auto-moto sur annoncesjaunes.fr') 
    } else if (window.sidebar.addPanel){
        window.sidebar.addPanel("Petites annonces immo-auto-moto sur annoncesjaunes.fr","http://www.annoncesjaunes.fr","");
    }
}

var _ficheDetailScrollDuration = 1000;
var _ficheDetailFixedMenuHeight = 84;
var _ficheDetailScrollXDecal = 10;

function FicheDetail_Scroll(anchorId) {
	var offsetTop = -1 * (_ficheDetailFixedMenuHeight + _ficheDetailScrollXDecal);

	var obj = $('#' + anchorId);
	$.scrollTo(obj, _ficheDetailScrollDuration, { offset: { top: offsetTop } })	
}


/*---- Fonction.js ----*/

String.prototype.toProperCase = function() {
	var length = this.length;

	if (length > 0) {
		return this.charAt(0).toUpperCase() + this.substring(1, length).toLowerCase();
	} else {
		return "";
	}
}

function PJPARemplaceOu(objValue) {

	var ouSaisi = PJPAPrepareMatch(objValue);

	NomRegion = new Array();
	NomRegion[0] = "ile de france";
	NomRegion[1] = "champagne ardenne";
	NomRegion[2] = "picardie";
	NomRegion[3] = "haute normandie";
	NomRegion[4] = "centre";
	NomRegion[5] = "basse normandie";
	NomRegion[6] = "bourgogne";
	NomRegion[7] = "nord pas de calais";
	NomRegion[8] = "lorraine";
	NomRegion[9] = "alsace";
	NomRegion[10] = "franche comte";
	NomRegion[11] = "pays de la loire";
	NomRegion[12] = "bretagne";
	NomRegion[13] = "poitou charentes";
	NomRegion[14] = "aquitaine";
	NomRegion[15] = "midi pyrenees";
	NomRegion[16] = "limousin";
	NomRegion[17] = "rhone alpes";
	NomRegion[18] = "auvergne";
	NomRegion[19] = "languedoc roussillon";
	NomRegion[20] = "provence alpes cote d azur";
	NomRegion[21] = "corse";

	Region = new Array();
	Region[0] = "75 77 78 91 92 93 94 95";
	Region[1] = "51 08 10 52";
	Region[2] = "80 02 60";
	Region[3] = "76 27";
	Region[4] = "45 18 28 36 37 41";
	Region[5] = "14 50 61";
	Region[6] = "21 58 71 89";
	Region[7] = "59 62";
	Region[8] = "57 54 55 88";
	Region[9] = "67 68";
	Region[10] = "25 39 70 90";
	Region[11] = "44 49 53 72 85";
	Region[12] = "35 22 29 56";
	Region[13] = "86 16 17 79";
	Region[14] = "33 24 40 47 64";
	Region[15] = "31 09 12 32 46 65 81 82";
	Region[16] = "87 19 23";
	Region[17] = "69 01 07 26 38 42 73 74";
	Region[18] = "63 03 15 43";
	Region[19] = "34 11 30 48 66";
	Region[20] = "13 04 05 06 83 84";
	Region[21] = "2A 2B";

	for (var i = 0; i < NomRegion.length; i++) {
		if (ouSaisi.indexOf(NomRegion[i]) > -1) {
			ouSaisi = ouSaisi.replace(NomRegion[i], Region[i]);
		}
	}
	return ouSaisi;
}

function DetectFlash(Flash, BtnShowFlash, photos, diaporamaPhoto, CadrePhotos) {
    var DivFlash = $("#" + Flash);
    var btnDetect = document.getElementById(BtnShowFlash);
    var DivPhotos = $("#" + photos);
    var DivDiaporamaPhoto = $("#" + diaporamaPhoto);

    if (DivFlash != undefined) {
        $(DivFlash).flash({ src: '/_swf/DetectFlash.swf' }, { version: '7' });

        var innerHtmlDetect = $(DivFlash).html();
        var CanAfficheFlash = (innerHtmlDetect == null || 
        innerHtmlDetect.indexOf('This content requires the Flash') == -1);

        if (CanAfficheFlash) {
            $(DivPhotos).fadeOut("slow", CallBackAfficheFlash(diaporamaPhoto, CadrePhotos));
        }
        else {
            $("#" + CadrePhotos).removeClass("CadrePhotos");
        }
        $(DivFlash).hide();
    }
}

function CallBackAfficheFlash(DivDiaporamaPhoto, CadrePhotos) {
    setTimeout('AfficheFlash("' + DivDiaporamaPhoto + '","' + CadrePhotos + '");', 500);
}

function AfficheFlash(DivDiaporamaPhoto, CadrePhotos) {
    $("#" + DivDiaporamaPhoto).fadeIn("slow");
    $("#" + CadrePhotos).removeClass("CadrePhotos");
   }



/// Focntion General ///
function ShowElement(id)
{
    document.getElementById(id).style.display='block';
}

function CallBackAfficheFlash(DivDiaporamaPhoto, CadrePhotos) {
	setTimeout('AfficheFlash("' + DivDiaporamaPhoto + '","' + CadrePhotos + '");', 500);
}
function AfficheFlash(DivDiaporamaPhoto, CadrePhotos) {
	$("#" + DivDiaporamaPhoto).fadeIn("slow");
	$("#" + CadrePhotos).removeClass("CadrePhotos");
}

function ShowElement(id) {
	document.getElementById(id).style.display = 'block';
}

function HideElement(id) {
	document.getElementById(id).style.display = 'none';
}

function ShowHideElement(id) {
	var element = document.getElementById(id);
	if (element.style.display == 'none') {
		ShowElement(id);
	}
	else {
		HideElement(id);
	}
}

function HideToggle(id) {
	if (document.getElementById(id).style.display == 'none') {
		ShowElement(id);
	}
	else {
		HideElement(id);
	}
}

function EcrireCookie(nom, valeur) {
	var argv = EcrireCookie.arguments;
	var argc = EcrireCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;

	document.cookie = nom + "=" + escape(valeur) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function getCookieVal(offset) {

	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function LireCookie(nom) {
	var arg = nom + "=";
	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 EffaceCookie(nom) {
	date = new Date;
	date.setFullYear(date.getFullYear() - 1);
	EcrireCookie(nom, null, date);
}

function DisplayWaitIfOk(obj1, obj2) {
	var ok = false;
	
	if (obj1 != undefined && obj1.value != "" && obj2 != undefined && obj2.value != "")
		ok = true;

	if (ok) {
		DisplayWait();
	}	
}

function DisplayWait() {
	hideSelects();
	document.getElementById('wait2').style.display = 'block';
	document.getElementById('wait').style.display = 'block';
}

function HiddeWait() {
	document.getElementById('wait2').style.display = 'none';
	document.getElementById('wait').style.display = 'none';
}

function RewriteDefaultValue(pTextBoxId, defaultValue) {
	pTextBox = getObj(pTextBoxId);
	if (pTextBox.value == '') {
		pTextBox.value = defaultValue;
		pTextBox.className = "default";
	}
}
function ClearDefaultValue(pTextBoxId, defaultValue) {
	pTextBox = getObj(pTextBoxId);
	if (pTextBox.value == defaultValue) {
		pTextBox.value = '';
		pTextBox.className = "";
	}
}

function HidePopUpRequiredFieldForTextBox() {
	if (document.getElementById('ZoneGeographiqueIsRequired') != null)
		document.getElementById('ZoneGeographiqueIsRequired').style.display = 'none';

	if (document.getElementById('ZoneGeographiqueIsRequiredForApproxd') != null)
		document.getElementById('ZoneGeographiqueIsRequiredForApproxd').style.display = 'none';
}


function ManageDropDownStyle(pObject) {
	var value = pObject.options[pObject.selectedIndex].value;
	if (value == '') {
		pObject.options[pObject.selectedIndex].style.fontStyle = 'italic';
		pObject.options[pObject.selectedIndex].style.color = 'gray';
	}
}

function ValidateIfFieldIsRegion(pTextBoxValue) {
	if (RegionTab != undefined) {
		for (var i = 0; i < RegionTab.length; i++) {
			if (pTextBoxValue.toLowerCase().indexOf(RegionTab[i].toLowerCase()) != -1)
				return true;
		}
	}
	return false;
}

function RefreshDropDownListSelectedValueStyles(id) {
	var select = document.getElementById(id);
	for (var i = 0; i < select.options.length; i++) {
		if (select.options[i].selected) {
			select.className = select.options[i].className;
		}
	}
}

function InitializeDropDownListDefaultValueStyles(id) {
	var select = document.getElementById(id);
	for (var i = 0; i < select.options.length; i++) {
		select.options[i].className = "select_normal";
	}
	select.options[0].className = "select_default";
	RefreshDropDownListSelectedValueStyles(id);
	select.onchange = function() {	RefreshDropDownListSelectedValueStyles(id);	}
}

function prepareMatchPrix(prix) {
	var caractereAutorise = "0123456789";
	var returnPrix = "";
	for (i = 0; i < prix.length; i++) {
		if (caractereAutorise.indexOf(prix.charAt(i)) > -1)
			returnPrix += prix.charAt(i);
		else
			returnPrix += " ";
	}
	returnPrix = returnPrix.replace(/\s+/g, '');
	returnPrix = FormatPrixZapette(returnPrix);
	// Symbole euros : \u20AC
	return returnPrix;
}


function FormatPrixZapette(prix) {
	// Formatter les prix 1 000 , 100, 1 500 ,15 000, 100 000 => supprimer tous les espaces
	prix = prix.replace(/\s+/g, '');
	var newPrix = '';
	var prixLength = prix.length;
	var d = 10000000;
	var firstTime = true;
	var compteur = 2;
	if (prixLength > 0) {
		while (d != 0) {
			var val = Math.floor(prix / d);
			if (val != 0) {
				firstTime = false;
				newPrix += val;
			}
			else if (!firstTime)
				newPrix += 0;
			compteur = compteur - 1;
			prix = prix - (val * d);
			prixLength = prix.toString().length;
			d = d / 10;
			d = Math.floor(d);
			if (compteur == 0) {
				if (!firstTime)
					newPrix += ' ';
				compteur = 3;
			}
		}
	}
	return newPrix;
}

function afficheCalqueAndClass(idDiv, idLink, classe) {
	var obj = getObj(idLink);
	var targetElement = document.getElementById(idDiv);
	if (targetElement.style.display == "none") {
		targetElement.style.display = "";
		SetClassName(obj, classe);
	}
	else {
		targetElement.style.display = "none";
		SetClassName(obj, "");
	}
}

function afficheCalque(id) {
	var targetElement = document.getElementById(id);
	if (targetElement.style.display == "none")
		targetElement.style.display = "";
	else
		targetElement.style.display = "none";
}

function ChangeVisibilty_DivPlusDeVille(visible) {
	if (visible) {
		document.getElementById('lien_plusdeville').style.display = 'none';
		document.getElementById('div_plusdeville').style.display = 'block';
	}
	else {
		document.getElementById('lien_plusdeville').style.display = 'block';
		document.getElementById('div_plusdeville').style.display = 'none';
	}
}

function ChangeDisplay_LRTrLienAnnonce(idannonce, visible) {
	if (visible) {
		document.getElementById('tr_' + idannonce).style.display = "";
	}
	else {
		document.getElementById('tr_' + idannonce).style.display = "none";
	}
}

function ChangeDisplay_LRFondReliefAnnonce(idannonce, visible, decalIE) {
	var fondrelief = document.getElementById('fondrelief_' + idannonce);

	if (ie && typeof (decalIE) != 'undefined') {
		window.setTimeout("ChangeDisplay_LRFondReliefAnnonce('" + idannonce + "', " + visible + ")", decalIE);
	}
	else {
		if (visible) {
			fondrelief.style.display = "none";
		}
		else {
			fondrelief.style.display = "";

			var tbody = getObj('tbodyAnnonce_' + idannonce);
			var fondrelief_c_height = 0;
			if (ie) {
				var arraytr = GetElementsByTagName(tbody, "tr", 2);
				for (var i = 0; i < arraytr.length; i++) {
					fondrelief_c_height += arraytr[i].clientHeight;
				}
				fondrelief_c_height -= 24;
			}
			else {
				fondrelief_c_height = tbody.offsetHeight - 24;
			}

			var fondrelief_c = GetElementsByClassName(fondrelief, "fondrelief_c", 2)[0];
			fondrelief_c.style.height = fondrelief_c_height + "px";
		}
	}
}

function GetElementsByTagName(parent, tagname, profondeur) {
	if (typeof (profondeur) == 'undefined')
		profondeur = 1;

	var res = new Array();
	GetElementsByTagNameRec(parent, tagname, profondeur, res)
	return res;
}

function GetElementsByTagNameRec(parent, tagname, profondeur, array) {
	if (profondeur > 0) {
		for (var i = 0; i < parent.childNodes.length; i++) {
			var child = parent.childNodes[i];
			if (typeof (child.tagName) != 'undefined' && child.tagName.toUpperCase() == tagname.toUpperCase())
				array.push(child);
			GetElementsByTagNameRec(child, tagname, profondeur - 1, array);
		}
	}
}

function GetElementsByClassName(parent, classname, profondeur) {
	if (typeof (profondeur) == 'undefined')
		profondeur = 1;

	var res = new Array();
	GetElementsByClassNameRec(parent, classname, profondeur, res)
	return res
}

function GetElementsByClassNameRec(parent, classname, profondeur, array) {
	if (profondeur > 0) {
		for (var i = 0; i < parent.childNodes.length; i++) {
			var child = parent.childNodes[i];
			if (typeof (child.className) != 'undefined' && child.className.toLowerCase() == classname.toLowerCase())
				array.push(child);
			GetElementsByClassNameRec(child, classname, profondeur - 1, array);
		}
	}
}

function FillQuoi(elt, idDiv) {

	var quoiLabel = getObj(idQuoiLabel)
	quoiLabel.innerHTML = elt.innerHTML;

	quoiLabel.style.fontStyle = 'normal';
	var div = getObj(idDiv);
	if (div.style.visibility == "visible") {
		div.style.visibility = "hidden";
	}
}

function afficherCacher(leLay) {
	if (getObj(leLay).style.visibility == "hidden")
		afficher(leLay);
	else
		cacher(leLay);
}

function SetHiddenField(catValue, sousCatValue) {
	getObj(idHiddenFieldQuoi).value = catValue;
	getObj(idHiddenFieldSousCat).value = sousCatValue;

}


function ValidateFieldRequiredForZoneGeo(pSecteur) {
	// recuperer objets et valeur
	pTextBox = getObj(textBoxZoneGeoClientID);
	pDropDown = getObj(dropdownListClientID);

	var value = pDropDown.options[pDropDown.selectedIndex].value;
	var textBoxValue = pTextBox.value;

	if (value == '0') {
		if (pSecteur == 'immo') {
			if (textBoxValue == '' || textBoxValue == defaultValueZoneGeo) {
				document.getElementById("ZoneGeographiqueIsRequired").style.display = 'block';
				return false;
			}
		}
	}
	// La liste deroulante contient une valeur par defaut
	else {
		if (textBoxValue == '' || textBoxValue == defaultValueZoneGeo || ValidateIfFieldIsRegion(pTextBox.value)) {
			document.getElementById('ZoneGeographiqueIsRequiredForApproxd').style.display = 'block';
			return false;
		}
	}

	DisplayWait();

	return true;
}

function GetNombreAvecMotAccorde(nb, mot) {
	var str = nb + ' ' + mot;
	if (Number(nb) > 1)
		str += "s";
	return str;
}

function ChangeDisplay_Pager(id, visible) {
	var pager = getObj(id);
	if (pager != null) {
		if (visible) {
			pager.style.display = "";
		}
		else {
			pager.style.display = "none";
		}
	}
}

function DisplayBlocCharges(radioId, id) {
	var blocCharge = getObj(id);
	var radio = getObj(radioId);
	if (radio.checked) {
		blocCharge.style.visibility = "visible";
	}
}

function HideBlocCharges(radioId, id, txtId) {
	var blocCharge = getObj(id);
	var radio = getObj(radioId);
	var txtCharges = getObj(txtId);
	if (radio.checked) {

		txtCharges.value = "";
		blocCharge.style.visibility = "hidden";
	}
}

function RedirectUrl(url) {
	document.location = url;
}

function SetClassName(obj, classe) {
	if (obj != undefined) {
		obj.className = classe;
	}
}

function setPJPACookie(name, value, expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = name + "=" + escape(value) +
	((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

// Used in home page
function decrypturl() {
    args = decrypturl.arguments;
    var url = args[0].substr(1, args[0].length - 1);
    for (i = 1; i < args.length; i++) {
        url += args[i];
    }
    return url;
}


function ToggleBlock(obj, idDiv, hauteur) {

	var objContenu = getObj(idDiv);
	var speed = (hauteur < 30 ? 100 : 300);

	if (objContenu.style.display == "none") {
		obj.innerHTML = "Moins de crit&egrave;res";
		obj.className = "MoinsCriteres";

		if ($.browser.msie && jQuery.browser.version.substr(0, 2) == "6.") {
			$("#" + idDiv).show();
		}
		else {
			$("#" + idDiv).slideDown(speed);
		}

	}
	else {
		obj.className = "AutresCriteres";
		obj.innerHTML = "Plus de crit&egrave;res";
		if ($.browser.msie && jQuery.browser.version.substr(0, 2) == "6.") {
			$("#" + idDiv).hide();
		}
		else {
			$("#" + idDiv).slideUp(speed);
		}
	}
}





function afficherCacherBlocSelection(idBlocSelection) {
	var blocSelection = getObj(idBlocSelection);
	afficherCacher(idBlocSelection);
	if (IsNavigatorIe6() && typeof (dropdownListClientID) != 'undefined') {

		var dropdownList = getObj(dropdownListClientID);
		if (blocSelection.style.visibility == "visible") {
			dropdownList.style.visibility = "hidden";
		}
		else {
			dropdownList.style.visibility = "visible";
		}
	}

	if (typeof (LstDllCache) != 'undefined' && LstDllCache != undefined && IsNavigatorIe6()) {
		var lstDll = LstDllCache.split(",");
		for (var i = 0; i < lstDll.length; i++) {
			var DropdownList = getObj(lstDll[i]);
			if (blocSelection.style.visibility == "visible") {
				DropdownList.style.visibility = "hidden";
			}
			else {
				DropdownList.style.visibility = "visible";
			}
		}
	}
}

function CacherListeAfficherDropDown(idBlocSelection) {
	if (IsNavigatorIe6()) {
		if (typeof (dropdownListClientID) != 'undefined') {
			var dropdownList = getObj(dropdownListClientID);
			dropdownList.style.visibility = "visible";
		}

		if (typeof (LstDllCache) != 'undefined' && LstDllCache != undefined && IsNavigatorIe6()) {
			var blocSelection = getObj(idBlocSelection);
			var lstDll = LstDllCache.split(",");
			for (var i = 0; i < lstDll.length; i++) {
				var DropdownList = getObj(lstDll[i]);
				DropdownList.style.visibility = "visible";
			}
		}
	}
	cacher(idBlocSelection);
}



function AddListeSelected(objChk, label, hidden, valeur, isMultiSelect, defautval, ClientID) {
	if (isMultiSelect == "True") {
		var widthlabel = $(getObj(label).parentNode).css("width").replace(new RegExp("(px)", "gi"), ""); ;

		if (objChk.checked) {
			if (getObj(hidden).value != "-1") {
				getObj(hidden).value += valeur + ";";
			}
			else {
				getObj(hidden).value = valeur + ";";
			}
		}
		else {
			var valHidden = valeur + ";";
			getObj(hidden).value = getObj(hidden).value.replace(new RegExp("(" + valHidden + ")", "gi"), "");
			getObj(hidden).value = getObj(hidden).value.replace(new RegExp("(;;)", "gi"), "");
		}

		
		if (getObj(hidden).value == "") {
			getObj(label).innerHTML = defautval;
			getObj(hidden).value = "-1";
		}
		else {
			var reg = new RegExp("(;)", "gi");
			getObj(label).innerHTML = getObj(hidden).value.replace(reg, ", ");
			getObj(label).innerHTML += ";";
			getObj(label).innerHTML = getObj(label).innerHTML.replace(new RegExp("(, ;)", "gi"), "");
		}

		if (widthlabel != null && widthlabel != undefined) {
			var nbcar = parseInt(widthlabel) / 5 - 6;
			if (getObj(label).innerHTML.length > nbcar) {
				getObj(label).innerHTML = getObj(label).innerHTML.substring(0, nbcar) + "...";
			}
		}
		//$("#erreurJS").html($("#erreurJS").html() + "<br>" + getObj(hidden).value + "-" + getObj(label).innerHTML);
	
	}
	else {
		getObj(hidden).value = valeur;
		getObj(label).innerHTML = valeur;
		//$("#erreurJS").html($("#erreurJS").html() + "<br>" + getObj(hidden).value + "-" + getObj(label).innerHTML);
	
		
		eval(ClientID + "_isOnBlocSelection = 0;");
		eval(ClientID + "_isOnListe = 0;");
		CacherBlocSelection(ClientID);
	}
}

function CacherBlocSelection(ClientID) {
	var ListeSuggestion = getObj('liste_selection_' + ClientID);
	var isOnBlocSelection = eval(ClientID + "_isOnBlocSelection");
	var isOnListe = eval(ClientID + "_isOnListe");
	if (isOnBlocSelection == 0 && isOnListe != 1) {		
		if (ListeSuggestion != null) {
			ListeSuggestion.style.visibility = "hidden";
		}		
		eval(ClientID + "_isOnBlocSelection = 0;");
		eval(ClientID + "_isOnListe = 0;");
		FixIE6DDL(ListeSuggestion);
	}
}

function AfficherBlocSelection(ClientID) {
	currentIdClient = ClientID;
	var ListeSuggestion = getObj('liste_selection_' + ClientID);
	ListeSuggestion.style.visibility = "visible";
	eval(ClientID + "_isOnBlocSelection = 1;");
	FixIE6DDL(ListeSuggestion);
}

function CacherAfficherBlocSelection(ClientID) {
	var ListeSuggestion = getObj('liste_selection_' + ClientID);

	var isOnBlocSelection = eval(ClientID + "_isOnBlocSelection");
	var isOnListe = eval(ClientID + "_isOnListe");

	if (isOnBlocSelection == 1 && isOnListe == 0 && ListeSuggestion.style.visibility == "visible") {
		eval(ClientID + "_isOnBlocSelection = 0;");
		eval(ClientID + "_isOnListe = 0;");
		CacherBlocSelection(ClientID);
		return;
	}

	if (ListeSuggestion.style.visibility == "visible") {
		CacherBlocSelection(ClientID);
	}
	else if (ListeSuggestion.style.visibility == "hidden") {
		AfficherBlocSelection(ClientID);
	}
}

function cacherBlocSelectionTimeOut() {
	if (currentIdClient != undefined) {
		var fct = "CacherBlocSelection('" + currentIdClient + "');";
		setTimeout(fct, 100);
	}
}
var LstDllCache = undefined;

function FixIE6DDL(blocSelection) {
	
	var bisIE6 = IsNavigatorIe6();
	
	if (bisIE6) {
		if (LstDllCache != undefined) {
			var lstDll = LstDllCache.split(",");
			
			for (var i = 0; i < lstDll.length; i++) {
				var DropdownList = getObj(lstDll[i]);
				if (blocSelection.style.visibility == "visible") {
					DropdownList.style.visibility = "hidden";
				}
				else {
					DropdownList.style.visibility = "visible";
				}
			}
		}		
		
		if (dropdownListClientID != undefined) {

			var dropdownList = getObj(dropdownListClientID);
			if (blocSelection.style.visibility == "visible") {
				dropdownList.style.visibility = "hidden";
			}
			else {
				dropdownList.style.visibility = "visible";
			}
		}
	}
}

function ShowJquery(id, affiche) {
	$(document).ready(function() {
		if (affiche) {
			$('#' + id).show();
		}
		else {
			$('#' + id).hide();
		}
	});
}

function NotNullOrNotEmpty(object) {
	return (object != null && object != undefined && object!= "");
}

function NotUndefinedNotNull(object) {
	return (object != null && object != undefined);
}

function SessionEnd(nbSecond) {
	setTimeout('SessionEndMsg()', nbSecond * 1000);
}

function SessionEndMsg() {
	document.location = document.URL;
}

function ChangeClassNameDelay(idItem, idPresent, className, delay) {
	$('#' + idItem).hide();
	if (delay > 0) {
		setTimeout("ChangeClassName('" + idItem + "', '" + idPresent + "', '" + className + "')", delay);
	}
	else {
		getObj(idItem).className = className;
	}
}

function ChangeClassName(idItem, idPresent, className) {
	var objPresent = getObj(idPresent);
	if (objPresent != undefined) {
		getObj(idItem).className = className;
		$('#' + idItem).show();
	}
	else {
		setTimeout("ChangeClassName('" + idItem + "', '" + idPresent + "', '" + className + "')", 500);
	}
}

/*---- Formulaire.js ----*/

// Debut Formulaire.js

function AlertFormPjpa(NomChamps)
    {
    getObj('Background'+NomChamps).style.backgroundColor=CouleurAlert;
    getObj('ContainerErreur'+NomChamps).style.display='block';
    }

function DeAlertFormPjpa(NomChamps)
    {
    getObj('Background'+NomChamps).style.backgroundColor='';
    getObj('ContainerErreur'+NomChamps).style.display='none';
    }

function LinkCheckBox(IdCheckBox,Couleur)
    {
    
    //Modifie par ludovic - Remise a zero de TypeChangementZapette
    if (document.aspnetForm.TypeChangementZapette != null)
    {
        document.aspnetForm.TypeChangementZapette.value='';
    }
    
    if(getObj(IdCheckBox).checked)
        {
        getObj('link'+IdCheckBox).style.color='';
        getObj(IdCheckBox).checked=false;
        }
    else
        {
		getObj('link'+IdCheckBox).style.color=Couleur;
		getObj(IdCheckBox).checked=true;
        }
    }

function ClickCheckBox(IdCheckBox,Couleur)
    {
    if (document.aspnetForm.TypeChangementZapette != null)
    {
        document.aspnetForm.TypeChangementZapette.value='';
    }
    
    if(!getObj(IdCheckBox).checked)
        {
        getObj('link'+IdCheckBox).style.color='';
        }
    else
        {
        getObj('link'+IdCheckBox).style.color=Couleur;
        }
    }


function ErreurGenerique(NomChamps)
    {
    getObj('ContainerErreur'+NomChamps).innerHTML='Vous n\'avez pas correctement rempli ce champs';
    }
    
function checkMail(Email)
    {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(Email))
	    {
	    return true;
	    }
	else
	    {
	    return false;
	    }
    }
    
function checkCP(cp)
    {
	var cpok = /^[0-9]{5}$/;
	if (cpok.test(cp))
	    {
	    return true;
	    }
	else
	    {
	    return false;
	    }
    }

function checkTel(tel)
    {
	var Telok = /^[0-9]{10}$/;
	if (Telok.test(tel))
	    {
	    return true;
	    }
	else
	    {
	    return false;
	    }
    }
    

function checknum(num)
    {
	var numok = /^[0-9]{2,7}$/;
	if (numok.test(num))
	    {
	    return true;
	    }
	else
	    {
	    return false;
	    }
    }
    
function checkSurface(surface)
    {
	var surfaceok = /^[0-9]{1,4}$/;
	if (surfaceok.test(surface))
	    {
	    return true;
	    }
	else
	    {
	    return false;
	    }
    }

function checkVille(ville)
    {
	var villeok = /^[a-zA-Z]/;
	if (villeok.test(ville))
	    {
	    return true;
	    }
	else
	    {
	    return false;
	    }
    }
    
function checkDescript(text)
    {
	var textok = /^[a-zA-Z] {1,300}$/;
	if (textok.test(text))
	    {
	    return true;
	    }
	else
	    {
	    return false;
	    }
    }
    function checkAlpha(txtalpha)
    {
    var alphaok = /^[a-zA-Z]/;
    if (alphaok.test(txtalpha))
        {
        return true;
        }
    else
        {
        return false;
        }
    }   
    
 
 function disableOu() {
    var l__inputOuSelect = document.getElementById("champs_rech_ou").getElementsByTagName("input")[0];
    l__inputOuSelect.style.backgroundColor = "#ddd";
    l__inputOuSelect.value = "";
    l__inputOuSelect.disabled = true;
 }
 
  function enableOu() {
    var l__inputOuSelect = document.getElementById("champs_rech_ou").getElementsByTagName("input")[0];
    l__inputOuSelect.style.backgroundColor = "#fff";
    l__inputOuSelect.disabled = false;
 }
 
 
 function souligneImmo() {
     var l__contrainteQuoi = document.getElementById("DivRadioButtonImmo").getElementsByTagName("label")[0];
     l__contrainteQuoi.style.textDecoration="underline";backgroundColor="red";
 }
 
  
  function contrainteMoteurRadioQuoiImmo() {
    var l__contrainteQuoiImmo = document.getElementById("DivRadioButtonImmo").getElementsByTagName("label")[0];
    var l__contrainteQuoiAuto = document.getElementById("DivRadioButtonAuto").getElementsByTagName("label")[0];
    var l__contrainteQuoiMoto = document.getElementById("DivRadioButtonMoto").getElementsByTagName("label")[0];
    l__contrainteQuoiImmo.style.textDecoration="underline";
    l__contrainteQuoiAuto.style.textDecoration="none";
    l__contrainteQuoiMoto.style.textDecoration="none";
 }
 
 function contrainteMoteurRadioQuoiAuto() {
    var l__contrainteQuoiImmo = document.getElementById("DivRadioButtonImmo").getElementsByTagName("label")[0];
    var l__contrainteQuoiAuto = document.getElementById("DivRadioButtonAuto").getElementsByTagName("label")[0];
    var l__contrainteQuoiMoto = document.getElementById("DivRadioButtonMoto").getElementsByTagName("label")[0];
    l__contrainteQuoiImmo.style.textDecoration="none";
    l__contrainteQuoiAuto.style.textDecoration="underline";
    l__contrainteQuoiMoto.style.textDecoration="none";
 }
 
 function contrainteMoteurRadioQuoiMoto() {
    var l__contrainteQuoiImmo = document.getElementById("DivRadioButtonImmo").getElementsByTagName("label")[0];
    var l__contrainteQuoiAuto = document.getElementById("DivRadioButtonAuto").getElementsByTagName("label")[0];
    var l__contrainteQuoiMoto = document.getElementById("DivRadioButtonMoto").getElementsByTagName("label")[0];
    l__contrainteQuoiImmo.style.textDecoration="none";
    l__contrainteQuoiAuto.style.textDecoration="none";
    l__contrainteQuoiMoto.style.textDecoration="underline";
 }
 
 function emptyIntuitif()
 {
    for (i=0; i<3; i++)
        document.getElementById("moteurRecherche").getElementsByTagName("input")[i].value = "";
 }


 function ValeurDefaut() { }
 ValeurDefaut.OnBlur = function(obj, valDefaut, oldClass) {
     if (obj != undefined) {
         if (obj.value == '') {
             obj.className = oldClass + " italicgray";
             obj.value = valDefaut;
         }
     }
 }

 ValeurDefaut.OnClick = function(obj, valDefaut, oldClass) {
     if (obj != undefined) {
         if (obj.value == valDefaut) {
             obj.className = oldClass;
             obj.value = '';
         }
     }
 } 

 function VerificateurMinMax(nameVarGlobal, idMin, idMax, valmin, valmax, unite, valVideMin, valVideMax, divAlerte, msgAlerte) {
    this.ID = nameVarGlobal;
    this.ChampMin = document.getElementById(idMin);
    this.ChampMax = document.getElementById(idMax);
    this.MinValue = valmin;
    this.MaxValue = valmax;
    this.ValVideMin = valVideMin;
    this.ValVideMax = valVideMax;
    this.ChampMin.IsFocus = 0;
    this.ChampMax.IsFocus = 0;
        
    this.Unite = unite;
    this.MsgAlerte = msgAlerte;

    this.OldClassNameMin = this.ChampMin.className;
    this.OldClassNameMax = this.ChampMax.className;

    this.DivAlerteTexte = "id" + divAlerte + "_texte";
    this.DivAlerte = PJPAPopinAlerte.ErreurFormulaire(divAlerte, "id" + divAlerte, "id" + divAlerte + "_texte", this.MsgAlerte, 50, 35, 185);
    this.ObjAlerteTexte = document.getElementById(this.DivAlerteTexte);
}

VerificateurMinMax.prototype.SetPositionAlerte = function(leftMin, leftMax, leftMiddle, top, width, isFlechG) {
	this.LeftMin = leftMin;
	this.LeftMax = leftMax;
	this.LeftMiddle = leftMiddle;
	this.Top = top;
	if (width != undefined) {
		this.Width = width;
	}
	else {
		this.Width = 200;
	}
	
	if (width != undefined) {
		$("#" + this.DivAlerteTexte).css("width", width);
	}

	if (isFlechG == 1) {
		var $alerte = this.DivAlerte.find(".alerte_hg");
		if ($alerte != undefined) {
			$alerte.attr("class", "alerte_bd");
		}
	}
}

VerificateurMinMax.prototype.MovePositionAlerte = function(left, top, width) {
	this.DivAlerte.css("left", left);
	this.DivAlerte.css("top", top);
	$("#" + this.DivAlerteTexte).css("width", width);
}

VerificateurMinMax.prototype.OnBlur = function(isMin) {
	if (isMin) {
		if (this.ChampMin.value == "" || this.ChampMin.value == this.ValVideMin) {
			this.ChampMin.className += " gray";
			this.ChampMin.value = this.ValVideMin;
		}
		this.ChampMin.IsFocus = 0;
	}
	else {
		if (this.ChampMax.value == "" || this.ChampMax.value == this.ValVideMax) {
			this.ChampMax.className += " gray";
			this.ChampMax.value = this.ValVideMax;

		}
		this.ChampMax.IsFocus = 0;
	}
}

VerificateurMinMax.prototype.OnFocus = function(isMin) {
	if (isMin) {
		if (this.ChampMin.value == this.ValVideMin) {
			this.ChampMin.value = "";
			this.ChampMin.className = this.OldClassNameMin;
		}
		this.ChampMin.IsFocus = 1;
	}
	else {
		if (this.ChampMax.value == this.ValVideMax) {
			this.ChampMax.value = "";
			this.ChampMax.className = this.OldClassNameMax;
		}
		this.ChampMax.IsFocus = 1;
	}
	$(this.DivAlerte).hide();
}

VerificateurMinMax.prototype.ShowAlerte = function() {
	setTimeout("showAlerte('" + this.ID + "');", 100);
}

function showAlerte(idObj) {
	var objetId = eval(idObj + ".DivAlerte");
	var ChampMin = eval(idObj + ".ChampMin");
	var ChampMax = eval(idObj + ".ChampMax");
	
	if (ChampMin.IsFocus == 0 && ChampMax.IsFocus == 0) {
		$(objetId).show();
	}
}

VerificateurMinMax.prototype.ClickOk = function(autoriseVide) {

	var strValMin = PJPACleanForNumber(this.ChampMin.value, this.Unite);
	var strValMax = PJPACleanForNumber(this.ChampMax.value, this.Unite);

	var okVal = true;

	var b_isVideOrDefautMin = (this.ChampMin.value == "" || this.ChampMin.value == this.ValVideMin);
	var b_isVideOrDefautMax = (this.ChampMax.value == "" || this.ChampMax.value == this.ValVideMax);

	if (b_isVideOrDefautMin) {
		strValMin = "";
	}

	if (b_isVideOrDefautMax) {
		strValMax = "";
	}

	if (!autoriseVide && b_isVideOrDefautMin && b_isVideOrDefautMax) {
		okVal = false;
		this.ObjAlerteTexte.innerHTML = this.MsgAlerte.toProperCase() + " minimum ou maximum ne peuvent &ecirc;tre vide.";
		this.MovePositionAlerte(this.LeftMiddle, this.Top, this.Width);
		this.ShowAlerte();
	}
	else if (!b_isVideOrDefautMin || !b_isVideOrDefautMax) {

		var b_DecimalMin = strValMin.indexOf(".") != -1 || strValMin.indexOf(",") != -1;
		var b_DecimalMax = strValMax.indexOf(".") != -1 || strValMax.indexOf(",") != -1;
		if (!b_isVideOrDefautMin && b_DecimalMin && !b_DecimalMax) {
			okVal = false;
			this.ObjAlerteTexte.innerHTML = this.MsgAlerte.toProperCase() + " minimum doit &ecirc;tre un nombre entier.";
			this.MovePositionAlerte(this.LeftMin, this.Top, this.Width);
			this.ShowAlerte();
		}
		else if (!b_isVideOrDefautMax && b_DecimalMax && !b_DecimalMin) {
			okVal = false;
			this.ObjAlerteTexte.innerHTML = this.MsgAlerte.toProperCase() + " maximum doit &ecirc;tre un nombre entier.";
			this.MovePositionAlerte(this.LeftMax, this.Top, this.Width);
			this.ShowAlerte();
		}
		else if (!b_isVideOrDefautMin && !b_isVideOrDefautMax && b_DecimalMax && b_DecimalMin) {
			okVal = false;
			this.ObjAlerteTexte.innerHTML = this.MsgAlerte.toProperCase() + " minimum et " + this.MsgAlerte + " maximum doivent &ecirc;tre des nombres entier.";
			this.MovePositionAlerte(this.LeftMiddle, this.Top, this.Width);
			this.ShowAlerte();
		}

		if (okVal) {

			var intValMin = PJPATryParseInt(strValMin, -1);
			var intValMax = PJPATryParseInt(strValMax, -1);

			var bIsCharMin = !b_isVideOrDefautMin && intValMin == -1 && this.ChampMin.value != "-1";
			var bIsCharMax = !b_isVideOrDefautMax && intValMax == -1 && this.ChampMax.value != "-1";

			if (bIsCharMin && !bIsCharMax) {
				okVal = false;
				this.ObjAlerteTexte.innerHTML = this.MsgAlerte + " minimum n'est pas un chiffre.";
				this.MovePositionAlerte(this.LeftMin, this.Top, this.Width);
				this.ShowAlerte();
			}
			else if (!bIsCharMin && bIsCharMax) {
				okVal = false;
				this.ObjAlerteTexte.innerHTML = this.MsgAlerte + " maximum n'est pas un chiffre.";
				this.MovePositionAlerte(this.LeftMax, this.Top, this.Width);
				this.ShowAlerte();
			}
			else if (bIsCharMin && bIsCharMax) {
				okVal = false;
				this.ObjAlerteTexte.innerHTML = this.MsgAlerte + " minimum et " + this.MsgAlerte + " maximum ne sont pas des chiffres.";
				this.MovePositionAlerte(this.LeftMiddle, this.Top, this.Width);
				this.ShowAlerte();
			}

			if (okVal) {

				var bInIntervalMin = (!b_isVideOrDefautMin && intValMin >= 0 && intValMin <= 999999999) || this.ChampMin.value != "-1";
				var bInIntervalMax = (!b_isVideOrDefautMax && intValMax >= 0 && intValMax <= 999999999) || this.ChampMax.value != "-1";
				if (!bInIntervalMin || !bInIntervalMax) {
					okVal = false;
					if (!bInIntervalMin && bInIntervalMax) {
						this.ObjAlerteTexte.innerHTML = this.MsgAlerte + " minimum doit &ecirc;tre compris entre " + this.MinValue + " et " + this.MaxValue + ".";
						this.MovePositionAlerte(this.LeftMin, this.Top, this.Width);
					}
					else if (bInIntervalMin && !bInIntervalMax) {
						this.ObjAlerteTexte.innerHTML = this.MsgAlerte + " maximum doit &ecirc;tre compris entre " + this.MinValue + " et " + this.MaxValue + ".";
						this.MovePositionAlerte(this.LeftMax, this.Top, this.Width);
					}
					else if (!bInIntervalMin && !bInIntervalMax) {
						this.ObjAlerteTexte.innerHTML = this.MsgAlerte + " minimum et " + this.MsgAlerte + " maximum doivent &ecirc;tre compris entre " + this.MinValue + " et " + this.MaxValue + ".";
						this.MovePositionAlerte(this.LeftMiddle, this.Top, this.Width);
					}

					this.ShowAlerte();
				}

				if (okVal && !b_isVideOrDefautMin && !b_isVideOrDefautMax && intValMin > intValMax) {
					okVal = false;
					var msg = this.MsgAlerte.split(' ');
					var sup = (msg[0] == "le" ? "au " : "&agrave; la ");
					this.ObjAlerteTexte.innerHTML = this.MsgAlerte + " maximum doit &ecirc;tre sup&eacute;rieur(e) " + sup + msg[1] + " minimum.";
					this.MovePositionAlerte(this.LeftMiddle, this.Top, this.Width);
					this.ShowAlerte();
				}
			}
		}
	}

	if (okVal) {
		return true;
	}
	
	return false;
}



/*function VerificateurLocalite(nameVarGlobal, secteur, idBtnValidation, divAlerte, champLocalite, msgDefaut) {
    this.ID = nameVarGlobal;
    this.Secteur = secteur;
    this.ChampLocalite = document.getElementById(champLocalite);
    this.MsgDefaut = msgDefaut;
    this.IsZappette = true;
    this.CheckRegion = true;

    this.OldClassNameLocalite = this.ChampLocalite.className;

    this.OnBlur();

    this.DivAlerteTexte = "id" + divAlerte + "_texte";
    this.DivAlerte = PJPAPopinAlerte.ErreurFormulaire(divAlerte, "id" + divAlerte, "id" + divAlerte + "_texte", this.MsgDefaut, 35, 55, 185);
    this.ObjAlerteTexte = document.getElementById(this.DivAlerteTexte);
   }*/

   function VerificateurLocalite(nameVarGlobal, secteur, idBtnValidation, divAlerte, champLocalite, ddlDistance, msgDefaut) {
   	this.ID = nameVarGlobal;
   	this.Secteur = secteur;
   	this.ChampLocalite = document.getElementById(champLocalite);
   	this.MsgDefaut = ddlDistance;
   	if (msgDefaut != undefined) {
   		this.MsgDefaut = msgDefaut;
   		
   	}
   	if (this.ddlDistance != '') {
   		this.ChampDistance = document.getElementById(ddlDistance);
   	}
   	
   	this.IsZappette = true;
   	this.CheckRegion = true;

   	this.OldClassNameLocalite = this.ChampLocalite.className;
   	if (this.ChampDistance != null) {
   		this.OldClassNameDistance = this.ChampDistance.className;
   	}

   	this.OnBlur();

   	this.DivAlerteTexte = "id" + divAlerte + "_texte";
   	this.DivAlerte = PJPAPopinAlerte.ErreurFormulaire(divAlerte, "id" + divAlerte, "id" + divAlerte + "_texte", this.MsgDefaut, 35, 55, 185);
   	this.ObjAlerteTexte = document.getElementById(this.DivAlerteTexte);
   }

VerificateurLocalite.prototype.SetIsZappette = function(isZappette) {
	this.IsZappette = isZappette;
}

VerificateurLocalite.prototype.SetCheckRegion = function(checkRegion) {
	this.CheckRegion = checkRegion;	
}

VerificateurLocalite.prototype.CheckRegion = function(left, top, width, isFlechG) {

	this.Left = left;
	this.Top = top;
	if (width != undefined) {
		this.Width = width;
	}
	else {
		this.Width = 200;
	}

	if (width != undefined) {
		$("#" + this.DivAlerteTexte).css("width", width);
	}

	if (isFlechG == 1) {
		var $alerte = this.DivAlerte.find(".alerte_hg");
		if ($alerte != undefined) {
			$alerte.attr("class", "alerte_bd");
		}
	}
	this.MovePositionAlerte(this.Left, this.Top, this.Width);
}

VerificateurLocalite.prototype.MovePositionAlerte = function(left, top, width) {
	this.DivAlerte.css("left", left);
	this.DivAlerte.css("top", top);
	$("#" + this.DivAlerteTexte).css("width", width);
}

VerificateurLocalite.prototype.OnBlur = function() {
	if (this.ChampLocalite.value == "" || this.ChampLocalite.value == this.MsgDefaut) {
		if (this.ChampLocalite.className.indexOf("italicgray") == -1) {
			this.ChampLocalite.className = this.OldClassNameLocalite + " italicgray";
		}
		this.ChampLocalite.value = this.MsgDefaut;
	}
}

VerificateurLocalite.prototype.OnFocus = function() {
	if (this.ChampLocalite.value == "" || this.ChampLocalite.value == this.MsgDefaut) {
        this.ChampLocalite.value = "";
        this.ChampLocalite.className = this.OldClassNameLocalite;
    }
    $(this.DivAlerte).hide();
}

function ButtonDistanceClickJS(txtBox, verifLoc, idButtonClick, idTxtBoxDist) {
	var MsgDefaut = eval(verifLoc + ".MsgDefaut");
	var ChampLocalite = txtBox;
	var ButtonClick = getObj(idButtonClick);
	var TxtBoxDist = getObj(idTxtBoxDist);
	
	if (ChampLocalite != undefined && ButtonClick != undefined) {
		if (ChampLocalite.value != "" && ChampLocalite.value != MsgDefaut || TxtBoxDist.value != "0" ) {
			ButtonClick.click();
		}
		else {
			eval(verifLoc + ".OnBlur();");
		}
	}
}

VerificateurLocalite.prototype.OnClick = function() {
	if (this.ChampLocalite.value == "" || this.ChampLocalite.value == this.MsgDefaut) {
		this.ChampLocalite.value = "";
		this.ChampLocalite.className = this.OldClassNameLocalite;
	}
	/*if (this.ChampLocalite.value == "" || this.ChampLocalite.value == this.MsgDefaut) {
	if (this.ChampLocalite.className.indexOf("italicgray") == -1) {
	this.ChampLocalite.className = this.OldClassNameLocalite + " italicgray";
	}
	this.ChampLocalite.value = this.MsgDefaut;
	}

	var value = this.ChampDistance.options[this.ChampDistance.selectedIndex].value;
	if (value == '0') {
	this.ChampDistance.className += this.OldClassNameLocalite + " italicgray";
	}*/

	var value = this.ChampDistance.value;
}

VerificateurLocalite.prototype.OnChange = function() {
	var value = this.ChampDistance.value;
	if (value == '0') {
		this.ChampDistance.className += this.OldClassNameLocalite + " italicgray";
	}
	$(this.DivAlerte).hide();
}

VerificateurLocalite.prototype.IsAllOk = function(testOk) {
    if (testOk) {
        this.IsLocaliteOk();
    }
}

VerificateurLocalite.prototype.IsLocaliteOk = function() {

	var value = '0';
	if (this.ChampDistance != undefined) {
		if (this.ChampDistance.value != undefined) {
			var value = this.ChampDistance.value;
		}		
	}
	if (this.ChampLocalite != undefined) {
		var textBoxValue = this.ChampLocalite.value;
	}
	var isOK = true;

	if ((value != '0') && (textBoxValue == '' || textBoxValue == this.MsgDefaut)) {
		this.ObjAlerteTexte.innerHTML = " Veuillez pr&eacute;ciser une ville, un d&eacute;partement ou une r&eacute;gion";
		$(this.DivAlerte).show();
		isOK = false;
		if (this.IsZappette) {
			HiddeWait();
		}
	}
	else if (value == '0') {
		if (this.Secteur == 'Immobilier') {
			if (textBoxValue == '' || textBoxValue == this.MsgDefaut) {
				this.ObjAlerteTexte.innerHTML = " Veuillez pr&eacute;ciser une ville, un d&eacute;partement ou une r&eacute;gion";
				$(this.DivAlerte).show();
				isOK = false;
				if (this.IsZappette) {
					HiddeWait();
				}
			}
		}
	}
	else {
		if (this.IsZappette) {
			var testInRegion = _pjpaRegionDictionaire.IsRegion(textBoxValue);
			if (textBoxValue == '' || textBoxValue == this.MsgDefaut || testInRegion) {
				this.ObjAlerteTexte.innerHTML = " Le crit&egrave;re \"dans un rayon de... \", ne fonctionne qu'avec une ville ou un d&eacute;partement ";
				$(this.DivAlerte).show();
				isOK = false;
				if (this.IsZappette) {
					HiddeWait();
				}
			}
		}
	}

	if (isOK) {
		if (this.IsZappette) {
			DisplayWait();
		}
		return true;
	}
	return false;
}


VerificateurLocalite.prototype.IsLocaliteCriteresAvancesOk = function(surfaceOK, prixminmaxOK) {
	var value = this.ChampDistance.value;
	var textBoxValue = this.ChampLocalite.value;
	var isOK = true;

	if (value != '0' && (textBoxValue == '' || textBoxValue == this.MsgDefaut)) {
		this.ObjAlerteTexte.innerHTML = " Veuillez pr&eacute;ciser une ville, un d&eacute;partement ou une r&eacute;gion";
		$(this.DivAlerte).show();
		isOK = false;
	}
	else if (value == '0') {
		if (this.Secteur == 'Immobilier') {
			if (textBoxValue == '' || textBoxValue == this.MsgDefaut) {
				this.ObjAlerteTexte.innerHTML = " Veuillez pr&eacute;ciser une ville, un d&eacute;partement ou une r&eacute;gion";
				$(this.DivAlerte).show();
				isOK = false;
			}
		}
	}
	else {
		if (this.IsZappette) {
			if (this.CheckRegion) {
				var testInRegion = _pjpaRegionDictionaire.IsRegion(textBoxValue);
				if (textBoxValue == '' || textBoxValue == this.MsgDefaut || testInRegion) {
					this.ObjAlerteTexte.innerHTML = " Le crit&egrave;re \"dans un rayon de... \", ne fonctionne qu'avec une ville ou un d&eacute;partement ";
					$(this.DivAlerte).show();
					isOK = false;
				}
			}
		}
	}

	if (isOK && surfaceOK && prixminmaxOK) {
		if (this.IsZappette) {
			DisplayWait();
		}
		return true;
	}
	return false;
}


function PJPAValeurDefaut() { 
}

PJPAValeurDefaut.OnFocus = function(obj, valDefaut) {
	if (obj.value == valDefaut) {
		obj.value = "";
	}
}

PJPAValeurDefaut.OnBlur = function(obj, valDefaut) {
	if (obj.value == "") {
		obj.value = valDefaut;
	}
}

function PJPAPopinAlerte() {}

PJPAPopinAlerte.ErreurFormulaire = function(divConteneur, id, idtexte, texteAlerte, left, top, width) {
    var doc = document.getElementById(divConteneur);

    var conteneur = document.createElement("DIV");

    var alerteDiv = document.createElement("DIV");
    alerteDiv.id = id;
    alerteDiv.style.top = top + "px";
    alerteDiv.style.left = left + "px";
    alerteDiv.className = "alerte_champ_requis alerte_champ_ou";

    var sousDiv = document.createElement("DIV");

    var alerteHg = document.createElement("DIV");
    alerteHg.className = "alerte_hg";

    var alerteTop = document.createElement("SPAN");
    alerteTop.className = "alerte_top";

    var alerteBottom = document.createElement("SPAN");
    alerteBottom.className = "alerte_bottom";

    var alertePointe = document.createElement("SPAN");
    alertePointe.className = "alerte_pointe";

    var texte = document.createElement("P");
    texte.id = idtexte;
    if (width != undefined) {
        texte.style.width = width + "px";
    }

    $(texte).html(texteAlerte);

    alerteHg.appendChild(alerteTop);
    alerteHg.appendChild(alerteBottom);
    alerteHg.appendChild(alertePointe);
    alerteHg.appendChild(texte);

    sousDiv.appendChild(alerteHg);
    alerteDiv.appendChild(sousDiv);
    conteneur.appendChild(alerteDiv);

    doc.innerHTML = conteneur.innerHTML;

    return $("#" + id);
 }

 PJPAPopinAlerte.ChangeCss = function(obj, newCss) {
 	var $alerte = $(obj).find(".alerte_hg");
 	if ($alerte != undefined) {
 		$alerte.attr("class", "alerte_" + newCss);
 	}
 }


function PJPACleanForNumber(input, unite) {
    var listOfAccentedLetters = [unite, ' ', String.fromCharCode(8364), String.fromCharCode(160)];
    var listOfUnAccentedLetters = ['', '', '', ''];

    var l__input = input;
    if (l__input != '') {
        for (var i = 0; i < listOfAccentedLetters.length; i++) {
            if (l__input.indexOf(listOfAccentedLetters[i]) != -1) {
                if (listOfAccentedLetters[i] == '(' || listOfAccentedLetters[i] == ')') {
                    var reg = new RegExp("(\\" + listOfAccentedLetters[i] + ")", "g");
                }
                else {
                    var reg = new RegExp(listOfAccentedLetters[i], "gi");
                }

                l__input = l__input.replace(reg, listOfUnAccentedLetters[i]);
            }
        }
    }
    return l__input;
}

function ValideAllIsOk(TagXiti, param1) {
	var b_ok = true;
	for (var i = 1; i < ValideAllIsOk.arguments.length; i++) {
		b_ok = b_ok && ValideAllIsOk.arguments[i];
	}
	if (b_ok && TagXiti != undefined && TagXiti != "") {
		xt_med('C', '0', TagXiti, 'N');
	}
	return b_ok;
}

function ValideAllIsOkWithXiti(xiti, bool) {
	if (bool) {
		xt_med('C', '0', xiti, 'N');
	}
	return bool;
}


function DemandeInfoChange(obj, idsecteur, msgBox, info) {	
	var msg = "" + info;
	if (idsecteur == 1) {
		if (obj.selectedIndex == 0) {
			msg = "Bonjour, \n\n Je d%E9sire prendre un rendez-vous pour visiter le bien " + info + " visible sur annoncesjaunes.fr.";
		}
		else if (obj.selectedIndex == 1) {
			msg = "Bonjour, \n\n Je d%E9sire avoir plus d'informations concernant le bien " + info + " visible sur annoncesjaunes.fr.";
		}
		else if (obj.selectedIndex == 2) {
			msg = "";
		}
	}
	else {
		if (obj.selectedIndex == 0) {
			msg = "Bonjour, \n\n Je d%E9sire prendre un rendez-vous pour un essai du v%E9hicule " + info + " visible sur annoncesjaunes.fr.";
		}
		else if (obj.selectedIndex == 1) {
			msg = "Bonjour, \n\n Je d%E9sire avoir plus d'informations concernant le v%E9hicule " + info + " visible sur annoncesjaunes.fr.";
		}
		else if (obj.selectedIndex == 2) {
			msg = "";
		}
	}

	$("#" + msgBox).attr("value", unescape(msg));

}

function msgErreur(idObj, idObjMsg, msg) {
	if (msg != undefined && msg != "") {
		var obj = getObj(idObj);
		var objMsg = getObj(idObjMsg);
		//$(objMsg).html(msg);
		$(obj).show();
		HiddeWait();
	}
	else {
		var obj = getObj(idObj);
		$(obj).hide();
	}
}

function FctKeyPressEnter(idValidation) {
	var _EventKeycode = event.keyCode;
	
	if (idValidation != '' && idValidation != undefined && idValidation != null) {
		if (_EventKeycode == 13 || _EventKeycode == 3) {
			getObj(idValidation).click();
			return true;
		}
	}
}

// Fin Formulaire.js



/*---- Home_page.js ----*/

//Used in Mot de passe oublie
function VideInput(Obj,ValueDep)
{ 
    if(Trim(Obj.value)==Trim(ValueDep))
    {
    Obj.value=''; 
    }            
}

//Ajouter par jjb pour recherche.js
function Trim(STRING){
    while(STRING.charAt(0)==" "){
    STRING = STRING.replace(STRING.charAt(0),"");
    }
    while(STRING.charAt((STRING.length -1))==" "){
    STRING = STRING.substring(0,STRING.length-1);
    }
    return STRING;
}
 
// Used in all web site  
function WriteChargementEnCours()
{
if(getObj('ChargementEnCour')!=null)
    {
    getObj('ChargementEnCour').style.height=document.body.clientHeight;
    SetToXY('ChargementEnCour',0,document.body.scrollTop);
    afficher('ChargementEnCour');
    }
}   
    
function CacheAlertPjpa()
    {
    //GUBOI we must empty the container, otherwise modifications done on it will only be seen the second time it is displayed.
    getObj('ContenerAlertPjpa').innerHTML = "";
    cacher('ContenerAlertPjpa');
    SetToXY('ContenerAlertPjpa',-1000,-1000)

    //Div which avoids clicks when the alert is operationnal
    if (getObj("AlertPjpaDivAntiClick"))
        getObj("AlertPjpaDivAntiClick").style.display="none";
}

function AlertPjpa(Title, NameLelay, Top, Left) {
	if (!getObj(NameLelay)) {
		WriteAlertXHR(Title, NameLelay);
	}
	else {
		WriteAlert(Title, NameLelay);
	}
	
    if(Left!=false){
        LeftAlert=Left;
    }
    else{        
        LeftAlert=222;        
    }       
    
    if(Top!=false){ 
        TopAlert=Top;
    }
    else{
        TopAlert=93;
       }     
    
    HeightAlert = document.getElementById('ContenerAlertPjpa').clientHeight;
    if (document.body.scrollTop + document.body.clientHeight < TopAlert + HeightAlert) { 
        TopAlert=document.body.scrollTop + document.body.clientHeight - HeightAlert;
    }            
    if (document.body.scrollTop > TopAlert) { 
        TopAlert=document.body.scrollTop;
    }
    if (TopAlert<93) TopAlert=93;
    if (getObj('PosXYPage') && parent && parent.location.href.indexOf('annoncesjaunes.fr') != -1) {
    	SetToXY('ContenerAlertPjpa', getLeft(getObj('PosXYPage')) + LeftAlert, getTop(getObj('PosXYPage')) + TopAlert);
    }
    else {
    	if (NameLelay == "AccesOubliPro") {
    		SetToXY('ContenerAlertPjpa', 428, 182);
    	}
    	else {
    		SetToXY('ContenerAlertPjpa', 350, 80);
    	}
    }   
    if (NameLelay == 'Media') {
        WidthAlert = document.getElementById('ContenerAlertPjpa').clientWidth;
        if (WidthAlert > 600) document.getElementsByName('VisuPhoto')[1].width = 570;
    }
    afficher('ContenerAlertPjpa');
    //Div which avoids clicks when the alert is operationnal
    if (getObj("AlertPjpaDivAntiClick"))
        getObj("AlertPjpaDivAntiClick").style.display="block";
}   
     
function ViewPhotoXHR(UrlMedia,Title)
{
    var XHR = CreateXHR();
    XHR.onreadystatechange=function() {
        InsertAlertXHR(XHR, Title);
    }
    XHR.open("POST","/_XMLHttpRequest/MasterPageGlobal/Layers.aspx", true);
    XHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    XHR.send("IdLayer=Media&UrlMedia="+UrlMedia+"&ImageTitle="+Title);
    // 341,13
    LeftAlert=222;
    TopAlert=93;        
    
    HeightAlert = document.getElementById('ContenerAlertPjpa').clientHeight;
    if (document.body.scrollTop + document.body.clientHeight < TopAlert + HeightAlert) { 
        TopAlert=document.body.scrollTop + document.body.clientHeight - HeightAlert;
    }            
    if (document.body.scrollTop > TopAlert) { 
        TopAlert=document.body.scrollTop;
    }
    if (TopAlert<93) TopAlert=93;
    if (getObj('PosXYPage')&&parent&&parent.location.href.indexOf('annoncesjaunes.fr') != -1) {
        SetToXY('ContenerAlertPjpa',getLeft(getObj('PosXYPage'))+LeftAlert,getTop(getObj('PosXYPage'))+TopAlert);
    }
    else {
        SetToXY('ContenerAlertPjpa',400,580);
    }    
    WidthAlert = document.getElementById('ContenerAlertPjpa').clientWidth;
    if (WidthAlert > 600) {
        document.getElementsByName('VisuPhoto')[1].width = 570;
    }
    afficher('ContenerAlertPjpa');
    
    //Div which avoids clicks when the alert is operationnal
    if (getObj("AlertPjpaDivAntiClick"))
        getObj("AlertPjpaDivAntiClick").style.display="block";
}

    
function WriteAlertXHR(Title,NameLelay)
    {

    var XHR = CreateXHR();
    //XHR.onreadystatechange=AccesOublie;
    XHR.onreadystatechange=function() {
        InsertAlertXHR(XHR, Title);
    }
    XHR.open("POST","/_XMLHttpRequest/MasterPageGlobal/Layers.aspx", true);
    XHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    XHR.send("IdLayer="+NameLelay);
   }
   
   
   function InsertAlertXHR(XHR, Title)
   { 
       if(XHR.readyState == 4)
       {
       		var data = XHR.responseText;
       		HtmlAlert = "";

            HtmlAlert='<table cellpadding="0" cellspacing="0" border="0">';
            HtmlAlert+='    <tr>';
            HtmlAlert+='    <td style="height:9px;width:11px;"><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaTopLeft.png"  alt=""/></td>';
            HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaTopCentre.png);"><img src="/_Images/pix.gif" alt="" /></td>';
            HtmlAlert+='    <td style="width:11px;"><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaTopRight.png" alt=""/></td>';
            HtmlAlert+='    </tr><tr>';
            HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaLeft.png);"></td>';
            HtmlAlert+='    <td style="background-color:#ffffff;" >';
            HtmlAlert+='    <table cellpadding="0" cellspacing="0" border="0">';
            HtmlAlert+='        <tr>';
            HtmlAlert+='        <td style="height:10px;" colspan="3"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
            HtmlAlert+='        </tr>';
            HtmlAlert+='        <tr>';
            HtmlAlert+='        <td style="width:5px;"><img src="/_Images/pix.gif" width="5" height="1" alt="" /></td>';
            HtmlAlert+='        <td class="txtorange14"><b>'+Title+'</b></td>';
            HtmlAlert+='        <td style="padding-right:5px;" align=right><img src="/_Images/Pictos/picto_fermer.gif" alt="" onclick="CacheAlertPjpa();" width="11" height="11" style="cursor:pointer"/></td>';
            HtmlAlert+='        </tr><tr>';
            HtmlAlert+='        <td style="height:9px;" colspan="3"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
            HtmlAlert+='        </tr><tr>';
            HtmlAlert+='        <td style="width:5px;"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
            HtmlAlert+='        <td style="text-align:center;background-color:#EDEDED"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
            HtmlAlert+='        <td style="width:5px;"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
            HtmlAlert+='        </tr><tr>';
            HtmlAlert+='        <td></td>';
            HtmlAlert+='        <td colspan=2 style="width:390px">'+data+'</td>';
            HtmlAlert+='        </tr>';
            HtmlAlert+='    </table>';
            HtmlAlert+='    </td>';
            HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaRight.png);"></td>';
            HtmlAlert+='    </tr><tr>';
            HtmlAlert+='    <td style="height:11px;"><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaBottomLeft.png"  alt=""/></td>';
            HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaBottomCentre.png);"><img src="/_Images/pix.gif" alt="" /></td>';
            HtmlAlert+='    <td><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaBottomRight.png" alt=""/></td>';
            HtmlAlert+='    </tr>';
            HtmlAlert += '</table>';
		/*
			HtmlAlert += '<div class="Popup400_c">';
			HtmlAlert += '<div class="Popup400_h"></div>';
			HtmlAlert += '<div class="Popup400_b"></div>';
			HtmlAlert += '<div style="width: 378px;" class="popup">';
			HtmlAlert += '<div style="border: 1px solid rgb(204, 204, 209); background-color: White; position: relative; width: 378px; min-height: 156px;">';
			HtmlAlert += '<div class="hg"></div><div class="hd"></div><div class="bg"></div><div class="bd"></div>';
			HtmlAlert += '<div style="width: 358px;" class="Contenu">';
			HtmlAlert += '<a href="javascript:CacheAlertPjpa();" class="fermer_popup" title="Fermer" >';
			HtmlAlert += 'Fermer <img alt="Fermer" src="/_Images/commun/picto_fermer.gif">';
			HtmlAlert += '</a>';
			HtmlAlert += '<h3 class="Titre">' + Title + '</h3>';
			HtmlAlert += '</div>';
			HtmlAlert += '<div class="the_breaker"></div>';
			HtmlAlert += '<div class="Contenu" >';
			HtmlAlert += data;
			HtmlAlert += '</div>';							
			HtmlAlert += '<div class="the_breaker"></div>';
			HtmlAlert += '</div>';
			HtmlAlert += '</div>';
			HtmlAlert += '</div>';
			HtmlAlert += '</div>';
            */
            if(typePage == 'HomePage')
            {
                HeightInput='13px;';
            }
            else
            {
                HeightInput='18px;';
            }       
            getObj('ContenerAlertPjpa').innerHTML=HtmlAlert.replace('[INPUT]','<input type="text" name="EmailAccesOublie" value="Votre e-mail" class="InputAccesOubli" style="height:'+HeightInput+'" onfocus="VideInput(this,\'Votre e-mail\');"  />');
       }
      }  
    
    function WriteAlert(Title,NameLelay) {
/*
    	HtmlAlert += '<div class="Popup400_c">';
    	HtmlAlert += '<div class="Popup400_h"></div>';
    	HtmlAlert += '<div class="Popup400_b"></div>';
    	HtmlAlert += '<div style="width: 378px;" class="popup">';
    	HtmlAlert += '<div style="border: 1px solid rgb(204, 204, 209); background-color: White; position: relative; width: 378px; min-height: 156px;">';
    	HtmlAlert += '<div class="hg"></div><div class="hd"></div><div class="bg"></div><div class="bd"></div>';
    	HtmlAlert += '<div style="width: 358px;" class="Contenu">';
    	HtmlAlert += '<a href="javascript:CacheAlertPjpa();" class="fermer_popup" title="Fermer" >';
    	HtmlAlert += 'Fermer <img alt="Fermer" src="/_Images/commun/picto_fermer.gif">';
    	HtmlAlert += '</a>';
    	HtmlAlert += '<h3 class="Titre">' + Title + '</h3>';
    	HtmlAlert += '</div>';
    	HtmlAlert += '<div class="the_breaker"></div>';
    	HtmlAlert += '<div class="Contenu" >';
    	HtmlAlert += getObj(NameLelay).innerHTML;
    	HtmlAlert += '</div>';
    	HtmlAlert += '<div class="the_breaker"></div>';
    	HtmlAlert += '</div>';
    	HtmlAlert += '</div>';
    	HtmlAlert += '</div>';
    	HtmlAlert += '</div>';  */
    	  
        HtmlAlert='<table cellpadding="0" cellspacing="0" border="0">';
        HtmlAlert+='    <tr>';
        HtmlAlert+='    <td style="height:9px;width:11px;"><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaTopLeft.png"  alt=""/></td>';
        HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaTopCentre.png);"><img src="/_Images/pix.gif" alt="" /></td>';
        HtmlAlert+='    <td style="width:11px;"><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaTopRight.png" alt=""/></td>';
        HtmlAlert+='    </tr><tr>';
        HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaLeft.png);"></td>';
        HtmlAlert+='    <td style="background-color:#ffffff;" >';
        HtmlAlert+='    <table cellpadding="0" cellspacing="0" border="0">';
        HtmlAlert+='        <tr>';
        HtmlAlert+='        <td style="height:10px;" colspan="3"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
        HtmlAlert+='        </tr>';
        HtmlAlert+='        <tr>';
        HtmlAlert+='        <td style="width:5px;"><img src="/_Images/pix.gif" width="5" height="1" alt="" /></td>';
        HtmlAlert+='        <td class="txtorange14"><b>'+Title+'</b></td>';
        HtmlAlert+='        <td style="padding-right:5px;" align=right><img src="/_Images/Pictos/picto_fermer.gif" alt="" onclick="CacheAlertPjpa();" width="11" height="11"  style="cursor:pointer"/></td>';
        HtmlAlert+='        </tr><tr>';
        HtmlAlert+='        <td style="height:9px;" colspan="3"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
        HtmlAlert+='        </tr><tr>';
        HtmlAlert+='        <td style="width:5px;"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
        HtmlAlert+='        <td style="text-align:center;background-color:#EDEDED"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
        HtmlAlert+='        <td style="width:5px;"><img src="/_Images/pix.gif" width="1" height="1" alt="" /></td>';
        HtmlAlert+='        </tr><tr>';
        HtmlAlert+='        <td></td>';
        HtmlAlert+='        <td colspan=2 style="width:390px">'+getObj(NameLelay).innerHTML+'</td>';
        HtmlAlert+='        </tr>';
        HtmlAlert+='    </table>';
        HtmlAlert+='    </td>';
        HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaRight.png);"></td>';
        HtmlAlert+='    </tr><tr>';
        HtmlAlert+='    <td style="height:11px;"><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaBottomLeft.png"  alt=""/></td>';
        HtmlAlert+='    <td style="background-image: url(/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaBottomCentre.png);"><img src="/_Images/pix.gif" alt="" /></td>';
        HtmlAlert+='    <td><img src="/_Images/MasterPageGlobal/AlertPjpa/AlertPjpaBottomRight.png" alt=""/></td>';
        HtmlAlert+='    </tr>';
        HtmlAlert+='</table>';
        
        if(typePage == 'HomePage')
        {
            HeightInput='13px;';
        }
        else
        {
            HeightInput='18px;';
        }       
        getObj('ContenerAlertPjpa').innerHTML=HtmlAlert.replace('[INPUT]','<input type="text" name="EmailAccesOublie" value="Votre e-mail" class="InputAccesOubli" style="height:'+HeightInput+'" onfocus="VideInput(this,\'Votre e-mail\');"  />');
       
    }  
////////////////////////////////////////////////////////////////////////////

//////////////////////DEBUT SCRIPT HOME PAGE/////////////////////////////////    
function ViewTypeHomePage(Type)
    {
        var depot = getObj('ContenerDepotAnnonce');
        var consult = getObj('ContenerConsulteAnnonce');
    if(Type=='Consulte')
        {
        consult.style.display="inline";
        consult.style.visibility="visible";
        depot.style.display="none";
        depot.style.visibility="hidden";
        }
    else
        {
        depot.style.display="inline";
        depot.style.visibility="visible";
        consult.style.display="none";
        consult.style.visibility="hidden";
        }    
     }

//////////////////////////////////////////////////////////////////////////////    

/*---- Infobulle.js ----*/

// --- Infobulle ---
function GetScrollLeft()
{
    if (document.documentElement && !document.documentElement.scrollLeft)
        return document.documentElement.scrollLeft; // IE6 +4.01 but no scrolling going on
    else if (document.documentElement && document.documentElement.scrollLeft)
        return document.documentElement.scrollLeft; // IE6 +4.01 and user has scrolled
    else if (document.body && document.body.scrollLeft)
        return document.body.scrollLeft;
}

function GetScrollTop()
{
    if (document.documentElement && !document.documentElement.scrollTop)
        return document.documentElement.scrollTop  // IE6 +4.01 but no scrolling going on
    else if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollTop // IE6 +4.01 and user has scrolled
    else if (document.body && document.body.scrollTop)
        return document.body.scrollTop
}

var MousePosX;
var MousePosY;
var xOffset;
var yOffset;
function InitBulle() {
    MousePosX = 0;
    MousePosY = 0;
    xOffset = 5;
    yOffset = 20;
    document.write('<div id="bulle" class="alt_conteneurInfoBulle"></div>');
    document.onmousemove = getMousePos;
}

function getMousePos(e) {
  if (document.all) {
        MousePosX = event.clientX + GetScrollLeft();
        MousePosY = event.clientY + GetScrollTop();        
  }
  else {
        MousePosX = e.pageX;
        MousePosY = e.pageY;
  }
}

function HideBulle() {
        clearTimeout(TimerPositionneBulle);
        var bulle = document.getElementById("bulle");
        if (bulle)
            bulle.style.visibility = 'hidden';
}

var TimerPositionneBulle = "";
function AffBulle(texte, width) {
        contenu = '<table cellspacing="0" cellpadding="3" class="alt_infoBulle" ' 
        if (width > 0)
            contenu += 'style="width:' + width + 'px"';
        contenu += ' ><tr><td class="orange">' + texte + '</td></tr></table>';

        var bulle = document.getElementById("bulle");
        if (bulle)
        {
            bulle.innerHTML = contenu;
            bulle.style.visibility = 'visible';
        }
        PositionneBulle();
}

function PositionneBulle()
{
    var finalMousePosX = MousePosX - xOffset;
    if (finalMousePosX<0) 
        finalMousePosX=0;
    
    var bulle = document.getElementById("bulle");
    if (bulle)
    {
        bulle.style.top = MousePosY + yOffset + 'px';
        bulle.style.left = finalMousePosX + 'px';
    }
    TimerPositionneBulle = setTimeout("PositionneBulle()", 20);
}

/*---- InitControl.js ----*/

function InitControl() {}

InitControl.prototype.SetInputChecked = function(id, value) {
	var elt = $('#' + id);

	if (value == true) {
		elt.attr('checked', 'checked');
	} else {
		elt.removeAttr('checked');
	}
}

var _initControl = new InitControl();

/*---- les_plus_recherches.js ----*/

/*******************LIENS LES PLUS RECHERCHES EN HOME PAGE ACCUEIL, IMMO, AUTO, MOTO **********************************/

function AfficheLiensAccueil(div1, secteur, btn) {
	if (secteur == "immo") {
		SetClassName(getObj('recherche_accueil_immo'), "invisible");
		SetClassName(getObj('recherche_accueil_immo_vente'), "invisible");
		SetClassName(getObj('recherche_accueil_immo_location'), "invisible");
		SetClassName(getObj('recherche_accueil_immo_dept'), "invisible");
		SetClassName(getObj('recherche_accueil_immo_ville'), "invisible");

		getObj('btnRechImmo').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechImmoVente').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechImmoLocation').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechImmoDept').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechImmoVille').src = "/_Images/Fleches/PlusGris.png";
	}
	if (secteur == "auto") {
		SetClassName(getObj('recherche_accueil_auto_marques'), "invisible");
		SetClassName(getObj('recherche_accueil_auto_modeles'), "invisible");
		SetClassName(getObj('recherche_accueil_auto_carrosseries'), "invisible");

		getObj('btnRechAutoMarque').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechAutoModele').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechAutoCarr').src = "/_Images/Fleches/PlusGris.png";
	}
	if (secteur == "moto") {
		SetClassName(getObj('recherche_accueil_moto_modeles'), "invisible");
		SetClassName(getObj('recherche_accueil_moto_marques'), "invisible");
		SetClassName(getObj('recherche_accueil_moto_cylindrees'), "invisible");
		SetClassName(getObj('recherche_accueil_moto_categories'), "invisible");

		getObj('btnRechMotoMarque').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechMotoModele').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechMotoCyl').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechMotoCat').src = "/_Images/Fleches/PlusGris.png";

	}
	SetClassName(getObj(div1), "visible");

	btn.src = "/_Images/Fleches/MoinsGris.png";
}


/*
function selectLienLesPlusRechImmo(onglet_name) {
    InitOngletLienLesPlusRechercher();
    if (onglet_name == "rech_onglet_immo_vente") {
        getObj("rech_onglet_immo_vente").className = "rech_onglet_immo_vente selected";
        getObj("lien_plus_recherche_immo_vente").className = "visible";
    }
    else if (onglet_name == "rech_onglet_immo_location") {
        getObj("rech_onglet_immo_location").className = "rech_onglet_immo_location selected";
        getObj("lien_plus_recherche_immo_location").className = "visible";
    }
    CacherLienLesPlusRech(onglet_name);
}

function selectLienLesPlusRechAccueil(onglet_name, div_name, classe) {
    ToutCacherLienLesPlusRech();
    getObj(onglet_name).className = classe + " selected";
    getObj(div_name).className = "visible";
    InitOngletLienLesPlusRechercher();
}

function AfficheLiensAccueil(div1, secteur, btn) {
    if (secteur == "immo") {
        SetClassName(getObj('recherche_accueil_immo'), "invisible");
        SetClassName(getObj('recherche_accueil_immo_vente'), "invisible");
        SetClassName(getObj('recherche_accueil_immo_location'), "invisible");
        SetClassName(getObj('recherche_accueil_immo_dept'), "invisible");

        getObj('btnRechImmo').src = "/_Images/Fleches/PlusGris.png";
        getObj('btnRechImmoVente').src = "/_Images/Fleches/PlusGris.png";
        getObj('btnRechImmoLocation').src = "/_Images/Fleches/PlusGris.png";
        getObj('btnRechImmoDept').src = "/_Images/Fleches/PlusGris.png"; 
    }
    if (secteur == "auto") {
		SetClassName(getObj('recherche_accueil_auto_marques'), "invisible");
		SetClassName(getObj('recherche_accueil_auto_modeles'), "invisible");
		SetClassName(getObj('recherche_accueil_auto_carrosseries'), "invisible");

		getObj('btnRechAutoMarque').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechAutoModele').src = "/_Images/Fleches/PlusGris.png";
		getObj('btnRechAutoCarr').src = "/_Images/Fleches/PlusGris.png";
    }
    if (secteur == "moto") {
        SetClassName(getObj('recherche_accueil_moto_modeles'), "invisible");
        SetClassName(getObj('recherche_accueil_moto_marques'), "invisible");
        SetClassName(getObj('recherche_accueil_moto_categories'), "invisible");

        getObj('btnRechMotoMarque').src = "/_Images/Fleches/PlusGris.png";
        getObj('btnRechMotoModele').src = "/_Images/Fleches/PlusGris.png";
        getObj('btnRechMotoCat').src = "/_Images/Fleches/PlusGris.png";
        
    }
    SetClassName(getObj(div1), "visible");
    
    btn.src = "/_Images/Fleches/MoinsGris.png";
}

function AfficheLiensLesPlusRech(div1, secteur, btn) {

    if (secteur == "auto") {
        SetClassName(getObj('auto_les_plus_recherche_par_modeles'), "invisible");
        SetClassName(getObj('auto_les_plus_recherche_par_carrosseries'), "invisible");
    }
    else
    {
        SetClassName(getObj('moto_les_plus_recherche_par_modeles'), "invisible");
        SetClassName(getObj('moto_les_plus_recherche_par_categories'), "invisible");
        SetClassName(getObj('moto_les_plus_recherche_par_cylindrees'), "invisible");
    }  
    
    SetClassName(getObj(div1), "visible");
}

function ToutCacherLienLesPlusRech() {

    RestoreClassNameWithID(getObj("rech_onglet_immo"), "rech_onglet_immo");
    RestoreClassNameWithID(getObj("rech_onglet_auto"), "rech_onglet_auto");
    RestoreClassNameWithID(getObj("rech_onglet_moto"), "rech_onglet_moto");
    RestoreClassNameWithID(getObj("rech_onglet_emploi"), "rech_onglet_service");
    RestoreClassNameWithID(getObj("rech_onglet_service"), "rech_onglet_service");

    RestoreClassNameWithID(getObj("rech_onglet_immo_vente"), "rech_onglet_immo_vente");
    RestoreClassNameWithID(getObj("rech_onglet_immo_location"), "rech_onglet_immo_location");
    RestoreClassNameWithID(getObj("rech_onglet_immo_villes"), "rech_onglet_immo_villes");

    SetClassName(getObj("lien_plus_recherche_immo"), "invisible");
    SetClassName(getObj("lien_plus_recherche_auto"), "invisible");
    SetClassName(getObj("lien_plus_recherche_moto"), "invisible");
    SetClassName(getObj("lien_plus_recherche_emploi"), "invisible");
    SetClassName(getObj("lien_plus_recherche_service"), "invisible");
    SetClassName(getObj("lien_plus_recherche_immo_vente"), "invisible");
    SetClassName(getObj("lien_plus_recherche_immo_location"), "invisible");
    SetClassName(getObj("lien_plus_recherche_immo_villes"), "invisible");
} 

function InitOngletLienLesPlusRechercher() {
    CacheOngletSiAucunLien(getObj("lien_plus_recherche_immo"), getObj("rech_onglet_immo"));
    CacheOngletSiAucunLien(getObj("lien_plus_recherche_auto"), getObj("rech_onglet_auto"));
    CacheOngletSiAucunLien(getObj("lien_plus_recherche_moto"), getObj("rech_onglet_moto"));
    CacheOngletSiAucunLien(getObj("lien_plus_recherche_emploi"), getObj("rech_onglet_emploi"));
    CacheOngletSiAucunLien(getObj("lien_plus_recherche_service"), getObj("rech_onglet_service"));

    CacheOngletSiAucunLien(getObj("lien_plus_recherche_immo_vente"), getObj("rech_onglet_immo_vente"));
    CacheOngletSiAucunLien(getObj("lien_plus_recherche_immo_location"), getObj("rech_onglet_immo_location"));
    CacheOngletSiAucunLien(getObj("lien_plus_recherche_immo_villes"), getObj("rech_onglet_immo_villes"));
}

function CacheOngletSiAucunLien(objDiv, objOnglet) {
    if (TestVideDIV(objDiv) == 0) {
        SetClassName(objOnglet, "invisible");
    }
}

function TestVideDIV(obj) {
    if (obj != undefined) {
        if (obj.innerHTML.length < 50) {
            return 0;
        }
        else
            return 1;
    }
    return 2;
}

function RestoreClassNameWithID(obj, classe) {
    if (obj != undefined) {
        if (classe == "") {
            obj.className = obj.id;
        }
        else
            obj.className = classe;
    }
}
*/

/*******************FIN LIENS LES PLUS RECHERCHES EN HOME PAGE ACCUEIL, IMMO, AUTO, MOTO **********************************/

/*---- Library.js ----*/

// Library.js
var focusNom = false;
function setFocusTextBox(NomTextBox)
{
    if(!focusNom)
    {
        getObj(NomTextBox).focus();
        focusNom = true;
    }
}

function ConfirmChangementMail(textBox_Email, EmailConnected ) 
{
    var valeurSaisie = getObj(textBox_Email).value;
    if(valeurSaisie != EmailConnected)
    {
        if (confirm("L'Email que vous avez saisi pour votre alerte n'est pas celui de votre compte. \nVoulez-vous changer l�e-mail associ� � votre compte ?")) 
        {
           return true;
        }
        else
        {
            getObj(textBox_Email).value = "";
            return false;
        }        
    }
    return true;
}

function onMouseOverEmployeur()
{
    var blocTitre= getObj('bloc_titre');
    var blocPrestatataire= getObj('bloc_prestataire');
    var prestataireStyle = blocPrestatataire.className;
    
    if(prestataireStyle =="titre_secteur_prestataire_selected")
        blocTitre.className ="employeurHighlight";
    else    
       blocTitre.className ="employeur";   
}

function onMouseOutEmployeur()
{
    var blocTitre= getObj('bloc_titre');
    var titreDisplay = blocTitre.style.display;
    if(blocTitre != undefined)
        blocTitre.className ="employeur";
}

function onMouseOverPrestataire()
{
    var blocTitre= getObj('bloc_titre_prestataire');
    var blocEmployeur = getObj('bloc_employeur');
    var employeurStyle = blocEmployeur.className;
    
    if(employeurStyle == "titre_secteur_employeur_selected")
        blocTitre.className ="prestataireHighlight";
    else
        blocTitre.className ="prestataire";
}

function onMouseOutPrestataire()
{
    var blocTitre= getObj('bloc_titre_prestataire');
    var titreDisplay = blocTitre.style.display;
    if(blocTitre != undefined)
        blocTitre.className ="prestataire";

}


function changeEtiquetteDPE(textbox, obj) 
{
    var valeur = parseInt(getObj(textbox).value);

    if (valeur <= 50) 
    {
        getObj(obj).options[1].selected = true;
    }
    else if (valeur >= 51 && valeur <= 90) 
    {
        getObj(obj).options[2].selected = true;
    }
    else if (valeur >= 91 && valeur <= 150)
    {
        getObj(obj).options[3].selected = true;
    }
    else if (valeur >= 151 && valeur <= 230)
    {
        getObj(obj).options[4].selected = true;
    }
    else if (valeur >= 230 && valeur <= 330)
    {
        getObj(obj).options[5].selected = true;
    }
    else if (valeur >= 331 && valeur <= 450)
    {
        getObj(obj).options[6].selected = true;
    }
    else if (valeur >= 451)
    {
        getObj(obj).options[7].selected = true;
    }
}

function changeEtiquetteGES(textbox, obj) 
{
    var valeur = parseInt(getObj(textbox).value);

    if (valeur <= 5) 
    {
        getObj(obj).options[1].selected = true;
    }
    else if (valeur >= 6 && valeur <= 10) 
    {
        getObj(obj).options[2].selected = true;
    }
    else if (valeur >= 11 && valeur <= 20) 
    {
        getObj(obj).options[3].selected = true;
    }
    else if (valeur >= 20 && valeur <= 35) 
    {
        getObj(obj).options[4].selected = true;
    }
    else if (valeur >= 36 && valeur <= 55) 
    {
        getObj(obj).options[5].selected = true;
    }
    else if (valeur >= 56 && valeur <= 80) 
    {
        getObj(obj).options[6].selected = true;
    }
    else if (valeur >= 81) 
    {
        getObj(obj).options[7].selected = true;
    }
}


function selectEmployeur()
{
    afficherDisplay('employeur');
    cacherDisplay('prestataire');
    getObj('bloc_employeur').className = "titre_secteur_employeur_selected";
    getObj('bloc_prestataire').className = "titre_secteur_prestataire";
}

function selectPrestataire()
{
    afficherDisplay('prestataire');
    cacherDisplay('employeur');
    getObj('bloc_employeur').className = "titre_secteur_employeur";
    getObj('bloc_prestataire').className = "titre_secteur_prestataire_selected";
}

function keyPressPrix(e)
{
    var unicode=e.keyCode? e.keyCode : e.charCode
    var actualkey=String.fromCharCode(unicode);
    //alert(actualkey);
    //if(actualkey == '.' 
    
    
}

function saisie(obj, valeur)
{
    if(obj.value == valeur)
    {
        obj.className = obj.className.replace("Italic", "");
        obj.value ="";
    }
}

function champsVide(obj, valeur)
{
    if(obj.value == '')
    {
        obj.className = obj.className + " Italic";
        obj.value = valeur;
    }
    else
    {
        obj.className = obj.className.replace("Italic", "");
        obj.Value = valeur;
    }
}

function rollOver(img, num_conseil, couleur, taille)
{

    var d = getObj(img);
    if(d != undefined)
    {
        d.src='/_Images/BlogVideo/num_conseil/'+ num_conseil + '_' + taille + '_' + couleur + '.png'; 
    }
}

function cocherPartenaire(nomChk)
{
    getObj(nomChk).checked = !getObj(nomChk).checked;
}

function cacherDescriptionVideo(nomDescription)
{
    if(getObj(nomDescription) != undefined)
    {
        if(getObj(nomDescription).style.visibility == "visible")
            getObj(nomDescription).style.visibility = "hidden";
        else
            getObj(nomDescription).style.visibility = "visible";
    }
}

function Trim(s) 
   {
   	// Remove leading spaces and carriage returns
   	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
   	 { s = s.substring(1,s.length); }
     
   	// Remove trailing spaces and carriage returns
 while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
   	 { s = s.substring(0,s.length-1); }
     
   	return s;
   }


function getObj(name)
{
    if (document.getElementById)
    {
        return document.getElementById(name);
    }
    else if (document.all)
    {
        return document.all[name];
    }
    else if (document.layers)
    {
        return document.layers[name];
    }
    else return false;
}

//OpenCloseMenuDyn
function cacherDynamo(lelay) {
    if (getObj(lelay) != undefined) {
        if (getObj(lelay).style.display == 'none') {
            afficherDisplay(lelay);
        }
        else {
            cacherDisplay(lelay);
        }
    }
}
//OpenCloseMenuDynImage
function imageDynamo(lelay) {
    if (getObj(lelay) != undefined) {
        if (getObj(lelay).className == 'tous') {
            getObj(lelay).className = 'tous_reduit';
        }
        else {
            getObj(lelay).className = 'tous';
        }
    }
}

function cacherDisplay(lelay)
{
    try {
    getObj(lelay).style.display='none';
    }
    catch(error) {}
}

function afficherDisplay(lelay, displayType)
{
    try {
    if (typeof displayType == "undefined")
        displayType = 'inline';
    getObj(lelay).style.display= displayType;
    }
   catch(error) {}
}


function afficher(lelay)
{
    if(getObj(lelay))
    {
        var oLelay;
        oLelay= getObj(lelay);
        oLelay.style.visibility="visible";
    }
    else
    {
        setTimeout("afficher("+lelay+");",100);
    }
}

function afficherDisplayBlocDynamo(lelay) {
	try {

		var displayType = getObj(lelay).style.display;
		if (displayType == 'undefined' || displayType == 'none') {
			displayType = 'block';
		}
		else {
			displayType = 'none';
		}
		getObj(lelay).style.display = displayType;
	}
	catch (error) { }
}
var nbAppelCacher = 0;
function cacher(lelay) {
	var obj = getObj(lelay);

	if (obj != undefined && obj != null) {
		obj.style.visibility = "hidden";
		nbAppelCacher = 0;
	}
	else {
		nbAppelCacher++;
		if (nbAppelCacher < 3) {
			setTimeout("cacher('" + lelay + "');", 100);
		}
	}
}

function SetToXY(DivId,x,y)
{
    try
	    { 
	    if (document.getElementById)
	        {
	        if (document.getElementById(DivId).style.pixelLeft) {
	            document.getElementById(DivId).style.pixelLeft = x;
                document.getElementById(DivId).style.pixelTop = y;
	            } else {
	            document.getElementById(DivId).style.left = x +"px";
                document.getElementById(DivId).style.top = y +"px";
	            }            
	        }
        else if (document.all)
	        {
	        document.all[name].style.left = x +"px";
            document.all[name].style.top = y +"px";
	        //return document.all[name];
	        }
        else if (document.layers)
	        {
	        document.layers[name].style.left = x +"px";
            document.layers[name].style.top = y +"px";
	        //return document.layers[name];
	        }
	    //document.getElementById(DivId).style.left = x +"px";
        //document.getElementById(DivId).style.top = y +"px";
       }
    catch (Identificateur)
	    {
        setTimeout("SetToXY('"+DivId+"','"+x+"','"+y+"');",100);		
	    } 
}

function getLeft(MyObject)
	{
	if (dom || ie)
		{
	    if (MyObject.offsetParent)
	        return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
	    else 
	        return (MyObject.offsetLeft);
	    }
	}
	
function getTop(MyObject)
	{
	if (dom || ie)
		{
		if (MyObject.style.position == "fixed") return document.body.scrollTop;
		if (MyObject.offsetParent)
			return (MyObject.offsetTop + getTop(MyObject.offsetParent));
		else
			return (MyObject.offsetTop);
		}
	}

function getCookie(name){var ToExec = new RegExp(name + "=([^;]+)");var valeur = ToExec.exec(document.cookie);return (valeur != null) ? valeur[1] : null;}
function setCookie(name, value) {document.cookie=  name + "=" + value + "; path=/; domain=annoncesjaunes.fr";}
function delCookie( name )
{
    document.cookie = name + "=\"\"; path=/; domain=annoncesjaunes.fr; expires=Thu, 01-Jan-1970 00:00:01 GMT";		
}

var keys = new Array();
document.write('<input type="hidden" name="EnterFunctionLoad">');

var HasTextBoxDescriptionBienFocus = false;

function disableEnterKey(e)
{
    var key;
    if(window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    if(key == 13)
    {
        if(!HasTextBoxDescriptionBienFocus)  //ne rien faire si saisi dans TextBoxDescriptionBien
        {
            if (document.aspnetForm.EnterFunctionLoad.value!='')
            { 
                eval(document.aspnetForm.EnterFunctionLoad.value+'()')
            }
            return false;
        }
    }
    else
    {
        return true;
    }
}

function getHeight(DivId)
	{
	try
		{ 
	        if (dom){
		        return (document.getElementById(DivId).offsetHeight);
		        }
	        if (ie) 
		        {return (document.all[DivId].clientHeight);
	            }
	    }
	catch (Identificateur)
			{
	        setTimeout("getHeight('"+DivId+"');",50);		
			}
	}
	
function getWidth(DivId)
	{
	try
		{ 
	        if (dom){
		        return (document.getElementById(DivId).offsetWidth);
		        }
	        if (ie) 
		        {return (document.all[DivId].clientWidth);
	            }
	    }
	catch (Identificateur)
			{
	        setTimeout("getHeight('"+DivId+"');",50);		
			}
	}
	
function PopupCentrer(page,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function PopupCentrer(page,largeur,hauteur,options) 
{
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function initBase64()
{
	enc64List = new Array();
	dec64List = new Array();
	var i;
	for (i=0; i<26; i++)
	{
		enc64List[enc64List.length] = String.fromCharCode(65+i);
	}
	for (i=0; i<26; i++)
	{
		enc64List[enc64List.length] = String.fromCharCode(97+i);
	}
	for (i=0; i<10; i++)
	{
		enc64List[enc64List.length] = String.fromCharCode(48+i);
	}
	enc64List[enc64List.length] = "+";
	enc64List[enc64List.length] = "/";
	for (i=0; i<128; i++)
	{
		dec64List[dec64List.length] = -1;
	}
	for (i=0; i<64; i++)
	{
		dec64List[enc64List[i].charCodeAt(0)] = i;
	}
}
function base64Encode(str)
{
	var c, d, e, end = 0;
	var u, v, w, x;
	var ptr = -1;
	var input = str.split("");
	var output = "";
	while (end == 0)
	{
		c = (typeof input[++ptr] != "undefined") ? input[ptr].charCodeAt(0) : ((end=1) ? 0 : 0);
		d = (typeof input[++ptr] != "undefined") ? input[ptr].charCodeAt(0) : ((end += 1) ? 0 : 0);
		e = (typeof input[++ptr] != "undefined") ? input[ptr].charCodeAt(0) : ((end += 1) ? 0 : 0);
		u = enc64List[c >> 2];
		v = enc64List[(0x00000003 & c) << 4 | d >> 4];
		w = enc64List[(0x0000000F & d) << 2 | e >> 6];
		x = enc64List[e & 0x0000003F];
		// handle padding to even out unevenly divisible string lengths
		if (end>=1)
		{
			x = "=";
		}
		if (end == 2)
		{
			w = "=";
		}
		if (end<3)
		{
			output += u+v+w+x;
		}
	}
	// format for 76-character line lengths per RFC
	var formattedOutput = "";
	var lineLength = 76;
	while (output.length>lineLength)
	{
		formattedOutput += output.substring(0, lineLength)+"\n";
		output = output.substring(lineLength);
	}
	formattedOutput += output;
	return formattedOutput;
}
function base64Decode(str) {
    var c=0, d=0, e=0, f=0, i=0, n=0;
    var input = str.split("");
    var output = "";
    var ptr = 0;
    do {
        f = input[ptr++].charCodeAt(0);
        i = dec64List[f];
        if ( f >= 0 && f < 128 && i != -1 ) {
            if ( n % 4 == 0 ) {
                c = i << 2;
            } else if ( n % 4 == 1 ) {
                c = c | ( i >> 4 );
                d = ( i & 0x0000000F ) << 4;
            } else if ( n % 4 == 2 ) {
                d = d | ( i >> 2 );
                e = ( i & 0x00000003 ) << 6;
            } else {
                e = e | i;
            }
            n++;
            if ( n % 4 == 0 ) {
                output += String.fromCharCode(c) + 
                          String.fromCharCode(d) + 
                          String.fromCharCode(e);
            }     }
    }
    while (typeof input[ptr] != "undefined");
    output += (n % 4 == 3) ? String.fromCharCode(c) + String.fromCharCode(d) : 
              ((n % 4 == 2) ? String.fromCharCode(c) : "");
    return output;
}
initBase64();

function wrap(text, lineMaxLength) 
    {
    var wrappers = new Array(" ", "-");
    
    if (text.length <= lineMaxLength) return text;
    var iEnd = 0;
    var str = text.substr(iEnd, lineMaxLength);
    var result = "";    
    var i = 0;    
    while (str != "") 
        {
        var iwrapper = 0;
        while (iwrapper < wrappers.length && str.lastIndexOf(wrappers[iwrapper]) == -1) iwrapper++; //v2
        if (iwrapper == wrappers.length) iwrapper = 1; //v2
        //if (str.lastIndexOf("-") != -1) { //v2
        if (str.lastIndexOf(wrappers[iwrapper]) != -1) { //v2
            //str = str.substring(0, str.lastIndexOf("-") + 1); //v2
            str = str.substring(0, str.lastIndexOf(wrappers[iwrapper]) + 1); //v2
            //iEnd = iEnd + str.lastIndexOf("-") + 1; //v2
            iEnd = iEnd + str.lastIndexOf(wrappers[iwrapper]) + 1; //v2
        } else {
            if (str.length >= lineMaxLength) {
              //str = str.substring(0, str.length - 1) + "-"; //v2
              str = str.substring(0, str.length - 1) + wrappers[iwrapper]; //v2
              iEnd = iEnd + str.length - 1;
            } else {
              iEnd = iEnd + str.length + 1;
            }
        }
	    if (result != "") result = result + "<br/>";
	    result = result + str;
	    str = text.substr(iEnd, lineMaxLength); 
           i++;
           if (i >= 300) return result;
        }      
        return result;
    }
    
// Fin Library.js

/*---- Liste_resultats.js ----*/

//////////////////////DEBUT SCRIPT LISTE DE RESULTATS//////////////////////////


function IsNavigatorIe6() 
{
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();
    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);
    var iePos = appVer.indexOf('msie');
    if (iePos !=-1) {
    is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
    is_major = parseInt(is_minor);
    }
    var is_ie = ((iePos!=-1));
    var is_ie6 = (is_ie && is_major == 6);
    
    return is_ie6;
}

function SetVisibilitySelects(i__Visible)
{
    if (i__Visible)
        var l__Visibility = 'visible';
    else
        var l__Visibility = 'hidden';
    
    for (var i = 0; i < document.forms.length; i++)
    {
        var l__Form = document.forms[i];
        for (var j = 0; j < l__Form.length; j++) 
        {
            var l__Element = l__Form.elements[j];
            if (l__Element.options)
            {
                l__Element.style.visibility = l__Visibility;
            }
        }
    }
}

//FONCTION POUR LA DE-AJAXIFICATION
function hideSelects() 
{
    if (IsNavigatorIe6())
    {
        SetVisibilitySelects(false);
    }
 }
//FONCTION POUR LA DE-AJAXIFICATION
function showSelects() 
{ 
    if (IsNavigatorIe6())
    {
        SetVisibilitySelects(true);
    }
}
 
//Used in MaSelection and VoirMaSelection
function ListCheckAll(chkAll, ListContainer)
{
    var l__resultList = document.getElementById(ListContainer);
    var l__allInputs = l__resultList.getElementsByTagName("input");    
    for(i = 0; i < l__allInputs.length; i++)
    {
        var l__input = l__allInputs[i];
        if (l__input.type == "checkbox")
        {
            if(l__input.checked != chkAll.checked)
            {
                l__input.click();
            }
        }
    }
 }

var _listeResultatsScrollDuration = 0;
var _listeResultatsFixedMenuHeight = 37;
var _listeResultatsScrollXDecal = 5;

function ListeResultats_AnchorScroll() {
	window.setTimeout("ListeResultats_AnchorScrollCore();", 2000);
}

function ListeResultats_AnchorScrollCore() {

	var location = new String(document.location);
	var indexOfSharp = location.indexOf("#");
	
	if (indexOfSharp > -1) {
		var anchorIndex = location.substring(indexOfSharp + 1, location.length);
		var anchorId = 'AncreLRAd' + anchorIndex

		var offsetTop = -1 * (_listeResultatsFixedMenuHeight + _listeResultatsScrollXDecal);
		var obj = $('#' + anchorId);
		$.scrollTo(obj, _listeResultatsScrollDuration, { offset: { top: offsetTop} })	
	}
}

//////////////////////FIN SCRIPT LISTE DE RESULTATS//////////////////////////

/*---- MaSelectionWS.js ----*/

//var _pjpaUrlProxy = "/test/V2/proxy.aspx";
var _pjpaCarrouselServeur = "http://www-dev.annoncesjaunes.fr:8080";

var webServiceAddAdMaSelection = '/WebServices/User/Selection.asmx/AddAdMaSelection';
var webServiceRemoveAdMaSelection = '/WebServices/User/Selection.asmx/RemoveAdMaSelection';
var webServiceGetMesSelections = '/WebServices/Carrousel.asmx/GetMesSelections';

var WebServiceContentType = "application/json; charset=utf-8";
var _pjpaUrlProxyCarrousel = "/test/V2/proxy.aspx";
/************Fonction JSON : Liste IMAGE CARROUSEL*************************************************************/
function PJPAAddAdMaSelection(idannonce, secteur, idlevel, chapitre, lienId, imgId, urlImage, Methode) {

	if (Methode == "POST") {
		PJPAAddAdMaSelectionPOST(idannonce, secteur, idlevel, chapitre, lienId, imgId, urlImage);
	}

}

function PJPAAddAdMaSelectionPOST(idannonce, secteur, idlevel, chapitre, lienId, imgId, urlImage) {
	$.ajax({
		type: "POST",
		url: webServiceAddAdMaSelection,
		data: '{ "adId" : "' + idannonce + '", "secteur" : "' + secteur + '"}',
		contentType: WebServiceContentType,
		dataType: "json",
		success: PJPAMaSelectionSucceed,
		error: PJPAMaSelectionError,
		idAnnonce: idannonce,
		lienId: lienId,
		imgId : imgId,
		urlImage: urlImage,
		idlevel: idlevel,
		secteur: secteur,
		chapitre: chapitre
	});
}
/*****************************/
function PJPARemoveAdMaSelection(idannonce, secteur, idlevel, chapitre, lienId, Methode) {
	if (Methode == "POST") {
		PJPARemoveAdMaSelectionPOST(idannonce, secteur, idlevel, chapitre, lienId);
	}
}

function PJPARemoveAdMaSelectionPOST(idannonce, secteur, idlevel, chapitre, lienId) {
	$.ajax({
		type: "POST",
		url: webServiceRemoveAdMaSelection,
		data: '{ "adId" : "' + idannonce + '", "secteur" : "' + secteur + '"}',
		contentType: WebServiceContentType,
		dataType: "json",
		success: PJPAMaSelectionSucceed,
		error: PJPAMaSelectionError,
		idAnnonce: idannonce,
		lienId: lienId,
		secteur: secteur,
		idlevel: idlevel,
		chapitre: chapitre
	});
}

/*****************/
function PJPAMesSelectionsLaunchCall(Secteur, IdDivToHide, NameVarGlobal, Methode) {
	if (Methode == "POST") {
		PJPAMesSelectionsLaunchCallPOST(Secteur, IdDivToHide, NameVarGlobal);
	}
}

function PJPAMesSelectionsLaunchCallPOST(secteur, IdDivToHide, NameVarGlobal) {
	if (window.location.hostname.indexOf('googleusercontent') == -1) {
		$.ajax({
			type: "POST",
			url: webServiceGetMesSelections,
			data: '{ "secteur" : "' + secteur + '" }',
			contentType: WebServiceCarrouselContentType,
			dataType: "json",
			success: PJPAMesSelectionsAjaxCallSucceedJson,
			error: MesSelectionsAjaxCallError,
			idDivToHide: IdDivToHide,
			nameVarGlobal: NameVarGlobal,
			Secteur: secteur
		});
	}
}
// to do 
function PJPAMesSelectionsAjaxCallSucceedJson(response) {
	if (response != null && response != undefined) {

		var Nbmanquant = (response.length % 4 != 0 ? (4 - response.length % 4) : 0);
		Nbmanquant = (response.length == 0 ? 4 : Nbmanquant);

		if (Nbmanquant > 0) {
			var currentLength = response.length;
			for (var i = currentLength; i < currentLength + Nbmanquant; i++) {
				var newData = getAdObject("/_Images/commun/pixGris.png", undefined, undefined, "", null, null, null, null);
								
				response[i] = new Object();
				response[i] = newData;
			}
		}
		
		_PJPAMesSelections = new PJPACarroussel(this.Secteur, response, this.idDivToHide, 4, 48, 36, true, this.nameVarGlobal, this.nameVarGlobal, PJPA_MODE_SEL, "", true, "");
	}
	else {
		MesSelectionsAjaxCallError("");
	}
}

/*****************************/

/**************** Annonces consultées **************************/

function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else var expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name, "", -1);
}

function getAdsViewsFromCookies(CookieName) {

	var cookiekValue = readCookie(CookieName);
	var arrayobjAds = new Array();
	var arrayAdInfos = new Array();
	var arrayAdViews = new Array();
	
	if (cookiekValue != null && cookiekValue != undefined && cookiekValue != "undefined") {
	
	// Tableau des annonces consultées
		arrayobjAds = cookiekValue.split('|');
		// Chercher les éléments de tableau
		var j = 0;
		for (i = 0; i < arrayobjAds.length; i++) {

			arrayAdInfos = arrayobjAds[i].split('$')

			if (arrayAdInfos != null && arrayAdInfos != undefined) {

				var newData = getAdObject(arrayAdInfos[0], arrayAdInfos[1], arrayAdInfos[2], "", null, null, null, null)
				arrayAdViews[j] = new Object();
				arrayAdViews[j] = newData
				j++;
			}
		}
	}
	
	return arrayAdViews;

}

function GetAdViews() {

	var arrayAdViews = new Array();

	arrayAdViews = getAdsViewsFromCookies("adViews");

	var Nbmanquant = (arrayAdViews.length % 4 != 0 ? (4 - arrayAdViews.length % 4) : 0);
	Nbmanquant = (arrayAdViews.length == 0 ? 4 : Nbmanquant);

	if (Nbmanquant > 0) {
		var currentLength = arrayAdViews.length;
		for (var i = currentLength; i < currentLength + Nbmanquant; i++) {
			var newData = getAdObject("/_Images/commun/pixGris.png", undefined, undefined, "", null, null, null, null)

			arrayAdViews[i] = new Object();
			arrayAdViews[i] = newData;
		}
	}

	return arrayAdViews;
}



function PJPAMesAnnoncesConsulteesCall(Secteur, idDivToHide, nameVarGlobal, newViewAd) {


	var arrayAdViews = new Array();

	arrayAdViews = getAdsViewsFromCookies("adViews");
	
	var Nbmanquant = (arrayAdViews.length % 4 != 0 ? (4 - arrayAdViews.length % 4) : 0);
	Nbmanquant = (arrayAdViews.length == 0 ? 4 : Nbmanquant);

	if (Nbmanquant > 0) 
	{
		var currentLength = arrayAdViews.length;
		for (var i = currentLength; i < currentLength + Nbmanquant; i++) 
		{
			var newData =  getAdObject("/_Images/commun/pixGris.png", undefined, undefined, "", null, null, null, null)

			arrayAdViews[i] = new Object();
			arrayAdViews[i] = newData;
		}
	}
	
	//Ajouter une nouvelle annonce consultées
	if (newViewAd != null && newViewAd != undefined) {

		AddAdViewToCookie(newViewAd);
	}
	
	_PJPAConsultees = new PJPACarroussel(Secteur, arrayAdViews, idDivToHide, 4, 48, 36, true, nameVarGlobal, nameVarGlobal, PJPA_MODE_SEL, "", true, "");
	
}

function getAdObject(ImageUrl, LienAnnonce, IdAnnonce, TagPJPA, Titre, PrixAff, Description1, Description2) {

	var newData = new Object();
	newData.ImageUrl = ImageUrl;
	newData.LienAnnonce = LienAnnonce;
	newData.IdAnnonce = IdAnnonce;
	newData.TagPJPA = TagPJPA;
	newData.Titre = Titre;
	newData.PrixAff = PrixAff;
	newData.Description1 = Description1;
	newData.Description2 = Description2;
	return newData;

}

function AddAdViewToCookie(newViewAd) {
	if (newViewAd != undefined) {
		//Ajouter la nouvelle annonce consultée
		//placer la denrière annonce en 1ere position

		var arrayNewAdViews = new Array();
		var arrayAdViews = new Array();
		arrayNewAdViews[0] = new Object();
		arrayNewAdViews[0] = newViewAd;

		arrayAdViews = getAdsViewsFromCookies("adViews");

		var currentLength = arrayAdViews.length;
		//alert(arrayAdViews.length);			
		var j = 1;
		for (var i = 0; i < currentLength && j < 8; i++) {

			if (NotUndefinedNotNull(arrayAdViews[i]) && NotUndefinedNotNull(newViewAd) && arrayAdViews[i].IdAnnonce != newViewAd.IdAnnonce) {
				arrayNewAdViews[j] = new Object();
				arrayNewAdViews[j] = arrayAdViews[i];
				j++;
			}
		}

		// Sérialiser le tableau en chaine
		var _newAdViews = "undefined";
		for (var i = 0; i < arrayNewAdViews.length; i++) {
			if (NotUndefinedNotNull(arrayNewAdViews[i]) && arrayNewAdViews[i].IdAnnonce != null && arrayNewAdViews[i].IdAnnonce != undefined) {

				var newData = getAdObject(arrayNewAdViews[i].ImageUrl,
									  arrayNewAdViews[i].LienAnnonce,
									  arrayNewAdViews[i].IdAnnonce,
									  arrayNewAdViews[i].TagPJPA,
									  arrayNewAdViews[i].Titre,
									  arrayNewAdViews[i].PrixAff,
									  arrayNewAdViews[i].Description1,
									  arrayNewAdViews[i].Description2
									  
									  );

				if (_newAdViews != "undefined") {
					_newAdViews += '|' + newData.ImageUrl + '$' + newData.LienAnnonce + '$' + arrayNewAdViews[i].IdAnnonce;
				}
				else {
					_newAdViews = newData.ImageUrl + '$' + newData.LienAnnonce + '$' + arrayNewAdViews[i].IdAnnonce;
				}
			}

		}

		setCookie("adViews", _newAdViews);
	}
}

function SelOnglet(currentlinkId, linkIdOff, OngletIdOn, OngletIdOff) {

	var ObjLinkOff = document.getElementById(linkIdOff);
	var currentlink = document.getElementById(currentlinkId);
	var ObjOngletOn = document.getElementById(OngletIdOn);
	var ObjOngletOff = document.getElementById(OngletIdOff);

	//alert(currentlink.id);
	if (currentlink != null && currentlink != undefined) {
		if (currentlink.className.indexOf("Sel") == -1) {
			currentlink.className += " Sel";
		}		
	}

	//alert(ObjLinkOff.id);
	if (ObjLinkOff != null && ObjLinkOff != undefined) {

		ObjLinkOff.className = ObjLinkOff.className.replace(" Sel", "")
		//alert(ObjLinkOff.className); 

	}
	if (ObjOngletOn != null && ObjOngletOn != undefined) {

		ObjOngletOn.style.display = "inline";
	}

	if (ObjOngletOff != null && ObjOngletOff != undefined) {

		ObjOngletOff.style.display = "none";

	}

}

/******************** fin annonces consultées ******************/


function MesSelectionsAjaxCallError(error) {
	$("#" + this.idDivToHide).hide();
	return;
}

function PJPAMaSelectionSucceed(response) {
	if (response != null && response != undefined) {
		if (response == 1) {
			AjoutSelectionRetour(this.secteur, this.idlevel, this.chapitre, this.lienId, this.idAnnonce, this.imgId, this.urlImage);
		}
		else if (response == -1) {
			PJPAMaSelectionError("");
		}
	}
}

function PJPAMaSelectionError(error) {
	var btn = "#" + _BtnErreur;
	$(btn).click();
	return false;
}

function AjoutSelection(lien, idannonce, imgId, urlImage, secteur, idlevel, chapitre) {
	if (lien != undefined) {
		if (lien.innerHTML.indexOf("Ajouter") != -1) {
			PJPAAddAdMaSelection(idannonce, secteur, idlevel, chapitre, lien.id, imgId, urlImage, "POST");
			SelOnglet('MesSelections', 'AnnoncesConsultees', 'divMesSels', 'divMesConslt');
		}
		else {
			PJPARemoveAdMaSelection(idannonce, secteur, idlevel, chapitre, lien.id, "POST");
		}
	}
}

function ChangeSelection(linkId) {
	var link = getObj(linkId);

	if (link != undefined) {
		if (link.innerHTML.indexOf("Ajouter") != -1) {
			DelaiModifierAnchor(link);
		}
		else {
			link.innerHTML = "Ajouter à ma sélection";
			link.className = "NoSel";
		}
	}
}

// Fonction pour mettre un délai.
function DelaiModifierAnchor(lien) {
	var x = setTimeout(function() { RetirerMaSelection(lien); }, 750);
}

function RetirerMaSelection(lien) {
	lien.innerHTML = "Retirer de ma sélection";
	lien.className = "Sel";
}

function AjoutSelectionRetour(secteur, idlevel, chapitre, lienId, idannonce, imgId, urlImage) {
	var NbMesSelections = getObj('PJPANbMesSelections');
	var LienMesSelections = getObj('LienMesSelections');

	var lien = getObj(lienId);
	var img = getObj(imgId);

	if (NbMesSelections != undefined && lien == undefined) {		
		var nbcurrent = PJPATryParseInt(NbMesSelections.innerHTML, 0);
		nbcurrent = nbcurrent - 1;
		NbMesSelections.innerHTML = nbcurrent;
		
		if (nbcurrent == 0) {
			LienMesSelections.style.visibility = "hidden";
		}
	}

	if (NbMesSelections != undefined && lien != undefined) {
		var nbcurrent = PJPATryParseInt(NbMesSelections.innerHTML, 0);
		if (lien != undefined) {
			if (lien.innerHTML.indexOf("Ajouter") != -1) {
				nbcurrent = nbcurrent + 1;
				NbMesSelections.innerHTML = nbcurrent;
				
				// Application d'un délai avant de modifier le lien
				DelaiModifierAnchor(lien);
				
				
				var imageSCR = (img != undefined && img != null ? img.src : urlImage);
				selectAd(imgId, idannonce, imageSCR);
				PJPATagXitiSelection(idlevel, secteur, chapitre, "Ajouter_selection");
			}
			else {
				nbcurrent = nbcurrent - 1;
				NbMesSelections.innerHTML = nbcurrent;
				lien.innerHTML = "Ajouter à ma sélection";
				lien.className = "NoSel";
				_PJPAMesSelections.RemoveSelection(idannonce);
				PJPATagXitiSelection(idlevel, secteur, chapitre, "Retirer_selection");
			}
			
			if (nbcurrent == 0) {
				LienMesSelections.style.visibility = "hidden";
			}
			else {
				var PJPAMesSelectionsTexte = getObj('PJPAMesSelectionsTexte');
				if (nbcurrent == 1) {
					
					PJPAMesSelectionsTexte.innerHTML = "Ma sélection";
				}
				else {
					PJPAMesSelectionsTexte.innerHTML = "Mes sélections";
				}

				LienMesSelections.style.visibility = "visible";
			}
		}
	}
}

function selectAd(imgId, idannonce, imgSrc) {
	var img = getObj(imgId);
	if (img != undefined && img != null) {
		var urlImg = img.src.replace("_Gondole", "_Liste");
		$('#popup').attr("src", img.src);
		$('#popup').attr("style", "display:none;position:absolute; left:0px; top:130px; border:none; filter:alpha(opacity=100); -moz-opacity: 1; opacity: 1;");
		var offsetImg = $(img).offset();
		var offsetDiv = $('#DivVotreSelection').offset();

		$('#popup').css({ top: offsetImg.top, left: offsetImg.left });
		$("#popup").animate({ width: "48px", height: "37px", opacity: 0, top: offsetDiv.top + 20, left: offsetDiv.left }, 700, "linear", function() { hideSlow(idannonce, imgSrc); });
	}
	else {
		hideSlow(idannonce, imgSrc);
	}
}

function hideSlow(idAnnonce, srcImg) {
	_PJPAMesSelections.AddSelection(idAnnonce, srcImg);
}

function popup(message) { }


var cacheFicSemiDet = null;
var isOnFicSemiDet = 0;
var canGo = 0;
var cantGo = 0;
var canDisplay = 1;

function fsdClick(obj) {
	if (canGo == 1) {

		var $UrlSiteOrpi = $(obj).find(".AdImg .CptPro #UrlSiteOrpi");
		if ($UrlSiteOrpi != undefined) {
			var urlOrpi = $UrlSiteOrpi.attr("value");
			if (urlOrpi != undefined && urlOrpi != '-1') {				
				var externalPopup = window.open(urlOrpi, '', 'width=668, height=500, menubar=yes, status=yes, toolbar=yes, location=yes,scrollbars = yes,resizable = yes');
				externalPopup.blur();
				window.focus();
			} 			
		}

		var $linkAd = $(obj).find(".AdLig .AdTitre a");
		if ($linkAd != undefined) {
			$linkAd.mouseover();
			var url = $linkAd.attr("href");
			document.location = url;
		}
	}
}

function fsdLaunchClick(id) {
	if (cantGo != 1) {
		$("#" + id).click();
	}
}

function LaunchCreate(id) {
	if (canDisplay == 1) {
		eval($("#" + id).attr("href"));
	}
}

function fsdIn(obj, nbPhoto) {
	currentIdFsd = GetCurrentIdFsd(obj);
	
	var $imgAd = $(obj).find(".AdImg img");
	var scrImg = $imgAd.attr("src");
	var haveImg = scrImg.indexOf("Non_Dispo") == -1;

	if (haveImg) {
		scrImg = scrImg.replace("_Gondole", "_Zoom");
		SetBigImage(scrImg);
		var url = GetHref(obj, ".AdLig .AdTitre");
		
		if (url == undefined) {
			var $urlCacher = $(obj).find(".AdLiens .AdPlus input:hidden");
			var url = $urlCacher.attr("value");
		}

		$("#ficSemDet").click(function() { if (canGo == 1) { document.location = url; } });
		$("#ficSemDetImg").click(function() { if (canGo == 1) { document.location = url; } });

		SetStyleBigImage(obj, ".AdDesc");
		DisplayText(nbPhoto);
		ShowPopup();
	}
	else {
		$("#ficSemDet").hide();
	}
	isOnFicSemiDet = 1;
}

function EmailAlertIn(obj, url, id) {
	currentIdFsd = GetCurrentIdFsd(obj);
	SetBigImage(url);
	var method = $("#" + id).attr("href");

	$("#ficSemDet").unbind("click");
	$("#ficSemDetImg").unbind("click");

	$("#ficSemDet").click(function() { if (canDisplay == 1) { eval(method); } });
	$("#ficSemDetImg").click(function() { if (canDisplay == 1) { eval(method); } });

	SetStyleBigImage(obj, ".Text");

	$("#ficSemDetTxt").hide();

	ShowPopup();
	isOnFicSemiDet = 1;
}

function fsdOut(obj) {
	cacheFicSemiDet = setTimeout('fsdCache()', 500);
	isOnFicSemiDet = 0;
}

function SetStyleBigImage(obj, className) {
	var objRef = $(obj).find(className);
	var offsetImg = $(objRef).offset();
	var widthDiv = $(objRef).css("width");
	widthDiv = parseInt(widthDiv.replace(/px/gi, ""));

	$('#ficSemDet').css({ top: offsetImg.top - 70, left: offsetImg.left + widthDiv + 10 });
}

function DisplayText(nbPhoto) {
	if (nbPhoto > 1) {
		$("#ficSemDetTxt").html("+" + (nbPhoto - 1) + " photos");
		$("#ficSemDetTxt").show();
	}
	else {
		$("#ficSemDetTxt").hide();
	}
}

var currentIdFsd = undefined;

function fsdCache() {
	if (isOnFicSemiDet == 0) {
		if (currentIdFsd != undefined) {
			$("#" + currentIdFsd).removeClass(" sel");
		}
		$("#ficSemDet").hide();
		$("#ficSemDetChgt").show();
		$("#ficSemDetImg").hide();
		$("#ficSemDetTxt").hide();
	}
	else {
		cacheFicSemiDet = null;
	}
}

function PJPATagXitiSelection(idLevel, secteur, chapitre, clic) {
	if (idLevel != "undefined" && secteur != "undefined" && chapitre != "undefined" && clic != "undefined") {
		subSecteur = "";
		if (secteur == "Automobile")
		{
			subSecteur = "Auto::";
		}
		else if (secteur == "Moto")
		{
			subSecteur = "Moto::";
		}
		TagClick("C", idLevel, subSecteur + chapitre + "::" + clic, "A");
	}
}

function GetCurrentIdFsd(obj) {
	if (currentIdFsd != undefined) {
		$("#" + currentIdFsd).removeClass(" sel");
	}
	$(obj).addClass(" sel");
	return $(obj).attr("id");
}

function SetBigImage(url) {
	$('#ficSemDetImg').attr("src", url);
	//$('#ficSemDetImg').css({ width: 196, height: 162 });
}

function GetHref(obj, className) {
	var $linkAd = $(obj).find(className + " a");
	return $linkAd.attr("href");
}

function ShowPopup() {
	$('#ficSemDetImg').ready(function() {
		$("#ficSemDetImg").show();
		$("#ficSemDetChgt").hide();
	});

	$("#ficSemDet").show();
}


/*---- PageInfos.js ----*/

function PageInfos() { }

PageInfos.prototype.ToggleDbCommandSqlExecuted = function(obj) {
	$(obj).toggleClass('Open');
	$(obj).next().toggle();
}

var _pageInfos = new PageInfos();

/*---- Page_Accueil.js ----*/

var _pjpaRegionDictionaire = new RegionDictionnary();

function RegionDictionnary() {
    this.NomRegion = new Array();
    this.NomRegion[0] = "ile de france";
    this.NomRegion[1] = "champagne ardenne";
    this.NomRegion[2] = "picardie";
    this.NomRegion[3] = "haute normandie";
    this.NomRegion[4] = "centre";
    this.NomRegion[5] = "basse normandie";
    this.NomRegion[6] = "bourgogne";
    this.NomRegion[7] = "nord pas de calais";
    this.NomRegion[8] = "lorraine";
    this.NomRegion[9] = "alsace";
    this.NomRegion[10] = "franche comte";
    this.NomRegion[11] = "pays de la loire";
    this.NomRegion[12] = "bretagne";
    this.NomRegion[13] = "poitou charentes";
    this.NomRegion[14] = "aquitaine";
    this.NomRegion[15] = "midi pyrenees";
    this.NomRegion[16] = "limousin";
    this.NomRegion[17] = "rhone alpes";
    this.NomRegion[18] = "auvergne";
    this.NomRegion[19] = "languedoc roussillon";
    this.NomRegion[20] = "provence alpes cote d azur";
    this.NomRegion[21] = "corse";

    this.Region = new Array();
    this.Region[0] = " 75 77 78 91 92 93 94 95 ";
    this.Region[1] = " 51 08 10 52 ";
    this.Region[2] = " 80 02 60 ";
    this.Region[3] = " 76 27 ";
    this.Region[4] = " 45 18 28 36 37 41 ";
    this.Region[5] = " 14 50 61 ";
    this.Region[6] = " 21 58 71 89 ";
    this.Region[7] = " 59 62 ";
    this.Region[8] = " 57 54 55 88 ";
    this.Region[9] = " 67 68 ";
    this.Region[10] = " 25 39 70 90 ";
    this.Region[11] = " 44 49 53 72 85 ";
    this.Region[12] = " 35 22 29 56 ";
    this.Region[13] = " 86 16 17 79 ";
    this.Region[14] = " 33 24 40 47 64 ";
    this.Region[15] = " 31 09 12 32 46 65 81 82 ";
    this.Region[16] = " 87 19 23 ";
    this.Region[17] = " 69 01 07 26 38 42 73 74 ";
    this.Region[18] = " 63 03 15 43 ";
    this.Region[19] = " 34 11 30 48 66 ";
    this.Region[20] = " 13 04 05 06 83 84 ";
    this.Region[21] = " 2A 2B ";
}

RegionDictionnary.prototype.IsRegion = function(localite) {

	var ouSaisi = prepareMatch(localite);

	NomRegion = _pjpaRegionDictionaire.NomRegion;
	Region = _pjpaRegionDictionaire.Region;

	for (var i = 0; i < this.NomRegion.length; i++) {
		//        if (ouSaisi.indexOf(this.NomRegion[i]) > -1) {
		//            return true;
		//           }
		if (this.NomRegion[i].indexOf(ouSaisi) > -1) {
			return true;
		}
	}
	return false;
}

function RemplaceOu(obj) {

    var ouSaisi = prepareMatch(obj.value);

    NomRegion = _pjpaRegionDictionaire.NomRegion;
    Region = _pjpaRegionDictionaire.Region;

    for (var i = 0; i < NomRegion.length; i++) {
        if (ouSaisi.indexOf(NomRegion[i]) > -1) {
            ouSaisi = ouSaisi.replace(NomRegion[i], Region[i]);
        }
    }

    return ouSaisi;
}

function RemplaceOuV2(objValue) {

    var ouSaisi = prepareMatch(objValue);

    NomRegion = _pjpaRegionDictionaire.NomRegion;
    Region = _pjpaRegionDictionaire.Region;

    for (var i = 0; i < NomRegion.length; i++) {
        if (ouSaisi.indexOf(NomRegion[i]) > -1) {
            ouSaisi = ouSaisi.replace(NomRegion[i], Region[i]);
        }
    }

    return ouSaisi;
}



function RemoveAccents(input) {
    var listOfAccentedLetters = ['é', 'è', 'ë', 'ê', 'à', 'â', 'î', 'ï', 'ô', 'û', 'ù', 'ü', 'ç'];
    var listOfUnAccentedLetters = ['e', 'e', 'e', 'e', 'a', 'a', 'i', 'i', 'o', 'u', 'u', 'u', 'c'];

    var l__input = input;
    if (l__input != '') {
        for (var i = 0; i < listOfAccentedLetters.length; i++) {
            if (l__input.indexOf(listOfAccentedLetters[i]) != -1) {
                var reg = new RegExp("(" + listOfAccentedLetters[i] + ")", "gi");

                l__input = l__input.replace(reg, listOfUnAccentedLetters[i]);
            }
        }
    }
    return l__input;
}


function prepareMatch(ou) {
    var returnOu = "";
    if (ou != '' && ou != undefined) {
        var avant = ou;
        var caractereAutorise = "azertyuiopqsdfghjklmwxcvbnéèàùçêûîâ0123456789";
        

        while (ou.indexOf("(") > -1) {
            var debParenthese = ou.indexOf("(");
            var finParenthese = ou.indexOf(")", debParenthese);
            ou = ou.substring(0, debParenthese) + ou.substring(finParenthese + 1);
        }
        ou = ou.toLowerCase();

        for (i = 0; i < ou.length; i++) {
            if (caractereAutorise.indexOf(ou.charAt(i)) > -1)
                returnOu += ou.charAt(i);
            else
                returnOu += " ";
        }

        returnOu = RemoveAccents(returnOu);
        returnOu = returnOu.trim();
    }
    return returnOu;
}

function DeSelect() {
    if (selectedItem != undefined) {
        selectedItem.className = "";
    }
}

function Reselect() {
    if (selectedItem != undefined) {
        selectedItem.className = "selected";
    }
    getObj('fleche_ddl').className = 'fleche_roll';
}

function dCacherListes() {

    if (onService == 1 && isOnListService == 0) {

        cacher('liste_services');
        onService = 0;
    }
    if (onOu == 1) {
        CacherListe();
        onOu = 0;
    }
    isOnListService = 0;
    getObj('fleche_ddl').className = 'fleche';
}

function ReplacePopupAlerteOu(secteur) {
    if (secteur == "Immobilier") {
        getObj('whereFieldIsRequired').style.left = '149px';
        getObj('whereFieldIsRequired').style.top = '219px';
    }
}


function Select(obj) {
    obj.className = 'selected';
}

function UnSelect(obj) {
    obj.className = '';
}	
	

/*---- PopupUnder.js ----*/

function PopupUnder(name, url, width, height) {
	this.Name = name;
	this.Url = url;
	this.Width = width;
	this.Height = height;
	this.Scrollbars = 'yes';
	this.Resizable = 'yes';
	this.Toolbar = 'yes';
	this.MenuBar = 'yes';
	this.Status = 'yes';
	this.Location = 'yes';
	this.Top = '20';
	this.Left = '85';
	this.Target = '_blank';

	this.Options = 'scrollbars=' + this.Scrollbars + ', resizable=' + this.Resizable + ', toolbar=' + this.Toolbar + ', menubar=' + this.MenuBar + ', status=' + this.Status + ', location=' + this.Location + ', left=' + this.Left + ' top=' + this.Top + ', height=' + this.Height + ',width=' + this.Width;
}




PopupUnder.prototype.Open = function() {
	var win2 = window.open(this.Url, this.Name, this.Options, this.Target);
	win2.blur();
	if (navigator.userAgent.indexOf('Chrome/') > 0) {
		window.blur();
	}
	setTimeout('window.focus()', 100);

}



/*---- RollOver.js ----*/

function PJPARollOverOut() { }

PJPARollOverOut.Change = function(obj, css) {
	obj.className = css;
}

PJPARollOverOut.ChangeById = function(objId, css) {
	var obj = document.getElementById(objId); ;
	obj.className = css;
}

function PJPAChoixItem(id, defautId, defautItemToShowId) {
	this.ID = id;
	this.SelectItem(document.getElementById(defautId), defautItemToShowId);
}

PJPAChoixItem.prototype.SelectItem = function(NewItem, ItemToShowId) {
	if (this.CurrentItem != undefined && this.CurrentItem != null) {
		this.CurrentItem.className = this.CurrentItem.className.replace(/Over/gi, "");
		this.CurrentItem.className = this.CurrentItem.className.replace(/Selected/gi, "");
	}

	if (this.ItemToShow != undefined && this.ItemToShow != null) {
		$(this.ItemToShow).hide();
	}

	if (NewItem != undefined) {
		this.CurrentItem = NewItem;
		this.CurrentItem.className += " Selected";
	}
	
	if (ItemToShowId != undefined && ItemToShowId != '') {
		this.ItemToShow = document.getElementById(ItemToShowId);
		if (this.ItemToShow != undefined && this.ItemToShow != null) {
			$(this.ItemToShow).show();
		}
	}
}

PJPAChoixItem.prototype.ChgCss = function(obj, css) {
	if (this.CurrentItem.id != obj.id) {
		obj.className = css;
	}
}



function md(Obj, Css) {
	var oldCss = Obj.className;
	var fctOldCss = "ocs('" + Obj.id + "','" + oldCss + "');";
	setTimeout(fctOldCss, 1000);
	Obj.className = Css;
}

function ocs(id, css) {
	document.getElementById(id).className = css;
}

function mu(Obj, css) {
	Obj.className = css;
}

var _pjpaBtnCache = new Object();
function PJPABtnCache(IdBtn, Css) {
	_pjpaBtnCache[IdBtn] = Css;
}
var cpt = 0;
function mld(Obj, Css) {
	Obj.className = Css + "_" + 'On';
	if (Obj.id == "" || Obj.id == undefined) {
		var dt = new Date();
		Obj.id = "btn_" + dt.getMinutes() + dt.getSeconds() + dt.getMilliseconds();
	}
	Obj.onmouseover = null;
	$(Obj).mouseover(function() { mlu(Obj.id, Css, 'On'); });
	$(Obj).mouseout(function() { mlu(Obj.id, Css, 'Off'); });
	$(Obj).mousedown(function() { mlu(Obj.id, Css, 'App'); });
	$(Obj).mouseup(function() { mlu(Obj.id, Css, 'On'); });
}

function mlu(ObjId, Css, Action) {
	var Obj = document.getElementById(ObjId);
	if (Obj != null && Obj != undefined) {
		Obj.className = Css + "_" + Action;
	}
}


/*---- Tag.js ----*/

function TagClick(type, siteLvl2, linkName, clickType) {
    return xt_click(this, type, siteLvl2, linkName, clickType);
}

/*---- WebSiteExit.js ----*/

/* Version qui marche sous FF et Chrome mais pas IE */
/*function FctUnLoadSite() {
	DisplayIntersticial();
	return ("Etes-vous sûr de vouloir quitter cette page ?");
}

function QuitteOk() {
	changeQuitte(0);
}

function QuitteKo() {
	changeQuitte(1);
}

function changeQuitte(val)
{
	if (val == 0) {
		window.onbeforeunload = FctUnLoadSite;
	}
	else {
		window.onbeforeunload = "";
	}
}

window.onmouseout = QuitteOk;
window.onmouseover = QuitteKo;*/

/* Version qui marche sur tous les navigateurs */
/*var Mouse_X;
var Mouse_Y;

function WhereMouse(e) {
	var DocRef;
	if (e) {
		Mouse_X = e.pageX;
		Mouse_Y = e.pageY;
	}
	else {
		Mouse_X = event.clientX;
		Mouse_Y = event.clientY;
		if (document.documentElement && document.documentElement.clientWidth)
			DocRef = document.documentElement;
		else
			DocRef = document.body;

		Mouse_X += DocRef.scrollLeft;
		Mouse_Y += DocRef.scrollTop;
	}
}
document.onmousemove = WhereMouse;*/

//function closeIt() {
//	var href = document.location.href;
//	var reg = new RegExp("^http://www[^/]+.fr/(immobilier(-[^/])?.*/a/[^/]+.*/p/[1-9]/|Immobilier/Liste.aspx.*)$");

//	//Avec JQuery ça sera mieux
//	//navigator.appName = "Microsoft Internet Explorer" "Netscape"	
//	//navigator.userAgent = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1'
//	//"Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0"

//	if (Mouse_Y < 20 && reg.test(href)) {
//		DisplayIntersticial();
//		return "Etes-vous sûr de vouloir quitter cette page ?";
//	}
//}
//window.onbeforeunload = closeIt;

function DisplayIntersticial() {
	var $button = $("#ctl00_ContentPlaceHolder1_CloseWebSite");
	var $input = $("#ctl00_ContentPlaceHolder1_CloseWebSiteHidden");	
	$input.val("1");
	$button.click();
}

/*---- XmlHttpRequest.js ----*/

// Debut XmlHttpRequest.js

// Used in AccueilPj.aspx
function SaveTypeForm(TypeForm)
{
    document.aspnetForm.EnterFunctionLoad.value=TypeForm;
}
    
// Used in layers       
function XHRAccesOublie()
{
    WriteChargementEnCours();
    var XHR = CreateXHR();
    XHR.onreadystatechange=function() {
        AccesOublie(XHR);
    }
    XHR.open("POST","/_XMLHttpRequest/MasterPageGlobal/AccesOublie.aspx", true);
    XHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    XHR.send("Email="+encodeURIComponent(document.aspnetForm.EmailAccesOublie.value));
}

function AccesOublie(XHR)
{
if(XHR.readyState == 4)
    {
    cacher('ChargementEnCour'); 
    var data = XHR.responseText;
        if(data=='false')
            {
            getObj('AccesOubliMessage').innerHTML='<table cellpadding="0" cellspacing="0" border="0"><tr><td style="height:6px;"></td></tr><tr><td class="txtnoir11" valign="top" style="height:120px;width:284px;">Cet e-mail ne correspond pas &agrave; un membre inscrit sur le site.<br /><br /><br><div align="center"><a href="javascript:AlertPjpa(\'R&eacute;cup&eacute;rer votre mot de passe\',\'AccesOubli\',260,280);" class="txtnoir11"><img src="/_Images/Pictos/btn_retour.gif" alt="" width="71" height="28" /></a></div></td><td style="width:22px;"><img src="/_Images/pix.gif" style="width:22px;" alt="" /></td></tr></table>';
            AlertPjpa('R&eacute;cup&eacute;rer votre mot de passe','AccesOubliMessage',260,280);
            }
         if(data=='true')
            {
            getObj('AccesOubliMessage').innerHTML='<table cellpadding="0" cellspacing="0"><tr><td colspan="2" style="height:6px;"></td></tr><tr><td class="txtnoir11" valign="top" style="height:50px;">Votre mot de passe vous a &eacute;t&eacute; envoy&eacute; sur votre adresse e-mail.</td><td style="width:22px;"><img src="/_Images/pix.gif" style="width:22px;" alt="" /></td></tr><tr><td style="height:40px; text-align:right; vertical-align:top;"><a href="#" onclick="CacheAlertPjpa();" ><img src="/_Images/Pictos/btn_fermer.gif" alt="" width="81" height="28" /></a></td><td>&nbsp;</td></tr></table>';
            AlertPjpa('R&eacute;cup&eacute;rer votre mot de passe','AccesOubliMessage',260,280);
            }
       }
}

// Used in all web site
function CreateXHR()    
{
    try
        {
        var XHR = new ActiveXObject("Msxml2.XMLHTTP");
        }
    catch(e)
        {
        try
            {
            var XHR = new ActiveXObject("Microsoft.XMLHTTP");            
            }
        catch(E)
            {
            var XHR = false;
            }    
        }
    if(!XHR && typeof XMLHttpRequest !='undefined')
        {
        var XHR = new XMLHttpRequest();
        }    
    return XHR;
}    

// Fin XmlHttpRequest.js


