

function setImgParams(width, height) {
    var winWidth=($(document).width()/2)-(width/2);
   var winHeigth=(($(document).height()/2)-(height/2))*0.7;

   $("#lay-popup").css({"top":winHeigth+"px","left":winWidth+"px"});
  $("#lay-popup").append('<span id="popup-close"></span>');
   $("#popup-close").click(function() {$("#lay-popup").hide();});
   setTimeout(function(){ 
       $("#lay-popup").hide();
  }, 9000 ); 
}


     $(document).ready(function () {
   //$("#lay-popup").hide();
   if($("#lay-popup img").width()!=null)
  { 
      

     if($.browser.webkit) {
         //$('img').attr('src', $("#lay-popup img").attr('src'));
         
         codeHs = '';
         for(i = 0; i < 20; i++) {
             codeHs = codeHs + Math.floor(Math.random()*500);
         }
         $("#lay-popup img").attr('src', $("#lay-popup img").attr('src')+'?q='+codeHs);
         
         $("#lay-popup img").load(
                function() {
                    $("#lay-popup").show(1000);
                    var imgWidth=$(this).width();
                    var imgHeight=$(this).height();
                    setImgParams(imgWidth, imgHeight);
                }
            );
     } else {
         $("#lay-popup").show(1000);
         var imgWidth=$("#lay-popup img").width();
         var imgHeight=$("#lay-popup img").height();
         setImgParams(imgWidth, imgHeight);
     }
            
     }else{
         $("#lay-popup").hide();
     }
 });
    
  


