// JavaScript Document


//  listBlockPopup (2009-11-04)
//  this object adding special popup paging into simple list pages


function listBlockPopup() {
  var self = this;
  //
  this.init = function() {
    // transform nojs to js version
    dojo.removeClass(dojo.byId('pagingspecialnumbers'),"paging-special-nojs");
    dojo.addClass(dojo.byId('pagingspecialnumbers'),"paging-special-js");
    //
    dojo.query('#pagingspecialnumbers a').forEach(function(node,index){
      var span = node.getElementsByTagName('span')[0];
      if (span) {
        span.listBlockPopupHeight = span.offsetHeight;
      }
      span.style.height = 0+'px';
      dojo.connect(node,"onmouseover",self.show);
      dojo.connect(node,"onmouseout",self.hide);
      dojo.connect(dojo.query('span img',node)[0],"onload",self.imageOnLoadResize);
    });
  };
  //
  this.imageOnLoadResize = function(e,thisElem) {
    if (!thisElem) thisElem = this;
    var span = thisElem.parentNode;
    span.style.height = 'auto';
    span.listBlockPopupHeight = span.offsetHeight;
    span.style.height = 0+'px';
  };
  //
  this.show = function(e,thisElem) {
    if (!thisElem) thisElem = this;
    thisElem.getElementsByTagName('i')[0].style.display = 'block';
    var span = thisElem.getElementsByTagName('span')[0];
    if (span) {
      dojo.animateProperty({node:span,properties:{height:span.listBlockPopupHeight}}).play();
    }
  };
  //
  this.hide = function(e,thisElem) {
    if (!thisElem) thisElem = this;
    thisElem.getElementsByTagName('i')[0].style.display = 'none';
    var span = thisElem.getElementsByTagName('span')[0];
    if (span) {
      dojo.animateProperty({node:span,properties:{height:0}}).play();
    }
  };
  //
  return self.init();
}


// end of document
