   function verificarFormEnviarAmicCast(form, url) 
   {
	   if (form.nom.value == "" || form.nom.value.length<3 )
	   {
		  alert("Por favor introduzca su nombre.");
		  form.nom.focus();
		  return false;
	   }      
	   else if (form.email.value == "")
	   {
		  alert("Por favor introduzca un e-mail válido.");
		  form.email.focus();
		  return false;
	   }      
	   else if (form.missatge.value.length > 255)
	   {
		  alert("Por favor introduzca un mensaje de máximo 255 carácteres (actualmente tiene " + form.missatge.value.length + ").");
		  form.missatge.focus();
		  return false;
	   }      
       else
	   {
	   	  go(form, url);
	   }      
   }
   function verificarFormEnviarAmic(form, url) 
   {
	   if (form.nom.value == "" || form.nom.value.length<3 )
	   {
		  alert("Siusplau introdueixi un nom.");
		  form.nom.focus();
		  return false;
	   }      
	   else if (form.email.value == "")
	   {
		  alert("Siusplau introdueixi un email vàlid.");
		  form.email.focus();
		  return false;
	   }      
	   else if (form.missatge.value.length > 255)
	   {
		  alert("Siusplau introdueixi un missatge de menys de 255 caràcters (actualment en té " + form.missatge.value.length + ").");
		  form.missatge.focus();
		  return false;
	   }      
       else
	   {
	   	  go(form, url);
	   }      
   }

function obrirFinestra_mail( form, nomFinestra, amplada, altura, top, left )
{
	alert("a dins obrir");

	var valor = form.oferta.value;
	
	var url = "oferta.php?idOferta=" + valor;
	
	alert(" a dins ");
	var wf = "";	
	wf = wf + "width=" + amplada;
	wf = wf + ",height=" + altura;
	wf = wf + ",resizable=no";
	wf = wf + ",title='"+ nomFinestra +"'";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";
	wf = wf + ",top=" + top;
	wf = wf + ",left=" + left;	
//	wf = wf + ",top=" + ((screen.availWidth-amplada)/2);
//	wf = wf + ",left=" + ((screen.availHeight-altura)/2);

	alert(" a dins, abans open ");

	window.open(url,nomFinestra,wf);
	opener.window.close();
}
function obrirFinestra( url, nomFinestra, amplada, altura, top, left )
{
	var wf = "";	
	wf = wf + "width=" + amplada;
	wf = wf + ",height=" + altura;
	wf = wf + ",resizable=no";
	wf = wf + ",title='"+ nomFinestra +"'";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";
	wf = wf + ",top=" + top;
	wf = wf + ",left=" + left;	
//	wf = wf + ",top=" + ((screen.availWidth-amplada)/2);
//	wf = wf + ",left=" + ((screen.availHeight-altura)/2);
	window.open(url,nomFinestra,wf);
}
function testejar()
{
 	if (navigator.userAgent.indexOf('Safari') != -1)
 	{
		window.document.contacto.politica.disabled = false;
 	}
 	else if (navigator.userAgent.indexOf('MSIE') != -1)
 	{
	    // funciona de totes dues maneres, com en el Mozilla també
		if (parent.document.getElementById("politica").checked)
		{
			parent.document.getElementById("enviar").disabled = false;
		}
		else
		{
			parent.document.getElementById("enviar").disabled = true;
		}	
	}
 	else if (navigator.userAgent.indexOf('Mozilla') != -1)
 	{
		if (window.document.getElementById("politica").checked)
		{
			window.document.getElementById("enviar").disabled = false;
		}
		else
		{
			window.document.getElementById("enviar").disabled = true;
		}	
		//window.document.contacto.politica.disabled = false;
	}
 	else if (navigator.userAgent.indexOf('Netscape') != -1)
 	{
		window.document.contacto.politica.disabled = false;
 	}
	else 
	{
		window.document.contacto.politica.disabled = false;
	}
}
   function verificarForm(form, url) 
   {
	   valor = form.remitente.value;
       correo = "valor.lastIndexOf('@')!=valor.indexOf('@') || valor.indexOf('@')<2 || valor.lastIndexOf('.')<valor.length-4 || valor.lastIndexOf('.')>valor.length-3";

	   if (form.nombre.value == "" || form.nombre.value.length<3 )
	   {
		  alert("Siusplau introdueixi un nom.");
		  form.nombre.focus();
		  return false;
	   }      
	   else if (form.telF2.value != "" && (form.telF1.value == "" || form.telF3.value == "" || form.telF4.value == "" || form.telF1.value.length < 2 || form.telF2.value.length < 3 || form.telF3.value.length < 3 || form.telF4.value.length < 3 || !Number(form.telF1.value) || !Number(form.telF2.value) || !Number(form.telF3.value) || !Number(form.telF4.value)))
	   {
			alert("Siusplau introdueixi un telèfon fix vàlid.");
			form.telF1.focus();
			return false;
	   }       
	   else if (form.telM1.value != "" && (form.telM2.value == "" || form.telM3.value == "" || form.telM1.value.length < 3 || form.telM2.value.length < 3 || form.telM3.value.length < 3 || !Number(form.telM1.value) || !Number(form.telM2.value) || !Number(form.telM3.value)))
	   {
		  alert("Siusplau introdueixi un telèfon mòbil vàlid.");
		  form.telM1.focus();
		  return false;
	   }       
	   else if (form.remitente.value == "" || eval(correo))
	   {
		  alert("Siusplau introdueixi un email vàlid per poder respondre les seves qüestions.");
		  form.remitente.focus();
		  return false;
	   }      
	   else if (form.asunto.value == "" || form.asunto.value.length<3 )
	   {
		  alert("Siusplau introdueixi el tema de contacte en el camp assumpte.");
		  form.asunto.focus();
		  return false;
	   }      
	   else if (form.mensaje.value == ""  || form.mensaje.value.length<5 )
	   {
		  alert("Siusplau introdueixi la raó del seu contacte amb la nostra empresa.");
		  form.mensaje.focus();
		  return false;
	   }      
       else
	   {
	   	  go(form, url);
	   }      
   }
