// Ultima Actualzacion: 15/nov/2006
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_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_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_validateForm() { //v4.0 art
  var a,i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { 
    test=args[i+2]; 
  	mensaje=args[i+1];
	val=MM_findObj(args[i]);
	a=0;
    if(test=='RS') {	// art revisa Select valor Numerio <> 0
      if (val.value==0 || val.value=='0' || val.selectedIndex == 0) { errors += '- '+mensaje+' es requerido.\n';}
      a=1;
	 } // if test RS
	 
	if (val && a==0) {
	  nm=val.name; 
	  if ((val=val.value)!="") {  
        if (test.indexOf('isEmail')!=-1) { 
		  p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) { errors+='- '+mensaje+' debe ser una dirección de e-mail.\n'; }
        } else 
		  if (test!='R') {
            if (isNaN(val)) { errors+='- '+mensaje+' debe ser un Número.\n'; }
            if (test.indexOf('inRange') != -1) { 
			  p=test.indexOf(':');
              min=parseFloat(test.substring(8,p)); max= parseFloat(test.substring(p+1));
              if (val < min || val > max) { errors+='- '+mensaje+' ('+val+') debe ser un Número entre '+min+' y '+max+'.\n'; }
    		} 
	  	  } // test
	  } else 
	    if (test.charAt(0) == 'R') { errors += '- '+mensaje+' es requerido.\n';}
	} // if val
  } // for
  if (errors) { alert('Ocurrieron los siguientes errores:\n'+errors); }
  document.MM_returnValue = (errors == '');
}



function lanzar()
{
top.carro.location.href="carro.php";
}

// FUNCION PARA CONFIRMAR ELIMINACION DE DATOS
// Asi se manda el mensaje para confirmar eliminacion
//<a href="../eliminar.php?id=5" onclick="return confirmar('¿Está seguro que desea eliminar el registro?')">Eliminar</a>
function confirmar (quien) {
	mensaje="Seguro que Quiere "+quien;
	return confirm( mensaje );
} 

 
// FUNCION  PARA DETECTAR PA POSICION DE MOUSE
var mouse_x;
var mouse_y;
window.onload = function() {
	if (window.Event)
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = function(e) {
		mouse_x = (window.Event) ? e.pageX : event.clientX;
		mouse_y = (window.Event) ? e.pageY : event.clientY;
	};
}

// FUNCION PARA ABRIR IMAGENES FLOTANTES
function flotanteCh(imagen){
	imagenSrc = '../fotos/'+imagen;
	eImg = document.createElement('img');
	eImg.setAttribute('id','foto');
	eImg.setAttribute('src',imagenSrc);
	eImg.setAttribute('border','0');
	x = document.getElementById('imgFlotante');
	x.appendChild(eImg);
	x.style.visibility='visible';
	x.style.position = 'absolute';
	x.style.top = mouse_y - 5;
	x.style.left = mouse_x + 30;
}
function ocultaImg() {
	o = document.getElementById('imgFlotante');
	r = document.getElementById('foto');
	o.removeChild(r);
	o.style.position = 'absolute';
	o.style.top =  -1000;
	o.style.left = -1000;
	o.style.visibility='hidden';
}
// FIN FUNCION PARA ABRIR IMAGENES FLOTANTES

// FUNCION PARA AGRANDAR IMAGENES DE DETALLE (CATALOGO)
function ocultaDetalle() {
	o = document.getElementById('DetalleFlotante');
	o.style.position = 'absolute';
	o.style.top =  -1000;
	o.style.left = -1000;
	o.style.visibility='hidden';
}
function flotanteDet(imagen){
	imagenSrc = '../fotos/'+imagen;
	x = document.getElementById('DetalleFlotante');
	r = document.getElementById('fotoDet');
	r.setAttribute('src',imagenSrc);
	r.setAttribute('border','0');
	x.style.visibility='visible';
	x.style.position = 'relative';
	x.style.top =  0;
	x.style.left = 0;

}
// FUNCION PARA AGRANDAR IMAGENES DE DETALLE (CATALOGO)

function confirmaPass() {
		var p=document.Forma1.pass1.value;
		var c=document.Forma1.contrasenaD.value;
	if (p == ''  || c == '') {
		alert("Es necesario escribir una Clave\n y su Confirmación");
		return(false);
  } else { 
    if (p == c) {
		return(true); 
     } else { 
       alert("La Clave y la Confirmación son Diferentes.");
	   focus(document.Forma.pass2);
	   document.Forma1.contrasenaD.value="";
	   document.Forma1.pass1.value="";
       return(false);  
	 }
   }
 }

function veapues(){
	 alert("Ventana abierta");	
}

function WinOpen(strUrl,vent) { 
 newWindow = window.open( strUrl, 'Mensaje', vent);
 newWindow.focus();
}
 
 function enviapass(){
	 MM_validateForm('MailUS','Email','RisEmail');
	 if (document.MM_returnValue) { WinOpen("recursos/enviaClave.php?mail="+document.Logueo.MailUS.value,"toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,copyhistory=no,width=300,height=70, left=40")
	 }
 }
 
function soloNumeros(e) {
    evt = e ? e : event;
    tcl = (window.Event) ? evt.which : evt.keyCode;
    if ((tcl < 48 || tcl > 57) && (tcl != 8 && tcl != 0 && tcl != 46))
    {
        alert("Solo debe ingresar Numeros, los decimales deben estar separados por punto");	
		return false;
    }
    return true;
}
