function mouse_over(celda){
	celda.style.cursor='hand';
}

function mouse_out(celda){
	celda.style.cursor='arrow';
}

function mouse_over_texte(celda){
	celda.style.cursor='hand';
	celda.style.color="#EF7900";
}

function mouse_out_texte(celda){
	celda.style.cursor='arrow';
	celda.style.color="#1A385B";
}

function mouse_over_texte2(celda){
	celda.style.cursor='hand';
	celda.style.color="#1A385B";
}

function mouse_out_texte2(celda){
	celda.style.cursor='arrow';
	celda.style.color="#FFFFFF";
}

function mouse_over_color(celda, color){
	celda.style.cursor='hand';
	celda.style.backgroundColor=color;
}

function mouse_out_color(celda, color){
	celda.style.cursor='arrow';
	celda.style.backgroundColor=color;
}

function mouse_over_color2(celda, color){
	celda.style.cursor='hand';
	celda.style.backgroundColor=color;
}

function mouse_out_color2(celda, color){
	celda.style.cursor='arrow';
	celda.style.backgroundColor=color;
	celda.style.color="#EF7900";
}

function canvia_imatge(img_name, img_src)
{
   document[img_name].src = "../clientes/imagenes/"+img_src;
}

function abrirVentana(url,llargada,alsada)
{
	finestra=window.open(url,'nom','height='+llargada+',width='+alsada+',scrollbars=yes,status=no');
	if (window.focus) {finestra.focus()}
}

function abrirVentana2(url,llargada,alsada)
{
	finestra=window.open(url,'nom','height='+llargada+',width='+alsada+',scrollbars=yes,status=no');
	if (window.focus) {finestra.focus()}
}

function centrar()
{
	x = (screen.width - 600) / 2;
	y = (screen.height - 750) / 2;

	moveTo(x,y);
}

function TamVentana() { 
  var Tamanyo = [0, 0]; 
  if (typeof window.innerWidth != 'undefined') 
  { 
    Tamanyo = [ 
        window.innerWidth, 
        window.innerHeight 
    ]; 
  } 
  else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) 
  { 
 Tamanyo = [ 
        document.documentElement.clientWidth, 
        document.documentElement.clientHeight 
    ]; 
  } 
  else   { 
    Tamanyo = [ 
        document.getElementsByTagName('body')[0].clientWidth, 
        document.getElementsByTagName('body')[0].clientHeight 
    ]; 
  } 
  return Tamanyo; 
} 


function margeTop(){
	var Tam = TamVentana();  
	document.write("<style type='text/css'> body { margin-top: "+((Tam[1]-578)/2)+"px; } <\/style>");
	window.onresize = function(){
	document.location.reload();	
	}
}

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 comprobarMultiple(aux,b,id){
	a=aux.value;
	if ((a%b)!=0){
		if (id=="es")
		{
			window.alert("La cantidad solicitada ("+ a +") debe ser múltiple de la unidad de conjunto ("+b+")");
			aux.focus();
		}
		if (id=="ca")
		{
			window.alert("La quantitat sol·licitada ("+ a +") ha de ser múltiple de la unitat de conjunt ("+b+")");
			aux.focus();
		}
		if (id=="en")
		{
			window.alert("La quantitat sol·licitada ("+ a +") ha de ser múltiple de la unitat de conjunt ("+b+")");
			aux.focus();
		}
		if (id=="fr")
		{
			window.alert("La quantitat sol·licitada ("+ a +") ha de ser múltiple de la unitat de conjunt ("+b+")");
			aux.focus();
		}
		if (id=="it")
		{
			window.alert("La quantitat sol·licitada ("+ a +") ha de ser múltiple de la unitat de conjunt ("+b+")");
			aux.focus();
		}
	}
}

function comprobarextension(a,id)
{
	if (id=="es")
	{
		if(String(a.value).substr(a.value.length-3)!="xls")
		{
			window.alert("Debe seleccionar un fichero de excel.");
			a.focus();
		}
	}
	if (id=="ca")
	{
		if(String(a.value).substr(a.value.length-3)!="xls")
		{
			window.alert("Ha de seleccionar un fitxer d'excel.");
			a.focus();
		}
	}
	if (id=="en")
	{
		if(String(a.value).substr(a.value.length-3)!="xls")
		{
			window.alert("You have to select a xls file.");
			a.focus();
		}
	}
	if (id=="fr")
	{
		if(String(a.value).substr(a.value.length-3)!="xls")
		{
			window.alert("Debe seleccionar un fichero de excel.");
			a.focus();
		}
	}
	if (id=="it")
	{
		if(String(a.value).substr(a.value.length-3)!="xls")
		{
			window.alert("Debe seleccionar un fichero de excel.");
			a.focus();
		}
	}
}

