sas_tmstp=Math.round(Math.random()*10000000000);
sas_masterflag=1;
function SmartAdServer(sas_pageid,sas_formatid,sas_target) {
	if (sas_masterflag == 1) {sas_masterflag = 0;sas_master = 'M';} else { sas_master = 'S'; }
	document.write('<SCR'+'IPT SRC="http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR'+'IPT>');
}

//var request = null;

function getRequest() {
	var request = null;
	var result = request;
	
	if (result == null) {
		if (window.XMLHttpRequest) {
		  result = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
		  try {
			result = new ActiveXObject("Msxml2.XMLHTTP");
		  } 
		  catch (e) {
			 try {
				result = new ActiveXObject("Microsoft.XMLHTTP");
			 } 
			 catch (e) {
				window.alert("Votre navigateur ne prend pas en charge l'objet XMLHTTPRequest.");
			 }
		  } 
		}
	}
	
	return result;

}

var objNewWindow = null;
var strPreviousUrl;

function openNewWindow(strUrl, name, width, height) {

 	var left = "left=" + (screen.availWidth - width) / 2; 
 	var top = "top=" + (screen.availHeight - height) / 2; 

	if (objNewWindow == null || objNewWindow.closed) {
		objNewWindow = window.open(strUrl, name, "scrollbars=yes, width=" + width + ", height=" + height + "," + left + "," + top);
		objNewWindow.focus();
	}
	else if (strPreviousUrl != strUrl) { 
		objNewWindow = window.open(strUrl, name, "scrollbars=yes, width=" + width + ", height=" + height + "," + left + "," + top);
		objNewWindow.focus();
	}
	else {
		objNewWindow.focus();
	}
	strPreviousUrl = strUrl;
	
}

function blnIsEmail(strEmail) {
	
	var objRegExp;
	objRegExp = new RegExp("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,3}$");
	if (strEmail.search(objRegExp) == -1 ) { return false; } else {	return true; }
	
}
function blnIsnumerique(chaine) {
    var exp=new RegExp("^[0-9]*$","g");
    return exp.test(chaine);
  }

function testNumber(val) {
	val = val.replace(/\s{2,}/g," "); ;
	val = val.replace(/\+/g,"");
	val = val.replace(/\-/g,"");
	val = val.replace(/\./g,"");
	val = val.replace(/\,/g,"");
	if (!isNaN(val)) {
		return true;
	}
	else 
	{ 
		return false;
	}	
}

function getNewDate(d) { //d - nombre de jours
	
	var date = new Date();
	var newdate = new Date(date.getTime() + (1000 * 60 * 60 * 24 * d));
	var day = (newdate.getDate()).toString();
	var month = (newdate.getMonth() + 1).toString();
	var year = (newdate.getFullYear()).toString();;

	if (day.length == 1) { day = "0" + day; }
	if (month.length == 1) { month = "0" + month; }
	
	var date = day + "/" + month + "/" + year;
	
	return date;
	
}

