var eff;

function getScrollOffset(){
     var x=0,y=0;
     if (self.pageYOffset) // all except Explorer
     {
          x = self.pageXOffset;
          y = self.pageYOffset;
     }
     else if (document.documentElement && typeof(document.documentElement.scrollTop)!=undefined)
          // Explorer 6 Strict
     {
          x = document.documentElement.scrollLeft;
          y = document.documentElement.scrollTop;

     }
     else if (document.body) // all other Explorers
     {
          x = document.body.scrollLeft;
          y = document.body.scrollTop;
     }
     return {left: x, top: y};
}

function WindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return {width: myWidth, height: myHeight};
}

function load_foto_to_container(event,path,widht_foto,height_foto,el){
   
   var event = event || window.event;
   $('foto').src = '/'+path;
   scroll_info  = getScrollOffset();
   w_size = WindowSize();
   widht_foto = widht_foto-0;

   Position.clone(el, $('foto_container'));
   
   (Event.pointerX(event) + widht_foto+50>w_size.width)? left=Event.pointerX(event)-widht_foto-50 : left = Event.pointerX(event)+20 ;
   $('foto_container').style.left = left+'px';
   
   if (scroll_info['top'] + w_size.height - Event.pointerY(event) - 0 < height_foto-0) {
     $('foto_container').style.top = (parseInt($('foto_container').style.top) - height_foto - 10) + 'px';
   }else{
     $('foto_container').style.top = (parseInt($('foto_container').style.top) + 10) + 'px';
   }
   eff = new Effect.Appear('foto_container', {duration:.9, queue: {position: 'end', scope: 'foto_container', limit:1} } );
   //$('foto_container').style.display='block';
}

function hide_foto(){
   eff.cancel();
   $('foto_container').style.display = 'none';
  //new Effect.Fade('foto_container'); 
}



