/**
 * jQuery Dropdown Extension - date: 2010 authors: abaker, jangel
 */
 
(function($) {

   $.fn.closeAllSliders = function(speed, easing, callback) {
      $(this).each(function(i, obj){
         $(obj).closeSlider(speed, easing, callback); 
      });	
   };
   
   $.fn.closeSlider = function (speed, easing, callback) {
      if (parseInt($(this).css('marginTop')) > 0)
      {				
         var otherH = $.crossSiteSlider.heightOffset + $(this).height() + parseInt($(this).css('paddingTop')) + parseInt($(this).css('paddingBottom'));
         return $(this).animate({marginTop: -otherH}, speed, easing, callback);	  
      }
      else return false;
   };
   $.fn.openSlider = function (speed, easing, callback) {
      if (parseInt(this.css('marginTop')) < 0)
      {
         return this.animate({marginTop: $.crossSiteSlider.heightOffset}, speed, easing, callback);	  
      }
      else {
         return false;
      }
   }
   
   $.crossSiteSlider = {
      heightOffset : 0,
      widthOffset : 0,
      setOffset : function (coords) {
         if (typeof coords == "object") {
            if(coords.x && !(isNaN(coords.y))) {
               this.heightOffset = coords.y;
            }
            if (coords.y && !(isNaN(coords.x))) {
               this.widthOffset = coords.x;
            }
         }
         else if (typeof coords == "number") {
            this.heightOffset = coords;
         }
      }
   }
})(jQuery);
