
function view_div(id, type){
        //alert(document.getElementById(id).style.display);
        if(type == '')
                type = 'block';
        if(document.getElementById(id)){
                if(document.getElementById(id).style.display == 'none' || document.getElementById(id).style.display == '')
                        document.getElementById(id).style.display = type;
                else
                        document.getElementById(id).style.display = 'none';

        }

}


function check_left_right_bar(){
		
	if(document.getElementById('rightbar') &&  document.getElementById('maindiv')){
		var right = document.getElementById('rightbar');
		var center = document.getElementById('maindiv');
		if( (right.offsetHeight) > center.offsetHeight){
			center.style.marginBottom = (right.offsetHeight - center.offsetHeight + 10 ) + 'px';
		}	
	}

	if(document.getElementById('leftbar') &&  document.getElementById('maindiv')){
		var left = document.getElementById('leftbar');
		var center = document.getElementById('maindiv');
		if( (left.offsetHeight) > center.offsetHeight){
			center.style.marginBottom = (left.offsetHeight - center.offsetHeight + 20) + 'px';
		}
	}
}


function ChangeGraphVieuw(type, nohidemap){
		tabType = ['precip', 'temp', 'swell', 'cond', 'water']; 
		if (nohidemap != 'true') 
			document.getElementById('ggmap').style.display =  'none'
		
		for(i=0;i<5;i++){
			if(document.getElementById('graph-'+tabType[i])){
				if(tabType[i] == type){
					if(document.getElementById('graph-'+tabType[i]).style.display == 'block'){
						document.getElementById('graph-'+tabType[i]).style.display =  'none';
						document.getElementById('ggmap').style.display =  'block'
					}else{
					
						document.getElementById('graph-'+tabType[i]).style.display =  'block';
					}
				}else{
					document.getElementById('graph-'+tabType[i]).style.display =  'none';
				}
			}
		}
		
	}
	
function ViewFieldset(idf){
	display = document.getElementById('field'+idf).style.display == 'block' ? 'none' : 'block';
	document.getElementById('field'+idf).style.display = display;	
}



/************* PhotoEngine ***********/
function SendSelected(ac){
	pengine.action = ac;
	pengine.sendphotoselected();
}

function PhotoToSpot(num){
	//alert(pengine.action);
	pengine.addphotoselected(num);
}

function DeletPhoto(num){
	pengine.action = 'deletuserimg';
	pengine.addphotoselected(num);
}

function DeletFromArea(type, pid, aid){
	if(confirm('Yes'))
		pengine.deletfromarea(type, pid);
}

function PhotoDeselected(num, ac){
	pengine.action = ac;
	pengine.removephotoselected(num);
}
function ChangePage(nump){ 
	pengine.changepage(nump);	 
}
function ChangeTotal(num){
	pengine.changetotalbypage(num);
}
function ViewPhoto(num){
	pengine.viewonephoto(num);
}  

function ViewOtherPhoto(fname ){
	pengine.viewotherphoto(fname);
} 

function ClosePhoto(num){
	pengine.closeonephoto(num);
}  
	
	
function PhotoEngine(){
		this.photoselected = null
		this.user_id = null;
		this.spot_id = null;
		this.totalbypage = null;
		this.currentpage = null;
		this.action = null;
		this.xsl = null;
		this.xslresult = null;
		this.url = null;
		this.htmlid =null;
		this.ajax = null;
		this.output = '';
		this.currenty = 0;
		this.currentopened = 0;
		this.xmlinfo = null;
		this.lastaction = '';
		this.typearea = 'spot'
		this.reload = false;
		this.xslzoom = false;
		this.numaddremove = 2;
	}
	
PhotoEngine.prototype.changetotalbypage = function(n){
		if(n >0)
			this.totalbypage += this.numaddremove;
		else
			this.totalbypage -= this.numaddremove;
		if(this.totalbypage<this.numaddremove)
			this.totalbypage=this.numaddremove;
		this.changepage(1);
	}
	
PhotoEngine.prototype.createxml = function(){
		if (document.implementation && document.implementation.createDocument) {
			docXml = document.implementation.createDocument('', '', null);
		}else if (window.ActiveXObject){
			docXml = new ActiveXObject("Microsoft.XMLDOM");
		}
		
		docXml.appendChild(docXml.createElement("root"));
		docXml.lastChild.setAttribute('action',this.action);
		
		return docXml;
	}
	
PhotoEngine.prototype.viewotherphoto = function(fname, event){
		docXml = this.createxml();
		docXml.firstChild.appendChild(docXml.createElement('photo'));
		docXml.firstChild.firstChild.appendChild(docXml.createTextNode(fname));
		
		document.getElementById('specialdiv').innerHTML = this.returnxhtmlcode(docXml, this.xslzoom);
		document.getElementById('specialdiv').style.display = 'block';
		this.currenty = window.scrollY ?  window.scrollY : document.documentElement.scrollTop;
		window.scrollTo(0,0);
	}
	 
	
PhotoEngine.prototype.viewonephoto = function(n, event){
		docXml = this.createxml();
		var photos = this.xmlinfo.getElementsByTagName('photo');
		for (j=0;j<photos.length;j++){
			if(photos[j].getAttribute('id') == n){
				docXml.firstChild.appendChild(photos[j].cloneNode(true));
			}
		}
		document.getElementById('specialdiv').innerHTML = this.returnxhtmlcode(docXml, this.xslzoom);
		document.getElementById('specialdiv').style.display = 'block';
		this.currenty = window.scrollY ?  window.scrollY : document.documentElement.scrollTop;
		window.scrollTo(0,0);
	}
	
PhotoEngine.prototype.closeonephoto = function(n){
			window.scrollTo(0,this.currenty);
			document.getElementById('specialdiv').style.display = 'none';
	} 
	
	
	
PhotoEngine.prototype.deletfromarea = function(type, pid){
	var last = this.currentpage;
	this.currentpage = pid;
	this.action = 'removefrom'+type;
	this.htmlid ='actionresponse';
	this.launchajax(this.xslresult);
	this.currentpage = last;
	this.photoselected = null;
	this.reload =true;
}

	
PhotoEngine.prototype.sendphotoselected = function(){
		var last = this.currentpage;
		this.currentpage = '';
		var photos = this.photoselected.getElementsByTagName('photo');
		for (j=0;j<photos.length;j++){
			this.currentpage += photos[j].getAttribute('id')+';';
		}
		this.htmlid ='actionresponse';
		this.launchajax(this.xslresult);
		this.currentpage = last;
		this.photoselected = null;
		this.reload =true;
		//this.changepage(this.currentpage);
	} 
	
PhotoEngine.prototype.removephotoselected = function(n){
		var photos = this.photoselected.getElementsByTagName('photo');
		var tmpxml = this.createxml();
		for (j=0;j<photos.length;j++){
			if(photos[j].getAttribute('id') != n){
				tmpxml.firstChild.appendChild(photos[j].cloneNode(true));
			}
		}
		this.photoselected = tmpxml;
		document.getElementById('actionresponse').innerHTML = this.returnxhtmlcode(this.photoselected, this.xslresult);
	}
	
PhotoEngine.prototype.addphotoselected = function(n){
		if(!this.photoselected){
			this.photoselected = this.createxml();
			
		}else{
			var photos = this.photoselected.getElementsByTagName('photo');
			for (j=0;j<photos.length;j++){
				if(photos[j].getAttribute('id') == n){
					return null;
				}
			}
		}
		//var node = this.photoselected.getElementsByTagName('action');
		//node.setAttribute('val',this.action);
		
		var photos = this.xmlinfo.getElementsByTagName('photo');
		for (j=0;j<photos.length;j++){
			if(photos[j].getAttribute('id') == n){
				this.photoselected.firstChild.appendChild(photos[j].cloneNode(true));
			}
		}
		
		document.getElementById('actionresponse').innerHTML = this.returnxhtmlcode(this.photoselected, this.xslresult);
	} 
	
PhotoEngine.prototype.launchajax=  function(){
		this.ajax = new AjaxEngine(this);
		this.ajax.url = this.url;
		this.ajax.AddVariable('user', this.user_id);
		this.ajax.AddVariable('spot', this.spot_id);
		this.ajax.AddVariable('tbp', this.totalbypage);
		this.ajax.AddVariable('cp', this.currentpage);
		this.ajax.AddVariable('action', this.action);
		this.ajax.AddVariable('type', this.typearea);
		//document.write(this.ajax.MakeUrl());
		this.ajax.SendRequest();
		
		return true;
	}
	
PhotoEngine.prototype.changepage = function(n){
	//alert(this.action);
		if(this.action == '')
				this.action = 'getimglist';
		this.lastaction = this.action;
		this.action = 'getimglist';
		this.currentpage = n; 
		this.htmlid ='photolist';
		this.launchajax();
		//this.action = this.lastaction;
		
	}
	
PhotoEngine.prototype.SetInfos = function(user, spot, tbp, cp){
		this.user_id = user;
		this.spot_id = spot;
		this.totalbypage = tbp;
		this.currentpage = cp;
	}
	
PhotoEngine.prototype.SetUser = function(user){
		this.user_id = user;
		this.spot_id = 0;
		this.changepage(1);
	}
	
PhotoEngine.prototype.SetSpot = function(spot, type){
		if(type != '')
			this.typearea = type;
		this.user_id = 0;
		this.spot_id = spot;
		this.changepage(1);
	}
	
	
PhotoEngine.prototype.returnxhtmlcode = function(xmlDoc, xslf){
		if(window.ActiveXObject){
			var FileXSL = new ActiveXObject("Microsoft.xmldom");
			FileXSL.async = false; 
			FileXSL.load(xslf);
			return xmlDoc.transformNode(FileXSL);
			
		}else{
			var xslDoc = document.implementation.createDocument('', '', null);
			xslDoc.async = false; 
			xslDoc.load(xslf);
			var xslt = new XSLTProcessor();
			xslt.importStylesheet(xslDoc);
			var result = xslt.transformToDocument(xmlDoc);
			var xmls = new XMLSerializer();
                        return xmls.serializeToString(result);
                }
	}
	