function comprova_form(idioma)
{
	var pass=true;
	var msg="";
	if (document.frmcontacto.empresa.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir el nombre de la empresa";
				break;
			case "ca":
				msg="Ha d'escriure el nom de l'empresa";
				break;
			case "it":
				msg="È necessario scrivere il nome della società";
				break;
			case "en":
				msg="You must write the name of the company";
				break;
		}
		alert(msg)
		document.frmcontacto.empresa.focus()
		return 0;
	}
	if (document.frmcontacto.sector.selectedIndex==0){
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escoger un sector de la empresa";
				break;
			case "ca":
				msg="Ha d'escollir el sector de l'empresa";
				break;
			case "it":
				msg="Devi scegliere un settore di attività";
				break;
			case "en":
				msg="You have to choose a business sector";
				break;
		}
		alert(msg)
		document.frmcontacto.sector.focus()
		return 0;
	}
	if ((document.frmcontacto.sector.selectedIndex==3) && (document.frmcontacto.sectormanual.value.length==0)){
		switch(idioma)
		{
			case "es":	
				msg="Escriba el sector";
				break;
			case "ca":
				msg="Escrigui el sector";
				break;
			case "it":
				msg="Digitare nel settore";
				break;
			case "en":
				msg="Type in the sector";
				break;
		}
		alert(msg)
		document.frmcontacto.sectormanual.focus()
		return 0;
	}
	if (document.frmcontacto.contacto.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir el nombre de la persona de contacto";
				break;
			case "ca":
				msg="Ha d'escriure el nom de la persona de contacte";
				break;
			case "it":
				msg="Si deve scrivere il nome della persona da contattare";
				break;
			case "en":
				msg="You must write the name of the contact person";
				break;
		}
		alert(msg)
		document.frmcontacto.contacto.focus()
		return 0;
	}
	if (document.frmcontacto.direccion.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir la dirección";
				break;
			case "ca":
				msg="Ha d'escriure l'adreça";
				break;
			case "it":
				msg="Devi scrivere l'indirizzo";
				break;
			case "en":
				msg="You must write the address";
				break;
		}
		alert(msg)
		document.frmcontacto.direccion.focus()
		return 0;
	}
	if (document.frmcontacto.tlf.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir el teléfon de contacto";
				break;
			case "ca":
				msg="Ha d'escriure el telèfon de l'empresa";
				break;
			case "it":
				msg="È necessario inserire un numero di telefono di contatto";
				break;
			case "en":
				msg="You must enter a contact phone number";
				break;
		}
		alert(msg)
		document.frmcontacto.tlf.focus()
		return 0;
	}
	if (document.frmcontacto.pobla.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir la población";
				break;
			case "ca":
				msg="Ha d'escriure la població";
				break;
			case "it":
				msg="È necessario inserire la popolazione";
				break;
			case "en":
				msg="You must enter the population";
				break;
		}
		alert(msg)
		document.frmcontacto.pobla.focus()
		return 0;
	}
	if (document.frmcontacto.cp.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir el código postal";
				break;
			case "ca":
				msg="Ha d'escriure el codi postal";
				break;
			case "it":
				msg="Devi inserire il tuo codice ZIP";
				break;
			case "en":
				msg="You must enter your ZIP code";
				break;
		}
		alert(msg)
		document.frmcontacto.cp.focus()
		return 0;
	}
	if (document.frmcontacto.prov.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir la provincia";
				break;
			case "ca":
				msg="Ha d'escriure la província";
				break;
			case "it":
				msg="È necessario scrivere la provincia";
				break;
			case "en":
				msg="You have to enter the province";
				break;
		}
		alert(msg)
		document.frmcontacto.prov.focus()
		return 0;
	}
	if (document.frmcontacto.pais.value.length==0)
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir el pais";
				break;
			case "ca":
				msg="Ha d'escriure el país";
				break;
			case "it":
				msg="Devi entrare nel paese";
				break;
			case "en":
				msg="You have to enter the country";
				break;
		}
		alert(msg)
		document.frmcontacto.pais.focus()
		return 0;
	}
	
	if (!valida_email(document.frmcontacto.mail.value))
	{
		switch(idioma)
		{
			case "es":	
				msg="Tiene que escribir una dirección de email correcta";
				break;
			case "ca":
				msg="Ha d'escriure una adreça d'email correcte";
				break;
			case "it":
				msg="Devi inserire un indirizzo email corretto";
				break;
			case "en":
				msg="You must enter a correct email address";
				break;
		}
		alert(msg)
		document.frmcontacto.mail.focus()
		return 0;
	}
	
	document.frmcontacto.submit();	
}
function valida_sector()
{
	if(document.frmcontacto.sector.selectedIndex==3)
	{
		document.frmcontacto.sectormanual.disabled=false;
		document.frmcontacto.sectormanual.style.backgroundColor="#ffffff";	
	}
	else
	{
		document.frmcontacto.sectormanual.disabled=true;
		document.frmcontacto.sectormanual.style.backgroundColor ="#cccccc";
	}
}
function valida_email(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){return (true)} else {return (false);}
}

