function menuPrincipal(elemento){
	if (elemento != ""){
			document.getElementById(elemento).style.color="#FFAF20";
	}
	else{
			//document.getElementById('inicio').style.color="#FFAF20";	
	}
	
}

function menuSecundario(elemento){
			document.getElementById(elemento).style.color="#FFAF20";
}

function esLetra(miparam) {
	var cadena = document.getElementById(miparam).value;
	if(cadena.search(/[^a-zA-Z\s]/) != -1){
		return false;
	}
	else{
		return true;
	}
}

function validarNoticia(id){
	if(document.getElementById('titulo').value == ""){
		alert("Por favor, introduzca el título de la noticia.");
		document.getElementById('titulo').focus();
	}
	else if(document.getElementById('contenido').value == ""){
		alert("Por favor, introduzca el contenido de la noticia.");
		document.getElementById('contenido').focus();
	}
	else if(document.getElementById('link').value == ""){
		alert("Por favor, introduzca el link de la noticia.");
		document.getElementById('link').focus();
	}
	else{
		document.formulario.action = "/webnovedades07/gestor/editar.asp?seccion=noticia&id=" + id;
		document.formulario.submit();	
	}
}
function validarCampania(id){
	
	if(document.getElementById('titulo').value == ""){
		alert("Por favor, introduzca el título de la campaña.");
		document.getElementById('titulo').focus();
	}
	else if(document.getElementById('contenido').value == ""){
		alert("Por favor, introduzca el contenido de la campaña.");
		document.getElementById('contenido').focus();
	}
	else if(document.formulario.restringida[0].checked == true && document.getElementById('pdf').value == ""){
		alert("Por favor, introduzca un pdf para la campaña restringida.");
		document.getElementById('pdf').focus();
	}
	else{
		document.formulario.action = "/webnovedades07/gestor/editar.asp?seccion=campana&id=" + id;
		document.formulario.submit();	
	}
}

function verImagenes(id){
		document.formulario.action = "/webnovedades07/gestor/editarCampania.asp?id=" + id;
		document.formulario.submit();	
}

function verImagenPortada(){
		document.formulario.action = "/webnovedades07/gestor/imagenNoticias.asp";
		document.formulario.submit();	
}

function validarTienda(){
	
		/*User names format rules:
		1 - Minimum length: 8 digits
		
		3 - Cannot contain any of following digits:  @ / , ' = \" ( ) # + < > ;
		4 - Connot contain spaces
		
		Password format rules:
		1 - Minimum length: 8 digits
		2 - Cannot be equal to username
		3 - Cannot contain following digits: ( ) { }*/
		
		var username = document.getElementById('username');
		var password = document.getElementById('password');

		
		if(username.value == ""){
			alert("Por favor, introduzca un usuario.");
			username.focus();
		}
		else if(username.value.length < 8){
			alert("Por favor, el usuario debe contener un mínimo de 8 dígitos.");
			username.focus();
		}
		else if((/^\w+([\.-]?\w+)+$/.test(username.value) != true)){
			alert("Por favor, el usuario no debe contener caracteres extraños.");
			username.focus();
		}
		else if(username.value == password.value){
			alert("Por favor, el usuario y la contraseña no pueden ser iguales.");
			password.focus();
		}
		else if(password.value == ""){
			alert("Por favor, introduzca una contraseña.");
			password.focus();
		}
		else if(password.value.length < 8){
			alert("Por favor, la contraseña debe contener un mínimo de 8 dígitos.");
			password.focus();
		}
		else if((/^\w+([\.-]?\w+)+$/.test(password.value) != true)){
			alert("Por favor, la contraseña no debe contener caracteres extraños.");
			password.focus();
		}
		else{
			document.formulario.action = "http://cmp.computergross.it/portal/login.do?j_username=" + username.value + "&j_password=" + password.value;
			document.formulario.submit();	
		}
}