PhotoEngine.prototype.AnalyseResponse =  function(xmlDoc){
		this.xmlinfo = xmlDoc;
		if(this.action == 'getimglist'){
			xl = this.xsl;	
		}else{
			
			xl = this.xslresult
		}
		if(this.action != this.lastaction)
			this.action = this.lastaction;
			
		this.output = this.returnxhtmlcode(this.xmlinfo, xl);
		document.getElementById(this.htmlid).innerHTML = this.output ;
		//+ this.ajax.MakeUrl();
		if(this.reload){
			this.reload =false;
			this.changepage(this.currentpage);
		}
			
	}
 




	

/************* Ajax Engine ***********/
function ValidRequest(ae){
	if(ae.http.readyState == 4){
		ae.parent.AnalyseResponse(ae.http.responseXML);
	}
}
	
	
var AjaxEngine = Class.create();
AjaxEngine.prototype = {

	initialize: function(par){
		this.parent = par;
		this.http = null;
		this.method = 'GET';
		this.url = '';
		this.variablesn = new Array;
		this.variablesv = new Array;
		this.countvar = 0;
		
	},

	InitRequest: function(){
		if (window.XMLHttpRequest){     
			this.http = new XMLHttpRequest();    
		}else if (window.ActiveXObject){   
			this.http = new ActiveXObject("Microsoft.XMLHTTP");    
		}
		var ae = this;
		this.http.onreadystatechange = function(){ValidRequest(ae);}
	},
	
	
	SendRequest: function(){
		this.InitRequest();
		//document.write(this.MakeUrl());
//document.write(this.MakeUrl());
		this.http.open( this.method, this.MakeUrl(), true);
		//alert(this.MakeUrl());
		this.http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
		this.http.send(null); 
	},

	ResetVariable: function(){
		this.variablesn = new Array;
		this.variablesv = new Array;
		this.countvar = 0;
	},
	
	AddVariable: function(name, value){
		this.variablesn[this.countvar] = name;
		this.variablesv[this.countvar] = value;
		this.countvar ++;
	},

	MakeUrl: function(){
		var tmp = this.url + '?';
		for(i=0;i<this.countvar;i++){
			tmp = tmp + this.variablesn[i] +'='+this.variablesv[i]+'&';
		}
		return tmp;
	}
}

/******************** SEARCH Engine **************/



/*********** MAP engine ***************/

function mapEngine(cmap){
	this.map = cmap;
	this.listoptions = new Array('lang', 'viewchild', 'action', 'type', 'x', 'y', 'zoom', 'boundnex', 'boundney', 'boundswx', 'boundswy', 'detailtype', 'detailid', 'filterzoom', 'filtermap', 'stop');
	this.options = new Array(this.listoptions.length);
	this.alltype = new Array('country', 'zone-surf', 'destination', 'spot' , 'zone-snow', 'resort');
	for(var i=0;i<this.listoptions.length;i++){
		this.options[this.listoptions[i].toString()] = '';
	}
	this.history = new Array(); 
	for(var i=0;i<20;i++){
		this.history[i] = '';
	}
	this.listopened = '';
	this.ongletcount = 1;
	this.lastzoom = '1';
	this.historypos = 0;
	this.flagadd = '';
	this.currentong = 0;
	this.lang ='fr';
	this.flaghisto = true;
	this.options['action'] = 'getlist';
	this.options['stop'] =false;
	this.options['filterzoom'] =false;
	this.options['viewchild'] =true;
	this.options['filtermap'] =false;
	this.url = 'http://trip.estimfriends.com/commun/ajax/ajax_mapnav_getinfo.php';
	this.xmlinfo = null;
	this.overlays = new Object(); 
	this.xslf = 'http://trip.estimfriends.com/commun/ajax/ajax_mapnav_list.xsl';
	this.ajax = new AjaxEngine(this);
}

mapEngine.prototype.launch = function (){
	this.view('country');
}

mapEngine.prototype.HideViewList = function (){
	if(document.getElementById('map_navlist').style.display == 'none')
		document.getElementById('map_navlist').style.display = 'block';
	else
		document.getElementById('map_navlist').style.display = 'none';
}

mapEngine.prototype.FilterZoom = function(){
	if(this.options['filterzoom'])
		this.options['filterzoom'] =false;
	else
		this.options['filterzoom'] =true;
	this.launchajax();
}
mapEngine.prototype.FilterMap = function(){
	if(this.options['filtermap'])
		this.options['filtermap'] = false;
	else
		this.options['filtermap'] = true;
	this.launchajax();
}
mapEngine.prototype.Stop = function(){
	if(this.options['stop'])
		this.options['stop'] =false;
	else
		this.options['stop'] =true;
}
mapEngine.prototype.ViewChild = function(){
	if(this.options['viewchild'])
		this.options['viewchild'] =false;
	else
		this.options['viewchild'] =true;
}

mapEngine.prototype.CloseLoadImg = function(){
	if(document.all)
		document.getElementById('superglobal').filters.alpha.opacity=100;
	else
		document.getElementById('superglobal').style.MozOpacity=1;
}
mapEngine.prototype.OpenLoadImg = function(){
	if(document.all)
		document.getElementById('superglobal').filters.alpha.opacity=50;
	else
		document.getElementById('superglobal').style.MozOpacity=0.5;
}
mapEngine.prototype.ChangeType =  function (t) {
	this.map.setMapType(t);
}
mapEngine.prototype.ChangeZoom = function(z){
	
	this.map.setZoom(this.map.getZoom() + z);
}

mapEngine.prototype.CheckOptions = function(){
	var li = new Array('viewchild', 'filterzoom', 'filtermap', 'stop');
	for(var i=0;i<li.length;i++){
		document.getElementById('input-'+li[i]).checked = this.options[li[i]];
	}
	li = null;
	for(var i=0;i<this.alltype.length;i++){
		if(this.options['type'].toString().indexOf(this.alltype[i].toString()) >= 0){
			document.getElementById('input-'+this.alltype[i].toString()).checked = true;
		}else{
			document.getElementById('input-'+this.alltype[i].toString()).checked = false;
		}
	}
	
	
}

mapEngine.prototype.MoveTo = function(x, y, z, type, id){
		this.options['filtermap'] = true;
		this.options['filterzoom'] = false;
		this.options['detailid'] = id;
		this.options['detailtype'] = type;
		if(this.options['type'].toString().indexOf(type) == -1){
			this.options['type'] += ';'+type;
			//alert(this.options['type']);
		}
		this.options['zoom'] = z;
		this.map.setCenter(new GLatLng(x, y), parseInt(z) );
}

mapEngine.prototype.SetOptions = function(){
	if(!this.options['stop']){
		this.options['lang'] = this.lang;
		this.options['zoom'] = this.map.getZoom();
		this.options['boundnex'] = this.map.getBounds().getNorthEast().lng();
		this.options['boundney'] = this.map.getBounds().getNorthEast().lat();
		this.options['boundswx'] = this.map.getBounds().getSouthWest().lng();
		this.options['boundswy'] = this.map.getBounds().getSouthWest().lat();
		this.options['y'] = this.map.getBounds().getCenter().lat();
		this.options['x'] = this.map.getBounds().getCenter().lng();
		this.ajax.ResetVariable();
		for(var i=0;i<this.listoptions.length;i++){
			this.ajax.AddVariable(this.listoptions[i], this.options[this.listoptions[i].toString()]); 
		}
	}
}

mapEngine.prototype.MoveMap = function(){
	if(!this.options['stop']){
		this.SetOptions();
		if(  this.flaghisto &&( 
			(!this.options['filtermap'] && !this.options['filterzoom']) ||
			
			(this.options['type']==';' || this.options['type']=='') ||
			(this.lastzoom == this.map.getZoom() && !this.options['filtermap'])
			))
		{
			this.checkhistory();
		}else{
			//alert('l');
			//alert(this.lastzoom+'--'+this.map.getZoom());
			this.lastzoom = parseInt(this.map.getZoom());
			this.map.clearOverlays();
			this.launchajax();
		}
		
		
		
		
			
	}
	
}

mapEngine.prototype.returnhtmlinfo = function(){
	if(window.ActiveXObject){
		var FileXSL = new ActiveXObject("Microsoft.xmldom");
		FileXSL.async = false; 
		FileXSL.load(this.xslf);
		return this.xmlinfo.transformNode(FileXSL);
			
	}else{
		var xslDoc = document.implementation.createDocument('', '', null);
		xslDoc.async = false; 
		xslDoc.load(this.xslf);
		var xslt = new XSLTProcessor();
		xslt.importStylesheet(xslDoc);
		var result = xslt.transformToDocument(this.xmlinfo);
		var xmls = new XMLSerializer();
                return xmls.serializeToString(result);
        }
}
	
	
mapEngine.prototype.view = function(ctype){
	
	if(this.options['type'].lastIndexOf(ctype) == -1){
		if(this.options['type'] == '' || this.options['type'] == ';'){
			this.icon = null;
			this.options['type'] = ctype;
			this.launchajax();
		}else{
			//this.flagadd = this.options['type'];
			this.icon = null;
			this.options['type'] = this.options['type']+';'+ctype;
			this.launchajax();
			//this.options['type'] = this.flagadd +';'+ctype;
			
		}
	}else{
		this.map.clearOverlays();
		this.options['type'] = this.options['type'].replace(ctype, '');
		this.options['type'] = this.options['type'].replace(';;', ';');
		this.options['type'] = this.options['type'].replace(';;', ';');
		if(this.options['type']==';' || this.options['type']==''){
			this.options['type'] = '';
			document.getElementById('map_navlist').innerHTML = '';
		}else{
			this.launchajax();
		}
	}
	
}
mapEngine.prototype.decodeUrl = function(url){
	
	var tab = url.split('?');
	tab = tab[1].split('&');
	for(var i =0;i<tab.length;i++){
		var inf = tab[i].split('=');
		if(inf.length == 2 && this.options[inf[0]]!= undefined){
			if(inf[1] == 'true'){
				this.options[inf[0]] = true;
			}else if(inf[1] == 'false'){
				this.options[inf[0]] = false;
			}else{
				this.options[inf[0]] = inf[1];
			}
		}
	}
	
}
mapEngine.prototype.MoveMapToOptions = function(){
	var x = parseFloat(this.options['x']);
	var y = parseFloat(this.options['y']);
	var z = parseInt(this.options['zoom']);
	//alert(y +' -- '+x+' -- '+z);
	//this.options['stop'] = true;
	this.map.setCenter(new GLatLng(y, x),z );
	
}

