// JavaScript Document
<!--

var tecla;
function capturaTecla(e){
	if(document.all)
		tecla=event.keyCode;
	else
		tecla=e.which; 
	if(tecla==13)
		enviar();
} 

function capturaTecla2(e,destino){
	if(document.all)
		tecla=event.keyCode;
	else
		tecla=e.which; 
	if(tecla==13)
		eval(destino);
} 
//document.onkeypress = capturaTecla;
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function ingresar(){
	d = document.login;
	msg = "";

	if (d.usuario.value=="")
		msg += "- Nombre de usuario\n";
	if (d.password.value=="")
		msg += "- Contraseña\n";


if (msg=="")
		return true;
	else {
		msg = "Atención: Debe completar los siguientes campos:\n\n" + msg;
		alert(msg);
		return false;
	}
}
function enviar() {
	d = document.login;
	msg = "";
	campo = "";
	
	if(d.usuario.value==""){
		if(msg=="") d.usuario.select();
		msg += "- E-Mail\n";
	}
	if(d.password.value==""){
		if(msg=="") d.password.select();
		msg += "- Clave\n";
	}
	
	if(msg==""){
		d.submit()
	} else {
		msg = "Atención: Debe completar los siguientes campos:\n\n" + msg;
		alert(msg);
	}

}
function checkNum()
{
	var key = String.fromCharCode(event.keyCode) ;
	if ( (isNaN(key)) || (key==' ') ) {return false ;} else { return true ;}
}
function checkDec(cont) {
	var key = String.fromCharCode(event.keyCode) ;
	if (cont.value.indexOf(".") == -1){
	  if (key == ".")
		return true;
	}
	if ( (isNaN(key)) || (key==' ') ) 
	  return false;
	else
	  return true;
}

function addToFavorite(favTitle){
  if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) {
    window.external.AddFavorite(location.href, unescape(favTitle));
  }
}

function MM_showHideLayers2() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers2.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

sortitems = 1; 
 
function move(fbox,tbox) {
for(var i=0; i<fbox.options.length; i++) {
if(fbox.options[i].selected && fbox.options[i].value != "") {
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
   }
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
}
function BumpUp(box)  {
for(var i=0; i<box.options.length; i++) {
if(box.options[i].value == "")  {
for(var j=i; j<box.options.length-1; j++)  {
box.options[j].value = box.options[j+1].value;
box.options[j].text = box.options[j+1].text;
}
var ln = i;
break;
   }
}
if(ln < box.options.length)  {
box.options.length -= 1;
BumpUp(box);
   }
}
 
function SortD(box)  {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++)  {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++)  {
for(var y=(x+1); y<temp_opts.length; y++)  {
if(temp_opts[x].text > temp_opts[y].text)  {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
temp = temp_opts[x].value;
temp_opts[x].value = temp_opts[y].value;
temp_opts[y].value = temp;
      }
   }
}
for(var i=0; i<box.options.length; i++)  {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
   }
}

function guardar(mensaje_top, campos, formulario, nombre_mostrar, email, campo, mensaje) {

	eval ("d = document." + formulario);
		
	msg = "";
	
	for(i = 0; i < campos.length; i++) {															//BUCLE PARA CREAR LA CONDICION DE CADA CAMPO
		
		if( eval ("d. " + campos[i] + ".value == ''")) {												//SI EL CAMPO ESTA VACIO
			
			if(msg == "") { eval ("d." + campos[i] + ".focus();"); }								//SI MSG ES VACIO, HACE FOCUS AL CAMPO QUE KEREMOS
			
			msg += "- " + nombre_mostrar[i] + "\n";
			
		}																							//SI EL CAMPO ESTA VACIO
	}																								//BUCLE PARA CREAR LA CONDICION DE CADA CAMPO
	
	if (email == 1) {
		
		if ( (eval("d." + campo + ".value.indexOf('@') == -1"))  || ( eval("d." + campo + ".value.indexOf('.') == -1"))) {
			
			msg += mensaje;
			
		}
	}
	
	if (msg != "") {																				//SI MENSAJE TIENE ALGO, MUESTRA LO QUE TIENE QUE COMPLKETAR EL USUARIO
		
		msg = mensaje_top + "\n\n" + msg;
		alert(msg);
		
	} else {																						//SI MENSAJE NO TIENE ALGO HACE SUBMIT DEL FORMULARIO
		
		eval ("document." + formulario + ".submit();");
		
	}																								//SI MENSAJE NO TIENE ALGO HACE SUBMIT DEL FORMULARIO
}

//cambia el valor del campo nombre por el del archivo (sin la direccion entera) en la apagina de agregar imagenes a las galerias
function cambiar_nombre_imagen() {
	
	d = document.frm;
	imagen = d.archivo.value;
	nombre = d.nombre.value;
	
	imagen_array = imagen.split("/");
	imagen_total = imagen_array.length - 1;
	imagen_array = imagen_array[imagen_total].split("\\");
	
	imagen_total = imagen_array.length - 1;
	
	d.nombre.value = imagen_array[imagen_total];
	
}

//-->