var ERROR_OBLIGA = "ERROR! Debe RELLENAR los Campos OBLIGATORIOS";
var ERROR_NECESI = "ERROR! Debe ELEGIR una Opcion";
var ERROR_NOMBRE = "ERROR! Debe RELLENAR el Campo 'Nombre y Apellidos'";
var ERROR_CORREO = "ERROR! Debe RELLENAR el Campo 'E-Mail'";
var ERROR_COR_IN = "ERROR! El 'E-Mail' introducido ES INCORRECTO";
var ERROR_COMENT = "ERROR! Debe RELLENAR el Campo 'Motivo de la Consulta'";
var ERROR_PRIVAC = "ERROR! Debe ACEPTAR la POLITICA de PROTECCION de DATOS";
var ERROR_SERVIC = "ERROR! Debe ELEGIR un 'Tipo de Servicio a Contratar'";
var ERROR_EMPRES = "ERROR! Debe RELLENAR el Campo 'Nombre de la Empresa'";
var ERROR_CIF_EM = "ERROR! Debe RELLENAR el Campo 'CIF/NIF'";
var ERROR_TELFNO = "ERROR! Debe RELLENAR el Campo 'Telefono'";
var ERROR_CONTAC = "ERROR! Debe RELLENAR el Campo 'Nombre del Contacto'";
var ERROR_FORMAP = "ERROR! Debe ELEGIR una 'Forma de Pago'";
var ERROR_NOM_DO = "ERROR! Debe RELLENAR el Campo 'Nombre del Dominio'";
var ERROR_SIT_DO = "ERROR! Debe RELLENAR el Campo 'Situacion del Dominio'";
var ERROR_INI_DO = "ERROR! Debe ELEGIR si QUIERE o NO QUIERE 'Iniciar los Tramites para el Registros de su Dominio'";
var ERROR_PASSWO = "ERROR! Las 'ContraseÃ±as' NO COINCIDEN'";

function Numeros(e)
{
	var tecla = (document.all) ? e.keyCode : e.which;
	
    if (tecla==8 || tecla == 0) return true; //Tecla de retroceso (para poder borrar) y Tecla Tabulación y Suprimir (0)
    patron = /\d/; //Solo acepta números
    var te = String.fromCharCode(tecla);
    
	return patron.test(te);
}

function Letras(e)
{
	var tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8 || tecla == 0) return true; //Tecla de retroceso (para poder borrar) y Tecla Tabulación y Suprimir (0)
   
    var patron =/[A-Za-z ]/; // Solo acepta letras
   
    var te = String.fromCharCode(tecla);
    return patron.test(te);  
}

