
	popupAjax = function(url,width) {
		img = new Element('img',{src: '/img/ajax-spinner.gif'});
		$('popup-update').update(img);
		new Ajax.Updater('popup-update',url,{
			evalScripts: true,
			onComplete: function() {
				popupcentra(width);		
			}
		});
	}
	
	click_banner = function(id) {
		new Ajax.Request('/banners/click/'+id);
	}
	popupcentra = function(width) {
		pageSize = getPageSize(document.body);
		scrollbar = getWindowScroll(document.body);
		marginTop = parseInt(((pageSize.windowHeight-$('popup-wrap').getHeight())/2)+scrollbar.top);
		if(marginTop <= 0) marginTop = 5;
		//cbb.init();
		//marginTop = (scroll.top+200)+'px';
		$('popup-wrap').setStyle({top: marginTop+'px', 'width': width+'px'});
		$('popup-container').setStyle({visibility: 'visible'});
		new Effect.Opacity('popup-container',{from: 0.0,to: 1.0,duration: 1.0});
	}
	
	popupClose = function() {
		//Effect.Fade('popup-container',{afterFinish: function(){$('popup-update').update('');}});
		new Effect.Opacity('popup-container',{from: 1.0,to: 0.0,duration: 1.0,afterFinish: function(){$('popup-update').update('');}});
		//$('popup-container').setStyle({visibility: 'hidden'});
	}
		
  function getPageSize(parent){
    parent = parent || document.body;              
    var windowWidth, windowHeight;
    var pageHeight, pageWidth;
    if (parent != document.body) {
      windowWidth = parent.getWidth();
      windowHeight = parent.getHeight();                                
      pageWidth = parent.scrollWidth;
      pageHeight = parent.scrollHeight;                                
    } 
    else {
      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 { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
      }


      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: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
  }
  
  function getWindowScroll(parent) {
    var T, L, W, H;
    parent = parent || document.body;              
    if (parent != document.body) {
      T = parent.scrollTop;
      L = parent.scrollLeft;
      W = parent.scrollWidth;
      H = parent.scrollHeight;
    } 
    else {
    	T = f_scrollTop();
        L = f_scrollLeft();
        W = f_clientWidth();
        H = f_clientHeight();
    }
    return { top: T, left: L, width: W, height: H };
  }
  
	function f_clientWidth() {
		return f_filterResults (
			window.innerWidth ? window.innerWidth : 0,
			document.documentElement ? document.documentElement.clientWidth : 0,
			document.body ? document.body.clientWidth : 0
		);
	}
	function f_clientHeight() {
		return f_filterResults (
			window.innerHeight ? window.innerHeight : 0,
			document.documentElement ? document.documentElement.clientHeight : 0,
			document.body ? document.body.clientHeight : 0
		);
	}
	function f_scrollLeft() {
		return f_filterResults (
			window.pageXOffset ? window.pageXOffset : 0,
			document.documentElement ? document.documentElement.scrollLeft : 0,
			document.body ? document.body.scrollLeft : 0
		);
	}
	function f_scrollTop() {
		return f_filterResults (
			window.pageYOffset ? window.pageYOffset : 0,
			document.documentElement ? document.documentElement.scrollTop : 0,
			document.body ? document.body.scrollTop : 0
		);
	}
	function f_filterResults(n_win, n_docel, n_body) {
		var n_result = n_win ? n_win : 0;
		if (n_docel && (!n_result || (n_result > n_docel)))
			n_result = n_docel;
		return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
	}