function go(form,url) 
{
	form.action = url;
	form.submit();
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function seguent(element)
{
	if (element == 2)
	{
		if (document.forms[0].elements[element].value.length == 2 && document.forms[0].elements[element].value != 34)
			document.forms[0].elements[element + 1].focus();
	}
	else if (document.forms[0].elements[element].value.length == 3)
			document.forms[0].elements[element + 1].focus();
}
function obrirFinestra2( url, nomFinestra, amplada, altura, top, left )
{ 
	var wf = "";	
	wf = wf + "width=" + amplada;
	wf = wf + ",height=" + altura;
	wf = wf + ",resizable=no";
	wf = wf + ",title="+ nomFinestra;
	wf = wf + ",scrollbars=no";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";
	wf = wf + ",top=" + ((screen.availHeight-amplada)/2);
	wf = wf + ",left=" + ((screen.availHeight-altura)/2);	

	window.open(url,nomFinestra,wf);
 	if (navigator.userAgent.indexOf('Safari') != -1)
 	{
		window.document.contacto.politica.disabled = false;
 	}
 	else if (navigator.userAgent.indexOf('MSIE') != -1)
 	{
	    // funciona de totes dues maneres
		//parent.document.getElementById("politica").disabled = false;
		window.document.contacto.politica.disabled = false;
	}
 	else if (navigator.userAgent.indexOf('Mozilla') != -1)
 	{
		window.document.contacto.politica.disabled = false;
	}
 	else if (navigator.userAgent.indexOf('Netscape') != -1)
 	{
		window.document.contacto.politica.disabled = false;
 	}
	else 
	{
		window.document.contacto.politica.disabled = false;
	}
}
   function verificarFormBuscador(form, castella) 
   {
       if (form.dataFins.value == "")
	   {
	   	  if (castella == true)
  		     alert("Debe seleccionar un período, inicio y final, para delimitar las ofertas a buscar.");
		  else
		     alert("Siusplau seleccioni un període (inici i final) per les ofertes a mostrar.");
		  form.dataFins.focus();
		  return false;
	   }      
       else if (form.dataDesde.value == "")
	   {
	   	  if (castella == true)
  		     alert("Debe seleccionar un período, inicio y final, para delimitar las ofertas a buscar.");
		  else
			 alert("Siusplau seleccioni un període (inici i final) per les ofertes a mostrar.");
		  form.dataDesde.focus();
		  return false;
	   }      
       else if (form.preuDesde.value != "" && !Number(form.preuDesde.value))
	   {
	   	  if (castella == true)
  		     alert("Por favor introduzca un precio desde correcto.");
		  else
			  alert("Siusplau introdueixi un preu des de correcte.");
		  form.preuDesde.focus();
		  return false;
	   }      
       else if (form.preuFins.value != "" && !Number(form.preuFins.value))
	   {
	   	  if (castella == true)
  		     alert("Por favor introduzca un precio hasta correcto.");
		  else
			  alert("Siusplau introdueixi un preu fins correcte.");
		  form.preuFins.focus();
		  return false;
	   }      
       else
	   {
	   	   go(form, "consulta_buscador.php");
	   }      
   }
function obrirFinestra3( url, nomFinestra, amplada, altura, top, left )
{
	var wf = "";
	
	window.close();	
	wf = wf + "width=" + amplada;
	wf = wf + ",height=" + altura;
	wf = wf + ",resizable=no";
	wf = wf + ",title='"+ nomFinestra +"'";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";
	wf = wf + ",top=" + top;
	wf = wf + ",left=" + left;	
//	wf = wf + ",top=" + ((screen.availWidth-amplada)/2);
//	wf = wf + ",left=" + ((screen.availHeight-altura)/2);
	window.open(url,nomFinestra,wf);
}
function obrirFoto2(titol,foto,alcada,amplada,esquerra,superior, principal) 
{  
  var x,a=obrirFoto2.arguments;
  
     myWin= open("", "", "width="+amplada+",height="+alcada+",left="+esquerra+",top="+superior);
  
  // open document for further output
  myWin.document.open();
  
  // create document
  myWin.document.write("<html><head><title>" + titol + "</title>");
  if (principal)
  {
     x=MM_findObj(a[1]);
     myWin.document.write("<style type='text/css'><!-- .fondogaleria { background-image: url(" + x.src + ");	background-repeat: no-repeat;}</style>");
  }
  else
  {
     myWin.document.write("<style type='text/css'><!-- .fondogaleria { background-image: url(" + foto + ");	background-repeat: no-repeat;}</style>");
  }  
  myWin.document.write("<style type='text/css'><!-- a:link, a:visited, a:hover { color: #000000; text-decoration: none; font-weight: bold;} </style>");
  myWin.document.write("<style type='text/css'><!-- a:hover { text-decoration: underline;} </style>");
  myWin.document.write("</head>");
  myWin.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'> ");
  myWin.document.write("<table width=" + amplada + " height=" + alcada + " border='0' align='center' class='fondogaleria'>");
  myWin.document.write("<tr> <td height=" + (alcada - 37) + ">&nbsp;</td>");
  myWin.document.write("</tr><tr><td align='left'></td></tr>");
  myWin.document.write("</table>");
  myWin.document.write("</body></html>");

  // close the document - (not the window!)
  myWin.document.close();  
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function activar_dates()
{
 	if (navigator.userAgent.indexOf('Safari') != -1)
 	{
		window.document.buscador.dates.disabled = false;
 	}
 	else if (navigator.userAgent.indexOf('MSIE') != -1)
 	{
	    // funciona de totes dues maneres, com en el Mozilla també
		if (parent.document.getElementById("dates").checked)
		{
			parent.document.getElementById("ddD").disabled = false;
			parent.document.getElementById("mmD").disabled = false;
			parent.document.getElementById("aaD").disabled = false;
			parent.document.getElementById("ddF").disabled = false;
			parent.document.getElementById("mmF").disabled = false;
			parent.document.getElementById("aaF").disabled = false;
		}
		else
		{
			parent.document.getElementById("ddD").disabled = true;
			parent.document.getElementById("mmD").disabled = true;
			parent.document.getElementById("aaD").disabled = true;
			parent.document.getElementById("ddF").disabled = true;
			parent.document.getElementById("mmF").disabled = true;
			parent.document.getElementById("aaF").disabled = true;
		}	
	}
 	else if (navigator.userAgent.indexOf('Mozilla') != -1)
 	{
		if (window.document.getElementById("dates").checked)
		{
			window.document.getElementById("ddD").disabled = false;
			window.document.getElementById("mmD").disabled = false;
			window.document.getElementById("aaD").disabled = false;
			window.document.getElementById("ddF").disabled = false;
			window.document.getElementById("mmF").disabled = false;
			window.document.getElementById("aaF").disabled = false;
		}
		else
		{
			window.document.getElementById("ddD").disabled = true;
			window.document.getElementById("mmD").disabled = true;
			window.document.getElementById("aaD").disabled = true;
			window.document.getElementById("ddF").disabled = true;
			window.document.getElementById("mmF").disabled = true;
			window.document.getElementById("aaF").disabled = true;
		}	
		//window.document.contacto.politica.disabled = false;
	}
 	else if (navigator.userAgent.indexOf('Netscape') != -1)
 	{
		window.document.buscador.dates.disabled = false;
 	}
	else 
	{
		window.document.buscador.dates.disabled = false;
	}
}
   function verificarForm2(form) 
   {
	   valor = form.email.value;
       correo = "valor.indexOf('*') != -1 || valor.lastIndexOf('@')!=valor.indexOf('@') || valor.indexOf('@')<2 || valor.lastIndexOf('.')<valor.length-4 || valor.lastIndexOf('.')>valor.length-3";
       var idTipus1 = form.idTipus1.options[form.idTipus1.selectedIndex].value;
       var idTipus2 = form.idTipus2.options[form.idTipus2.selectedIndex].value;
       var idTipus3 = form.idTipus3.options[form.idTipus3.selectedIndex].value;

       if ((idTipus1 == 0 || idTipus1 == "") && (idTipus2 == 0 || idTipus2 == "") && (idTipus3 == 0 || idTipus3 == ""))
	   {
		  alert("Siusplau seleccioni com a mínim un tipus d'oferta de la qual vol rebre informació de forma periòdica via correu electrònic .");
		  form.idTipus1.focus();
		  return false;
	   }      
	   else if (form.nom.value == "" || form.nom.value.length<3 )
	   {
		  alert("Siusplau introdueixi el nom del client.");
		  form.nom.focus();
		  return false;
	   }      
	   else if (form.email.value == "" || eval(correo))
	   {
		  alert("Siusplau introdueixi el correu electrònic del client.");
		  form.email.focus();
		  return false;
	   }      
       else
	   {
	   	  go(form, "insercio_client.php");
	   }      
   }
