// JavaScript Document

function validarboletin(f){

	idpob = document.getElementById('poblacion');
	idhidd = document.getElementById('poblacion_hidden');
	idhidd.value = idpob.value; 

	if(f.clnombre.value == ""){
		alert("Por favor, rellene el campo Nombre");
		f.clnombre.focus();
		return false;
	}

	if(f.provincia.value == 0){
		alert("Por favor, rellene el campo Provincia");
		f.provincia.focus();
		return false;
	}

	if(idhidd.value == 0){
		alert("Por favor, rellene el campo Poblacion");
		document.getElementById('poblacion').focus();
		return false;
	}

	if(f.clemail.value == ""){
        alert("Por favor, rellene el campo Email");
		return false;
	}else{
         sEmail = f.clemail.value;
         sel1=sEmail.indexOf("@");
         sel2=sEmail.indexOf(".");
         if ((sEmail.length>0) && (sel1!=-1) && (sel2!=-1)) {
           
         } else {
           alert("El Email introducido es incorrecto");
		   f.clemail.focus();
		   return false;
         }
	}

}

	var xmlhttp
	
	function cargaPoblacion2(id) {
		loadXMLDoc('poblacion-ajax2.asp?id='+id);
	}
	
	function loadXMLDoc(url) {

	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=xmlhttpChange
	  xmlhttp.open("GET",url,true)
	  xmlhttp.send(null)
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		if (xmlhttp)
		{
		xmlhttp.onreadystatechange=xmlhttpChange
		xmlhttp.open("GET",url,true)
		xmlhttp.send()
		}
		
	  }
	
	}
	
	function xmlhttpChange()
	{
	// if xmlhttp shows "loaded"
	if (xmlhttp.readyState==4)
	  {
	  // if "OK"
	  if (xmlhttp.status==200)
		{
			texto = xmlhttp.responseText;
			//alert(objxml);
			sel = document.getElementById('seelect');
			sel.innerHTML=texto;
		}
	  else
		{
	//    alert("Problem retrieving XML data")
		}
	  }
	}

