
// addloadevent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}



// Fonctions clicks
var id3_keyStr = "ABCDEFGHIJKLMNOP" +
                "QRSTUVWXYZabcdef" +
                "ghijklmnopqrstuv" +
                "wxyz0123456789+/" +
                "=";


function slgoh() {
	id3_go('/');
}

function id3_go(u) {document.location.href=u;}
function id3_go64(url)
{
    var url = id3_decode64(url);
    id3_go(url);
    return false;
}

function id3_go64b(url) {
	var url = id3_decode64(url);
	window.open(url,'_blank');
	return false;
}

function id3_goidb(id)
{
	var o=document.getElementById(id);
	if (o)
		window.open(o.href,'_blank');
}
function sl_goliensp(keyword) {
	id3_go('/s_'+'overt'+'ure.htm?'+'search='+keyword);
}


function id3_decode64(input) {
   var output = "";
   var chr1, chr2, chr3 = "";
   var enc1, enc2, enc3, enc4 = "";
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   var base64test = /[^A-Za-z0-9\+\/\=]/g;
   if (base64test.exec(input)) {
      return '';
   }
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = id3_keyStr.indexOf(input.charAt(i++));
      enc2 = id3_keyStr.indexOf(input.charAt(i++));
      enc3 = id3_keyStr.indexOf(input.charAt(i++));
      enc4 = id3_keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }

      chr1 = chr2 = chr3 = "";
      enc1 = enc2 = enc3 = enc4 = "";

   } while (i < input.length);

   return output;
}
// fin fonctions clicks



Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
    var i;
    for (i=0; i < this.length; i++) {
        // Matches identical (===), not just similar (==).
        if (this[i] === value) {
            return true;
        }
    }
    return false;
};


function stopError() {
  return false;
}

//window.onerror = stopError;



function gxo2 () {document.location.replace('/'); window.event.cancelBubble=true; return false;}

function ow (url,name,x,y,scroll) {
	return window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable=yes,width='+x+',height='+y);
}



function carte(ur) {
	go3(ur,'map',"height=530,width=480,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no");
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName == pTagName)
		return el;
	else
		return getParent(el.parentNode, pTagName);
}