mapEngine.prototype.historyback = function(){
	this.historypos +=1;
	if(this.historypos <= 19 && this.history[this.historypos] != ''){
		
		//alert(this.history[this.historypos]);
		//this.OpenLoadImg();
		this.map.clearOverlays();
		this.decodeUrl(this.history[this.historypos]);
		//this.launchajax(true);
		this.flaghisto = false;
		this.MoveMapToOptions();
	}else{
		this.historypos -=1;
	}
	
}
	
mapEngine.prototype.historynext = function(){
	this.historypos -=1;
	if(this.historypos >= 0 && this.history[this.historypos] != ''){
		//this.OpenLoadImg();
		this.map.clearOverlays();
		this.decodeUrl(this.history[this.historypos]);
		this.flaghisto = false;
		this.MoveMapToOptions();
		
		
	}else{
		this.historypos +=1;
	}
}


mapEngine.prototype.checkhistory = function(){
	this.SetOptions();
	//alert(this.historypos);
	for(var i=0;i<this.historypos;i++){
		this.history.shift();
	}
	for(var i=19-this.historypos;i<=19;i++){
		//alert(this.history[i]);
	}
	this.historypos = 0;
	for(var i=19;i>=0;i--){
		//alert(i + '--' + this.history[i]);
		this.history[i+1] = this.history[i];
	}
	this.history[0] = this.ajax.MakeUrl(); 
	//alert(this.history[0]);
}

mapEngine.prototype.launchajax = function(histo){
	if(this.options['type']==';' || this.options['type']=='')
		return;
	this.SetOptions();
	this.OpenLoadImg();
	this.ajax.url = this.url;
	this.SetOptions();   
	if(this.flaghisto){
		
		this.checkhistory();
		
	}else{
		this.flaghisto = true;
	}
	this.ajax.SendRequest();
	
}

mapEngine.prototype.overout = function(){
	document.getElementById('specialdiv2').style.display ='none';
	document.getElementById('specialdiv2').innerHTML = '';
}

mapEngine.prototype.overinfo = function(ctype, cid){
	
	//alert('toto');
	var typenode = this.xmlinfo.getElementsByTagName('list');
	var text = '';
		for(var i=0;i<typenode.length;i++) {
			if(typenode[i].getAttribute('type') == ctype){
				var areanode = typenode.item(i).getElementsByTagName('area');
				for(var j=0;j<areanode.length;j++) {
					if(areanode[j].getAttribute('id') == cid){
						text = '<div><p>'+areanode[j].getAttribute('typestr')+'<br/> '+areanode[j].getAttribute('name')+areanode[j].getAttribute('infos').replace('-', '<br/>')+'</p></div>';
						
					}
				}
				areanode = null;
			}
		}
	typenode = null;
	document.getElementById('specialdiv2').style.display ='block';
	document.getElementById('specialdiv2').innerHTML = text;
	//alert(document.getElementById('ggmap').offsetX);
	document.getElementById('specialdiv2').style.left = document.getElementById('ggmap').offsetLeft +'px';
	document.getElementById('specialdiv2').style.top = document.getElementById('ggmap').offsetTop +'px';
}



mapEngine.prototype.AnalyseResponse = function(xmlDoc){
	//alert('start');document.getElementById('specialdiv2').style.display ='none';
	document.getElementById('specialdiv2').style.display ='none';
		this.xmlinfo = xmlDoc;
		var typenode = this.xmlinfo.getElementsByTagName('list');
		for(var i=0;i<typenode.length;i++) {
			var areanode = typenode.item(i).getElementsByTagName('area');
			;
			for(var j=0;j<areanode.length;j++) {
				if(this.options['type'].toString().indexOf(areanode.item(j).getAttribute('type')) == -1){
					this.options['type'] += ';'+areanode.item(j).getAttribute('type');
					
				}
				this.createMarker(this.checkIcon(typenode.item(i).getAttribute('type')), 
					areanode.item(j).getAttribute('id'), areanode.item(j).getAttribute('y'), 
					areanode.item(j).getAttribute('x') , areanode.item(j).getAttribute('z') , 
					areanode.item(j).getAttribute('type'));
			}
			areanode = null;
		}
		typenode = null;
		if(this.flagadd != ''){
			document.getElementById('map_navlist').innerHTML +=  this.returnhtmlinfo();
			this.flagadd = '';
		}else{
			
			document.getElementById('map_navlist').innerHTML =  this.returnhtmlinfo();
		}
		var detailnode = this.xmlinfo.getElementsByTagName('areadetail');
		var tmpnode = this.xmlinfo.getElementsByTagName('htmlcode');
		if(tmpnode.length == 1 && this.listopened.lastIndexOf(detailnode.item(0).getAttribute('typestr')+ ' -- '+tmpnode.item(0).getAttribute('name')) == -1){
			this.listopened += detailnode.item(0).getAttribute('typestr')+ ' -- '+tmpnode.item(0).getAttribute('name');
			var tmpdiv = document.createElement("DIV");
			tmpdiv.innerHTML = tmpnode.item(0).getAttribute('value');
			tmpdiv.id = 'mapnav_onglet_'+this.ongletcount;
			tmpdiv.style.display = 'block'
			document.getElementById('mapnavglobal').appendChild(tmpdiv);
			tmpdiv = null;
			
			
			var tmpdiv = document.createElement("DIV");
			
			var tmplinkclose = document.createElement("A");
			tmplinkclose.innerHTML = 'X';
			tmplinkclose.className = 'mapnav_close';
			tmplinkclose.href = 'javascript:cmapEngine.closeOng('+this.ongletcount+')';
			/*tmplinkclose = 'mapnav_menuspan_'+this.ongletcount;*/
			
			
			var tmplink = document.createElement("A");
			tmplink.className = 'mapnav_menuahover ';
			tmplink.id = 'mapnav_menua_'+this.ongletcount;
			tmplink.innerHTML = detailnode.item(0).getAttribute('typestr')+ ' -- '+tmpnode.item(0).getAttribute('name');
			tmplink.href = 'javascript:cmapEngine.viewOng('+this.ongletcount+')';
			tmpdiv.appendChild(tmplink);
			
			document.getElementById('mapnav_menu').appendChild(tmpdiv);
			tmpdiv.appendChild(tmplinkclose);
			for(var s=1;s<=this.ongletcount;s++){
				document.getElementById('mapnavglobal').childNodes[s].style.display = 'none';
				document.getElementById('mapnav_menu').childNodes[s].firstChild.className = 'mapnav_menua'
				
			}
			//document.getElementById('mapnavglobal').childNodes[0].style.display = 'none';
			this.currentong = this.ongletcount;
			this.ongletcount += 1;
			
			//document.getElementById('map_navresult').innerHTML =  '<h1><a href="'+tmpnode.item(0).getAttribute('url')+'">'+tmpnode.item(0).getAttribute('name')+'</a></h1>'+tmpnode.item(0).getAttribute('value') ;
		} 
		tmpnode = null
		//this.ajax = null;
		this.CheckOptions();
		
		this.options['detailid'] = 0;
		this.options['detailtype'] = '';
		
		this.CloseLoadImg();
}

mapEngine.prototype.closeOng = function(id) {
	if(this.currentong == id){
		this.viewOng(0);
	}
	this.listopened = this.listopened.replace(document.getElementById('mapnav_menu').childNodes[id].firstChild.innerHTML, '');
	document.getElementById('mapnav_menu').removeChild(document.getElementById('mapnav_menu').childNodes[id]);
	document.getElementById('mapnavglobal').removeChild(document.getElementById('mapnavglobal').childNodes[id]);
	this.ongletcount -= 1;
}
mapEngine.prototype.viewOng = function(id) {
	this.currentong = id;
	for(var s=0;s<this.ongletcount;s++){
		if(s != id){
			document.getElementById('mapnavglobal').childNodes[s].style.display = 'none';
			document.getElementById('mapnav_menu').childNodes[s].firstChild.className = 'mapnav_menua'
		}else{
			document.getElementById('mapnavglobal').childNodes[s].style.display = 'block';
			document.getElementById('mapnav_menu').childNodes[s].firstChild.className = 'mapnav_menuahover '
		}
		
		
		//document.getElementById('mapnav_menu').removeChild(document.getElementById('mapnav_menu').childNodes[s]);
	}
}
	
mapEngine.prototype.checkIcon = function(type) {
	var icon = new GIcon();
	icon.image = "http://trip.estimfriends.com/img/ggmapflag_"+type+".png";
	icon.iconSize = new GSize(20, 20);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);
	return icon;
}
	
mapEngine.prototype.createMarker = function(icon, id, x, y , z,  type) {
			var point = new GLatLng(x,y);
			var marker = new PdMarker(point, icon);
			GEvent.addListener(marker, 'mouseover', function() {
					 cmapEngine.overinfo(type, id)  });
			 GEvent.addListener(marker, 'mouseout', function() {
					 cmapEngine.overout()  });
			//marker.setTooltip(this.overinfo(type, id));
			GEvent.addListener(marker, 'click', function() {
					 cmapEngine.MoveTo(x, y, z, type, id)  });
			this.map.addOverlay(marker);
			point = null;
			marker = null;
}



