/*
	Copyright MAPIDIRECTORIO.COM 2008
	Author: Sergio Armando Vasquez Colorado
	Email: servas@pgmail.com
	
	MAPIDIRECTORIO.COM Sistema publico Version 1.02
*/

function setCookieLatLng(value){
	c_name = "mapidirectorio_qp";
	expiredays = 365;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookieLatLng(){
	c_name = "mapidirectorio_qp";
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	  }
	return "";
}

function setCookieAyuda(value){
	c_name = "mapidirectorio_ayuda";
	expiredays = 365;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookieAyuda(){
	c_name = "mapidirectorio_ayuda";
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	  }
	return "";
}
	
/*
	Inicio Clase Punto
*/
	
	function Punto(lat,lng,domicilio,seccion,zona,barrio,negocioID,htmlCode,title) {
	    this.lat = lat;
		this.lng = lng;
		this.domicilio = domicilio;
		this.seccion = seccion;
		this.zona = zona;
		this.barrio = barrio;
		this.negocioID = negocioID;
		this.htmlCode = htmlCode;
		this.title = title;
	}

	Punto.prototype.lat;
	Punto.prototype.lng;
	Punto.prototype.domicilio;
	Punto.prototype.seccion;
	Punto.prototype.zona;
	Punto.prototype.barrio;
	Punto.prototype.negocioID;
	Punto.prototype.htmlCode;
	Punto.prototype.title;
	
