var xmlHttp


function GetXmlHttpObject()
{
	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)
 		{
  			if (!xmlhttp && typeof XMLHttpRequest!="undefined") xmlhttp=new XMLHttpRequest();
       	}
 	}
  	return xmlhttp; 
}

//select diaris
function alta_comentari(id_noticia)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		 alert ("Este navegador no soporta este gestor.")
		 return
	}
	
	var url="alta_comentari.php"
	url=url+"?id_noticia="+id_noticia
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged; 
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() 
{ 
	
	if (xmlHttp.readyState==1)
	{
		document.getElementById("comentaris").innerHTML='Carregant...'		
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("comentaris").innerHTML=xmlHttp.responseText 
	} 
}

//MUNICIPIS
function guardar_comentari(id_noticia,nom,email,ciutat,comentari)
{ 
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)
	{
		 alert ("Este navegador no soporta este gestor.")
		 return
	}
	var url="guardar_comentari.php" 
	url=url+"?id_noticia="+id_noticia
	url=url+"&nom="+nom
	url=url+"&email="+email
	url=url+"&ciutat="+ciutat
	url=url+"&comentari="+comentari
	url=url+"&sid="+Math.random()
	
	
	xmlHttp1.onreadystatechange=stateChanged2; 
	//document.getElementById("anadir_modelo").style.visibiliti = "visible"; 
	//document.all.anadir_modelo.visibility = "visible"; 
	xmlHttp1.open("GET",url,true)
	xmlHttp1.send(null)
}

function stateChanged2() 
{ 
	if (xmlHttp1.readyState==1)
	{
		document.getElementById("errors").innerHTML='Carregant...'		
	}
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	{ 
		document.getElementById("errors").innerHTML=xmlHttp1.responseText 
		document.getElementById("comentaris").style.visibility = "hidden"; 
	
	} 
}

function llistar_comentaris(id_noticia)
{ 
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null)
	{
		 alert ("Este navegador no soporta este gestor.")
		 return
	}
	
	var url="llistats_comentaris.php"
	url=url+"?id_noticia="+id_noticia
	url=url+"&sid="+Math.random()
	
	xmlHttp2.onreadystatechange=carregant_llistat; 
		
	xmlHttp2.open("GET",url,true)
	xmlHttp2.send(null)
}

function carregant_llistat() 
{ 
	if (xmlHttp2.readyState==1)
	{
		document.getElementById("llistat_comentaris").innerHTML='Carregant...'		
	}
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{ 
		document.getElementById("llistat_comentaris").innerHTML=xmlHttp2.responseText 
		
	} 
}

//LOGIN

function fi_login(errors,mostrar){
	 if(mostrar==0){
		document.getElementById('area_login').style.display = 'none'; 
		document.getElementById('area_modif').style.display = 'block';
		document.getElementById("errors_box").style.display = 'none';
		document.getElementById("menu_esq").style.display = 'none';
		document.getElementById("titol_seccions").style.display = 'none';
	 }else{
     document.getElementById("errors_login").innerHTML=errors;
	 document.getElementById("errors_box").style.display = 'block';
   	
	 //document.getElementById('formulari').style.display = 'none';
	 }

}


// FI EMAIL RECORDATORI PASS
function fi_recordatori(errors){
	 document.getElementById("form_pass").style.display = 'none';
     document.getElementById("errors_recomanar").innerHTML=errors;
	 document.getElementById("errors_recomanar").style.display = 'block';
   	
	 //document.getElementById('formulari').style.display = 'none';
	

}
