$(document).ready(function() {
    
  iframeFix(); 
  specialsCarouselInit();
  partnersCarouselInit();
  menuHover();
  expandImg();
   
});


function iframeFix() { 
  if($('iframe').length != 0){
    $("iframe").each(function(){
         var ifr_source = $(this).attr('src');
         var wmode = "wmode=transparent";
         if(ifr_source.indexOf('?') != -1) $(this).attr('src',ifr_source+'&'+wmode);
         else $(this).attr('src',ifr_source+'?'+wmode);
     });
   }
}


function specialsCarouselInit() {
  if ($('#specials .carousel div').length != 0) {  
  $("#specials .carousel div").jCarouselLite({
      btnNext: "#specials .next",
      btnPrev: "#specials .prev",
      circular: true,
      auto: 2000,
      pause: 1,
      visible: 4,
      speed: 1000,
      scroll: 2
    });
    }
}

function partnersCarouselInit() {
  if ($('#partners .carousel div').length != 0) {  
  $("#partners .carousel div").jCarouselLite({
      btnNext: "#partners .next",
      btnPrev: "#partners .prev",
      circular: true,
      auto: 2000,
      pause: 1,
      visible: 6,
      speed: 1000,
      scroll: 1
    });
    }
}

function menuHover(){
  $('header nav a').hover(
    function()
    {
      $(this).stop(false, true).animate(
        { 
        color: '#96dcff',
        borderBottomColor: '#96dcff'         
        }, 350)
    },
    function()
    {
      $(this).stop(false, true).animate(
        { 
        color: '#fff',
        borderBottomColor: '#58bdff'      
        }, 350);
    }
  );
}

function bottomLinksHover(){
  $('#bottom_links .allegro > a').hover(
    function()
    {
      $(this).stop(true).animate(
        { 
        backgroundColor: '#aaaaaa'         
        }, 150)
    },
    function()
    {
      $(this).stop(true).animate(
        { 
        backgroundColor: '#58bdff'      
        }, 150);
    }
  );
  
   $('#bottom_links .bsport > a').hover(
    function()
    {
      $(this).stop(true).animate(
        { 
        backgroundColor: '#aaaaaa'         
        }, 150)
    },
    function()
    {
      $(this).stop(true).animate(
        { 
        backgroundColor: '#0b53a3'      
        }, 150);
    }
  );
}

function expandImg() { 
   if ($('.gallery a').length != 0) {
    $('.gallery a').hover(function(){
        $(this).append('<span class="enlarge" style="top: 50%; left: 50%; margin: -24px 0 0 -24px"><img src="img/expand.png" /></span>');
        $(this).find('.enlarge').css({'display':'block'});   	
    },function(){
        $(this).find('.enlarge').remove();
    });    
  }
}
