// JavaScript Document
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function valida() {
		if (document.registrousuario.txtusername.value == "") {
				alert("Debe indicar el nombre de la cuenta")
				document.registrousuario.txtusername.focus()
				document.getElementById('txtusername').style.background="#FFF0F0"
				return false;
			}
		else if (document.registrousuario.textnombre.value == "") {
				alert("Debe indicar un nombre")
				document.registrousuario.textnombre.focus()
				document.getElementById('textnombre').style.background="#FFF0F0"
				return false;
			}
		else if (document.registrousuario.textapellido.value == "") {
				alert("Debe indicar un apellido")
				document.registrousuario.textapellido.focus()
				document.getElementById('textapellido').style.background="#FFF0F0"
				return false;
			}
		else if ((document.registrousuario.textsexo[0].checked == "") && (document.registrousuario.textsexo[1].checked == "")) {
				document.registrousuario.textsexo[0].focus()
				document.registrousuario.textsexo[0].style.background="#FFF0F0"
				alert("Debe indicar el sexo")
				return false;
			}
		else if (document.registrousuario.textmail.value == "" || (document.registrousuario.textmail.value.indexOf('@', 0) == -1) || (document.registrousuario.textmail.value.indexOf('.', 0) == -1)) {
				alert("Debe indicar un correo electronico valido")
				document.registrousuario.textmail.focus()
				document.getElementById('textmail').style.background="#FFF0F0"
				return false;
			}
		else if (document.registrousuario.textdir.value == "") {
				alert("Debe indicar una direccion")
				document.registrousuario.texttel.focus()
				document.getElementById('texttel').style.background="#FFF0F0"
				return false;
			}
		else if (document.registrousuario.texttel.value == "") {
				alert("Debe indicar un numero de telefono")
				document.registrousuario.texttel.focus()
				document.getElementById('texttel').style.background="#FFF0F0"
				return false;
			}
		else if (document.registrousuario.textpass.value == "") {
				alert("Debe indicar una contraseña")
				document.registrousuario.textpass.focus()
				document.getElementById('textpass').style.background="#FFF0F0"
				return false;
			}
		else if (document.registrousuario.textrepass.value == "") {
				alert("Debe indicar repetir la contraseña")
				document.registrousuario.textrepass.focus()
				document.getElementById('textrepass').style.background="#FFF0F0"
				return false;
			}
		else if (document.registrousuario.textpass.value != document.registrousuario.textrepass.value) {
				alert("La contraseña no coincide")
				document.registrousuario.textpass.focus()
				document.getElementById('textpass').style.background="#FFF0F0"
				return false;
		}
		else {
			document.getElementById('registrousuario').submit();
		}
}

function validanumero(object)
{
numero = object.value;
if (!/^([0-9])*$/.test(numero))
object.value = numero.substring(0,numero.length-1);
}

function cambiafondo() 
{ 
document.registrousuario.textnombre.style.background = '#000'; 
} 

function buscarnoticia() {
		if ((document.buscar.buscatitulo.value == "") && (document.buscar.desde.value == "") && (document.buscar.hasta.value == "")) {
			alert("Debe indicar al menos un parametro de busqueda")
			document.buscar.buscatitulo.focus()
			return false;
		}
		else {
			document.buscar.submit();
		}
}
function buscar() {
		if ((document.fbuscar.buscatitulo.value == "") && (document.fbuscar.desde.value == "") && (document.fbuscar.hasta.value == "")) {
			alert("Debe indicar al menos un parametro de busqueda")
			document.fbuscar.buscatitulo.focus()
			return false;
		}
		else {
			document.fbuscar.submit();
		}
}

function impresion(nombre, ancho, alto) {
dat = 'width=' + ancho + ',height=' + alto + ',left=0,top=0,scrollbars=no,resize=no,toolbar=yes,scrollbars=0,location=0,statusbar=1,status=1,menubar=0,resizable=0, tittlebar=no';
window.open(nombre,'',dat)
}

function borrar(){
	if (confirm("Esta Seguro de querer borrar el/los elemento(s) seleccionado(s)")){
		document.getElementById('fborrar').submit()
	}
	else {
		return false;
		}
}
function actualizar(){
	if (confirm("Esta Seguro de querer actualizar estos datos")){
		document.getElementById('factualizar').submit()
	}
	else {
		return false;
		}
}
function terminar(){
	if (confirm("Esta seguro de querer teminar:\r Una vez terminado no podra volver a esta area.")){
		window.open('index2.php', '_self')
	}
	else {
		return false;
		}
}