function go3(url,n,params) {window.open(url,n,params);}
function go(url,n,x,y) {window.open(url,n,"height="+y+",width="+x+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");}

function go2panier(ida,idb,ur,n,x,y) {
	go('/'+ida+'/'+idb+'/ajoutpanier.htm?'+ur,n,x,y);
	return false;
}

	function doTri(o) {
		if (o) {
			var tri = o.options[o.selectedIndex].value;
			if (tri=='-') return false;
			id3_go(urlpreliste+'?'+qryprelistesanstri+'&tri='+tri);
			return false;
		}
	}
	
	function refineLieux (idlieux) {
		id3_go(urlpreliste+'?'+urlrequerylieux+"&idlieux="+idlieux);
	}

	function dispLieux(chaine) {
		achaine= chaine.split('|');
		max=(((achaine.length)-1)/3)
		if (max>0) document.write ('<div class="addlieux">');
		for (i=0;i<max;i++) {
			switch (achaine[i*3+2]) {
				case '20':
					document.write ('<nobr><img border=0 src="/z/portail/sv5/images/lignes/metro.gif" align="absmiddle" hspace=4 vspace=1 />');
				break;
				case '21':
					document.write ('<nobr><img border=0 src="/z/portail/sv5/images/lignes/rer.gif" align="absmiddle" hspace=4 vspace=1 />');
				break;
				case '23':
					document.write ('<nobr><img border=0 src="/z/portail/sv5/images/lignes/metrolyon.gif" align="absmiddle" hspace=4 vspace=1 />');
				break;
			}

			document.write ('<a href=javascript:refineLieux('+achaine[i*3]+') alt="Affiner la selection sur '+achaine[i*3+1]+'" title="Affiner la selection sur '+achaine[i*3+1]+'">'+achaine[i*3+1]+'</a>');
		
			if (i<max-1) document.write ('&nbsp;');
		}
		if (max>0) document.write ('</div>');
	}
	
	function page(pg) {
		id3_go(urlbase+'?'+qrypreliste+'&immobw_ann_qrypg='+pg);
	}

function go2ami (ida,idb) {
	go('/'+ida+'/'+idb+'/reco2.htm','reco',500,280);
}

function go2print(ida,idb,ur) {
	go3('/'+ida+'/'+idb+'/print_annonce.htm?'+ur,'print','status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes');
return false;
}

function go2aideAudio(idannonce,query) {
	ow('/'+idannonce+'/aide_audio.htm?parametre='+query,'aide',550,450,'yes');
return false;
}

function go2audioteletranger(idannonce) {
	ow('/'+idannonce+'/aide_audio.htm#etranger','aide',550,450,'yes');
return false;
}

function goimvi (url)
{
 	o=window.open(url,"immovision_lancement","height=400,width=500,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no");
 //	setTimeout('o.close();',10000);
}

function pubfill468() {
	var is4 = false;
	var htmban='';

	var o =document.getElementById("pubmgn728");
	if (o) {
		var all=o.all;
		var l=all.length;
		for (var i = 0 ; i < l ; i++)
			if (all[i].width==468) is4=true;
		if (is4) {
				switch (Math.round(Math.random()*1)) {
				case 1:
					htmban='<a href="/argus,index.htm"><img src="/z/portail/sv5/images/pubs/72820/argus.gif" border=0></a>';
					break;
				default:
					htmban='<a href="/s_offredecredit/eSRubrf.htm"><img src="/z/portail/sv5/images/pubs/72820/financement.gif" border=0></a>';
				}
			o.innerHTML=htmban+'<br>'+o.innerHTML;
			o.innerHTML+=getPubDr();
		}
	}
}
function getPubDr () {
	var htmbanb='';
	switch (Math.round(Math.random()*10)) {

		case 1,2:
		htmbanb='<a href="/s_overture.htm?search=adsl" style="margin-left:4px;"><img src="/z/portail/sv5/images/pubs/468d/adsl.gif" border=0></a>';
		break;	
		case 3,9:
		htmbanb='<a href="/s_overture.htm?search=ordinateurs" style="margin-left:4px;"><img src="/z/portail/sv5/images/pubs/468d/ordinateurs.gif" border=0></a>';
		break;	
		case 4:
		htmbanb='<a href="/s_overture.htm?search=rencontres" style="margin-left:4px;"><img src="/z/portail/sv5/images/pubs/468d/rencontres.gif" border=0></a>';
		break;	
		case 5,8:
		htmbanb='<a href="/s_overture.htm?search=vacances" style="margin-left:4px;"><img src="/z/portail/sv5/images/pubs/468d/vacances.gif" border=0></a>';
		break;	
		default:
		htmbanb='<a href="/alerte,index.htm" style="margin-left:4px;"><img src="/z/portail/sv5/images/pubs/468d/alerte.gif" border=0></a>';
		break;	
	}
	return htmbanb;
}

//////////////////////////////////////////////////////////////////
// qTip - CSS Tool Tips - by Craig Erskine
// http://qrayg.com | http://solardreamstudios.com
//
// Inspired by code from Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
//////////////////////////////////////////////////////////////////



var qTipTag = Array ("a","input");
var qTipX = -30; 
var qTipY = 10;

tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle;

	for(var j=0;i<qTipTag.length; j++) 
	{
		var anchors = document.getElementsByTagName (qTipTag[j]);
		for (var i = 0; i < anchors.length; i ++) {
			a = anchors[i];
			alert(a);
			
			sTitle = a.getAttribute("title");
			if(sTitle) {
				a.setAttribute("tiptitle", sTitle);
				a.removeAttribute("title");
				a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
				a.onmouseout = function() {tooltip.hide()};
			}
	}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}



