if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() { try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {} try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {} throw new Error( "This browser does not support XMLHttpRequest." ) }; if (!Array.prototype.forEach) { Array.prototype.forEach = function(fun /*, thisp*/) { var len = this.length >>> 0; if (typeof fun != "function") throw new TypeError(); var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in this) fun.call(thisp, this[i], i, this); } }; } function loadContent(path,elemento,modal) { var overlayVar = document.getElementById('overlayDiv'); //Mostrar overlay overlayVar.style.visibility='visible'; xmlhttp = new XMLHttpRequest(); var elemento = document.getElementById(elemento); // alert(); xmlhttp.open("GET", path,true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { elemento.innerHTML = xmlhttp.responseText; //oculta overlay if (!modal) overlayVar.style.visibility='hidden'; //Cargar formulario //if(path.substring(4,7)=='frm'){ if(path.indexOf('frm')!=-1) { setTimeout("setAjaxForm('#nuevo_telecentro');",1000); } } } //alert(path); xmlhttp.send(null); } function setAjaxForm (form) { //alert(1); var options = { target: '#ajaxContent', // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit callback success: showResponse // post-submit callback }; $(form).submit(function() { //alert(3); $(this).ajaxSubmit(options); //alert(4); return false; }); //alert(2); } function showRequest(formData, jqForm, options) { // var overlayVar = document.getElementById('overlay'); // overlayVar.style.visibility='visible'; if (document.getElementById('cambios')) { return true; } else { var nombreT = document.getElementById('nombre_telecentro').value; var personaT = document.getElementById('persona_contacto').value; if(document.getElementById('provincia')){ var provinciaT = document.getElementById('provincia').selectedIndex; } // var municipioT = document.getElementById('municipio').selectedIndex; var emailT = document.getElementById('email').value; var pcT = document.getElementById('numero_pc').value; var xT = document.getElementById('_x').value; var tT = document.getElementById('_y').value; var zT = document.getElementById('_z').value; if ( nombreT=='' || personaT=='' || emailT=='' || pcT=='' || xT=='' || tT=='' || zT=='' || provinciaT==0 ) { alert("Los campos marcados con (*) son requeridos."); return false; } else { // var queryString = $.param(formData); return true; } } } function showResponse(responseText, statusText) { // var overlayVar = document.getElementById('overlay'); // overlayVar.style.visibility='hidden'; } function findPosX(obj) { var curleft = 0; if(obj.offsetParent) while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.x) curleft += obj.x; return curleft; } function findPosY(obj) { var curtop = 0; if(obj.offsetParent) while(1) { curtop += obj.offsetTop; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.y) curtop += obj.y; return curtop; } function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); center = new GLatLng(16.585825381874263, -73.916015625); map.setCenter(center, 5); GEvent.addListener(map, "zoomend", function() { zoom = map.getZoom(); if(zoom>10){ map.setMapType(G_SATELLITE_MAP); } else { map.setMapType(G_NORMAL_MAP); } // addCoords(marker.getPoint(),zoom); }); setTimeout("callMarkers()",1000); } } function reMap() { map.clearOverlays(); } $(document).ready(function(){ $("#btn_nuevo").click(function () { loadContent('inc/frm_telecentro.php?lan=en', 'ajaxContent', true); d = document.getElementById('ajaxContent'); d.style.width='400px'; d.style.backgroundColor='#ffffff'; d.style.height='500px'; d.style.height='500px'; $("#ajaxContent").show("slow"); $("#ajaxContent").css('left',$('#btn_nuevo').offset().left); $("#ajaxContent").css('top',$('#btn_nuevo').offset().top+$('#btn_nuevo').height()); setTimeout("cargarMiniMapa()",2000); }); $("#btn_filtro").click(function () { loadContent('inc/frm_filtro.php', 'ajaxContent', true); d = document.getElementById('ajaxContent'); d.style.width='400px'; d.style.backgroundColor='#ffffff'; d.style.height='400px'; // d.style.height='500px'; $("#ajaxContent").show("slow"); $("#ajaxContent").css('left',$('#btn_filtro').offset().left); $("#ajaxContent").css('top',$('#btn_filtro').offset().top+$('#btn_filtro').height()); }); $("#overlayDiv").height($(document).height());//$(window).height() $("#overlayDiv").width($(document).width());//$(window).width() $("#overlayDiv").css('left',0); $("#overlayDiv").css('top',0); $("#overlayDiv").css('opacity',0.5); }); function cargarMiniMapa(){ miniMap = new GMap2(document.getElementById("mapMarker")); var __x = document.getElementById('_x').value; var __y = document.getElementById('_y').value; var __z = document.getElementById('_z').value; if(__x != '' && __y != '' && __z != '') { miniMapCenter = new GLatLng(__x, __y); miniMap.setCenter(miniMapCenter, 6); } else { ///////////// miniMapCenter = new GLatLng(20.585825381874263, -73.916015625); miniMap.setCenter(center, 5); //////////// //miniMapCenter = new GLatLng(18.687878686034182, -70.6640625); } // miniMap.setCenter(miniMapCenter, 6); miniMap.addMapType(G_SATELLITE_MAP); miniMap.addControl(new GSmallMapControl()); miniMap.addControl(new GMapTypeControl()); var marker = new GMarker(miniMapCenter, {draggable: true}); GEvent.addListener(marker, "dragstart", function() { miniMap.closeInfoWindow(); }); GEvent.addListener(marker, "dragend", function() { // marker.openInfoWindowHtml("Drag this marker to the correct location, Zoom in as necessary"); addCoords(marker.getPoint(),miniMap.getZoom()); }); GEvent.addListener(miniMap, "zoomend", function() { zoom = miniMap.getZoom(); if(zoom>10){ miniMap.setMapType(G_SATELLITE_MAP); } else { miniMap.setMapType(G_NORMAL_MAP); } addCoords(marker.getPoint(),zoom); }); miniMap.addOverlay(marker); marker.openInfoWindowHtml("Drag this marker to the correct location, Zoom in as necessary"); // $(function() { // $("#fecha_creacion").datepicker(); // $('#fecha_creacion').datepicker('option', {dateFormat: 'dd/mm/yy'}); // }); } function callMarkers() { $.get("inc/markers.js.php?lan=en", addMarkers); } function addMarkers(data){ eval("locations="+data); map.clearOverlays(); var blueIcon = new GIcon(G_DEFAULT_ICON); blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png"; // Set up our GMarkerOptions object markerOptions = { icon:blueIcon }; locations.forEach(function(element, index, array) { if (element.publicado==0){ var marker = new GMarker( new GLatLng(element.lat, element.lon), markerOptions ); } else { var marker = new GMarker( new GLatLng(element.lat, element.lon) ); } // var marker = new GMarker( new GLatLng(element.lat, element.lon) ); map.addOverlay(marker); GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(element.info); }); }); } function addMarker(lat,lon,info,color) { var blueIcon = new GIcon(G_DEFAULT_ICON); blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png"; // Set up our GMarkerOptions object markerOptions = { icon:blueIcon }; var marker = new GMarker( new GLatLng(lat, lon), markerOptions ); map.addOverlay(marker, { icon:blueIcon }); map.setCenter(GLatLng(lat, lon)); marker.openInfoWindowHtml(info); GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(info); }); } function addCoords(p,__z){ document.getElementById('_x').value=p.lat(); document.getElementById('_y').value=p.lng(); document.getElementById('_z').value=__z; } function cerrar(elem){ document.getElementById('overlayDiv').style.visibility='hidden'; $("#ajaxContent").hide("slow"); } function solicitarCambio(i) { loadContent('inc/frm_cambio.php?id='+i+'&lan=en', 'ajaxContent', true); d = document.getElementById('ajaxContent'); d.style.width='400px'; d.style.backgroundColor='#ffffff'; d.style.height='250px'; $("#ajaxContent").show("slow"); $("#ajaxContent").css('left',$('#btn_nuevo').offset().left); $("#ajaxContent").css('top',$('#btn_nuevo').offset().top+$('#btn_nuevo').height()); // setTimeout("cargarMiniMapa()",2000); }