  var enlarging = false;
  var waiting = 500;
  var timer;
  
  function addEvent( obj, type, fn ) {
    if ( obj.attachEvent ) {
      obj['e'+type+fn] = fn;
      obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
      obj.attachEvent( 'on'+type, obj[type+fn] );
    } else
      obj.addEventListener( type, fn, false );
  }
  function initPubblicita() {
    var pubdiv = document.getElementById("divPubblicita");
    var dx = pubdiv.offsetLeft;
    var b = document.body;
    pubdiv.style.left = "0px";
    //pubdiv.style.width = b.clientWidth + "px";
    addEvent(pubdiv,"mouseover",onpubMouseOver);
    addEvent(pubdiv,"mouseout",onpubMouseOut);
    //checkScroll();
    //alert(b.clientWidth);
    //alert("scroll" + document.body.scrollTop+","+document.body.scrollHeight);
  }
  
  function onpubMouseOver() {
    enlarging = true;
    if (waiting > 0) {
    	waiting -= 10;
	    window.setTimeout(onpubMouseOver,30);
	    return;
    }
    
    var pubdiv = document.getElementById("divPubblicita");
    var pdh = pubdiv.clientHeight+10;
    pubdiv.style.height= pdh + "px";
    //checkScroll();
    if (pdh < 300) {
    	window.clearTimeout(timer);
      timer = window.setTimeout(onpubMouseOver,30);
    } else {
      enlarging = false;
    }
  }
  function onpubMouseOut() {
//    if (! enlarging) {
	  waiting = 500;
      var pubdiv = document.getElementById("divPubblicita");
      var pdh = pubdiv.clientHeight-10;
      pubdiv.style.height= pdh + "px";
      //checkScroll();
//    }
    if (pdh > 30) {
    	window.clearTimeout(timer);
      timer = window.setTimeout(onpubMouseOut,30);
    } else {
      pubdiv.style.height= "30px";
    }
  }
  
  function checkScroll() {
    //alert("scroll" + document.body.scrollTop+","+document.body.scrollHeight);
    var pubdiv = document.getElementById("divPubblicita");
    var b = document.body;
    pubdiv.style.top = "" + (b.clientHeight-pubdiv.clientHeight+b.scrollTop) + "px";
  }
  
  addEvent(window,"load",initPubblicita);
  //addEvent(window,"scroll",checkScroll);