/*
	Fin Clase Punto
*/
	
	var homeHTML = "<strong style='color:#239DCB'>Globo de Ubicacion Actual</strong><br /><img src='img/marker.gif' hspace='10' align='left' />Arrastre este punto hasta su ubicacion actual.<br /><span style='font-size:10px;'>Cada vez que inicie MAPIDIRECTORIO.COM ver&aacute; este punto en el centro del mapa.</span><br />";
	var puntoInicial = "(6.249797783371488, -75.568106174469)";
	
	var paginaNegocio_Global = false;
	var resultadoBusquedas_Global = false;
	var queryText_Global;
	
	var map;
	var homemarker;
	var Markers;
	var MarkersInteres;
	var Puntos;
	var puntos_interes;
	var blankIcon;
	var homeIcon;
	var iconsec = new Array();
	var minMapScale = 12;
	var maxMapScale = 18;
	var mm;
	var comunaActual = "";
	var barrioActual = "";
	var idNegocio = "";
	
    function initialize() {
      if (GBrowserIsCompatible()) {
		  
        map = new GMap2(document.getElementById("map_canvas"));
		
		var cookie = getCookieLatLng();
		eval("var center = new GLatLng"+puntoInicial+"");
		if(cookie != null && cookie != ""){
	        eval("center = new GLatLng" + cookie +"");
		}
		
        map.setCenter(center, 16);
		map.enableScrollWheelZoom();
		map.enableContinuousZoom();
		map.setMapType(G_HYBRID_MAP);
		
		map.openInfoWindowHtml(center,"<strong style='color:#239DCB'>MAPIDIRECTORI0.COM</strong><br><strong>Cargando Datos. Por favor espere...</strong>");

		loadMarkerIcons();
		
        homemarker = new GMarker(center, {icon: homeIcon, title: "Mi ubicacion fisica (Punto arrastrable)" ,draggable: true});
		
        GEvent.addListener(homemarker, "dragstart", function() {
          map.closeInfoWindow();
        });
        GEvent.addListener(homemarker, "dragend", function() {
		  setCookieLatLng(homemarker.getPoint());
		  if(getCookieAyuda() != "yes"){
			  setCookieAyuda("no");
		  }
          homemarker.openInfoWindowHtml(homeHTML);
        });
		GEvent.addListener(homemarker, "click", function() {
          homemarker.openInfoWindowHtml(homeHTML);
        });
		
		setTimeout("loadDataAndMarkers()",10);
		
		setTimeout("loadMapAddOns()",1000);
		
		
  GMarker.prototype.hide = function (){
    if (this.getPoint().lat() < 90)
      try {
        this.savePoint = this.getPoint();
        this.setPoint(new GLatLng(90, 0));
      } catch(e) {}
  }
  GMarker.prototype.show = function (){
    if (this.getPoint().lat() == 90)
    if (this.savePoint)
      try {
        this.setPoint(this.savePoint);
        this.savePoint = null;
      } catch(e) {}
  } 
  
	var tooltip = document.getElementById("tooltip");
	ox=10;
	oy=10;
	lockX=0;
	lockY=0;
	tooltip.style.padding="0px 0px 0px 0px";
  
      }
    }
	
	function loadMapAddOns(){
		// get array of map types
		var mapTypes = map.getMapTypes();
		// overwrite the getMinimumResolution() and getMaximumResolution() methods for each map type
		for (var i=0; i<mapTypes.length; i++) {
			mapTypes[i].getMinimumResolution = function() {return minMapScale;}
			mapTypes[i].getMaximumResolution = function() {return maxMapScale;}
		} 
		
		var fisico = G_PHYSICAL_MAP;
		fisico.getMinimumResolution = function() {return minMapScale;};
		map.addMapType(fisico);	

		map.addControl(new GScaleControl());
		map.addControl(new GLargeMapControl());
		
		var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
		
		new GKeyboardHandler(map);
	}
	
	function loadMarkerIcons(){
		// Marcador inicio
		blankIcon = new GIcon(G_DEFAULT_ICON);
        blankIcon.image = "img/blankmarker.gif";
		
		homeIcon = new GIcon(G_DEFAULT_ICON);
        homeIcon.image = "img/marker.gif";
		
		iconsec[11] =  new GIcon(G_DEFAULT_ICON);
        iconsec[11].image = "img/marker11.gif";
		
		iconsec[29] =  new GIcon(G_DEFAULT_ICON);
        iconsec[29].image = "img/marker29.gif";
		
		iconsec[37] =  new GIcon(G_DEFAULT_ICON);
        iconsec[37].image = "img/marker37.gif";
		
		iconsec[43] =  new GIcon(G_DEFAULT_ICON);
        iconsec[43].image = "img/marker43.gif";

		iconsec[48] =  new GIcon(G_DEFAULT_ICON);
        iconsec[48].image = "img/marker48.gif";	
		
		iconsec[51] =  new GIcon(G_DEFAULT_ICON);
        iconsec[51].image = "img/marker51.gif";	
		
		iconsec[52] =  new GIcon(G_DEFAULT_ICON);
        iconsec[52].image = "img/marker52.gif";
		iconsec[52].iconSize = new GSize(25,20);
	}
	
	function loadDataAndMarkers(){
		new Ajax.Request("load_negocios_markers.php", {
		  method: 'get',
		  onSuccess: function(transport) {
			eval(transport.responseText);
			loadMarkers();
		  }
		});
	}
	
	function loadMarkers(){
		//map.clearOverlays();
		mm = new GMarkerManager(map); 
		Markers = new Array();
		for (var i = 0; i < Puntos.length; i++) {
			
			var latlng = new GLatLng(Puntos[i].lat,Puntos[i].lng);
			switch(Puntos[i].seccion){
				case 11:
					Markers[i] = new GMarker(latlng,{icon: iconsec[Puntos[i].seccion], title: Puntos[i].title});
					break;
				case 29:
					Markers[i] = new GMarker(latlng,{icon: iconsec[Puntos[i].seccion], title: Puntos[i].title});
					break;
				case 37:
					Markers[i] = new GMarker(latlng,{icon: iconsec[Puntos[i].seccion], title: Puntos[i].title});
					break;
				case 43:
					Markers[i] = new GMarker(latlng,{icon: iconsec[Puntos[i].seccion], title: Puntos[i].title});
					break;
				case 48:
					Markers[i] = new GMarker(latlng,{icon: iconsec[Puntos[i].seccion], title: Puntos[i].title});
					break;
				case 51:
					Markers[i] = new GMarker(latlng,{icon: iconsec[Puntos[i].seccion], title: Puntos[i].title});
					break;
				case 52:
					Markers[i] = new GMarker(latlng,{icon: iconsec[Puntos[i].seccion], title: Puntos[i].title});
					break;
					
				default:
					Markers[i] = new GMarker(latlng,{icon: blankIcon, title: Puntos[i].title});
				
			}
			
			eval("GEvent.addListener(Markers["+i+"], 'click', function() {Markers["+i+"].openInfoWindowHtml(Puntos["+i+"].htmlCode); });");
			
			//mm.addMarker(Markers[i],13); 
        }
		mm.addMarkers(Markers, 14)
		mm.refresh();
		
		var evento = GEvent.addListener(mm, "changed", function(bounds,markerCount) {
			map.addOverlay(homemarker);
			if(!paginaNegocio_Global)setTimeout("homemarker.openInfoWindowHtml(homeHTML)",500)
			GEvent.removeListener(evento);
			loadPuntosInteres();
		});
	}
	
	function loadPuntosInteres(){
		new Ajax.Request("load_sitios_interes_markers.php", {
		  method: 'get',
		  onSuccess: function(transport) {
			eval(transport.responseText);
			loadMarkersInteres();
		  }
		});
	}
	
	function loadMarkersInteres(){
		var parkico =  new GIcon(G_DEFAULT_ICON);
        parkico.image = "img/park-icon.gif";
		
		MarkersInteres = new Array();
		//alert (puntos_interes.length);
		for (var i = 0; i < puntos_interes.length; i++) {
			var latlng = new GLatLng(puntos_interes[i].lat,puntos_interes[i].lng);
			if(puntos_interes[i].seccion == 1){
			  MarkersInteres[i] = new GMarker(latlng,{icon: parkico, title: puntos_interes[i].title});
			  eval("GEvent.addListener(MarkersInteres["+i+"], 'click', function() {MarkersInteres["+i+"].openInfoWindowHtml(puntos_interes["+i+"].htmlCode); });");
			}
		}
		
		mm.addMarkers(MarkersInteres, 14);
		mm.refresh();
		if(paginaNegocio_Global)setTimeout("findNegocio("+idNegocio+")",500);
	}
	
	function ventanaAyuda(){
		var winHelp = new Window("ventana_inicia_ayuda",{className: "alphacube", title: "Ayuda - Mapi Directorio", width:485, height:225, resizable:false,minimizable:false,maximizable:false, recenterAuto:false, showEffectOptions: {duration:1.5}});
		winHelp.setContent("ayuda_inicial");
		
		if(getCookieAyuda() == "yes") document.getElementById("nomasayudainicial").checked = false;
		
		//win.setHTMLContent(document.getElementById("ayuda_inicial").innerHTML)
		winHelp.setZIndex(5);
		if(getCookieAyuda() != "no" && !paginaNegocio_Global && !resultadoBusquedas_Global){
			myObserver = { onClose: function(eventName, win) { 
				if (win == winHelp) { 
					if(document.getElementById("nomasayudainicial").checked){
						setCookieAyuda("--");
					}else{
						setCookieAyuda("yes");
					}
					//document.getElementById("ventana_inicia_ayuda").
				}
			}}
			
			Windows.addObserver(myObserver);			
			winHelp.showCenter(true); 
			//winHelp.setDestroyOnClose();
		}
	}
	
	function cleanSecc(seccId){
		for(var i = 0; i < Puntos.length; i++){
			if(Puntos[i].seccion == seccId){
				//map.removeOverlay(Markers[i]);
				Markers[i].hide();
			}
		}
	}
	
	
	function addSecc(seccId){
		for(var i = 0; i < Puntos.length; i++){
			if(Puntos[i].seccion == seccId){
				//map.addOverlay(Markers[i]);
				Markers[i].show();
			}
		}
	}
	
	function cambiarSecc(obj,seccId){
		mantenerSoloUnaSecc(obj);
		loadNegocios();
		if(obj.checked){
			addSecc(seccId);
		}else{
			cleanSecc(seccId);
		}
	}
	
	function soloUnaSecc(obj){
		if(obj.checked){
			var seccs = document.getElementsByName("secciones[]");
			var tempSecc = false;
			for(var i =0; i< seccs.length ; i++){
				if(seccs[i].checked == true){
					if(tempSecc){
						seccs[i].checked = false;
						cleanSecc(seccs[i].value);
					}
					tempSecc = true;
				}
			}
		}else{
			var seccs = document.getElementsByName("secciones[]");
			for(var i =0; i< seccs.length ; i++){
				if(seccs[i].checked != true){
					seccs[i].checked = true;
					addSecc(seccs[i].value);
				}
			}
		}
		loadNegocios();
	}
	
	function mantenerSoloUnaSecc(obj){
		if(document.getElementById("unaseccion").checked){
			if(obj.checked){
				var seccs = document.getElementsByName("secciones[]");
				for(var i =0; i< seccs.length ; i++){
					if(seccs[i] != obj && seccs[i].checked == true){
						seccs[i].checked = false;
						cleanSecc(seccs[i].value);
					}
				}
			}
		}
	}
	
	function cleanSinDomicilios(){
		for(var i = 0; i < Puntos.length; i++){
			if(!Puntos[i].domicilio){
				//map.removeOverlay(Markers[i]);
				Markers[i].hide();
			}
		}
	}
	
	
	function addSinDomicilios(){
		for(var i = 0; i < Puntos.length; i++){
			if(!Puntos[i].domicilio){
				//map.addOverlay(Markers[i]);
				Markers[i].show();
			}
		}
	}
	
	function soloDomicilio(obj){
		loadNegocios()
		//alert(obj.checked);
		if(obj.checked){
			cleanSinDomicilios();
		}else{
			addSinDomicilios();
		}
	}
	
	function reubicarme(){
		var answer = confirm("Esta seguro de querer borrar su ubicacion actual en el mapa?");
		if(answer){
			homemarker.setPoint(map.getCenter());
			setCookieLatLng(homemarker.getPoint());
			homemarker.openInfoWindowHtml(homeHTML);
		}
	}
	
	
	function reubicarmapa(){
		map.panTo(homemarker.getPoint());
		//homemarker.openInfoWindowHtml(homeHTML);

	}
	
	function irAZona(lat,lng,obj){
		map.panTo(new GLatLng(lat,lng));
		clean(obj.parentNode);
		obj.style.background = "#04A2C9";
		obj.style.color = "#FFFFFF";
			
		//homemarker.openInfoWindowHtml(homeHTML);

	}
	
	function clean(obj){
		var objetos = obj.getElementsByTagName("div")
		for(var i=0; i < objetos.length; i++){
			objetos[i].style.background = "";
			objetos[i].style.color = "#000000";
		}
	}
	
	function openNegocioWindow(url, titulo){
		
		if (document.body && (document.body.clientWidth !=0)) {
		  clientWidth=document.body.clientWidth;
		  clientHeight=document.body.clientHeight;
	   }
	   if (document.documentElement && (document.documentElement.clientWidth!=0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth)) {
		  clientWidth=document.documentElement.clientWidth;   
		  clientHeight=document.documentElement.clientHeight;   
	   }   
		
		var win;
		if(clientHeight > 490){
			win = new Window({className: "alphacube", title: titulo+" - MAPIDIRECTORIO.COM", width:770, height:460, url: url,resizable:false,minimizable:false,maximizable:false, recenterAuto:false, showEffectOptions: {duration:1.5}});
		}else{
			win = new Window({className: "alphacube", title: titulo+" - MAPIDIRECTORIO.COM", width:770, height:(clientHeight-40), url: url,resizable:false,minimizable:false,maximizable:false, recenterAuto:false, showEffectOptions: {duration:1.5}});
		}
		
		win.setZIndex(5);
		
		win.showCenter(true); 
		win.setDestroyOnClose();
		//win.updateWidth();
		//setTimeout("win.updateWidth()",1500);
	}
	
	function loadBarrios(zona){
		comunaActual = zona;
		barrioActual = "";
		loadNegocios();
		document.getElementById("barrios_container").innerHTML = "<div style=\"text-align:center;margin-top:20px;\"><img src=\"img/ajax-loader.gif\" /></div>";
		new Ajax.Request("load_barrios.php?zona="+zona, {
		  method: 'get',
		  onSuccess: function(transport) {
			document.getElementById("barrios_container").innerHTML = transport.responseText;
		  }
		});
	}
	
	function loadNegocios(){
		var seccs = document.getElementsByName("secciones[]");
		var strSeccs = "";
		for(var i =0; i< seccs.length ; i++){
			if(seccs[i].checked == true){
				strSeccs = strSeccs + seccs[i].value + ",";
			}
		}
		var domicilios = "0";
		domicheck = document.getElementById("domicilios").checked;
		
		if(domicheck){
			var domicilios = "1";
		}
		
		//document.getElementById("negocios_container").innerHTML = "<div style=\"text-align:center;margin-top:20px;\"><img src=\"img/ajax-loader.gif\" /></div>";
		new Ajax.Request("load_negocios.php?barrio="+barrioActual+"&seccs="+strSeccs+"&solodom="+domicilios+"&zona="+comunaActual, {
		  method: 'get',
		  onSuccess: function(transport) {
			document.getElementById("negocios_container").innerHTML = transport.responseText;
		  }
		});
	}
	
	function resize(){
		var footerHeight = 45;
		var headerHeight = 68
		
		if (document.body && (document.body.clientWidth !=0)) {
		  clientWidth=document.body.clientWidth;
		  clientHeight=document.body.clientHeight;
	   }
	   if (document.documentElement && (document.documentElement.clientWidth!=0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth)) {
		  clientWidth=document.documentElement.clientWidth;   
		  clientHeight=document.documentElement.clientHeight;   
	   }   
		//alert(clientWidth);
		//alert(clientHeight);
		var contenedor = document.getElementById("content");
		var mapa = document.getElementById("map_canvas");
		var controlPanel = document.getElementById("controlPanel");
		var searchPanel = document.getElementById("searchPanel");
		var otrosPanel = document.getElementById("otrosPanel");
		var tooltipDiv = document.getElementById("tooltip");
		
		contenedor.style.width = clientWidth + "px";
		
		mapa.style.width = (clientWidth-4) + "px";
		mapa.style.height = (clientHeight-headerHeight-4-footerHeight) + "px";
		
		otrosPanel.style.top = searchPanel.style.top = controlPanel.style.top = (clientHeight-footerHeight - 270 - 4 - 0) + "px";
		otrosPanel.style.left = searchPanel.style.left = controlPanel.style.left = (clientWidth-780 -4)/2 + "px";
		
		tooltipDiv.style.top = (clientHeight-footerHeight - 270 - 4 - 102) + "px";
		tooltipDiv.style.left = ((clientWidth-780 -4)/2 + 682) + "px";
		
		if(clientWidth > 940){
			document.getElementById("headerBlankSpace").style.display="block";
			document.getElementById("headerBlankSpace").style.width = (clientWidth-305-472) + "px";
		}else{
			document.getElementById("headerBlankSpace").style.display="none";
		}
		
	}
	
	function showhideSearchPanel(){
		obj = document.getElementById("showhidebtsearch");
		
		if (document.getElementById("searchPanel").style.visibility != "visible"){
			if (document.getElementById("controlPanel").style.visibility == "visible"){
				document.getElementById("controlPanel").style.visibility = "hidden";
				objtmp = document.getElementById("showhidebt");
				if(objtmp)
				objtmp.innerHTML = "<img src=\"img/controlmapaon.png\" alt=\"Mostrar Panel de Control de MAPIDIRECTORIO.COM\" title=\"Mostrar Panel de Control de MAPIDIRECTORIO.COM\" border=\"0\" />";
			}else if (document.getElementById("otrosPanel").style.visibility == "visible"){
				document.getElementById("otrosPanel").style.visibility = "hidden";
				objtmp = document.getElementById("showhidebtotros");
				if(objtmp)
				objtmp.innerHTML = "<img src=\"img/otroson.png\" alt=\"Mostrar mas opciones de Mapa Directorio Medellin\" title=\"Mostrar mas opciones de Mapa Directorio Medellin\" border=\"0\" />";
			}
			document.getElementById("searchPanel").style.visibility = "visible";
			if(obj)
			obj.innerHTML = "<img src=\"img/buscaroff.png\" alt=\"Ocultar Panel de Busquedas\" title=\"Ocultar Panel de Busquedas\" border=\"0\" />";
			document.getElementById("q").select();
		}else{
			document.getElementById("searchPanel").style.visibility = "hidden";
			if(obj)
			obj.innerHTML = "<img src=\"img/buscaron.png\" alt=\"Mostrar Panel de Busquedas\" title=\"Mostrar Panel de Busquedas\" border=\"0\" />";
		}
	}
	
	function showhideControlPanel(){
		obj = document.getElementById("showhidebt");
		
		if (document.getElementById("controlPanel").style.visibility != "visible"){
			if (document.getElementById("searchPanel").style.visibility == "visible"){
				document.getElementById("searchPanel").style.visibility = "hidden";
				objtmp = document.getElementById("showhidebtsearch");
				if(objtmp)
				objtmp.innerHTML = "<img src=\"img/buscaron.png\" alt=\"Mostrar Panel de Busquedas\" title=\"Mostrar Panel de Busquedas\" border=\"0\" />";
			} else if (document.getElementById("otrosPanel").style.visibility == "visible"){
				document.getElementById("otrosPanel").style.visibility = "hidden";
				objtmp = document.getElementById("showhidebtotros");
				if(objtmp)
				objtmp.innerHTML = "<img src=\"img/otroson.png\" alt=\"Mostrar mas opciones de Mapa Directorio Medellin\" title=\"Mostrar mas opciones de Mapa Directorio Medellin\" border=\"0\" />";
			}
			document.getElementById("controlPanel").style.visibility = "visible";
			if(obj)
			obj.innerHTML = "<img src=\"img/controlmapaoff.png\" alt=\"Ocultar Panel de Control de MAPIDIRECTORIO.COM\" title=\"Ocultar Panel de Control de MAPIDIRECTORIO.COM\" border=\"0\" />";
			/*document.getElementById("controlPanel").onmouseout = function(){
				showhideControlPanel();
			};*/
		}else{
			document.getElementById("controlPanel").style.visibility = "hidden";
			if(obj)
			obj.innerHTML = "<img src=\"img/controlmapaon.png\" alt=\"Mostrar Panel de Control de MAPIDIRECTORIO.COM\" title=\"Mostrar Panel de Control de MAPIDIRECTORIO.COM\" border=\"0\" />";
			/*document.getElementById("controlPanel").onmouseout = function(){
				
			};*/
		}
	}
	
	function showhideOtros(){
		obj = document.getElementById("showhidebtotros");
		
		if (document.getElementById("otrosPanel").style.visibility != "visible"){
			if (document.getElementById("controlPanel").style.visibility == "visible"){
				document.getElementById("controlPanel").style.visibility = "hidden";
				objtmp = document.getElementById("showhidebt");
				if(objtmp)
				objtmp.innerHTML = "<img src=\"img/controlmapaon.png\" alt=\"Mostrar Panel de Control de MAPIDIRECTORIO.COM\" title=\"Mostrar Panel de Control de MAPIDIRECTORIO.COM\" border=\"0\" />";
			} else if (document.getElementById("searchPanel").style.visibility == "visible"){
				document.getElementById("searchPanel").style.visibility = "hidden";
				objtmp = document.getElementById("showhidebtsearch");
				if(objtmp)
				objtmp.innerHTML = "<img src=\"img/buscaron.png\" alt=\"Mostrar Panel de Busquedas\" title=\"Mostrar Panel de Busquedas\" border=\"0\" />";
			}
			document.getElementById("otrosPanel").style.visibility = "visible";
			if(obj)
			obj.innerHTML = "<img src=\"img/otrosoff.png\" alt=\"Ocultar otras opciones de Mapa Directorio Medellin\" title=\"Ocultar otras opciones de Mapa Directorio Medellin\" border=\"0\" />";
		}else{
			document.getElementById("otrosPanel").style.visibility = "hidden";
			if(obj)
			obj.innerHTML = "<img src=\"img/otroson.png\" alt=\"Mostrar mas opciones de Mapa Directorio Medellin\" title=\"Mostrar mas opciones de Mapa Directorio Medellin\" border=\"0\" />";
		}
	}
	
	function buscar(ciudadId){
		var q = document.getElementById("q").value;
		if(q){
			//alert(escape(q));
			document.getElementById("resultadosBuscador").innerHTML = "<div style=\"text-align:center;margin-top:50px;\"><img src=\"img/ajax-loader.gif\" /></div>";
			new Ajax.Request("../load_search.php?q="+q, {
			  method: 'get',
			  onSuccess: function(transport) {
				document.getElementById("resultadosBuscador").innerHTML = transport.responseText;
			  }
			});
		}
	}
	
	function buscarEnter(e){
		var keynum;
		
		if(window.event) // IE
		{
			keynum = e.keyCode
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which
		}

		if(keynum == 13)
			buscar(1);
	}
	
	function findNegocio(id){
		var breakvar = false;
		var i =0;
		while(i < Puntos.length && !breakvar){
			if(Puntos[i].negocioID == id){
				map.setCenter(Markers[i].getLatLng());
				//map.setCenter(Markers[i].getLatLng());
				//map.panTo(Markers[i].getLatLng());
				breakvar = true;
				
				setTimeout("Markers["+i+"].openInfoWindowHtml(Puntos["+i+"].htmlCode)",1000);
			}
			i++;
		}
	}
	
	function query(){
		document.getElementById("q").value = queryText_Global;
		showhideSearchPanel();
		buscar(1);
	}
	
	function empresaToolTip(img){
		tooltipDiv = document.getElementById("tooltip");
		tooltipDiv.innerHTML = "<table width=\"102\" height=\"102\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"right\" valign=\"bottom\"><img src=\"../mp_files/"+img+"\" border=1 style=\"border:#000000 solid 1px\" /></td></tr></table>";
		tooltipDiv.style.display = "block";
		mousePosX = 0;
		mousePosY = 0;
		//tooltipDiv.style.left = (mousePosX+15) + "px";
		//tooltipDiv.style.top = (mousePosY+3) + "px";
	}
	
	function noTooltip(){
		tooltipDiv = document.getElementById("tooltip");
		tooltipDiv.style.display = "none";
	}
	
	function hideSinDomicilios(){
		
	}
	
	function showSinDomicilios(){
		
	}
	
	window.onload = function(){
		resize();
		initialize();
		
		if(paginaNegocio_Global)negInicio();
		if(resultadoBusquedas_Global)query();
		ventanaAyuda();
		loadNegocios();
	}
	
	window.onresize = function(){
		resize();
	}
	
	window.unload = function(){
		GUnload();
	};