function ventana(url){
	window.open(url,"Detalle","toolbar=no,menubar=no,width=800,height=600");
}
// OBJETO AJAX 
function nuevoAjax() { 
	var xmlhttp=false; 
	try { // Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e){ 
		try{ // Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 	      
	return xmlhttp; 
}
//ACTUALIZACION DE CAMPOS DE LA JUNTA
function actualizar(id,campo1,campo2){
	c1=document.getElementById(campo1);
	persona=c1.value;
	c2=document.getElementById(campo2);
	empresa=c2.value;
	if(c1!="" && c2!=""){			
		var aleatorio=Math.random();
		ajax=nuevoAjax();
		ajax.open("GET", "actjunta.php?id="+id+"&persona='"+persona+"'&empresa='"+empresa+"'&nocache="+aleatorio, true);
		ajax.onreadystatechange=function() { 
			if (ajax.readyState==4){ 
				var resultado=ajax.responseText;
				if (resultado==1){					
					alert("Actualización de datos correcta");			
				}
				else{
					alert("Actualización de datos no realizada");	
				}
			} 
		}
		ajax.send(null); 						
	}
	else{
		alert("Es necesario rellenar tanto el campo de persona como la empresa a la que representa.");
	}
}
//FUNCION GENERICA QUE SE UTILIZA PARA ELIMINAR REGISTROS CON DEPENDENCIA DE LA TABLA ORIGEN
function eliminar(tabla,id){	
	if(id!=""){			
		var aleatorio=Math.random();
		ajax=nuevoAjax();
		ajax.open("GET", "elimina.php?tabla="+tabla+"&id="+id+"&nocache="+aleatorio, true);
		//alert( "elimina.php?tabla="+tabla+"&id="+id+"&nocache="+aleatorio);
		ajax.onreadystatechange=function() { 
			if (ajax.readyState==4){ 
				var resultado=ajax.responseText;
				if (resultado==1){										
					alert("Eliminacion realizada correctamente");					
				}
				else{
					alert("Ha ocurrido un error en la eliminación");	
				}
				window.location.reload();
			} 
		}
		ajax.send(null); 						
	}
	else{
		alert("Es necesario seleccionar un elemento de la tabla.");
	}
}
function pasara(formulario, num, actual){
	formulario.num.value=num;
	formulario.actual.value=actual;
	formulario.submit();
}

function posicionar() {
   if (GBrowserIsCompatible()) {
      var map = new GMap2(document.getElementById("map"));   
      map.setCenter(new GLatLng(40.872641,0.155673), 17);   
      map.addControl(new GLargeMapControl());
      map.setMapType(G_NORMAL_MAP);
      var point = new GPoint (0.155673,40.872641);
      var marker = new GMarker(point);
      map.addOverlay(marker); 
   }
}
