$(function() {
    equalHeight();
    $('#logos').simpleSpy(9,5000);
    $('.lightbox').fancybox();
    $('a[href^="http"]').attr('target','_blank');
});

function equalHeight() {
    //$('.column').css({'height':''});
	if ($('#contact').length > 0) $('#contact .textwrapper').setEqualHeight();
};



jQuery.fn.setEqualHeight=function(o) {
    var maxHeight=0;
    var maxElement=null;
    	jQuery(this).each(function(i) {
      		if((jQuery(this).height()+parseInt(jQuery(this).css("padding-bottom"))+parseInt(jQuery(this).css("padding-top")))>maxHeight) {
    		maxHeight=jQuery(this).height()+parseInt(jQuery(this).css("padding-top"))+parseInt(jQuery(this).css("padding-bottom"));
    		maxElement=this;
    	}
    });
    //jQuery(this).not($(maxElement)).each(function() {$(this).height(maxHeight-parseInt(jQuery(this).css("padding-top"))-parseInt(jQuery(this).css("padding-bottom")))})
    jQuery(this).each(function() {$(this).height(maxHeight-parseInt(jQuery(this).css("padding-top"))-parseInt(jQuery(this).css("padding-bottom")))})
};

(function ($) {    
    $.fn.simpleSpy = function (limit, interval) {
      // set some defaults
        limit = limit || 4;
        interval = interval || 4000;
        
        return this.each(function () {
            // capture a cache of all the list items
            var $list = $(this),
              items = [], // uninitialised
              currentItem = limit,
              total = 0, // initialise later on
              width = $list.find('> li:first').width();
                  
            // capture the cache
            $list.find('> li').each(function () {
              items.push('<li>' + $(this).html() + '</li>');
            });
            total = items.length; 
            $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();
                  
            function spy() {
                var $insert = $(items[currentItem]).css({
                    width : 0,
                    opacity : 0,
                    display : 'none'
                }).prependTo($list);

                $list.find('> li:last').animate({ opacity : 0}, 1000, function () {
                $insert.animate({ width : width }, 1000).animate({ opacity : 1 }, 1000);
                
                $(this).animate({ width : 0 }, 1000, function () {
                        $(this).remove();
                    });
                });
                currentItem++;
                if (currentItem >= total) {
                    currentItem = 0;
                }
                setTimeout(spy, interval);
            }
            spy();
        });
    };    
})(jQuery);


$(function () {
	
       $("#facebook-slider").hover(
               function(){
               $("#facebook-slider").stop(true, false).animate({right:"0"},"slow");
       },
               function(){
       $("#facebook-slider").stop(true, false).animate({right:"-348"},"slow");
               }
       );
		
})(jQuery);