function Comprueba_Sus(frmSuscrip)
{
	var nombre = document.frmSuscrip.nombre.value;
	var empres = document.frmSuscrip.empresa.value;
	var telfno = document.frmSuscrip.tlfno.value;
	var movil = document.frmSuscrip.movil.value;
	var email = document.frmSuscrip.email.value;
	var subven = document.frmSuscrip.tipo_sub.value;
	//var resp = document.frmSuscrip.respuesta.value;
	var marcado = document.frmSuscrip.proteccion_datos.checked;
	
	if (nombre == "" && email == "" && subven == "")
	{
		alert("Debe RELLENAR todos los CAMPOS");
		document.frmSuscrip.nombre.focus();
		return false;
	}
	else if (nombre == "")
	{
		alert("Debe RELLENAR el campo 'Nombre y Apellidos'");
		document.frmSuscrip.nombre.focus();
		return false;
	}
	else if (nombre.search(/^[A-Z ]+$/i) == -1)
	{
		alert("El campo 'Nombre y Apellidos' NO puede CONTENER Caracteres Especiales(tildes, ñ..) ni Numeros");
		document.frmSuscrip.nombre.focus();
		return false;
	}
	else if (email == "")
	{
		alert("Debe RELLENAR el campo 'Email'");
		document.frmSuscrip.email.focus();
		return false;
	}
	else if (!(email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
	{
		alert("El 'Email' introducido es INCORRECTO. Debe tener el siguiente formato:\n miemail@loquesea.com");
		document.frmSuscrip.email.focus();
		return false;
	}
	else if (subven == "")
	{
		alert("Debe ELEGIR un 'Tipo de SubvenciÃ³n'");
		document.frmSuscrip.tipo_sub.focus();
		return false;
	}
	/*else if (resp == "")
	{
		alert("Debe ESCRIBIR la RESPUESTA de la Operacion para Verificar\nque es una Persona quien escribe el Formulario");
		document.frmSuscrip.respuesta.focus();
		return false;
	}
	else if (resp != 20)
	{
		alert("ERROR! Esa no es la Respuesta correcta");
		document.frmSuscrip.respuesta.focus();
		return false;
	}*/
	else if (!marcado)
	{
		alert("Debe ACEPTAR la PolÃ­tica de ProtecciÃ³n de Datos para continuar");
		document.frmSuscrip.proteccion_datos.focus();
		return false;
	}
	else return true;
}

function Comprueba_Baja(frmBaja)
{
	var nom = document.frmBaja.nom.value;
	var cod = document.frmBaja.codigo.value;
	var sub = document.frmBaja.tipo_sub.value;
	
	if (nom == "" && cod == "" && sub == "")
	{
		alert("Debe RELLENAR todos los CAMPOS");
		document.frmBaja.nom.focus();
		return false;
	}
	else if (nom == "")
	{
		alert("Debe RELLENAR el campo 'Nombre y Apellidos'");
		document.frmBaja.nom.focus();
		return false;
	}
	else if (cod == "")
	{
		alert("Debe RELLENAR el campo 'Codigo de Suscripcion'");
		document.frmBaja.codigo.focus();
		return false;
	}
	else if (sub == "")
	{
		alert("Debe ELEGIR la Subvencion a la que te quieres Dar de Baja");
		document.frmBaja.tipo_sub.focus();
		return false;
	}
	else return true;
}

function Act_Nom()
{
	document.getElementById('nom').style.backgroundColor = '#FFFFFF';
	document.getElementById('lbnom').style.fontWeight = "bold";
	document.getElementById('lbnom').style.color = "#34376A";
}

function Des_Nom()
{
	document.getElementById('nom').style.backgroundColor = '#DFDFDF';
	document.getElementById('lbnom').style.fontWeight = "normal";
	document.getElementById('lbnom').style.color = "#000000";
}

function Act_Cod()
{
	document.getElementById('codigo').style.backgroundColor = '#FFFFFF';
	document.getElementById('lbcod').style.fontWeight = "bold";
	document.getElementById('lbcod').style.color = "#34376A";
}

function Des_Cod()
{
	document.getElementById('codigo').style.backgroundColor = '#DFDFDF';
	document.getElementById('lbcod').style.fontWeight = "normal";
	document.getElementById('lbcod').style.color = "#000000";
}

function Act_Sub()
{
	document.getElementById('lbbaj').style.fontWeight = "bold";
	document.getElementById('lbbaj').style.color = "#34376A";
}

function Des_Sub()
{
	document.getElementById('lbbaj').style.fontWeight = "normal";
	document.getElementById('lbbaj').style.color = "#000000";
}

function Mover()
{
	jQuery(".scroll_not").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		vertical: true,
		visible: 3,
		auto: 3000,
		speed: 1000
	});
}