////////////////////�********************************************************////////////////////////////////////


// retourne un objet xmlHttpRequest.
// m�thode compatible entre tous les navigateurs (IE/Firefox/Opera)


searchEngine.prototype.launchSearch = function(valeur){
	if(document.getElementById('quicksearch_loadimg'))
		document.getElementById('quicksearch_loadimg').style.display = 'inline';
	this.ajax.url = this.url;
	this.ajax.ResetVariable();
	this.ajax.AddVariable('str', valeur); 
	this.ajax.AddVariable('lang', this.lang); 
	this.ajax.AddVariable('optionbystr', this.optionbystr); 
	//alert(this.ajax.MakeUrl());

	this.ajax.SendRequest();
}



searchEngine.prototype.AnalyseResponse = function(xmlDoc){
	
	var options = xmlDoc.getElementsByTagName('area');
	var optionsListe = new Array();
	var lasttype = '';
	
	for (var i=0; i < options.length; ++i) {
		if(lasttype != options[i].getAttribute('type')){
			lasttype = options[i].getAttribute('type');	
			//optionsListe.push(options[i].getAttribute('typestr')+'</b> ---');
			optionsListe.push('<b>--- '+options[i].getAttribute('typestr')+'</b> ---');
		}
		optionsListe.push('<a href="'+options[i].getAttribute('url')+'">'+options[i].getAttribute('name')+'<i>'+options[i].getAttribute('infos')+'</i></a>');
		//optionsListe.push(options[i].getAttribute('name'));
	}
	
	this.cacheResults(this.inputField.value, optionsListe);
        this.metsEnPlace(this.inputField.value, optionsListe);
	if(document.getElementById('quicksearch_loadimg'))
		document.getElementById('quicksearch_loadimg').style.display = 'none';
	//this.completeDiv.style.visibility="visible";
}

function searchEngine(lang){
	this.optionbystr = true;
	this.resultCache = new Array();
	this.completeDivRows = 0;
	this.lang= lang;
	this.completeDivDivList = null;
	this.highlightedSuggestionIndex = -1;
	this.highlightedSuggestionDiv = null;

	this.ajax = new AjaxEngine(this);
	this.xmlinfo = null;
	this.completeListe = null;
	this.completeDiv = null;
	this.inputid = 'input-searchengine' ;
	this.url = 'http://trip.estimfriends.com/commun/ajax/ajax_search_getinfo.php';
	this.inputField = document.getElementById(this.inputid);
	this.documentForm=document.getElementById('input-form');
	this.submitButton=document.getElementById('input-submit');
	
	this.lastKeyCode=null;
	this.cursorUpDownPressed = null;
	this.eventKeycode = null;
	this.inputField.autocomplete="off";
	this.creeAutocompletionDiv();
	this.currentInputFieldValue = this.inputField.value;
	this.oldInputFieldValue= this.currentInputFieldValue;
	this.cacheResults("",new Array());
	document.onkeydown=onKeyDownHandler;
	this.inputField.onkeyup=onKeyUpHandler;
	this.inputField.onblur=onBlurHandler;
	window.onresize=onResizeHandler;
	setTimeout("mainLoop()",200)
	
}

function mainLoop(){
	se.mainLoop();
}

// tourne en permanence pour suggerer suite � un changement du champ texte
searchEngine.prototype.mainLoop = function(){
  if(this.oldInputFieldValue!=this.currentInputFieldValue){
    var valeur=this.escapeURI(this.currentInputFieldValue);
    var suggestions=this.resultCache[this.currentInputFieldValue];
    if(suggestions){ // la r�ponse �tait encore dans le cache
      this.metsEnPlace(valeur,suggestions)
    }else{
	    this.launchSearch(valeur); 
     // this.callSuggestions(valeur) // appel distant
    }
    this.inputField.focus()
  }
  this.oldInputFieldValue=this.currentInputFieldValue;
  setTimeout("mainLoop()",200); // la fonction se red�clenchera dans 200 ms
  return true
}

// echappe les caract�re sp�ciaux
searchEngine.prototype.escapeURI = function (La){
  if(encodeURIComponent) {
    return encodeURIComponent(La);
  }
  if(escape) {
    return escape(La)
  }
}


// Mecanisme de caching des r�ponses
searchEngine.prototype.cacheResults = function(debut,suggestions){
  this.resultCache[debut]=suggestions
}

//ins�re une r�gle avec son nom
searchEngine.prototype.insereCSS = function(nom,regle){
  if (document.styleSheets) {
    var I=document.styleSheets[0];
    if(I.addRule){ // m�thode IE
      I.addRule(nom,regle)
    }else if(I.insertRule){ // m�thode DOM
      I.insertRule(nom+" { "+regle+" }",I.cssRules.length)
    }
  }
}

searchEngine.prototype.initStyle = function(){
  var AutoCompleteDivListeStyle="font-size: 13px; font-family: arial,sans-serif; ";
  var AutoCompleteDivStyle="display: block; padding-left: 3px; padding-right: 3px; height: 16px; overflow: hidden; background-color: white;";
   var AutoCompleteDivAStyle="padding-left:1.5em;color:black;text-decoration:none;display:block;";
    var AutoCompleteDivIStyle="margin-left:1em;font-size:0.8em;";
  var AutoCompleteDivActStyle="background-color: #3366cc; color: white ! important; ";
  this.insereCSS(".AutoCompleteDivListeStyle",AutoCompleteDivListeStyle);
  this.insereCSS(".AutoCompleteDiv",AutoCompleteDivStyle);
  this.insereCSS(".AutoCompleteDivAct a",AutoCompleteDivActStyle);
   this.insereCSS(".AutoCompleteDivListeStyle a ",AutoCompleteDivAStyle);
    this.insereCSS(".AutoCompleteDivListeStyle a i",AutoCompleteDivIStyle);
}

searchEngine.prototype.setStylePourElement = function(c,name){
  c.className=name;
}

// calcule le d�calage � gauche
searchEngine.prototype.calculateOffsetLeft = function(r){
  return this.calculateOffset(r,"offsetLeft")
}

// calcule le d�calage vertical
searchEngine.prototype.calculateOffsetTop = function(r){
  return this.calculateOffset(r,"offsetTop")
}

searchEngine.prototype.calculateOffset = function(r,attr){
  var kb=0;
  while(r){
    kb+=r[attr];
    r=r.offsetParent
  }
  return kb
}

// calcule la largeur du champ
searchEngine.prototype.calculateWidth = function(){
  return this.inputField.offsetWidth-2*1
}

searchEngine.prototype.setCompleteDivSize = function(){
  if(this.completeDiv){
    this.completeDiv.style.left=this.calculateOffsetLeft(this.inputField)+"px";
    this.completeDiv.style.top=this.calculateOffsetTop(this.inputField)+this.inputField.offsetHeight-1+"px";
    this.completeDiv.style.width=this.calculateWidth()+"px"
  }
}

searchEngine.prototype.ChangeOptionbystr = function(){
	if(this.optionbystr){
		document.getElementById('optionsbystr').checked = false;
		this.optionbystr = false;
	}else{
		document.getElementById('optionsbystr').checked = true;
		this.optionbystr = true;	
	}
	this.launchSearch();
}


searchEngine.prototype.creeAutocompletionDiv = function() {
  this.initStyle();
  this.completeDiv=document.createElement("DIV");
  this.completeDiv.id="completeDiv";
  var borderLeftRight=1;
  var borderTopBottom=1;
  this.completeDiv.style.borderRight="black "+borderLeftRight+"px solid";
  this.completeDiv.style.borderLeft="black "+borderLeftRight+"px solid";
  this.completeDiv.style.borderTop="black "+borderTopBottom+"px solid";
  this.completeDiv.style.borderBottom="black "+borderTopBottom+"px solid";
  this.completeDiv.style.zIndex="1";
  this.completeDiv.style.paddingRight="0";
  this.completeDiv.style.paddingLeft="0";
  this.completeDiv.style.paddingTop="0";
  this.completeDiv.style.paddingBottom="0";
  this.setCompleteDivSize();
  this.completeDiv.style.visibility="hidden";
  this.completeDiv.style.position="absolute";
  this.completeDiv.style.backgroundColor="white";
  document.body.appendChild(this.completeDiv);
  this.setStylePourElement(this.completeDiv,"AutoCompleteDivListeStyle");
}

searchEngine.prototype.metsEnPlace = function(valeur, liste){
  while(this.completeDiv.childNodes.length>0) {
    this.completeDiv.removeChild(this.completeDiv.childNodes[0]);
  }
  // mise en place des suggestions
  for(var f=0; f<liste.length; ++f){
    var nouveauDiv=document.createElement("DIV");
    nouveauDiv.onmousedown=divOnMouseDown;
    nouveauDiv.onmouseover=divOnMouseOver;
    nouveauDiv.onmouseout=divOnMouseOut;
    this.setStylePourElement(nouveauDiv,"AutoCompleteDiv");
    var nouveauSpan=document.createElement("SPAN");
    nouveauSpan.innerHTML=liste[f]; // le texte de la suggestion
    nouveauDiv.appendChild(nouveauSpan);
    this.completeDiv.appendChild(nouveauDiv)
  }
  this.PressAction();
  if(this.completeDivRows>0) {
    this.completeDiv.height=16*this.completeDivRows+4;
  } else {
    this.hideCompleteDiv();
  }

}

searchEngine.prototype.onKeyDownHandler=function(event){
  // acc�s evenement compatible IE/Firefox
  if(!event&&window.event) {
    event=window.event;
  }
  // on enregistre la touche ayant d�clench� l'evenement
  if(event) {
    this.lastKeyCode=event.keyCode;
  }
}
// Handler pour le keydown du document
var onKeyDownHandler=function(event){
  se.onKeyDownHandler(event);
}


