function desplegaMenu(mostra) {
var e = document.getElementById("fons_interman");
if (mostra == true) {
e.className = "menu_obert";
}
else {
e.className = "menu_tancat";	
}
}


function desplegaMenu_02(mostra) {
var e = document.getElementById("fons_interman_02");
if (mostra == true) {
e.className = "menu_obert_02";
}
else {
e.className = "menu_tancat_02";	
}
}


function desplegaMenu_03(mostra) {
var e = document.getElementById("fons_interman_03");
if (mostra == true) {
e.className = "menu_obert_03";
}
else {
e.className = "menu_tancat_03";	
}
}

function desplegaMenu_04(mostra) {
var e = document.getElementById("fons_interman_04");
if (mostra == true) {
e.className = "menu_obert_04";
}
else {
e.className = "menu_tancat_04";	
}
}

function popup(url,windowname,width,height,scrollbars,features) {
	width=(width)?width:screen.width/2;
	height=(height)?height:screen.height/2;
	scrollbars=(scrollbars)?scrollbars:'no';
	var screenX = (screen.width/2 - width/2);
	var screenY = (screen.height/2 - height/2);
	var features= "width=" + width + ",height=" + height +",scrollbars=" + scrollbars + ",status=no";
	features += ",screenX=" + screenX + ",left=" + screenX;
	features += ",screenY=" + screenY + ",top=" + screenY;
	
	var mywin=window.open(url, windowname, features);
	if (mywin)
	mywin.focus();
	return mywin;
}

function confirmaEliminar(missatge,adreca){
var m = window.confirm(missatge)
	if (m==true){
	window.location = adreca
	}
}

function confirmaEliminar_submit(missatge,form){
var m = window.confirm(missatge)
	if (m==true){
	document.getElementById(form).submit();
	}
}
function comprova(){
	
	nom = document.getElementById("w_nombre").value;
	telf = document.getElementById("w_telefono").value;
	email = document.getElementById("w_email").value;
	nombre_empresa = document.getElementById("w_nombre_empresa").value;
	codi = document.getElementById("codi").value;
	
	var mailres = true;            
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
    
    var arroba = email.indexOf("@",0);
    if ((email.lastIndexOf("@")) != arroba) arroba = -1;
    
    var punto = email.lastIndexOf(".");
                
		for (var contador = 0 ; contador < email.length ; contador++){
			if (cadena.indexOf(email.substr(contador, 1),0) == -1){
				mailres = false;
				break;
		}
    }
	
	

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (email.length)) && (mailres == true) && (email.indexOf("..",0) == -1))
    mailres = true;
    else
    mailres = false; 
	 
	 
	
	if (nom!="" && telf!="" && email!="" && codi!="" && nombre_empresa!="" && mailres==true){		
		document.frm_ok.submit();	
	}else{
		
		if (mailres == false){
		alert("Error en el E-mail");	
		}else{		
		alert("Los campos marcados con un * son obligatorios");
		}
		
		return false;
	}	
}
function mostra(id){
		
		
	if (id==1){
		
		
		document.getElementById("div_metros").style.display="";		
	}else{
		document.getElementById("div_metros").style.display="none";	
	}
}


