	// cookie interstitial
	/*if ($.cookie("full-page-ad")!='true'){
		$.cookie("full-page-ad", "true");
		window.location.href='/interstitial.html';	
	}*/


$(document).ready(function() {
	
	// Jcarousel functions
	function carousel_initCallback(carousel) {
		id = $(carousel.list).attr("id");
    $('.control#'+id+' a').bind('click', function() {
      carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
      return false;
   	})
	};

	function carousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
		id = $(carousel.list).attr("id");
		$('.control#'+id+' a').removeClass("selected");
  	$('.control#'+id+' a:nth-child('+idx+')').addClass("selected"); 
	};

	// Jcarousel
	$(".carousel").jcarousel({
		scroll : 1,
		initCallback: carousel_initCallback,	
		itemVisibleInCallback: {
            onBeforeAnimation: carousel_itemVisibleInCallbackBeforeAnimation
    }
	});

	// Jquery ui tab
	$(".tabs").tabs();

  // Form transform

  $("#plot form, #sidebar form").jqTransform();

  // Sponsors tooltip

  $("#spon a").hover(
  function () {
    alt = $(this).html();
    $(this).parent().prepend($("<div>"+alt+"</div>"));
  },
  function () {
    $(this).parent().children('div').detach();
  });

  // Accordion

  $("#playersaccordion").accordion({
    autoHeight: false,
    collapsible: true,
    active: false
  });

  // National page switch
	$('#national-header #plot div:first-child').show();

  $('#national-header #sidebar p a').click(function(){
    var next = $(this).attr('rel');
    $('#national-header #sidebar p a').removeClass('active');
    $(this).addClass('active');
    cufonReplace();
    $('#national-header #plot>div').hide();
    $('#national-header #plot .'+next).show();
    return false;
  });

  // Active menu
  var path = location.pathname;
  var home = "/";
  $("#header .submenu a[href='" + [path || home] + "']").parent("li").each(function() {
    $(this).addClass("active");
    var wrapper = $(this).children().children();
    var menu = wrapper.html();
    wrapper.html("<img src='/css/images/arrow.png' />"+menu);
  });

  cufonReplace();


});

 // Cufon
  function cufonReplace(){
    Cufon.replace('#calendar h4,.events, .pagination-links, #national-header #sidebar h1,'
				+'#national-header #sidebar p a,.team-name,.gallery-details h3,.media li h4,.media li .date');
  }
 
	// databank form
  function leker_p01_0001(){ 
      document.lap.p_lepes.value      = 1;
      document.lap.p_evad.value       = document.lap.d_evad.value;
      document.lap.p_szervezet.value  = document.lap.d_szervezet.value;
      document.lap.p_verseny_id.value = document.lap.d_verseny_id.value;
      document.lap.p_fordulo.value    = document.lap.d_fordulo.value;
      document.lap.submit();      
  }