searchEngine.prototype.onKeyUpHandler = function(event){
	// acc�s evenement compatible IE/Firefox
  if(!event&&window.event) {
    event=window.event;
  }
  this.eventKeycode=event.keyCode;
  // Dans les cas touches touche haute(38) ou touche basse (40)
  if(this.eventKeycode==40||this.eventKeycode==38) {
    // on autorise le blur du champ (traitement dans onblur)
    this.blurThenGetFocus();
  }
  // taille de la selection
  var N=this.rangeSize(this.inputField);
  // taille du texte avant la selection (selection = suggestion d'autocompl�tion)
  var v=this.beforeRangeSize(this.inputField);
  // contenu du champ texte
  var V=this.inputField.value;
  if(this.eventKeycode!=0){
    if(N>0&&v!=-1) {
      // on recupere uniquement le champ texte tap� par l'utilisateur
      V=V.substring(0,v);
    }
    // 13 = touche entr�e
    if(this.eventKeycode==13||this.eventKeycode==3){
      var d=this.inputField;
      // on mets en place l'ensemble du champ texte en repoussant la selection
      if(this.inputField.createTextRange){
        var t=this.inputField.createTextRange();
        t.moveStart("character",this.inputField.value.length);
        this.inputField.select()
      } else if (d.setSelectionRange){
        this.inputField.setSelectionRange(this.inputField.value.length,this.inputField.value.length)
      }
     } else {
      // si on a pas pu agrandir le champ non selectionn�, on le mets en place violemment.
      if(this.inputField.value!=V) {
        this.inputField.value=V
      }
    }
  }
  // si la touche n'est ni haut, ni bas, on stocke la valeur utilisateur du champ
  if(this.eventKeycode!=40&&this.eventKeycode!=38) {
    // le champ courant n est pas change si key Up ou key Down
  	this.currentInputFieldValue=V;
  }
  if(this.handleCursorUpDownEnter(this.eventKeycode)&&this.eventKeycode!=0) {
    // si on a pr�ss� une touche autre que haut/bas/enter
    this.PressAction();
  }
  
   //window.location.href= this.getElementsByTagName('span')[0].firstChild.href;
   if(this.eventKeycode==13||this.eventKeycode==3){
	   var suggestionList=this.completeDiv.getElementsByTagName("div");
	     window.location.href=suggestionList.item(this.highlightedSuggestionIndex).getElementsByTagName('span')[0].firstChild.href;
   }
  
  
}

// Handler pour le keyup de lu champ texte
var onKeyUpHandler=function(event){
	se.onKeyUpHandler(event)
}

// Change la suggestion selectionn�.
// cette m�thode traite les touches haut, bas et enter
searchEngine.prototype.handleCursorUpDownEnter = function(eventCode){
  if(eventCode==40){
    this.highlightNewValue(this.highlightedSuggestionIndex+1);
    return false
  }else if(eventCode==38){
    this.highlightNewValue(this.highlightedSuggestionIndex-1);
    return false
  }else if(eventCode==13||eventCode==3){
    return false
  }
  return true
}



// g�re une touche press�e autre que haut/bas/enter
searchEngine.prototype.PressAction = function(){
  this.highlightedSuggestionIndex=-1;
  var suggestionList=this.completeDiv.getElementsByTagName("div");
  var suggestionLongueur=suggestionList.length;
  // on stocke les valeurs pr�c�dentes
  // nombre de possibilit�s de compl�tion
  this.completeDivRows=suggestionLongueur;
  // possiblit�s de compl�tion
  this.completeDivDivList=suggestionList;
  // si le champ est vide, on cache les propositions de compl�tion
  if(this.currentInputFieldValue==""||suggestionLongueur==0){
    this.hideCompleteDiv()
  }else{
    this.showCompleteDiv()
  }
  var trouve=false;
  // si on a du texte sur lequel travailler
  if(this.currentInputFieldValue.length>0){
    var indice;
    // T vaut true si on a dans la liste de suggestions un mot commencant comme l'entr�e utilisateur
    for(indice=0; indice<suggestionLongueur; indice++){ 
    if(this.getSuggestion(suggestionList.item(indice)).toUpperCase().indexOf(this.currentInputFieldValue.toUpperCase())==0) {
        trouve=true;
        break
      }
    }
  }
  // on d�s�lectionne toutes les suggestions
  for(var i=0; i<suggestionLongueur; i++) {
    this.setStylePourElement(suggestionList.item(i),"AutoCompleteDiv");
  }
  // si l'entr�e utilisateur (n) est le d�but d'une suggestion (n-1) on s�lectionne cette suggestion avant de continuer
  if(trouve){
    this.highlightedSuggestionIndex=indice;
    this.highlightedSuggestionDiv=suggestionList.item(this.highlightedSuggestionIndex);
  }else{
    this.highlightedSuggestionIndex=-1;
    this.highlightedSuggestionDiv=null
  }
  var supprSelection=false;
  switch(this.eventKeycode){
    // cursor left, cursor right, page up, page down, others??
    case 8:
    case 33:
    case 34:
    case 35:
    case 35:
    case 36:
    case 37:
    case 39:
    case 45:
    case 46:
      // on supprime la suggestion du texte utilisateur
      supprSelection=true;
      break;
    default:
      break
  }
  // si on a une suggestion (n-1) s�lectionn�e
  if(!supprSelection&&this.highlightedSuggestionDiv){
    this.setStylePourElement(this.highlightedSuggestionDiv,"AutoCompleteDivAct");
    var z;
    if(trouve) {
      z=this.getSuggestion(this.highlightedSuggestionDiv).substr(0);
    } else {
      z=this.currentInputFieldValue;
    }
    if(z!=this.inputField.value){
      if(this.inputField.value!=this.currentInputFieldValue) {
        return;
      }
      // si on peut cr�er des range dans le document
      if(this.inputField.createTextRange||this.inputField.setSelectionRange) {
        this.inputField.value=z;
      }
      // on s�lectionne la fin de la suggestion
      if(this.inputField.createTextRange){
        var t=this.inputField.createTextRange();
        t.moveStart("character",this.currentInputFieldValue.length);
        t.select()
      }else if(this.inputField.setSelectionRange){
        this.inputField.setSelectionRange(this.currentInputFieldValue.length,this.inputField.value.length)
      }
    }
  }else{
    // sinon, plus aucune suggestion de s�lectionn�e
    this.highlightedSuggestionIndex=-1;
  }
}



// permet le blur du champ texte apr�s que la touche haut/bas ai �t� press�.
// le focus est r�cup�r� apr�s traitement (via le timeout).
searchEngine.prototype.blurThenGetFocus = function(){
  this.cursorUpDownPressed=true;
  //this.inputField.blur();
  setTimeout("ifocus();",10);
  return
}

searchEngine.prototype.ifocus = function(){
	this.inputField.focus();
}

function ifocus(){
	se.ifocus()
}
// taille de la selection dans le champ input
searchEngine.prototype.rangeSize = function(n){
  var N=-1;
  if(n.createTextRange){
    var fa=document.selection.createRange().duplicate();
    N=fa.text.length
  }else if(n.setSelectionRange){
    N=n.selectionEnd-n.selectionStart
  }
  return N
}

// taille du champ input non selectionne
searchEngine.prototype.beforeRangeSize = function(n){
  var v=0;
  if(n.createTextRange){
    var fa=document.selection.createRange().duplicate();
    fa.moveEnd("textedit",1);
    v=n.value.length-fa.text.length
  }else if(n.setSelectionRange){
    v=n.selectionStart
  }else{
    v=-1
  }
  return v
}

// Place le curseur � la fin du champ
searchEngine.prototype.cursorAfterValue = function(n){
  if(n.createTextRange){
    var t=n.createTextRange();
    t.moveStart("character",n.value.length);
    t.select()
  } else if(n.setSelectionRange) {
    n.setSelectionRange(n.value.length,n.value.length)
  }
}


// Retourne la valeur de la possibilite (texte) contenu dans une div de possibilite
searchEngine.prototype.getSuggestion = function(uneDiv){
if(!uneDiv) {
    return null;
  }
  if( uneDiv.getElementsByTagName('span')[0].firstChild.firstChild.data){
	  return this.trimCR(uneDiv.getElementsByTagName('span')[0].firstChild.firstChild.data);
  }
  if(uneDiv.getElementsByTagName('span')[0].firstChild.data) {
    return this.trimCR(uneDiv.getElementsByTagName('span')[0].firstChild.data);
  }
  
}

// supprime les caract�res retour chariot et line feed d'une chaine de caract�res
searchEngine.prototype.trimCR = function(chaine){
  for(var f=0,nChaine="",zb="\n\r"; f<chaine.length; f++) {
    if (zb.indexOf(chaine.charAt(f))==-1) {
      nChaine+=chaine.charAt(f);
    }
  }
  return nChaine
}

// Cache completement les choix de completion
searchEngine.prototype.hideCompleteDiv = function(){
  this.completeDiv.style.visibility="hidden"
}

// Rends les choix de completion visibles
searchEngine.prototype.showCompleteDiv = function(){
  this.completeDiv.style.visibility="visible";
  this.setCompleteDivSize()
}

// Change la suggestion en surbrillance
searchEngine.prototype.highlightNewValue = function(C){
  if(!this.completeDivDivList||this.completeDivRows<=0) {
    return;
  }
  this.showCompleteDiv();
  if(C>=this.completeDivRows){
    C=this.completeDivRows-1
  }
  if(this.highlightedSuggestionIndex!=-1&&C!=this.highlightedSuggestionIndex){
    this.setStylePourElement(this.highlightedSuggestionDiv,"AutoCompleteDiv");
    this.highlightedSuggestionIndex=-1
  }
  if(C<0){
    this.highlightedSuggestionIndex=-1;
    this.inputField.focus();
    return
  }
  this.highlightedSuggestionIndex=C;
  this.highlightedSuggestionDiv=this.completeDivDivList.item(C);
  this.setStylePourElement(this.highlightedSuggestionDiv,"AutoCompleteDivAct");
  this.inputField.value=this.getSuggestion(this.highlightedSuggestionDiv);
}