function comprova2(){
	
	apellidos = document.getElementById("apellidos").value;
	nombre = document.getElementById("nombre").value;
	email = document.getElementById("email").value;
	empresa = document.getElementById("empresa").value;
	
	nif = document.getElementById("nif").value;
	pais = document.getElementById("pais").value;
	provincia = document.getElementById("provincia").value;
	ciudad = document.getElementById("ciudad").value;
	cp = document.getElementById("cp").value;
	telefono = document.getElementById("telefono").value;
		
		
	
	var mailres = true;            
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
    
    var arroba = email.indexOf("@",0);
    if ((email.lastIndexOf("@")) != arroba) arroba = -1;
    
    var punto = email.lastIndexOf(".");
                
		for (var contador = 0 ; contador < email.length ; contador++){
			if (cadena.indexOf(email.substr(contador, 1),0) == -1){
				mailres = false;
				break;
		}
    }
	
	

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (email.length)) && (mailres == true) && (email.indexOf("..",0) == -1))
    mailres = true;
    else
    mailres = false; 
	 
	 
	
	apellidos = document.getElementById("apellidos").value;
	nombre = document.getElementById("nombre").value;
	email = document.getElementById("email").value;
	empresa = document.getElementById("empresa").value;
	
	nif = document.getElementById("nif").value;
	pais = document.getElementById("pais").value;
	provincia = document.getElementById("provincia").value;
	ciudad = document.getElementById("ciudad").value;
	cp = document.getElementById("cp").value;
	telefono = document.getElementById("telefono").value;
	
	if (apellidos!="" && nombre!="" &&  email!="" &&  empresa!="" && mailres==true &&  nif!="" &&  pais!="" &&  provincia!="" &&  ciudad!="" &&  cp!="" &&  telefono!=""){		
		document.frm_presupuesto.submit();	
	}else{
		
		if (mailres == false){
		alert("Error en el E-mail");	
		}else{		
		alert("Los campos marcados con un * son obligatorios");
		}
		
		return false;
	}	
}
function comprova3(){
	
	apellidos = document.getElementById("apellidos").value;
	nombre = document.getElementById("nombre").value;
	email = document.getElementById("email").value;
	empresa = document.getElementById("empresa").value;
	
	nif = document.getElementById("nif").value;
	pais = document.getElementById("pais").value;
	provincia = document.getElementById("provincia").value;
	ciudad = document.getElementById("ciudad").value;
	cp = document.getElementById("cp").value;
	telefono = document.getElementById("telefono").value;
	acreditaciones = document.getElementById("acreditaciones").value;
	
	
	
		
	if (email!=""){
		var mailres = true;            
		var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
		
		var arroba = email.indexOf("@",0);
		if ((email.lastIndexOf("@")) != arroba) arroba = -1;
		
		var punto = email.lastIndexOf(".");
					
			for (var contador = 0 ; contador < email.length ; contador++){
				if (cadena.indexOf(email.substr(contador, 1),0) == -1){
					mailres = false;
					break;
			}
		}
		if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (email.length)) && (mailres == true) && (email.indexOf("..",0) == -1))
		mailres = true;
		else
		mailres = false; 
	}else{
		mailres =true	
	}
	 
	 
	 if (acreditaciones!="" && apellidos!="" && nombre!="" &&  empresa!="" && mailres==true &&  nif!="" &&  pais!="" &&  provincia!="" &&  ciudad!="" &&  cp!="" &&  telefono!=""){		
		document.frm_presupuesto.submit();	
	}else{
		
		if (mailres == false){
		alert("Error en el E-mail");	
		}else{		
		alert("Los campos marcados con un * son obligatorios");
		}
		
		return false;
	}	
}
function comprova4(){
	
	empleados1 = document.getElementById("empleados1").checked;
	empleados2 = document.getElementById("empleados2").checked;
	empleados3 = document.getElementById("empleados3").checked;
	empleados4 = document.getElementById("empleados4").checked;
	empleados5 = document.getElementById("empleados5").checked;
		
	cargo1 = document.getElementById("cargo1").checked;
	cargo2 = document.getElementById("cargo2").checked;
	cargo3 = document.getElementById("cargo3").checked;
	cargo4 = document.getElementById("cargo4").checked;
	cargo5 = document.getElementById("cargo5").checked;
	cargo6 = document.getElementById("cargo6").checked;
	cargo7 = document.getElementById("cargo7").checked;
	cargo8 = document.getElementById("cargo8").checked;
	cargo9 = document.getElementById("cargo9").checked;
	
	conocio1 = document.getElementById("conocio1").checked;
	conocio2 = document.getElementById("conocio2").checked;
	conocio3 = document.getElementById("conocio3").checked;
	conocio4 = document.getElementById("conocio4").checked;
	conocio5 = document.getElementById("conocio5").checked;
	
	 
	if (empleados1==true || empleados2==true || empleados3==true || empleados4==true || empleados5==true){
		enviar_1 = 1
	}else{ enviar_1 = 0 }
	if (cargo1==true || cargo2==true || cargo3==true || cargo4==true || cargo5==true || cargo6==true || cargo7==true || cargo8==true || cargo9==true){
		enviar_2 = 1
	}else{ enviar_2 = 0 }
	if (conocio1==true || conocio2==true || conocio3==true || conocio4==true || conocio5==true){
		enviar_3 = 1
	}else{ enviar_3 = 0 }
	
	
	if (enviar_1==1 && enviar_2==1 && enviar_3==1){		
		document.frm_presupuesto.submit();
	}else{
		alert("Los campos marcados con un * son obligatorios");
		return false;
	}
}