function Valida_Form_Contacto(Formulario_ayuda)
{
	var necest = document.Formulario_ayuda.Tipo_consulta.value;
	var nombre = document.Formulario_ayuda.nombre.value;
	var correo = document.Formulario_ayuda.email.value;
	var descri = document.Formulario_ayuda.detalles.value;
	var acepto = document.Formulario_ayuda.proteccion_datos.checked;
	
	if (necest == "" && nombre == "" && correo == "" && (descri == "" || descri == "Escriba aqui su texto.") && !acepto)
	{
		alert(ERROR_OBLIGA);
		document.Formulario_ayuda.Tipo_consulta.focus();
		return false;
	}
	else if (necest == "")
	{
		alert(ERROR_NECESI);
		document.Formulario_ayuda.Tipo_consulta.focus();
		return false;
	}
	else if (nombre == "")
	{
		alert(ERROR_NOMBRE);
		document.Formulario_ayuda.nombre.focus();
		return false;
	}
	else if (correo == "")
	{
		alert(ERROR_CORREO);
		document.Formulario_ayuda.email.focus();
		return false;
	}
	else if (!(correo.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
	{
		alert(ERROR_COR_IN);
		document.Formulario_ayuda.email.focus();
		return false;
	}
	else if (descri == "" || descri == "Escriba aqui su texto.")
	{
		alert(ERROR_COMENT);
		document.Formulario_ayuda.detalles.focus();
		return false;
	}
	else if (!acepto)
	{
		alert(ERROR_PRIVAC);
		document.Formulario_ayuda.proteccion_datos.focus();
		return false;
	}
	else return true;
}

function Valida_Form_Contratar_Planes(Contratar)
{
	var servicio = document.Contratar.tipo_servicio.value;
	var empresa = document.Contratar.empresa.value;
	var cif = document.Contratar.CIF.value;
	var telf = document.Contratar.telefono.value;
	var email = document.Contratar.email.value;
	var contacto = document.Contratar.contacto.value;
	var conocido = document.Contratar.conocer.value;
	var acepto = document.Contratar.condiciones.checked;
	
	if (servicio == "" && empresa == "" && cif == "" && telf == "" && email == "" && contacto == "" && conocido == "" && !acepto)
	{
		alert(ERROR_OBLIGA);
		document.Contratar.tipo_servicio.focus();
		return false;
	}
	else if (servicio == "")
	{
		alert(ERROR_SERVIC);
		document.Contratar.tipo_servicio.focus();
		return false;
	}
	else if (empresa == "")
	{
		alert(ERROR_EMPRES);
		document.Contratar.empresa.focus();
		return false;
	}
	else if (cif == "")
	{
		alert(ERROR_CIF_EM);
		document.Contratar.CIF.focus();
		return false;
	}
	else if (telf == "")
	{
		alert(ERROR_TELFNO);
		document.Contratar.telefono.focus();
		return false;
	}
	else if (email == "")
	{
		alert(ERROR_CORREO);
		document.Contratar.email.focus();
		return false;
	}
	else if (!(email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
	{
		alert(ERROR_COR_IN);
		document.Contratar.email.focus();
		return false;
	}
	else if (contacto == "")
	{
		alert(ERROR_CONTAC);
		document.Contratar.contacto.focus();
		return false;
	}
	else if (conocido == "")
	{
		alert(ERROR_NECESI);
		document.Contratar.conocer.focus();
		return false;
	}
	else if (!acepto)
	{
		alert(ERROR_PRIVAC);
		document.Contratar.condiciones.focus();
		return false;
	}
	else return true;
}

function Valida_Form_Contratar_Aloj(Contratar_Aloj)
{
	var servicio = document.Contratar_Aloj.tipo_servicio.value;
	var form_pag = document.Contratar_Aloj.forma_pago.value;
	var nom_empr = document.Contratar_Aloj.empresa.value;
	var cif_empr = document.Contratar_Aloj.CIF.value;
	var telefono = document.Contratar_Aloj.telefono.value;
	var cor_elec = document.Contratar_Aloj.email.value;
	var contacto = document.Contratar_Aloj.contacto.value;
	var nom_domi = document.Contratar_Aloj.dominio.value;
	var sit_domi = document.Contratar_Aloj.situacion_dominio.value;
	var ini_domi = document.Contratar_Aloj.inicio_tramites.value;
	var password = document.Contratar_Aloj.pass.value;
	var rep_pass = document.Contratar_Aloj.comprueba_pass.value;
	var conocido = document.Contratar_Aloj.conocer.value;
	var acep_con = document.Contratar_Aloj.condiciones.checked;
	
	if (servicio == "" && form_pag == "" && nom_empr == "" && cif_empr == "" && telefono == "" && cor_elec == "" && contacto == "" && nom_domi == "" && sit_domi == "" && ini_domi == "" && conocido == "" && !acep_con)
	{
		alert(ERROR_OBLIGA);
		document.Contratar_Aloj.tipo_servicio.focus();
		return false;
	}
	else if (servicio == "")
	{
		alert(ERROR_SERVIC);
		document.Contratar_Aloj.tipo_servicio.focus();
		return false;
	}
	else if (form_pag == "")
	{
		alert(ERROR_FORMAP);
		document.Contratar_Aloj.forma_pago.focus();
		return false;
	}
	else if (nom_empr == "")
	{
		alert(ERROR_EMPRES);
		document.Contratar_Aloj.empresa.focus();
		return false;
	}
	else if (cif_empr == "")
	{
		alert(ERROR_CIF_EM);
		document.Contratar_Aloj.CIF.focus();
		return false;
	}
	else if (telefono == "")
	{
		alert(ERROR_TELFNO);
		document.Contratar_Aloj.telefono.focus();
		return false;
	}
	else if (cor_elec == "")
	{
		alert(ERROR_CORREO);
		document.Contratar_Aloj.email.focus();
		return false;
	}
	else if (!(cor_elec.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
	{
		alert(ERROR_COR_IN);
		document.Contratar_Aloj.email.focus();
		return false;
	}
	else if (contacto == "")
	{
		alert(ERROR_CONTAC);
		document.Contratar_Aloj.contacto.focus();
		return false;
	}
	else if (nom_domi == "")
	{
		alert(ERROR_NOM_DO);
		document.Contratar_Aloj.dominio.focus();
		return false;
	}
	else if (sit_domi == "")
	{
		alert(ERROR_SIT_DO);
		document.Contratar_Aloj.situacion_dominio.focus();
		return false;
	}
	else if (ini_domi == "")
	{
		alert(ERROR_INI_DO);
		document.Contratar_Aloj.inicio_tramites.focus();
		return false;
	}
	else if (password != "" || rep_pass != "")
	{
		if (password != rep_pass)
		{
			alert(ERROR_PASSWO);
			document.Contratar_Aloj.pass.focus();
			return false;
		}
	}
	if (conocido == "")
	{
		alert(ERROR_NECESI);
		document.Contratar_Aloj.conocer.focus();
		return false;
	}
	else if (!acep_con)
	{
		alert(ERROR_PRIVAC);
		document.Contratar_Aloj.condiciones.focus();
		return false;
	}
	else return true;
}