//*************************************************************************
// Archivo de funciones javascripts
// 
// Autor: Carlos Villaran Wiegering
// Creado: 02.10.2005
//*************************************************************************
//*************************************************************************
function mouseDown(e) {
	var clickType=1;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") clickType=e.which;
		else clickType=event.button;

		if (clickType!=1) {
			alert("Evento desabilitado");
			return false;
		}
	}
	return true;
}
document.onmousedown = mouseDown;
if (navigator.appName=="Netscape") 
	document.captureEvents(Event.MOUSEDOWN);
/* **************************************************************************************************** */
function campos_llenos() {
	var ok, dato, iCont
	var oForm = document.frm;
	
		for(iCont=0;iCont<oForm.length; iCont++)
		{
			if(oForm[iCont].type=='text' || oForm[iCont].type=='password')
				if(oForm[iCont].value=='')
				{
					alert("Debe llenar todos los campos");
					oForm[iCont].focus();
					return false;
				}
		}
		
	return true;
}
/* **************************************************************************************************** */
function NoKeyPress() {
	event.returnValue=false;
}	
/* **************************************************************************************************** */
function NumeroKeyPress() {
	if (!((event.keyCode>=48) && (event.keyCode<=57))) {
		alert("El caracter ingresado no es válido");
		event.returnValue=false;
	}
}
/* **************************************************************************************************** */
function EsEmail(cad) {
	var i = 1;
	var cadLength = cad.length;
	
	// busca un '@'
	while ((i < cadLength) && (cad.charAt(i) != "@"))  i++;
	if ((i >= cadLength) || (cad.charAt(i) != "@"))	{
		return false;
	}
	else {
		i += 2;
	}
	// busca un '.'
	while ((i < cadLength) && (cad.charAt(i) != ".")) { 
		i++;
	}
	// debe haber por lo menos un caracter despues de '.'
	if ((i >= cadLength - 1) || (cad.charAt(i) != ".")) 
		return false;
    else return true;
}
/* **************************************************************************************************** */
function fPopup(mypage, myname, w, h, scroll, pos) {
	var win=null;
	if(pos=="random") {
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center") {
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	else if((pos!="center" && pos!="random") || pos==null) {
		LeftPosition=0;
		TopPosition=20
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
}