searchEngine.prototype.onResizeHandler=function(event){
  // recalcule la taille des suggestions
  this.setCompleteDivSize();
}

// Handler de resize de la fenetre
var onResizeHandler=function(event){
  se.onResizeHandler(event);
}

searchEngine.prototype.onBlurHandler=function(event){
	if(!this.cursorUpDownPressed){
    // si le blur n'est pas caus� par la touche haut/bas
    this.hideCompleteDiv();
    // Si la derni�re touche pr�ss� est tab, on passe au bouton de validation
    if(this.lastKeyCode==9){
      this.submitButton.focus();
      this.lastKeyCode=-1
    }
  }
  this.cursorUpDownPressed=false
}

// Handler de blur sur le champ texte
var onBlurHandler=function(event){
	se.onBlurHandler(event);
};


// declenchee quand on clique sur une div contenant une possibilite
var divOnMouseDown=function(){
	 se.inputField.value=se.getSuggestion(this);
	  window.location.href= this.getElementsByTagName('span')[0].firstChild.href;
};


// declenchee quand on passe sur une div de possibilite. La div pr�c�dente est passee en style normal
var divOnMouseOver=function(){
  if( se.highlightedSuggestionDiv) {
     se.setStylePourElement( se.highlightedSuggestionDiv,"AutoCompleteDiv");
  }
   se.setStylePourElement(this,"AutoCompleteDivAct")
   se.inputField.value=se.getSuggestion(this);
};

// declenchee quand la sourie quitte une div de possiblite. La div repasse a l'etat normal
var divOnMouseOut = function(){
   se.setStylePourElement(this,"AutoCompleteDiv");
};






/*
 PdMarker

 Purpose: extends Google Map API GMap and GMarker (hover effects, image swapping, moving)
 Details: http://wwww.pixeldevelopment.com/pdmarker.asp
 Updated: [see getPdMarkerRevisionInfo]
 Author:  Peter Jones
 Notes:   Relies on undocumented features of the Google Map API which may change.
	    Based on my own PJToolTip and ideas from GxMarker, TLabel and the Google Maps API forum.

 Contact www.pixeldevelopment.com for your custom Google Map needs
*/

function getPdMarkerRevisionInfo() {
var cr = "<br/>";
var s =
"1.99e 05/05/06 - fixed zoomed tooltip positioning &amp; non-centered marker graphics." + cr +
"1.99d 05/01/06 - fixed display &amp; blink when defining .transparent." + cr +
"1.99c 04/25/06 - added display and blink." + cr +
"1.99b 04/21/06 - added 'Powered By' version &amp; marker count display." + cr +
"1.99a 04/18/06 - revised for Google Maps API Version 2, GMap2 required." + cr +
"0.99c 01/30/06 - added setDetailWinClass and resetDetailWinClass." + cr +
"0.99a 10/12/05 - now handles maps in containers with undefined widths" + cr +
"define a div with id 'pdmarkerwork' to reduce flicker" + cr +
"0.99  10/03/05 - added setImageEnabled, allowLeftTooltips (global)" + cr +
"0.98  09/30/05 - fixed zoomToMarkers" + cr +
"0.97  09/24/05 - added setHoverImage, setShowDetailOnClick, setDetailWinHTML, showDetailWin, closeDetailWin" + cr +
"0.96  09/22/05 - added setTooltipHiding, getTooltipHiding" + cr +
"0.95  09/20/05 - handle zoom for lingering tooltips mouseOutEnabled(false) " +
		   "disables setImage and restoreImage" + cr +
"0.94  09/20/05 - added setTooltipClass and resetTooltipClass" + cr +
"0.93  09/19/05 - added slopPercentage [optional] parameter to zoomToMarkers" + cr +
"0.92  09/18/05 - added getMouseOutEnabled, setMouseOutEnabled" + cr +
"0.91  09/17/05 - fixed setOpacity";
return s;
}

function getPdMarkerVersion() {
	return getPdMarkerRevisionInfo().substring(0,15);
}

function getPdMarkerShortVersion() {
	return getPdMarkerRevisionInfo().substring(0,5);
}

var APIkey = "";

function getGoogleMapsVersion() {
	var i, a, b, c;
	var v = "unknown";

	if (document.getElementsByTagName)
		for(i=0; (a = document.getElementsByTagName("script")[i]); i++)
			if(a.getAttribute("src"))
			{
				b = a.getAttribute("src");
				c = b.indexOf("/mapfiles/maps");
				d = b.indexOf("http://maps.google.com/maps?file=api");
				e = b.indexOf("key=");
				if (c > 0)
					v = parseFloat(b.substring(c+14));
				if (d >= 0)
					if (e > 0)
						APIkey = b.substring(e+4);
			}
	return v;
}

function latLongToPixel(map,coord,zoom) {
	var topLeft = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GLatLng(0,0),true),map.getZoom());
	var point = map.getCurrentMapType().getProjection().fromLatLngToPixel(coord,map.getZoom());
	return new GPoint(point.x - topLeft.x, point.y - topLeft.y);
}

var pdMarkerExtList = [];

function PdMarkerAddToExtList(marker) {
	pdMarkerExtList.push(marker);
}

function PdMarkerRemoveFromExtList(id) {
	for (var i=0; i<pdMarkerExtList.length; i++)
		if (pdMarkerExtList[i].internalId == id)
			pdMarkerExtList.splice(i,1);
}

function PdMarkerFindInExtList(id) {
	for (var i=0; i<pdMarkerExtList.length; i++)
		if (pdMarkerExtList[i].internalId == id)
			return pdMarkerExtList[i];
}

function PdMarkerClose(id) {
	for (var i=0; i<pdMarkerExtList.length; i++)
		if (pdMarkerExtList[i].internalId == id)
			{
				pdMarkerExtList[i].closeDetailWin();
				pdMarkerExtList.splice(i,1);
			}
}

function PdMarkerBlinkOnOff(id) {
	var marker = PdMarkerFindInExtList(id);
	if (marker)
	{
		if (!marker.blinking) return;
		marker.blinkOn = !marker.blinkOn;
		marker.display(marker.blinkOn);
		setTimeout("PdMarkerBlinkOnOff(" + marker.getId() + ");", marker.blinkSpeed);
	}
}

// GMap extension for walking through PdMarker list
// Note: some overlays are not markers, some may not be PdMarkers

function isPdMarker(a) {
	if (a.isMarker)
		return true;		
	return false;
}

function getPdMarkerCount(a) {
	if (a.pdMarkers)
		return a.pdMarkers.length;
	return 0;
}

GMap2.prototype.getMarkerById = function(id) {
	var count = getPdMarkerCount(this);
	for (var i = 0; i < count; i++)
		if (isPdMarker(this.pdMarkers[i]))
			if (this.pdMarkers[i].internalId == id)
			{
				this.cursor = i;
				return this.pdMarkers[i];
			}
	return null;
}

GMap2.prototype.getFirstMarker = function() {
	var count = getPdMarkerCount(this);
	for (var i = 0; i < count; i++)
		if (isPdMarker(this.pdMarkers[i]))
		{
			this.cursor = i;
			return this.pdMarkers[i];
		}
	return null;
}

GMap2.prototype.getNextMarker = function() {
	var count = getPdMarkerCount(this);
	if (count > 0)
		if (this.cursor >= 0)
			for (var i = this.cursor+1; i < count; i++)
				if (isPdMarker(this.pdMarkers[i]))
				{
					this.cursor = i;
					return this.pdMarkers[i];
				}
	return null;
}

GMap2.prototype.getNthMarker = function(nTh) {
	var count = getPdMarkerCount(this);
	for (var i = 0; i < count; i++)
		if (isPdMarker(this.pdMarkers[i]))
		{
			nTh--;
			if (nTh == 0)
			{
				this.cursor = i;
				return this.pdMarkers[i];
			}
		}
	return null;
}

GMap2.prototype.getMarkerCount = function() {
	return getPdMarkerCount(this);
}

GMap2.prototype.boxMap = function(center, span) {
	var spec = this.spec;
	var zoom = spec.getLowestZoomLevel(center, span, this.viewSize);
	this.centerAndZoom(new GPoint(center.x, center.y), zoom);
}

GMap2.prototype.zoomToMarkers = function(slopPercentage, heightOffsetPct) {
	var count = 0;
	var thePoint, x, y, minX, maxX, minY, maxY, span;
	var marker = this.getFirstMarker();
	while (marker != null)
	{
		thePoint = marker.getPoint();
		// x = thePoint.x; y = thePoint.y;
		x = thePoint.lat(); y = thePoint.lng();
		if (count == 0)
		{
			minX = x; maxX = x; minY = y; maxY = y;
		}
		else
		{
			if (x < minX) minX = x;
			if (x > maxX) maxX = x;
			if (y < minY) minY = y;
			if (y > maxY) maxY = y;
		}
		marker = this.getNextMarker();
		count++;
	}
	if (count == 1)
		this.setCenter(new GLatLng(x,y), this.getZoom());
	else if (count > 1)
	{
		var center = new GLatLng((minX + maxX) / 2, (minY + maxY) / 2)
		span = new GSize(Math.abs(maxX - minX), Math.abs(maxY - minY));
		slopWid = 0;
		slopHgt = 0;
		if (typeof slopPercentage != "undefined")
		{
			slopWid = span.width * slopPercentage / 200;
			slopHgt = span.height * slopPercentage / 200;
			span.width  *= 1 + slopPercentage / 100;
			span.height *= 1 + slopPercentage / 100;
		}
		deltaHgt = 0;
		if (typeof heightOffsetPct != "undefined")
		{
			deltaHgt = span.height * heightOffsetPct / 100;
			center = new GLatLng(center.lat() + deltaHgt, center.lng());
		}
		// needs slop
		var bounds = new GLatLngBounds(new GLatLng(minX-slopHgt, minY-slopWid), new GLatLng(maxX+slopHgt, maxY+slopWid)); // sw, ne
		var zoom = this.getBoundsZoomLevel(bounds);
		this.setCenter(center, zoom);
	}
}

