function mouseWait(){
    
    $('#clubowe_all_gals_cont_gal1').hide('slow');  
    $('#cont_clubowe_cont1_el').fadeOut();
    
    $('#loader').fadeIn(500);
}

function mouseDefault(){
    
    $('#loader').hide();
}
 
 $(document).ready(function(){
    
    $(".img_360").overlay();
 
    
    $('a.lightbox').lightBox();
    
	after_ajax_cont();
    
    //nasluchiwanie ladowania strony
     $('.ajax_club').livequery('click', (function(){
    
            mouseWait();
                                
            var link = $(this).attr('d-href');
            $.ajax({
                  url: link+"&ajax=true",
                  //context: document.body,
                  success: function(data){
                    mouseDefault(); 
                    $("#imprezy_clubowe_karta_imprezy_tpl").html(data); 
                                                                                               
                  }
            });
      }));     
    
    //nasluchiwanie ladowania strony
     $('.ajax_biznes').livequery('click', (function(){
                              
            mouseWait();
               
            var link = $(this).attr('d-href');
            $.ajax({
                  url: link+"&ajax=true",
                  //context: document.body,
                  success: function(data){
                    mouseDefault();
                    $("#ajax_page").html(data);                     
                  }
            });
      }));    
    
	 $("#logo_mini_bizbes").css({ opacity: 0.0 });
                              
	  $('.show_firmowe').click(function() {

          show_firmowe();
		  
		});

      $('.show_clubowe').click(function() {
   	
         show_clubowe_card();
   
		});


      $("#logo_mini_club").css({ opacity: 0.0 });


        $('.glowna_club_a_div').hover(function(){
            
            
            $('.red_button_club').css('display','none');
            $('.blue_button_club').css('display','block');
            
        }, function(){
            
            
            $('.blue_button_club').css('display','none');
            $('.red_button_club').css('display','block');
            
        });
        
        $('.glowna_firmowe_a_div').hover(function(){
            
               $('.red_button_firm').css('display','none');
            $('.blue_button_firm').css('display','block');
            
        }, function(){
            
            $('.blue_button_firm').css('display','none');
            $('.red_button_firm').css('display','block');

            
        });
 });
 
 function show_firmowe(){
    
    
    clickAjaxBox();

		  $('.cont_firmowe').css('display','');

		  
	      var $marginLefty = $('.glowna');
	      $('.inner').animate({
	         marginLeft: parseInt($('.inner').css('marginLeft'),10) == 0 ?
	        ($marginLefty.outerWidth()) : 0
	      },0,function() {
		    // Animation complete.
	    	  
	    	  
	    	    jQuery('#mycarouse_zd').jcarousel({
	    	    	wrap: 'circular',
	    	    	scroll:1,
	    	    	auto:4 ,
	    	    	initCallback: mycarousel_initCallback,
                    //itemFirstInCallback: cufon_run,
	    	        buttonNextHTML: null,
	    	        buttonPrevHTML: null
	    	    });

              $('#newsletter_clubowe').hide();   
	    	  $('#newsletter_firmowy').show(999);
              $('#biznes_left_link_to_cub').show(1133);
	    	  
	    	  firmowe_back_run();
		  });
    
    
 }

function show_ajax_page(){

			  	  $("#ajax_container").css('display','block');
			  	   jQuery("#wyd_scrol3").jScrollPane({scrollbarWidth:8});
			  	  
                    $("#ajax_container").animate({
				    marginTop: "0px"
				  }, 500,function() {
				  
                  });
       
    after_ajax_cont();
}

function show_clubowe_card(animation){
    
     $.get(p+"imprezy_klub_warszawa.html&ajax=true", function(data) {
        		  $(".inc_imprezy_clubowe_tpl").html(data);
        		  after_ajax_cont();
                  show_clubowe_web(animation);
        	  });

}

function show_clubowe_web(animation){            
     clickAjaxBox();          
		  $('.cont_clubowe').css('display','');
		  jQuery("#wyd_scrol").jScrollPane({scrollbarWidth:8});
          showMiniaturesOverlay();
	      var $marginLefty = $('.glowna');
          
          
          $('.clubowe_inner').animate({
	         marginLeft: parseInt($('.clubowe_inner').css('marginLeft'),10) == 0 ?
	        (-$marginLefty.outerWidth()) : 0
	      }, ((animation==false) ? 0 : 2000 ),function() {
	       
		  });
          
	    	    jQuery('#club_mycarouse_zd').jcarousel({
	    	    	wrap: 'circular',
	    	    	scroll:1,
	    	    	auto:0 ,
	    	    	initCallback: club_mycarousel_initCallback,
                    itemFirstInCallback: cufon_run_banners,
	    	        buttonNextHTML: null,
	    	        buttonPrevHTML: null
	    	    });
	    	    
	    	    jQuery('#club_mycarouse_aktu_imprezy').jcarousel({
	    	    	wrap: 'circular',
	    	    	scroll:1,
	    	    	vertical: true,
	    	    	auto:4 ,
	    	    	initCallback: aktu_imprezy_mycarousel_initCallback,
                    itemFirstInCallback: cufon_run_banners,
	    	        buttonNextHTML: null,
	    	        buttonPrevHTML: null
	    	    });
	    	  
	    	  
	    	  $('#newsletter_firmowy').hide();   
	    	  $('#newsletter_clubowe').show(999);
	    	  $('#club_left_link_to_fir').show(1133);
	    	                            
	    	  clubowe_back_run();  

}


function clickAjaxBox(){
    
    
     $('#club_left_link_to_fir').click(function() {
        
        
        location.href = p+'imprezy_zamkniete.html';
        
	});
    
            
  $('#biznes_left_link_to_cub').click(function() {
    
    
    location.href = p+'imprezy_klub_warszawa.html';
  
  });
  
  
    
    
}

function cufon_run_banners(){
         Cufon.replace('.cufon3', {fontFamily: 'Niamey', textShadow: '1px 1px 0 #000' });
    }

	  function aktu_imprezy_mycarousel_initCallback(carousel) {
		    jQuery('#aktu_imprezyclubowe_mycarouse_zd-next').bind('click', function() {
		        carousel.next();
		        return false;
		    });

		    jQuery('#aktu_imprezyclubowe_mycarouse_zd-prev').bind('click', function() {
		        carousel.prev();
		        return false;
		    });
		};

	  function club_mycarousel_initCallback(carousel) {
		    jQuery('#clubowe_mycarouse_zd-next').bind('click', function() {
		        carousel.next();
		        return false;
		    });

		    jQuery('#clubowe_mycarouse_zd-prev').bind('click', function() {
		        carousel.prev();
		        return false;
		    });
		};

	  function mycarousel_initCallback(carousel) {
		    jQuery('#mycarouse_zd-next').bind('click', function() {
		        carousel.next();
		        return false;
		    });

		    jQuery('#mycarouse_zd-prev').bind('click', function() {
		        carousel.prev();
		        return false;
		    });
		};
        
        
var rotate = 0;

function loaderRotate(){
    
    rotate = rotate +1;
    $(".img_360").rotate(rotate);
    setTimeout('loaderRotate()', 0.1);    

}

function runRotate(){
    
    $(".img_360").rotate({ 
		   bind: 
		     { 
		        mouseover : function() { 
		            $(this).rotate({animateTo:360});
		        },
		        mouseout : function() { 
		            $(this).rotate({animateTo:0});
		        }
		     } 
		});
}
