/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//****************** Inicialitzem objecte ActiveX per ajax ********************************/
var xmlHttp = false;

try {
   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
  xmlHttp = new XMLHttpRequest();
}

var xmlHttp2 = false;

try {
   xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
  xmlHttp2 = new XMLHttpRequest();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//************ LOADING PAGE ****************

function loading_page(){

 
  
  var url = "loading_page.php";
  if(xmlHttp){
		xmlHttp.abort();
		xmlHttp.onreadystatechange = function() {};
  }
  
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange =  function(){
	  
	  if (xmlHttp.readyState == 4) {
		  //document.getElementById('box_text_serveis').style.visibility = 'visible';
		  ActualitzaCapa('box_text_serveis',xmlHttp);
		}
	 }
  
  
  xmlHttp.send(null);
     
}
function loading_page_perla(){

 
  
  var url = "loading_page_perla.php";
  if(xmlHttp){
		xmlHttp.abort();
		xmlHttp.onreadystatechange = function() {};
  }
  
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange =  function(){
	  
	  if (xmlHttp.readyState == 4) {
		  //document.getElementById('box_text_serveis').style.visibility = 'visible';
		  ActualitzaCapa('box_text_serveis_perla',xmlHttp);
		}
	 }
  
  
  xmlHttp.send(null);
     
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//************ LOADING NOVETATS ****************

function loading_novetats(){

 
  
  var url2 = "loading_novetats.php";
  if(xmlHttp2){
		xmlHttp2.abort();
		xmlHttp2.onreadystatechange = function() {};
  }
  
  xmlHttp2.open("GET", url2, true);
  xmlHttp2.onreadystatechange =  function(){
	  
	  if (xmlHttp2.readyState == 4) {
		  //document.getElementById('box_text_serveis').style.visibility = 'visible';
		  ActualitzaCapa('novetats_content',xmlHttp2);
		}
	 }
  
  
  xmlHttp2.send(null);
     
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//************ LOADING NOVETATS ****************

function loading_novetats2(){

 
  
  var url2 = "loading_novetats2.php";
  if(xmlHttp2){
		xmlHttp2.abort();
		xmlHttp2.onreadystatechange = function() {};
  }
  
  xmlHttp2.open("GET", url2, true);
  xmlHttp2.onreadystatechange =  function(){
	  
	  if (xmlHttp2.readyState == 4) {
		  //document.getElementById('box_text_serveis').style.visibility = 'visible';
		  ActualitzaCapa('novetats_content',xmlHttp2);
		}
	 }
  
  
  xmlHttp2.send(null);
     
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//************ VOLVER AL INICIO ****************

function Inicio(){

 
  
  var url = "index.html";
  if(xmlHttp){
		xmlHttp.abort();
		xmlHttp.onreadystatechange = function() {};
  }
  
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange =  function(){
	  
	  if (xmlHttp.readyState == 4) {
		  document.getElementById('content').style.visibility = 'hidden';
		  ActualitzaCapa('content',xmlHttp);
		}
	 }
  
  
  xmlHttp.send(null);
     
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//************ CAMPS OBLIGATORIS ****************

function camps_obligatoris(){
//alert("estoy dentro, tanque");

	if(document.getElementById("data").value==""){
		alert("Has d'omplir el camp Data per continuar l'operació");
		
	}
	if(document.getElementById("titol").value==""){
		alert("Has d'omplir el camp Titol per continuar l'operació");
		
	}
	if(document.getElementById("desccurta").value==""){
		alert("Has d'omplir el camp Descripcio Curta per continuar l'operació");
		
	}
	
	if(document.getElementById("ordre").value==""){
		alert("Has d'omplir el camp Ordre per continuar l'operació");
		
	}else if(isNaN(parseInt(document.getElementById("ordre").value))){
		alert("Has d'omplir el camp Ordre amb un número per continuar l'operació");
	
	}
	
	if(document.getElementById("data").value!="" && document.getElementById("titol").value!="" && document.getElementById("desccurta").value!="" && document.getElementById("ordre").value!="" && !isNaN(parseInt(document.getElementById("ordre").value))){
		document.forms['publicar'].submit();
	}
     
}

function camps_obligatoris_esp(){

	
	if(document.getElementById("titol").value==""){
		alert("Has d'omplir el camp Titol per continuar l'operació");
		
	}
	if(document.getElementById("iniciex").value==""){
		alert("Has d'omplir el camp Inici exhibició per continuar l'operació");
		
	}
	if(document.getElementById("finalex").value==""){
		alert("Has d'omplir el camp Final exhibició per continuar l'operació");
		
	}
	if(document.getElementById("datainici").value==""){
		alert("Has d'omplir el camp Inici gira per continuar l'operació");
		
	}
	if(document.getElementById("datafinal").value==""){
		alert("Has d'omplir el camp Final gira per continuar l'operació");
		
	}
	
	if(document.getElementById("ordre").value==""){
		alert("Has d'omplir el camp Ordre per continuar l'operació");
		
	}else if(isNaN(parseInt(document.getElementById("ordre").value))){
		alert("Has d'omplir el camp Ordre amb un número per continuar l'operació");
	
	}
	
	
	
	if(document.getElementById("iniciex").value!="" && document.getElementById("finalex").value!="" && document.getElementById("datainici").value!="" && document.getElementById("datafinal").value!="" && document.getElementById("titol").value!="" && document.getElementById("ordre").value!="" && !isNaN(parseInt(document.getElementById("ordre").value))){
		
		document.getElementById('publicar').submit();
	}
     
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////

/********* ACTUALITZEM CAPES *********/

//Funcio per actualitzar les capes
function ActualitzaCapa(nomcapa,objecte) {
    document.getElementById(nomcapa).innerHTML=objecte.responseText;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////



