function ComprobarBuscar (){
	
	//comprobaciones	
	/*
	// si todos están vacios
	
	// si hay alguno vacio da igual, sólo hay que comprobar que haya algo seleccionado en alguno de los campos como mínimo*/
	
	if(document.buscar.marcas.options[document.buscar.marcas.selectedIndex].value=="selecciona" && document.buscar.tp.options[document.buscar.tp.selectedIndex].value=="selecciona" && document.buscar.cp.value==""){
		 Sexy.alert('<h1>Debes rellenar almenos uno de los campos para tu busqueda</h1>');
	      return false;
		
	} else if (document.buscar.cp.value!="" && document.buscar.cp.value.length!=5){
		
		Sexy.alert('<h1>El código postal debe contener únicamente cinco digitos</h1>');
		return false;
	  
	} else {
		document.buscar.submit();	
	}
	
	
}



function IsNumber(evt){
evt = ( evt ) ? evt : window.event;
var charCode = ( evt.which ) ? evt.which : evt.keyCode
return (charCode <= 31 || (charCode >= 48 && charCode <= 57))
}





function ComprobarNlter (){
	
  var sDir = document.newsletter.mailn.value;
  var a = sDir;
  var filter=/^[A-Za-z][A-Za-z0-9_]+.[A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
	
	if (document.newsletter.mailn.value==""){
		
		Sexy.alert('<h1>Debes introducir tu mail</h1>');
		return false;
	  
	} else if (!filter.test(a)){ 
		
	   
	   //mail valido?
	
	
         Sexy.alert('<h1>Debes introducir un correo electrónico válido</h1>');
		return false;
			  
	   
		
	}else if (document.newsletter.cpn.value==""){
		
		Sexy.alert('<h1>Debes introducir tu codigo postal</h1>');
		return false;
	  
	} else if (document.newsletter.cpn.value.length!=5){
		
		Sexy.alert('<h1>El código postal debe contener únicamente cinco digitos</h1>');
		return false;
	  
	}else {
		document.newsletter.submit();	
	}
	
}



function ComprobarNlterNo (){
	
	if (document.newsletterNo.mailno.value==""){
		
		Sexy.alert('<h1>Debes introducir tu mail</h1>');
		return false;
	  
	}else {
		document.newsletterNo.submit();	
	}
	
}


function ComprobarPromo (){
	
	 var sDir = document.promos.mailp.value;
  var a = sDir;
  var filter=/^[A-Za-z][A-Za-z0-9_]+.[A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
	
	if (document.promos.nombrep.value==""){
		
		Sexy.alert('<h1>Debes introducir tu nombre para optar a la promocion</h1>');
		return false;
	  
	} else if (document.promos.dnip.value==""){
		
		Sexy.alert('<h1>Debes introducir tu dni para optar a la promocion</h1>');
		return false;
	  
	}else if (document.promos.tlfp.value==""){
		
		Sexy.alert('<h1>Debes introducir tu telefono para optar a la promocion</h1>');
		return false;
	  
	}else if (document.promos.cpp.value==""){
		
		Sexy.alert('<h1>Debes introducir tu codigo postal para optar a la promocion</h1>');
		return false;
	  
	}else if (document.promos.mailp.value==""){
		
		Sexy.alert('<h1>Debes introducir tu mail para optar a la promocion</h1>');
		return false;
	  
	}else if (!filter.test(a)){ 
		
	   
	   //mail valido?
	
	
         Sexy.alert('<h1>Debes introducir un correo electrónico válido para optar a la promocion</h1>');
		return false;
			  
	   
		
	}else if (document.promos.fcp.value==""){
		
		Sexy.alert('<h1>Debes introducir la fecha de compra del producto para optar a la promocion</h1>');
		return false;
	  
	} else if (document.promos.ntp.value==""){
		
		Sexy.alert('<h1>Debes introducir el nombre de la tienda del producto para optar a la promocion</h1>');
		return false;
	  
	}else if (document.promos.ntckp.value==""){
		
		Sexy.alert('<h1>Debes introducir el número del ticket de la oferta para optar a la promocion</h1>');
		return false;
	  
	} else {
		document.promos.submit();	
	}
	
}



function alertNewsOk() {
  Sexy.info('<h1>Su mail ha sido añadido correctamente a nuestra Newsletter. Gracias!<h1>');
}

function alertNewsRepe() {
  Sexy.alert('<h1>Su mail ya existe en nuestra base de datos. Gracias!<h1>');
}

function alertNewsKo() {
  Sexy.alert('<h1>Ha habido algún problema al insertar tu mail en la base de datos. Vuelva a intentarlo más tarde. Si su problema persiste contacta con el administrador. Disculpe las molestias.<h1>');
}


function alertNewsBajaOk() {
  Sexy.info('<h1>Su mail ha sido eliminado correctamente de nuestra Newsletter. Gracias!<h1>');
}


function alertNewsBajaKo() {
  Sexy.alert('<h1>Ha habido algún problema al eliminar tu mail en la base de datos.<br/><br/>  Vuelva a intentarlo más tarde. <br/><br/> Si su problema persiste contacta con el administrador. <br/><br/> Disculpe las molestias.<h1>');
}


function alertNewsBajaRepe() {
  Sexy.alert('<h1>Su mail no existe en nuestra base de datos. <br/><br/>No debería estar recibiendo nuestra newsletter, almenos no con el mail introducido.<br/><br/> Si sigue recibiendo nuestra newsletter contacte con el administrador. <br/><br/> Disculpe las molestias.<h1>');
}


function alertFormAgenteOk() {
  Sexy.info('<h1>Su formulario de alta de agente/distribuidor ha sido enviado correctamente. <br/><br/>Gracias!<h1>');
}


function alertFormAgenteKo() {
  Sexy.alert('<h1>Ha habido algún problema al enviar tu formulario de alta de agente/distribuidor.<br/><br/>  Vuelva a intentarlo más tarde. <br/><br/> Si su problema persiste contacta con el administrador. <br/><br/> Disculpe las molestias.<h1>');
}



function alertFormPuntoOk() {
  Sexy.info('<h1>Su formulario de alta de punto de venta ha sido enviado correctamente. <br/><br/>Gracias!<h1>');
}


function alertFormPuntoKo() {
  Sexy.alert('<h1>Ha habido algún problema al enviar tu formulario de alta de punto de venta.<br/><br/>  Vuelva a intentarlo más tarde. <br/><br/> Si su problema persiste contacta con el administrador. <br/><br/> Disculpe las molestias.<h1>');
}


function alertFormProOk() {
  Sexy.info('<h1>Su formulario de alta de fabricantes ha sido enviado correctamente. <br/><br/>Gracias!<h1>');
}


function alertFormProKo() {
  Sexy.alert('<h1>Ha habido algún problema al enviar tu formulario de alta de fabricantes.<br/><br/>  Vuelva a intentarlo más tarde. <br/><br/> Si su problema persiste contacta con el administrador. <br/><br/> Disculpe las molestias.<h1>');
}


function alertPromoOk() {
  Sexy.info('<h1>Sus datos han sido enviados para la promocion. <br/><br/> Gracias por participar.<h1>');
}


function alertPromoKo() {
  Sexy.alert('<h1>Ha habido algún problema al enviar sus datos para la promocion.<br/><br/>  Vuelva a intentarlo más tarde. <br/><br/> Si su problema persiste contacta con el administrador. <br/><br/> Disculpe las molestias.<h1>');
}

function alertPromoImgKo() {
	
	Sexy.alert('<h1>La foto adjuntada no es correcta, sóo se permiten archivos en formato jpg, gif o png.<br/><br/>  Vuelva a intentarlo de nuevo. <br/><br/><h1>');
}

function alertPromoRepe() {
  Sexy.alert('<h1>No puede apuntarse dos veces a la promoción.<br/><br/>  Su mail ya aparece asociado a esta promocion.<h1>');
}



function comprobarCamposAgente(){
	
	if (document.alta_agente.campo1.value==""){
		
		Sexy.alert('<h1>Debe insertar el agente comercial.</h1>');
		return false;
	  
	} else if (document.alta_agente.campo2.value==""){
		
		Sexy.alert('<h1>Debe insertar el distribuidor.</h1>');
		return false;
		
	} else if (document.alta_agente.campo3.value==""){
		
		Sexy.alert('<h1>Debe insertar su número de colegiado.</h1>');
		
		return false;
		
	} else if (document.alta_agente.campo4.value==""){
		
		Sexy.alert('<h1>Debe insertar su razón social.</h1>');
		
		return false;
		
	} else if (document.alta_agente.campo5.value==""){
		
		
		Sexy.alert('<h1>Debe insertar su cif.</h1>');
		return false;
		
	} else if (document.alta_agente.campo6.value==""){
		
		
		Sexy.alert('<h1>Debe insertar el año de inicio de la actividad.</h1>');
		return false;
		
	} else if (document.alta_agente.campo7.value==""){
		
		
		Sexy.alert('<h1>Debe insertar el nombre de la persona de contacto.</h1>');
		return false;
		
	} else if (document.alta_agente.campo8.value==""){
		
		
		Sexy.alert('<h1>Debe insertar la dirección.</h1>');
		return false;
		
	} else if (document.alta_agente.campo9.value==""){
		
		
		Sexy.alert('<h1>Debe insertar el código postal.</h1>');
		return false;
		
	} else if (document.alta_agente.campo10.value==""){
		
		
		Sexy.alert('<h1>Debe insertar la ciudad.</h1>');
		return false;
		
	} else if (document.alta_agente.campo11.value==""){
		
		
		Sexy.alert('<h1>Debe insertar la provincia.</h1>');
		return false;
		
	} else if (document.alta_agente.campo12.value==""){
		
		
		Sexy.alert('<h1>Debe insertar el país.</h1>');
		return false;
		
	} else if (document.alta_agente.campo13.value==""){
		
		
		Sexy.alert('<h1>Debe insertar el teléfono.</h1>');
		return false;

		
	} else if (document.alta_agente.campo15.value==""){
		
		Sexy.alert('<h1>Debe insertar el fax.</h1>');
		return false;
		
	} else if (document.alta_agente.campo16.value==""){
		
		Sexy.alert('<h1>Debe insertar su email.</h1>');
		return false;
		
	} else if (document.alta_agente.campo17.value==""){
		
		Sexy.alert('<h1>Debe insertar su web.</h1>');
		return false;
		
	} else if (document.alta_agente.campo18.value=="" || document.alta_agente.campo19.value=="" || document.alta_agente.campo20.value=="" || document.alta_agente.campo21.value==""){
		
		
		Sexy.alert('<h1>Debe especificar su sistema de trabajo.</h1>');
		return false;
		
	} else {
		
		return true;
	}
	
	
}



function comprobarCamposPunto(){
	
	if (document.alta_puntoVenta.Razon_Social.value==""){
		
		Sexy.alert('<h1>Debe indicar la razon social del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Nombre_del_establecimiento.value==""){
		
		Sexy.alert('<h1>Debe insertar el nombre del establecimiento del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Tipo_de_establecimiento[0].checked==false && document.alta_puntoVenta.Tipo_de_establecimiento[1].checked==false && document.alta_puntoVenta.cTipo_de_establecimiento[2].checked==false && document.alta_puntoVenta.Tipo_de_establecimiento[3].checked==false){
		
		Sexy.alert('<h1>Debe indicar el tipo de establecimiento del punto de venta.</h1>');
		return false;
		
		
	}if (document.alta_puntoVenta.CIF.value==""){
		
		Sexy.alert('<h1>Debe indicar el CIF del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Anyo_Fundación_1a_tienda.value==""){
		
		Sexy.alert('<h1>Debe indicar el año de fundacion de la primera tienda.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.m2totales.value==""){
		
		Sexy.alert('<h1>Debe indicar los metros cuadrados totales del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Persona_de_contacto.value==""){
		
		Sexy.alert('<h1>Debe indicar el nombre de la persona de contacto.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Direccion.value==""){
		
		Sexy.alert('<h1>Debe indicar la dirección del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Codigo_Postal.value==""){
		
		Sexy.alert('<h1>Debe indicar el código postal del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Ciudad.value==""){
		
		SSexy.alert('<h1>Debe indicar la ciudad del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Provincia.value==""){
		
		Sexy.alert('<h1>Debe indicar la provincia del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Pais.value==""){
		
		Sexy.alert('<h1>Debe indicar el pais del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Telefono.value==""){
		
		Sexy.alert('<h1>Debe indicar el telefono del punto de venta.</h1>');
		return false;
		
	}if (document.alta_puntoVenta.Fax.value==""){
		
		Sexy.alert('<h1>Debe indicar el fax del punto de venta.</h1>');
		return false;
		
	} if (document.alta_puntoVenta.E_mail.value==""){
		
		Sexy.alert('<h1>Debe indicar el email del punto de venta.</h1>');
		
		Sexy.alert('<h1>Debe indicar si el punto de venta esta informatizado o no.</h1>');
		return false;
		
	} if (document.alta_puntoVenta.Punto_de_venta_informatizado[0].checked==false && document.alta_puntoVenta.Punto_de_venta_informatizado[1].checked==false){
		
		Sexy.alert('<h1>Debe indicar si el punto de venta esta informatizado o no.</h1>');
		return false;
		
	} else {
		
		return true;
	}
	
	
	
}



function comprobarCamposProf(){
	
	if (document.alta_puntoProf.Nombre_contacto.value==""){
		
		Sexy.alert('<h1>Debe indicar el nombre de contacto de la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.Nombre_empresa.value==""){
		
		Sexy.alert('<h1>Debe indicar el nombre de la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.CIF.value==""){
		
		Sexy.alert('<h1>Debe indicar el CIF de la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.Direccion.value==""){
		
		Sexy.alert('<h1>Debe indicar la dirección de la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.Codigo_Postal.value==""){
		
		Sexy.alert('<h1>Debe indicar el código postal de la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.poblacion.value==""){
		
		Sexy.alert('<h1>Debe indicar la población donde se encuentra la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.Provincia.value==""){
		
		Sexy.alert('<h1>Debe indicar la provincia donde se encuentra la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.email.value==""){
		
		Sexy.alert('<h1>Debe indicar el email de contacto en la empresa.</h1>');
		return false;
		
	}if (document.alta_puntoProf.Telefono.value==""){
		
		Sexy.alert('<h1>Debe indicar el telefono de contacto de la empresa.</h1>');
		return false;
		
	} else {
		
		return true;
	}
	
	
	
}




