

//var ok=true,tmp="",fetmail=true;

function validar() // funcion para validar si el usuario a introducio todos los datos del formulario mail.
{
var ok=true,tmp="",fetmail=true;
var i;
		var car;
		var punt=0;
		var aroba=0;
		var space=0;
		var p=0;
		var a=0;
	if (form1.nombre.value=="")
	{
		form1.nombre.style.background="red";
		ok=false;
	}
	else
	{
		form1.nombre.style.background="white";
		
	}
	if (form1.apellidos.value=="")
	{
		form1.apellidos.style.background="red";
		ok=false;
	}
	else
	{
		form1.apellidos.style.background="white";
		
	}
	if (form1.msg.value=="")
	{
		ok=false;
		form1.msg.style.background="red";
	}
	else
	{
	form1.msg.style.background="white";
	
	}
//inicio mail-----
//validacion mail
	
														for(i=0;i<form1.mail.value.length;i++)
														{
															car=form1.mail.value.charAt(i);
															if(car=='@')
															{
																aroba=aroba+1;
															}
															if(car=='.')
															{
																punt=punt+1;
															}
															if(car==" ")
															{
																space=space+1;
															}
														}
														if(form1.mail.value=="")
														{
															form1.mail.style.background="red";
															/*alert("Omple el camp del e-mail");
															form1.mail.focus();
															*/
															fetmail=false;
														}
														else
														{
															//--sacar en que posicion se encuentra la '@' y el '.'
															a=form1.mail.value.indexOf('@');
															p=form1.mail.value.indexOf('.');
															//--si no tiene '@' o '.' o tienes mas de una '@' o '.' o el '.' esta delante de la '@', el e-mail será incorrecto
															if(((aroba==0)||(aroba>1)) || ((punt==0)||(punt>1))||(p<a)||(space>0))
															{
																form1.mail.style.background="red";
																/*alert("Omple CORRECTAMENT el camp del e-mail");
																*/form1.mail.focus();
																
																fetmail=false;
															}
															else
															{
																/*--Si la posición de la '@' o '.' es la primera, o si la '@' y el '.' estan juntos o si la posicion del '.' es la ultima
																	el e-mail será incorrecto*/ 
																if(((a==0)||(p==0))||(a+1==p)||(p==form1.mail.value.length-1))
																{
																	form1.mail.style.background="red";
																	/*
																	alert("Omple CORRECTAMENT el camp del e-mail");
																	form1.mail.focus();
																	*/
																	fetmail=false;
																}
																else
																{
																	form1.mail.style.background="white";
																	
																}
															}
														}
													

//fin mail----	
if ((ok==true) && (fetmail==true))
	{
	//alert("fetmail="+fetmail);
	return true;
	}
	else
	{
	//alert("false");
	return false;
	
	}
}//fin funcion



function popup (id)
{ 
   window.open("ofertas/oferta.php?ofert_id="+id,"ventana1","width=530,height=178,scrollbars=NO") 
} 
function ver_imagen(fitx_imagen)
{
window.open("../ofertas/img_ofertas/"+fitx_imagen,"ventana2","width=530,height=178,scrollbars=NO") 
}
function mostrar(id,accion) // parametros accion: 'hidden' o 'visible' referencia en: pag de selecion de prespuestos
{
document.getElementById(id).style.visibility =accion;
}


function duplicar(variable,valor)
{

}

function mostrar_tbl_modo(modo)
{
	if (modo=='ficha')
	{
		document.getElementById('tbl_enlace').style.display ='none';
		document.getElementById('tbl_ficha').style.display ='block';
	}
	else
	{
		document.getElementById('tbl_ficha').style.display ='none';
		document.getElementById('tbl_enlace').style.display ='block';
	}
}


function marcar_menu_1(opt)
{

	//alert(opt);


if (opt=="")
	{
		
				
				document.getElementById('inicio').className="mactivo";
			
	}
	
	else 
	{
		switch (opt) {
   			case 0:
       		
				
				document.getElementById('inicio').className="mactivo";
				
   	   		
	         break;
			 case 1:
       		
				
				document.getElementById('servicios').className="mactivo";
				
   	   		
	         break;
			 case 2:
       		
				
				document.getElementById('contacto').className="mactivo";
			
	         break;
			 case 3:
       	
				document.getElementById('tienda').className="mactivo";
			
	         break;
			 case 4:
       		
				document.getElementById('presupuestos').className="mactivo";
			
	         break;
			 case 5:
       		
				document.getElementById('aprofesional').className="mactivo";
				
	         break;
			 

		}
	}

}

