function  getPageSize(){
       var xScroll, yScroll;

       if (window.innerHeight && window.scrollMaxY) {
                  xScroll = document.body.scrollWidth;
                  yScroll = window.innerHeight + window.scrollMaxY;
       } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                  xScroll = document.body.scrollWidth;
                  yScroll = document.body.scrollHeight;
       } else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
                  xScroll = document.documentElement.scrollWidth;
                  yScroll = document.documentElement.scrollHeight;
       } else { // Explorer Mac...would also work in Mozilla and Safari
                  xScroll = document.body.offsetWidth;
                  yScroll = document.body.offsetHeight;
       }
 

       var windowWidth, windowHeight;
       if (self.innerHeight) { // all except Explorer
                 windowWidth = self.innerWidth;
                 windowHeight = self.innerHeight;
       } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                 windowWidth = document.documentElement.clientWidth;
                 windowHeight = document.documentElement.clientHeight;
       } else if (document.body) { // other Explorers
                 windowWidth = document.body.clientWidth;
                 windowHeight = document.body.clientHeight;
       }
  
  
       // for small pages with total height less then height of the viewport
       if(yScroll < windowHeight){
                 pageHeight = windowHeight;
       } else {
                 pageHeight = yScroll;
       }

       // for small pages with total width less then width of the viewport
       if(xScroll < windowWidth){
                 pageWidth = windowWidth;
       } else {
                 pageWidth = xScroll;
       }

       return [pageWidth,pageHeight,windowWidth,windowHeight];
}



function center_page(){
              var obj = {x: 0, y: 0};
              if (window.pageXOffset || window.pageXOffset == 0) {
                obj.x = window.pageXOffset + parseInt(window.innerWidth / 2)
                obj.y = window.pageYOffset + parseInt(window.innerHeight / 2)
              }
              else {
                if (document.documentElement) { 
                   obj.x = document.documentElement.scrollLeft + parseInt(document.documentElement.clientWidth / 2)
                   obj.y = document.documentElement.scrollTop + parseInt(document.documentElement.clientHeight / 2)
                }
                else {
                   obj.x = document.body.scrollLeft + parseInt(document.body.clientWidth / 2)
                   obj.y = document.body.scrollTop + parseInt(document.body.clientHeight / 2)
                }
              } 
                   
              return obj;
}

    

    $('<div id="zoom_image_field"></div>').css({
       background: '#555',
       position: 'absolute',
       left: 0,
       top: 0,
       width: 0,
       height: 0,
       opacity: 0,
       zIndex: 100
    }).appendTo('body').mousedown(function(){
       $('#zoom_iage_wrap').remove();
       
       
       $(this).css({
         width: 0,
         height: 0,
         opacity: 0
       })
       
       _showing = false;
       
    });
    
    var _showing = true;
    
   
    function zoom_image(url) {
      var im = new Image();
          im.src = url;
    
      $('<div id="zoom_iage_wrap"></div>').css({
      position: 'absolute',
      background: '#fff',
      padding: '10px',
      top: center_page().y,
      left: center_page().x,
      opacity: 0,
      zIndex: 200
    }).append(im).append($('<a style="cursor: pointer"></a>')).appendTo(document.body);

    
    $('#zoom_iage_wrap a').css({
      display: 'block',
      position: 'absolute',
      right: 15,
      bottom: 15,
      width: 34,
      height: 36,
      background: 'url(\'/skin/img/zoomer/close.png\') no-repeat left top'
    }).mousedown(function(){
      $('#zoom_iage_wrap').remove();
       
       $('#zoom_image_field').css({
         width: 0,
         height: 0,
         opacity: 0
       })
    });
    
    setTimeout(function(){
      $('#zoom_iage_wrap').css({
        marginTop: center_page().y <  Math.round($(im).height() / 2) ? (center_page().y - 60) * -1 : (Math.round($(im).height() / 2) + 10) * -1,
        //marginLeft: center_page().x <  Math.round($(im).width() / 2) ? (center_page().x - 10) * -1 : (Math.round($(im).width() / 2) + 10) * -1
        marginLeft: (Math.round($(im).width() / 2) + 10) * -1
      });
    }, 200)
      
      
      
     
      $('#zoom_image_field').css({
        width: $('#main_wrap')[0].offsetWidth,
        height: $('#main_wrap')[0].offsetHeight
      }).animate({
         opacity: '0.5'
      }, function(){
         $('#zoom_iage_wrap').animate({
           opacity: 1
         }, function(){
               if(!_showing) {
                  $('#zoom_iage_wrap').css({opacity: 0, width: 0, height: 0});
               }
            })
      });
      
      _showing = true;

    }

