//Default browsercheck, added to all scripts!
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()
//With nested layers for netscape, this function hides the layer if it's visible and visa versa
function showHide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	if(obj.visibility=='visible' || obj.visibility=='show') obj.visibility='hidden'
	else obj.visibility='visible'
}
//Shows the div
function show(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='visible'
}
//Hides the div
function hide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='hidden'
}

function Init(){
 setearFoco();
}

function setearFoco(){
	document.getElementById('titulo').focus();
}

function validar(){

	var errores = 0;       
	// Valido el titulo
	if (window.document.getElementById('titulo').value ==  ""){
		show('eTitulo');
		errores=1;
	}
	else{
		hide('eTitulo');
		errores=0;
	}


	// Valido la URL
	if ((window.document.getElementById('url').value).length <= 7){
		show('eUrl');
		errores=1;
	}
	else{
		hide('eUrl');
		errores=0;
	}

	// Valido la Descripcion
	if (window.document.getElementById('descripcion').value ==  ""){
		show('eDescripcion');
		errores=1;
	}
	else{
		hide('eDescripcion');
		errores=0;
	}

	// Valido el Nombre
	if (window.document.getElementById('nombre').value ==  ""){
		show('eNombre');
		errores=1;
	}
	else{
		hide('eNombre');
		errores=0;
	}

	// Valido el Email
	if (window.document.getElementById('email').value ==  ""){
		show('eEmail');
		errores=1;
	}
	else{
		hide('eEmail');
		errores=0;
	}

	// Valido la Localidad
	if (window.document.getElementById('localidad').value ==  ""){
		show('eLocalidad');
		errores=1;		
	}
	else{
		hide('eLocalidad');
		errores=0;
	}

	if (errores==0) // si no hay errores, hago submit
		document.miFormulario.submit();

}

function InicializarErrores(){
 hide('eTitulo');
 hide('eUrl');
 hide('eDescripcion');
 hide('eNombre');
 hide('eEmail');
 hide('eLocalidad');
}



