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

//****************** 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);
     
}

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

//************ 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(){

	var error = "NO";
	
   if(document.getElementById("data").value==""){
			error="SI";
	}
	if(document.getElementById("titol").value==""){
			error="SI";
	}
	if(document.getElementById("autor").value==""){
			error="SI";
	}
	if(document.getElementById("publicat_a").value==""){
			error="SI";
	}

	
	if(error=="SI"){
		alert("Revisi tots els camps obigatòris.");
	}
	
	if(error=="NO"){
		document.forms['publicar'].submit();
	}
     
}


function camps_obligatoris2(){
	var error = "NO";
	
   if(document.getElementById("data").value==""){
			error="SI";
	}
	if(document.getElementById("titol").value==""){
			error="SI";
	}
	
	if(error=="SI"){
		alert("Revisi tots els camps obigatòris.");
	}
	if(error=="NO"){
		document.forms['publicar'].submit();
	}
}

function camps_obligatoris_noveles(){
	var error = "NO";
	
   if(document.getElementById("any").value==""){
			error="SI";
	}
	if(document.getElementById("titol").value==""){
			error="SI";
	}
	
	if(error=="SI"){
		alert("Revisi tots els camps obigatòris.");
	}
	if(error=="NO"){
		document.forms['publicar'].submit();
	}
}

function camps_obligatoris3(){
	var error = "NO";
	
   if(document.getElementById("any").value==""){
			error="SI";
	}
	if(document.getElementById("titol").value==""){
			error="SI";
	}
	if(document.getElementById("descripcio").value==""){
			error="SI";
	}

	
	if(error=="SI"){
		alert("Revisi tots els camps obigatòris.");
	}
	if(error=="NO"){
		document.forms['publicar'].submit();
	}
}


function camps_obligatoris4(){
	var error = "NO";
	
   if(document.getElementById("any").value==""){
			error="SI";
	}
	if(document.getElementById("obra").value==""){
			error="SI";
	}
	if(document.getElementById("publicacio").value==""){
			error="SI";
	}

	
	if(error=="SI"){
		alert("Revisi tots els camps obigatòris.");
	}
	if(error=="NO"){
		document.forms['publicar'].submit();
	}
}

function print_pant(nombre){
	var ficha = document.getElementById(nombre);
	var ventimp = window.open(' ', 'popimpr');
	ventimp.document.write( ficha.innerHTML );
	ventimp.document.close();
	ventimp.print( );
	ventimp.close();
}