function shorten(x) {
	var factor = 1000000
	return Math.round(x * factor) / factor;
}

function poweredByClick(map) {
	var center = map.getCenter();
	var span = map.getBounds().toSpan();
	var zoom = map.getZoom();
	var url = "http://maps.google.com/maps?ll=" + center.lat() + "," + center.lng() + "&spn=" + shorten(span.lat()) + "," + shorten(span.lng()) + "&z=" + zoom + "&key=" + APIkey;
	document.location = url;
}

function poweredByMouseover(map) {
	var marker = map.getFirstMarker();
	var bounds = map.getBounds();
	var visibleCount = 0;
	var totalCount = 0;
	while (marker != null) {
		var point = marker.getPoint();
		if (bounds.contains(point))
			visibleCount++;
		totalCount = totalCount + 1;
		marker = map.getNextMarker();
	}
	var title = map.poweredByTitle + " (" + visibleCount + " markers of " + totalCount + " visible)"
	map.poweredByObj.setAttribute("title",title);
	map.poweredByObj.setAttribute("alt",title);
}

function getPoweredBy(map) {
	try {
		var tooltip = "GMap " + getGoogleMapsVersion() + " & PdMarker " + getPdMarkerShortVersion();
		map.poweredByTitle = tooltip;
		var b = document.createElement("img");
		b.setAttribute("src","http://www.google.com/intl/en_ALL/mapfiles/transparent.gif");
		b.setAttribute("width",62);
		b.setAttribute("alt",tooltip);
		b.setAttribute("title",tooltip);
		b.setAttribute("height",30);
		b.style.display = "block";
		b.style.position = "absolute";
		b.style.left    = "2px";
		b.style.bottom  = "0px";
		b.style.width   = "62px";
		b.style.height  = "30px";
		b.style.cursor  = "pointer";
		b.style.zIndex  = 600001;
		b.onclick = function() { poweredByClick(map); };
		b.onmouseover = function() { poweredByMouseover(map); };
	      map.getPane(G_MAP_FLOAT_PANE).parentNode.parentNode.appendChild(b);
		return b;
	}
	catch (e) {
	}
	return true;
}

function setPoweredBy(map) {
	getGoogleMapsVersion();
	if (!map.poweredByObj)
		map.poweredByObj = getPoweredBy(map);
}


// PdMarker code


function PdMarkerNamespace() {

var userAgent = navigator.userAgent.toLowerCase();
var n4=(document.layers);
var n6=(document.getElementById&&!document.all);
var ie=(document.all);
var o6=(userAgent.indexOf("opera") != -1);
var safari=(userAgent.indexOf("safari") != -1);
var msie  = (userAgent.indexOf("msie") != -1) && (userAgent.indexOf("opera") == -1);

var nextMarkerId = 10;
var permitLeft = true;

icon = new GIcon();
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(20, 34);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(9, 34);
icon.infoWindowAnchor = new GPoint(9, 2);
icon.infoShadowAnchor = new GPoint(18, 25);
icon.image = "http://www.google.com/mapfiles/marker.png";

// Globals - careful of multiple maps

function PdMarker(a, b, tooltip) {
	this.inheritFrom = GMarker;
	if (typeof b == "undefined") // pmj oct 23, 2005
		b = icon;
	this.inheritFrom(a,b);
	if (typeof tooltip != "undefined")
		this.pendingTitle = tooltip;
	else
		this.pendingTitle = "";
	this.internalId = nextMarkerId;
	nextMarkerId += 1;
	this.zIndexSaved = false;
	this.oldImagePath = "";
	this.pendingCursor = "";
	this.percentOpacity = 100;
	this.mouseOutEnabled = true;
	this.setImageOn = true;
	this.hidingEnabled = true;
	this.showDetailOnClick = true;
	this.detailOpen = false;
	this.userData = "";
}

// PdMarker.prototype = new GMarker;
PdMarker.prototype = new GMarker(new GLatLng(1, 1));


function addMarkerToMapList(map,marker) {
	try {
		if (map.pdMarkers.length) ;
	}
	catch(e) {
		map.pdMarkers = new Array();
	}
	// add to list
	map.pdMarkers.push(marker);
}

function removeMarkerFromMapList(map,marker) {
	var id = marker.internalId;
	for (var i=0; i<map.pdMarkers.length; i++)
		if (map.pdMarkers[i].internalId == id)
		{
			map.pdMarkers.splice(i,1);
			return;
		}
}

PdMarker.prototype.initialize = function(a) {
	if (typeof a == "GMap")
	{
		GLog.write("PdMarker requires GMap2");
		return;
	}
	addMarkerToMapList(a,this);
	try
	{
		GMarker.prototype.initialize.call(this, a);
		this.isMarker = true;
		if (this.pendingTitle.length > 0)
			this.setTitle(this.pendingTitle);
		if (this.pendingCursor.length > 0)
			this.setCursor(this.pendingCursor);

		this.map = a;
		setPoweredBy(a);

		GEvent.bindDom(this, "mouseover", this, this.onMouseOver);
		GEvent.bindDom(this, "mouseout",  this, this.onMouseOut);
		GEvent.bindDom(this, "click",  this, this.onClick);
		GEvent.bind(this.map, "zoomend", this, this.reZoom);
	}
	catch(e) {
		alert("PdMarker initialize error: " + e);
	}
}

PdMarker.prototype.allowLeftTooltips = function(a){
	permitLeft = a;
}

PdMarker.prototype.reZoom = function(){
	var didSet = false;
	if (this.tooltipObject)
		if (this.tooltipObject.style.display == "block")
		{
			setTTPosition(this);
			didSet = true;
		}
	if (this.detailObject)
	{
		if (!didSet)
			setTTPosition(this);
		this.detailObject.style.top  = this.ttTop + "px";
		this.detailObject.style.left  = this.ttLeft + "px";
	}
}

PdMarker.prototype.setId = function(id) {
	this.internalId = id;
}

PdMarker.prototype.getId = function() {
	return this.internalId;
}

PdMarker.prototype.setName = function(a) {
	this.name = a;
}

PdMarker.prototype.getName = function() {
	if (this.name)
		return this.name;
	else
		return null;
}

PdMarker.prototype.setUserData = function(a) {
	this.userData = a;
}

PdMarker.prototype.getUserData = function() {
	if (this.userData)
		return this.userData;
	else
//		return null;
		return "";
}

PdMarker.prototype.setUserData2 = function(a) {
	this.userData2 = a;
}

PdMarker.prototype.getUserData2 = function() {
	if (this.userData2)
		return this.userData2;
	else
		return "";
}

PdMarker.prototype.setImageEnabled = function(a) {
	this.setImageOn = a;
}

var PdMIN = "";
var PdMIA = "";

function PdCompPdMIN(marker) {
	if (PdMIN.length == 0)
		for (var i in marker)
			if (eval("typeof marker." + i) == "object")
				try {
					if (eval("typeof marker." + i + "[0].src") != "undefined")
					{
						PdMIA = "this." + i;
						PdMIN = PdMIA + "[0]";
					}
				}
				catch (e) {}
}



PdMarker.prototype.setImage = function(a) {
	var msFilter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + a + '")';
	if (this.mouseOutEnabled && this.setImageOn)
	{
		PdCompPdMIN(this);
		try {
			if (this.oldImagePath.length == 0)
				eval("this.oldImagePath = " + PdMIN + ".src");
			if (msie)
				eval(PdMIN + ".style.filter = msFilter");
			else
				eval(PdMIN + ".src = a");
		}
		catch (e) {}
	}
}

PdMarker.prototype.restoreImage = function() {
	if (this.mouseOutEnabled && this.setImageOn && this.oldImagePath.length > 0)
	{
		var a = this.oldImagePath;
		this.setImage(a);
		this.oldImagePath = "";
	}
}

PdMarker.prototype.display = function(a) {
	PdCompPdMIN(this);
	var b = "";
	if (!a)
	{
		this.hideTooltip();
		this.closeDetailWin();
		b = "none";
	}
	try {
		// for (i = 0; i < eval(PdMIA + ".length"); i++) // draggable X is also here, skip
		var count = 2;
		if (this.getIcon().transparent)
			count = 3;
		for (i = 0; i < count; i++)
			eval(PdMIA + "[" + i + "].style.display = b;");
	}
	catch (e) {}
}

PdMarker.prototype.blink = function(a,b) {
	if (a)
	{
		this.blinkOn = true;
		marker.blinkSpeed = b;
		if (!this.blinking)
		{
			this.blinking = a;
			PdMarkerAddToExtList(this);
			PdMarkerBlinkOnOff(this.getId());
		}
	}
	else
	{
		this.blinking = a;
		this.display(true);
		PdMarkerRemoveFromExtList(this);
	}
}

PdMarker.prototype.setIcon = function(a) {
	this.remove();
	this.icon = a;
	this.initialize(this.map);
	this.redraw(true); 
}

PdMarker.prototype.setMarkerZIndex = function(a) {
	if (!this.zIndexSaved)
	{
		this.zIndexSaved = true;
		this.oldZIndex = eval(PdMIN + ".style.zIndex");
	}
	eval(PdMIN + ".style.zIndex = a")
	this.redraw(true);
}

PdMarker.prototype.topMarkerZIndex = function() {
	this.setMarkerZIndex (600000);
}

PdMarker.prototype.restoreMarkerZIndex = function() {
	if (this.zIndexSaved)
	{
		this.zIndexSaved = false;
		eval(PdMIN + ".style.zIndex = this.oldZIndex")
		this.redraw(true);
	}
}

PdMarker.prototype.onInfoWindowOpen = function() {
	this.hideTooltip();
	GMarker.prototype.onInfoWindowOpen.call(this);
}

PdMarker.prototype.setHoverImage = function(a) {
	this.hoverImage = a;
}

var inMouseOver = false;

// problem.  if we use new method of changing image (re-init, etc), then we keep getting mouse-over events.
// which truly blows.
// maybe force things to 2.45 and use images array, assuming a name of 'eb'

PdMarker.prototype.onMouseOver = function() {
	if (inMouseOver)
		return;
	inMouseOver = true;
	if (this.hoverImage)
		this.setImage(this.hoverImage);
	if (!this.detailOpen)
		this.showTooltip();
	inMouseOver = false;
}

PdMarker.prototype.onMouseOut = function() {
	if (this.hoverImage)
		this.restoreImage();
	if (!this.detailOpen)
		if (this.mouseOutEnabled)
			this.hideTooltip();
}

PdMarker.prototype.setMouseOutEnabled = function(a) {
	this.mouseOutEnabled = a;
}

PdMarker.prototype.getMouseOutEnabled = function() {
	return this.mouseOutEnabled;
}

PdMarker.prototype.setTooltipHiding = function(a) {
	this.hidingEnabled = a;
}

PdMarker.prototype.getTooltipHiding = function() {
	return this.hidingEnabled;
}

PdMarker.prototype.setTitle = function(a) {
	this.tooltipText = "";
	PdCompPdMIN(this);
	try {
		eval(PdMIN + ".title = a");
	}
	catch (e) {
		this.pendingTitle = a;
	}
}

PdMarker.prototype.setCursor = function(a) {
	PdCompPdMIN(this);
	try {
		eval(PdMIN + ".style.cursor = a");
	}
	catch (e) {
		this.pendingCursor = a;
	}
}

PdMarker.prototype.setTooltipClass = function(a) {
	this.pendingClassName = a;
	if (this.tooltipObject)
	{
		var showing = (this.tooltipObject.style.display != "none");
		this.deleteObjects();
		if (this.tooltipRaw)
			this.setTooltipNoResize(this.tooltipRaw);
		if (showing)
			this.showTooltip();

	}
	else
		if (this.tooltipRaw)
			this.setTooltipNoResize(this.tooltipRaw);
}

PdMarker.prototype.resetTooltipClass = function() {
	this.setTooltipClass("markerTooltip");
}

PdMarker.prototype.getTooltip = function() {
	try {
		return this.tooltipRaw;
	}
	catch (e)
	{
		return "";
	}
}

PdMarker.prototype.setTooltipNoResize = function(a) {
	this.setTitle("");
	var ttClass = "markerTooltip";
	if (this.pendingClassName)
		ttClass = this.pendingClassName;
	this.tooltipRaw = a;
	this.tooltipText = "<div class='" + ttClass + "'>" + a + "</div>";
	if (this.tooltipObject)
		this.tooltipObject.innerHTML = this.tooltipText;
}

PdMarker.prototype.setTooltip = function(a) {
	this.setTooltipNoResize(a);
	this.deleteObjects();
}

PdMarker.prototype.showTooltip = function() {
	if (this.tooltipText)
	{
		if (!this.tooltipObject)
			initTooltip(this);
		setTTPosition(this);
		this.tooltipObject.style.display = "block";
	}
}

PdMarker.prototype.hideTooltip = function() {
	if (this.tooltipObject)
		if (this.hidingEnabled)
			this.tooltipObject.style.display = "none";
}

PdMarker.prototype.onClick = function(a) {
	if (this.showDetailOnClick && this.detailWinHTML)
		this.showDetailWin();
}

PdMarker.prototype.setShowDetailOnClick = function(a) {
	this.showDetailOnClick = a;
}

PdMarker.prototype.setDetailWinHTML = function(a) {
	this.detailWinHTML = a;
}




PdMarker.prototype.setDetailWinClass = function(a) {
	this.pendingDetailClassName = a;
}

PdMarker.prototype.resetDetailWinClass = function() {
	this.setDetailWinClass("markerDetail");
}



PdMarker.prototype.showDetailWin = function() {
	if (this.detailOpen)
	{
		this.closeDetailWin();
		return;
	}
	this.hideTooltip();
	this.setMouseOutEnabled(false);

	var winClass = "markerDetail";
	if (this.pendingWinClassName)
		winClass = this.pendingWinClassName;

	var html = "<table><tr><td>" + this.detailWinHTML + "<\/td><td valign='top'><a class='markerDetailClose' href='javascript:PdMarkerClose(" + this.internalId + ")'><img src='http://www.google.com/mapfiles/close.gif' width='14' height='13'><\/a><\/td><\/tr><\/table>";
	html = "<div class='" + winClass + "'>" + html + "</div>";
	this.detailOpen = true;
	if (!this.tooltipText)
	{
		this.ttWidth = 150;
		this.ttHeight = 30;
		setTTPosition(this); // compute ttTop, ttLeft
	}
	initDetailWin(this, this.ttTop, this.ttLeft, html);
	PdMarkerAddToExtList(this);
}


PdMarker.prototype.closeDetailWin = function() {
	this.detailOpen = false;
	if (this.detailObject)
	{
		this.setMouseOutEnabled(true);
		this.onMouseOut();
		// GEvent.trigger(this, "mouseout");
	      this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.detailObject);
		this.detailObject = null;
	}
}

