// JavaScript Document
<!--
sendForm = function(){
	var form = $('contact-form');
	var name = $F('name');
	var email = $F('email');
	var comments = $F('comments');
	var emailValido = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email);
	var control = 0;
	if(name == ""){
		alert('You must complete the Name field');
		control = control + 1;
	}
	
	if(comments == ""){
		alert('You must complete the Comments field');
		control = control + 1;
	}
	
	if(email == ""){
		alert('You must complete the E-mail field');
		control = control + 1;
	}
	
	if(!emailValido){
		alert('You must enter a valid E-mail');
		control = control + 1;
	}
	
	if(control == 0){
		form.submit();
	}
}

checkFormPortfolio = function(){
	var form = $('add-form');
	var categoria = $F('categoria_id');
	var trabajo = $F('imagen');
	var a = 0;
	
	if(categoria == 0){
		alert('Debe seleccionar una categoria');
		a = a + 1;
	}
	
	if(trabajo == ""){
		alert('Debe seleccionar una imagen');
		a = a + 1;	
	}
	
	if(a == 0){
		form.submit();
	}
}

checkFormLinks = function(){
	var form = $('add-link');
	var titulo = $F('titulo');
	var url = $F('url');
	var a = 0;
	
	if(titulo == ""){
		alert('Debe colocar un titulo');
		a = a + 1;
	}
	
	if(url == ""){
		alert("Debe colocar una URL (con 'http://')");
		a = a + 1;	
	}
	
	if(a == 0){
		form.submit();
	}
}

cambiarCategoria = function(id){
	if(id != 0){
		location.href='index.php?cat_id='+id;
	}
}

eliminarCategoria = function(id){
	var conf;
	conf = confirm("Esta seguro que desea eliminar esta categoria?\n\n(Se eliminaran todos los trabajos ligados a esta categoria)");
	if(conf == true){
		location.href='categorias.php?accion=delete&id='+id;
	}
}

eliminarLink = function(id){
	var conf;
	conf = confirm("Esta seguro que desea eliminar este link?");
	if(conf == true){
		location.href='links.php?accion=delete&id='+id;
	}
}

check = function(){
	var form = $('del-form');
	for(i=0; i<form.length; i++){
		form[i].checked = true;	
	}
}

uncheck = function(){
	var form = $('del-form');
	for(i=0; i<form.length; i++){
		form[i].checked = false;	
	}
}

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;
-->
