// JavaScript Document
var cuentaInicial = "20";
function mostrar() { 
   $("#pop").fadeIn('slow'); 
} //checkHover

function quitar() { 
  
   var cuentaInicial = "20";
   counterH();
} 
$(document).ready(function (){
 //Conseguir valores de la img 
   var img_w = $("#pop img").width() + 10; 
   var img_h = $("#pop img").height() + 28; 
    
   //Darle el alto y ancho 
   //$("#pop").css('width', img_w + 'px'); 
   //$("#pop").css('height', img_h + 'px'); 
   
   $("#pop").css('width', $(this).width() + 'px'); 
   $("#pop").css('height', $(this).height() + 'px'); 
   
   
   
   var yourShade = document.getElementById('pop');
		if(tb_detectMacXFF2()){
			//$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
			 yourShade.style.backgroundImage= "url(black-70.png)";
   			 yourShade.style.backgroundRepeat="repeat";
			 //$("#pop").addClass("TB_overlayBG");
		}else{
			$("#pop").addClass("TB_overlayBG");//use background and opacity
			//yourShade.style.backgroundImage= "url(black-70.png)";
   			//yourShade.style.backgroundRepeat="repeat";
		}
   
    
   //Esconder el popup 
   $("#pop").hide();
   
   //Consigue valores de la ventana del navegador 
   var w = $(this).width(); 
   var h = $(this).height(); 
    
   //Centra el popup    
   w = (w/2) - (img_w/2); 
   h = 400 - (img_h); 
   //$("#pop").css("left",w + "px"); 
   //$("#pop").css("top",h + "px");
   $("#pop").css("left",0 + "px"); 
   $("#pop").css("top",0 + "px");
   
   //$("#pop img").css("left",w + "px"); 
   $("#margenTop").css("height",10 + "%");
   $("#pop a img").addClass("opacy");
   $("#pop img").addClass("opacy");
   
	//temporizador, para que no aparezca de golpe 
   setTimeout("mostrar()",150);
   
   //Función para cerrar el popup 
   $("#pop").click(function (){ 
      $(this).fadeOut('slow'); 
   });
   
   quitar();
   //setTimeout("quitar()",10000);
});


function detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
    var ffversion = new Number(RegExp.$1);
    if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
      return true;
    }
  }
}

function tb_detectMacXFF2() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}




function fin() {
	$("#pop").fadeOut('slow');
}

function unoMenos() {
with (
document.forms["cuenta"]["regresiva"]) value ='  '+cuentaInicial;
if (
cuentaInicial-- > 0
) 
setTimeout("unoMenos()", 1000);
else fin();
}
function counterH() {
with (
document.forms["cuenta"]["regresiva"]) value =''+cuentaInicial--;
setTimeout("unoMenos()", 1000);
}