function setCookie(name, value, expires, path, domain, secure) {

	var today = new Date();
	today.setTime(today.getTime());
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + (expires));
	document.cookie = name + "=" + escape( value ) + ((expires) ? ";expires=" + expires_date.toGMTString() : "" ) + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ((secure) ? ";secure" : "");

}
//-------------------------------------------------------------------------------------------------------------
function createCookie(name,value,days) {
//	alert('value : ' + value);
	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 trim(string) { 
 
	return string.replace(/^\s*|\s*$/g, ""); 

}

function blnFound(string, pattern){
	
	var regexp = new RegExp(pattern,"gi");
	if (regexp.test(string)) {
		return true;
	}
	else {
		return false;
	}

}

function deleteAccent(string) {

	string = string.replace(/[àâä]/gi, "a");
	string = string.replace(/[éèêë]/gi, "e");
	string = string.replace(/[îï]/gi, "i");
	string = string.replace(/[ôö]/gi, "o");
	string = string.replace(/[ùûü]/gi, "u");
	string = string.replace(/[ÿ]/gi, "y");

	return string;
	
}

function getLeft(element) {
	var offsetLeft = 0;
	while (element != null) {
		offsetLeft += element.offsetLeft;
		element = element.offsetParent;
	}
	return offsetLeft;
}
function getTop(element) {
	var offsetHeight = element.offsetHeight;
	var offsetTop = 0;
	while (element != null) {
		offsetTop += element.offsetTop;
		element = element.offsetParent;
	}
	return offsetTop + offsetHeight;
}
function getPosition(element) { //array number
	var position = new Array();
	position[0] = getLeft(element);
	position[1] = getTop(element);
	return position;
}

function getSender(e) {

	var sender;
	if (!e) var e = window.event;
	if (e.target) sender = e.target;
	else if (e.srcElement) sender = e.srcElement;
	if (sender.nodeType == 3) sender = sender.parentNode; // Safari bug

	return sender;
	
}

function doSomething(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}

function getDepartementName(iDepartement) {
	iDepartement = parseInt(iDepartement,10);
	if (!isNaN(iDepartement)) {
		if (iDepartement <= 95) {
			var nom_departements = new Array("Ain", "Aisne", "Allier", "Alpes de Haute-Provence", "Hautes-Alpes", "Alpes Maritimes", "Ardèche", "Ardennes", "Ariège", "Aube", "Aude", "Aveyron", "Bouches-du-Rhône", "Calvados", "Cantal", "Charente", "Charente-Maritime", "Cher", "Corrèze", "Corse", "Côte d'Or", "Côtes d'Armor", "Creuse", "Dordogne", "Doubs", "Drôme", "Eure", "Eure-et-Loir", "Finistère", "Gard", "Haute-Garonne", "Gers", "Gironde", "Hérault", "Ille-et-Vilaine", "Indre", "Indre-et-Loire", "Isère", "Jura", "Landes", "Loir-et-Cher", "Loire", "Haute-Loire", "Loire-Atlantique", "Loiret", "Lot", "Lot-et-Garonne", "Lozère", "Maine-et-Loire", "Manche", "Marne", "Haute-Marne", "Mayenne", "Meurthe-et-Moselle", "Meuse", "Morbihan", "Moselle", "Nièvre", "Nord", "Oise", "Orne", "Pas-de-Calais", "Puy-de-Dôme", "Pyrénées-Atlantiques", "Hautes-Pyrénées", "Pyrénées-Orientales", "Bas-Rhin", "Haut-Rhin", "Rhône", "Haute-Saône", "Saône-et-Loire", "Sarthe", "Savoie", "Haute-Savoie", "Paris", "Seine-Maritime", "Seine-et-Marne", "Yvelines", "Deux-Sèvres", "Somme", "Tarn", "Tarn-et-Garonne", "Var", "Vaucluse", "Vendée", "Vienne", "Haute-Vienne", "Vosges", "Yonne", "Territoire de Belfort", "Essonne", "Hauts-de-Seine", "Seine Saint-Denis", "Val de Marne", "Val d'Oise");
			return nom_departements[iDepartement - 1];
		} else {
			if (iDepartement >= 971 && iDepartement <= 974) {
				var nomDomTom = new Array("Guadeloupe","Martinique","Guyane","La réunion");
				return nomDomTom[iDepartement - 971];
			}
		}
	}
	else return "";
}

function browser() {
	var browser = navigator.appName;
	var b_version = navigator.appVersion;
	var version = parseFloat(b_version);
	if (browser == "Microsoft Internet Explorer") {
		return "IE";
	}
	return "";
}


function onchange_rubrique(rub) {
	switch (rub){
	case '1': location.href = '/inscription/location/formulaire-location.asp'; break;
	case '2': location.href = '/inscription/location-vacances/formulaire-vacance.asp'; break;
	case '4': location.href = '/inscription/vente/formulaire-vente.asp'; break;
	case '8': location.href = '/inscription/vente-commerce/formulaire-commerce.asp'; break;
	default: location.href= '/inscription/vente/formulaire-vente.asp'; break;
	}
}

function favoris(url, titre)  {
	if ( window.sidebar )
		{ window.sidebar.addPanel(titre,url,""); 
	} else { 
		if (window.external) {
			window.external.AddFavorite(url,titre); 
		} else {
			if((navigator.userAgent.indexOf("Safari") > -1) && (navigator.platform.indexOf("Win") > -1)) {
				alert('Appuyez sur Ctrl-D pour ajouter aux favoris de Safari');
			}
		}
	}
}

function toolbar(url, title, printable) {
	if (title == null ||title == '') {
		title = document.title;
	}
	if (url == null || url == '') {
		url = document.location.href;
	}
	title = title.replace(/\'/g,"\\\'");
	var html = '<div class="toolbar">';
	
	html = html + '<span onclick="partage=window.open(\'http://www.facebook.com/sharer.php?u=' + url + '\',\'facebook\',\'width=600,height=400\')">';
	html = html + '<img src="/images/partage/facebook.gif" alt="Publier mon annonce sur Facebook" title="Publier mon annonce sur Facebook" /></span>';
	html = html + '<span onclick="partage=window.open(\'http://del.icio.us/post?url=' + url + '&title=' + title + '\',\'delicious\',\'width=600,height=400\')">';
	html = html + '<img src="/images/partage/delicious.png" alt="Publier mon annonce sur Delicious" title="Publier mon annonce sur Delicious" /></span>';
	
	if (window.sidebar || window.external) {
		html = html + '<span onclick="favoris(\''+ url +'\',\''+ title+'\');"><img src="/images/partage/favoris.jpg" alt="Ajouter aux favoris" title="Ajouter aux favoris" /></span>';
	}
	
	if (printable == null || printable) {
		html = html + '<span onclick="window.print();"><img src="/images/partage/impression.jpg" alt="Imprimer" title="Imprimer" /></span>';
	}
	html = html + '</div>';
	return html;
}

function logTemp(data,ref_ann,full){
	//alert(data +' - ' +ref_ann +' - ' +full);
	/*	if(data == 'Z'){
			$('.lightbox_index img').css('display', 'block');
			document.getElementById('lbindex').style.width = '403px';
			if (!document.getElementById('show-h2')) {	return null;}
			document.getElementById('show-h2').innerHTML = 'VOS DEMANDES';
			//document.getElementById('show-p').innerHTML = "Pour pouvoir accéder à vos messages, vous devez avoir souscrit l\'une de nos offes Basics, Sérénité ou Simplicité.<br />Pour plus de renseignements, nous vous invitions à prendre contact en <a href='http://www.entreparticuliers.com/groupe/contacter.asp?ref="+ref_ann+"&cas=5'>cliquant ici</a>.";
			document.getElementById('show-p').innerHTML = "Accéder à vos messages nécessite la souscription à l\'une de nos offes Basics, Sérénité ou Simplicité.<br />Pour en profiter, nous vous invitons à <a href='http://www.entreparticuliers.com/inscription/tarif/tarif_temporaire.asp?reference="+ref_ann+"'>cliquer ici</a>.";	
			$('div.div-show').click();
		}
		else{*/
			document.location.href='/EspacePerso/'+full;	
	//	}
	}

var uncrlnks = {
	_base16: "0A12B34C56D78E9F",
	_baseClassName:"hjgtrk",

	encode: function (str)
	{
		var retour="";
		for(var i=0;i<str.length;i++)
		{
			var cc=str.charCodeAt(i);
			var ch=cc>>4;
			var cl=cc-(ch*16);
			retour+=this._base16[ch]+this._base16[cl];
		}
		return this._baseClassName+retour;
	},

	decode: function (str)
	{
		var retour="";
		for(var i=0;i<str.length;i+=2)
		{
			var ch=this._base16.indexOf(str.charAt(i));
			var cl=this._base16.indexOf(str.charAt(i+1));
			retour+=String.fromCharCode((ch*16)+cl);
		}
		return retour;
	},
	
	init: function ()
	{
		var tagsA=document.getElementsByTagName("span");
		for(var i=0;i<tagsA.length;i++)
		{
			if (tagsA[i].title.substring(0,this._baseClassName.length)==this._baseClassName)
			{
				var url=this.decode(tagsA[i].title.substring(this._baseClassName.length));
				var nlink=document.createElement("A");
				nbl=tagsA[i].attributes.length;
				if (document.all)nlink.style.cssText = tagsA[i].style.cssText;
				for(var j=0;j<nbl;j++)
				{
					if (
						(tagsA[i].attributes[j].name != 'title') && 
						(tagsA[i].attributes[j].value != null) && 
						(tagsA[i].attributes[j].value != 'null')
						)
						{
						nlink.setAttribute(tagsA[i].attributes[j].name, tagsA[i].attributes[j].value);
						if (document.all && (tagsA[i].attributes[j].name.indexOf('on') == 0)) {
							eval("nlink." + tagsA[i].attributes[j].name +" = function(){"+tagsA[i].attributes[j].value+"};");
						}
					}
					tagsA[i].setAttribute(tagsA[i].attributes[j].name,'');
				}
				var nbl=tagsA[i].childNodes.length;
				for(var j=0;j<nbl;j++)
				{
					nlink.appendChild(tagsA[i].childNodes[0]);
				}
				nlink.disabled=false;
				nlink.href=url;
				if(document.all) {
					nlink.className=tagsA[i].className;
					tagsA[i].className = '';
				}
				tagsA[i].parentNode.insertBefore(nlink,tagsA[i]);
				tagsA[i].style.display='none';
				//if (document.location.href=='http://sql-back/immobilier/' && (url=='/groupe/contacter.asp')) {
				//}
				//tagsA[i].parentNode.removeChild(tagsA[i]);
			}
		}
	}	
}