/*
  Similarpopup plugin
  (P) PSNet, 2008 - 2011
  http://psnet.lookformp3.net/
*/

jQuery.fn.ShowMeWindow = function (o) {
  return this.each (function () {
    // get object scroll
    ObjectScrolled = $ (this).offset ().top;
    
    // correct view
    Similarpopup_TopOffset = (Similarpopup_Pixel_Count_To_Tags ? Similarpopup_Pixel_Count_To_Tags : 200);
    
    // while scrolling
    $ (window).bind ('scroll', function () {
      // get window scroll
      WindowScrolled = $ (window).scrollTop ();
      
      // compare
      NeedToShow = (WindowScrolled - ObjectScrolled + Similarpopup_TopOffset > 0 ? true : false);
      
      $ (o).animate ({ right: NeedToShow ? -30 : -500}, 300);
    });

    // close button action
    $ (o).find ('.CloseBox').bind ('click', function (e) {
      e.preventDefault ();

      $ (window).unbind ('scroll');
      
      $ (o).animate ({ right: -500}, 300);
    });
  });
}

