// JavaScript Document
function nuevoAjax()
{ 
 var xmlhttp=false; 
 try 
 { 
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
 }
 catch(e)
 { 
  try
  { 
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  } 
  catch(E) { xmlhttp=false; }
 }
 if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 
 
 return xmlhttp; 
}


function cargar_mapa(lat,lng,mapa,zom){
	if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById(mapa));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
        icon = new GIcon();
		icon.image = "http://www.guiapueblos.es/img/chincheta.png";
		icon.iconSize = new GSize(22, 32);
		icon.iconAnchor = new GPoint(5, 30);
		var point = new GLatLng(lat,lng);
		map.setCenter(point, zom);
		var marker = new GMarker(point,icon);
		map.addOverlay(marker);
	}
}

function inapropiada(id){
	var ajax = nuevoAjax();
	var txt = "txtofensiva"+id;
	var motivo = document.getElementById(txt).value;
	var strPos = "id="+id+"&motivo="+motivo;
	var capa = "coment"+id; 
	var capa2 = "sendcoment"+id;
	
	if(motivo!=""){
		ajax.open("POST","http://www.guiapueblos.es/inc/ajax.php?func=1",true);	
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.onreadystatechange=function() {
			if (ajax.readyState==1){
				document.getElementById(capa2).style.display="none";
				document.getElementById(capa).innerHTML="Enviando...";
			} 
			if (ajax.readyState==4){
				document.getElementById(capa).innerHTML=ajax.responseText;
			}
		}
		ajax.send(strPos);
		return;	
	}else{
		alert("Debe indicar un motivo");
		return;
	}
}

function fotoinapropiada(id){
	var ajax = nuevoAjax();
	var txt = "imgofensiva"+id;
	var motivo = document.getElementById(txt).value;
	var strPos = "id="+id+"&motivo="+motivo;
	var capa = "fotografia"+id; 
	var capa2 = "sendfoto"+id;
	
	if(motivo!=""){
		ajax.open("POST","http://www.guiapueblos.es/inc/ajax.php?func=2",true);	
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.onreadystatechange=function() {
			if (ajax.readyState==1){
				document.getElementById(capa2).style.display="none";
				document.getElementById(capa).innerHTML="Enviando...";
			} 
			if (ajax.readyState==4){
				document.getElementById(capa).innerHTML=ajax.responseText;
			}
		}
		ajax.send(strPos);
		return;	
	}else{
		alert("Debe indicar un motivo");
		return;		
	}
}

function addenlace(){
	if(document.getElementById("addenlace").style.display == "none"){
		document.getElementById("addenlace").style.display="block";	
	}else{
		document.getElementById("addenlace").style.display="none";	
	}
}

function addsitio(){
	if(document.getElementById("addsitio").style.display == "none"){
		document.getElementById("addsitio").style.display="block";	
	}else{
		document.getElementById("addsitio").style.display="none";	
	}
}

function vercapa(capa){
	if(document.getElementById(capa).style.display == "none"){
		document.getElementById(capa).style.display="block";	
	}else{
		document.getElementById(capa).style.display="none";	
	}	
}