function MostrarConsulta(datos,resultado){
        divResultado = document.getElementById(resultado);
        ajax=objetoAjax();
        ajax.open("GET",datos);
        ajax.onreadystatechange=function() { 
     if (ajax.readyState==4) {  divResultado.innerHTML = ajax.responseText;   }
        }
        ajax.send(null)
}


function confirmar(url){
if (!confirm("¿Está seguro de que desea eliminar el registro?")) {
return false;
}
else {
document.location= url;
return true;
}
}

function tamano(im,num,ancho,alto,proporcion) {
if (num==0) {
im.style.width = ancho+'px';
im.style.height = alto+'px';
}
else {
im.style.width =  (ancho*proporcion)+'px';
im.style.height = (alto*proporcion)+'px';
}
}


   function redondea(sVal, nDec){
    var n = parseFloat(sVal);
    var s = "0.00";
    if (!isNaN(n)){
     n = Math.round(n * Math.pow(10, nDec)) / Math.pow(10, nDec);
     s = String(n);
     s += (s.indexOf(".") == -1? ".": "") + String(Math.pow(10, nDec)).substr(1);
     s = s.substr(0, s.indexOf(".") + nDec + 1);
    }
    return s;
   } 



function sumarvalordecompra(Total,Incrememto,Cupon,Tracking,Demora,Moneda)
{
var nuevototal=(Total+Incrememto)-Cupon;
document.detalledevalordecompra.Total_a_Pagar.value=Moneda+' '+redondea(nuevototal,2);
document.confirmarcompraform.Tracking.value=Tracking;
document.detalledevalordecompra.Demora.value=Demora;
}

 
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_validateForm() { //v4.0
  var 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]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección de correo valida.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener numeros.\n';
        
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
          
    } 
    
    } } else if (test.charAt(0) == 'R') errors += '- '+nm+' *.\n'; }
  } if (errors) alert('Los Siguientes campos son Obligatorios:\n'+errors);
  document.MM_returnValue = (errors == '');
}
 


function verificarcheckbox(formu,campop,texto){ 
var pepez=0; 
for(i=0; ele=document.moddpass.elements[i]; i++){ 
if (ele.type=='checkbox') 
if (ele.checked){pepez=1;break;}} 
if (pepez==1){ }else{ 
alert(texto);return;} 
} 


function finalizarcomprafiltropago(valor){ 
document.confirmarcompraform.Pago.value=valor;
} 

function finalizarcomprafiltroenvio(){ 
document.confirmarcompraform.Envio.value=document.detalledevalordecompra.Envio.value;
} 





function comprobarClave(){
    clave1 = document.moddpass.password.value;
    clave2 = document.moddpass.Repite_tu_Password.value;
    if (clave1 != clave2)
       alert("Las Contrasenas no coinciden")
} 


function popUp(URL) 
 {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,  scrollbars=0,  location=0,  statusbar=0,  menubar=0,  resizable=0,  width=400,  height=300,  left = 312, top = 234');");
 }
 
 function abrir(direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, izquierda, arriba, sustituir,nombre,foco,preguntar,comentario,noabrirenpop){
     var opciones = "fullscreen=" + pantallacompleta +
                 ",toolbar=" + herramientas +
                 ",location=" + direcciones +
                 ",status=" + estado +
                 ",menubar=" + barramenu +
                 ",scrollbars=" + barrascroll +
                 ",resizable=" + cambiatamano +
                 ",width=" + ancho +
                 ",height=" + alto +
                 ",left=" + izquierda +
                 ",top=" + arriba;
     var pop_under = foco;   
if(preguntar=='1'){
if (!confirm(comentario)) {
return false;
}
else {
     if(noabrirenpop=='1'){
     document.location= direccion;
return true; } else {
     if (pop_under) {  window.focus(); }  
var ventana = window.open(direccion,nombre,opciones,sustituir);     
var uagent = navigator.userAgent.toLowerCase();
if (uagent.search('blackberry') > -1){
} else {
   if (pop_under=='1') {   document.getElementById('merlynasinfoco').style.display = 'block'; }}
}}} else {
     if(noabrirenpop=='1'){
     document.location=direccion;
return true; } else {
    if (pop_under) {  window.focus(); }  
var ventana = window.open(direccion,nombre,opciones,sustituir);     
var uagent = navigator.userAgent.toLowerCase();
if (uagent.search('blackberry') > -1){
} else {
   if (pop_under=='1') {   document.getElementById('merlynasinfoco').style.display = 'block'; }}}
}} 

 function capa1(){
                document.getElementById('capa1').style.display = 'block';
                document.getElementById('capa2').style.display = 'none';
                document.getElementById('capa3').style.display = 'none';
 					document.getElementById('capa4').style.display = 'none';
            }
            function capa2(){
                document.getElementById('capa2').style.display = 'block';
                document.getElementById('capa1').style.display = 'none';
                document.getElementById('capa3').style.display = 'none';
                document.getElementById('capa4').style.display = 'none';
            }
            function capa3(){
                document.getElementById('capa3').style.display = 'block';
                document.getElementById('capa1').style.display = 'none';
                document.getElementById('capa2').style.display = 'none';
                document.getElementById('capa4').style.display = 'none';
            }
                        function capa4(){
                document.getElementById('capa4').style.display = 'block';
                document.getElementById('capa1').style.display = 'none';
                document.getElementById('capa2').style.display = 'none';
                document.getElementById('capa3').style.display = 'none';
            }
            
            
            function maximo(obj,e,ma) {
tecla=(document.all)?e.keyCode:e.which;
if(obj.value.length==ma && tecla!=8)
return false;
}

function GetThis(T, C, U, L)
{
    var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T)
    + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
    window.open(targetUrl);
}

function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}


function validarBotonRadio(comentario,formulario,campo,campo1,campo2,campo3,campo4) { 
var s = "no"; 
 var casa=document.getElementById(formulario);
var acomprobar=document.getElementsByName(campo); 
with (casa){ 
for ( var i = 0; i < acomprobar.length; i++ ) { 
if (acomprobar[i].checked ) { 
s= "si"; 
return true;
break; 
} 
} 
if ( s == "no" ){ 
window.alert(comentario) ; 
return false;
} 
} 
} 