PdMarker.prototype.deleteObjects = function() {
	if (this.tooltipObject)
	{
	      this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.tooltipObject);
		this.tooltipObject = null;
	}
	if (this.detailObject)
	{
		this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.detailObject);
		this.detailObject = null;
	}
}

PdMarker.prototype.remove = function(a) {
	removeMarkerFromMapList(this.map, this);
	PdMarkerRemoveFromExtList(this.getId());
	GMarker.prototype.remove.call(this);
	this.deleteObjects();
}

PdMarker.prototype.setOpacity = function(b) {
	if (b < 0)
		b=0;
	if (b >= 100)
		b=100;
	var c = b / 100;
	this.percentOpacity = b;
	var d = document.getElementById(this.objId);
	if (d)
	{
		if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
		if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
		if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
		if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
	}
}

PdMarker.prototype.setOpacityNew = function(b) {
	setObjOpacity(this.objId);
	this.percentOpacity = b;
}

// ***** Private routines *****

function setObjOpacity(objId, b) {
	if (b < 0)
		b=0;
	if (b >= 100)
		b=100;
	var c = b / 100;
	var d = document.getElementById(objId);
	if (d)
	{
		if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
		if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
		if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
		if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
	}
}

function idToElemId(id) {
	return "ttobj" + id;
}

function initTooltip(theObj) {
	theObj.objId = idToElemId(theObj.internalId);
	theObj.anchorLatLng = theObj.point;

	var b = document.createElement('span');
	theObj.tooltipObject = b;
	b.setAttribute('id',theObj.objId);
	b.innerHTML = theObj.tooltipText;

	// append to body for size calculations
	var c = document.body;
	var d = document.getElementById("pdmarkerwork");
	if (d)
		c = d;
	c.appendChild(b);
	b.style.position = "absolute";
	b.style.bottom = "5px";
	b.style.left = "5px";
	b.style.zIndex = 1;
	if (theObj.percentOpacity)
		theObj.setOpacity(theObj.percentOpacity);
	var tempObj = document.getElementById(theObj.objId);
	theObj.ttWidth  = tempObj.offsetWidth;
	theObj.ttHeight = tempObj.offsetHeight;
	c.removeChild(b);

	b.style.zIndex = 600000;
	b.style.bottom = "";
	b.style.left = "";
	// theObj.map.div.appendChild(b);
	theObj.map.getPane(G_MAP_FLOAT_PANE).appendChild(b);
}

function initDetailWin(theObj, top, left, html) {
	theObj.detailId = "detail" + theObj.internalId;
	var b = document.createElement('span');
	theObj.detailObject = b;
	b.setAttribute('id',theObj.detailId);
	b.innerHTML = html;
	b.style.display = "block";
	b.style.position = "absolute";
	b.style.top  = top + "px";
	b.style.left = left + "px";
	b.style.zIndex = 600001;
	map = theObj.map;
	map.getPane(G_MAP_FLOAT_PANE).appendChild(b);
}

function setTTPosition(theObj) {
	var gap = 5;
	var map = theObj.map;
	var pt  = theObj.getPoint();
	var ttPos = latLongToPixel(map, pt, map.getZoom());
	var theIcon = theObj.getIcon();
	
//	ttPos.x += Math.floor(theIcon.iconAnchor.x/2);
	ttPos.y -= Math.floor(theIcon.iconAnchor.y/2);

	var rightSide = true;
	var bounds = map.getBounds();
	var boundsSpan	= bounds.toSpan();
	var longSpan = boundsSpan.lng();
	var mapWidth = map.getSize().width;

	var tooltipWidthInDeg = (theObj.ttWidth + theIcon.iconSize.width + 6) / mapWidth * longSpan;
	if (pt.lng() + tooltipWidthInDeg > bounds.getNorthEast().lng() && permitLeft)
		rightSide = false;
	if (rightSide)
	{
		ttPos.y -= Math.floor(theObj.ttHeight/2);
		ttPos.x += (theIcon.iconSize.width - theIcon.iconAnchor.x) + gap;

	}
	else
	{
		ttPos.y -= Math.floor(theObj.ttHeight/2);
		ttPos.x -= (theIcon.iconAnchor.x + theObj.ttWidth) + gap;
	}
	theObj.ttLeft = ttPos.x;
	theObj.ttTop  = ttPos.y;
	if (theObj.tooltipObject)
	{
		theObj.tooltipObject.style.left = ttPos.x + "px";
		theObj.tooltipObject.style.top  = ttPos.y + "px";
	}
}


function makeInterface(a) {
	var b = a || window;
	b.PdMarker = PdMarker;
}

makeInterface();
}


PdMarkerNamespace();


