function mycarousel_itemVisibleInCallbackAfterAnimation_dotsfive(carousel, item, idx, state) {

	var title = parseInt($(this).attr('title'));

	var index = Math.ceil(idx / 5.0).toFixed(0);

	var paging = $(item).parent().parent().parent().parent().parent().next();

	$(paging).find('a').removeClass('active');

	$(paging).find('a[title="'+index+'"]').addClass('active');

};



function mycarousel_itemVisibleInCallbackAfterAnimation_dots(carousel, item, idx, state) {

	var title = parseInt($(this).attr('title'));

	var index = Math.ceil(idx / 4).toFixed(0);	



	var paging = $(item).parent().parent().parent().parent().parent().next();

	$(paging).find('a').removeClass('active');

	$(paging).find('a[title="'+index+'"]').addClass('active');

};



function mycarousel_initCallback_small(carousel) {

	$('.small-slider .jcarousel-control a').bind('click', function() {

		var title = parseInt($(this).attr('title'));

		var index = (title - 1) * 5 + 1;

		$('.small-slider .jcarousel-control a').removeClass('active');

		$($(this)).addClass('active');

		carousel.scroll($.jcarousel.intval(index));

		return false;

	});	    

};



function mycarousel_initCallback_main(carousel) {

	$('.main-slider .jcarousel-control a').bind('click', function() {

		var title = parseInt($(this).attr('title'));

		var index = (title - 1) * 4 + 1;

		$('.main-slider .jcarousel-control a').removeClass('active');

		$($(this)).addClass('active');

		carousel.scroll($.jcarousel.intval(index));

		return false;

	});	    

};



function mycarousel_initCallback_ms_main(carousel) {

	$('.ms.main-slider.onerow .jcarousel-control a').bind('click', function() {

		var title = parseInt($(this).attr('title'));

		var index = (title - 1) * 4 + 1;

		$('.ms.main-slider.onerow .jcarousel-control a').removeClass('active');

		$($(this)).addClass('active');

		carousel.scroll($.jcarousel.intval(index));

		return false;

	});	    

};



function mycarousel_initCallback_ms_main_tworows(carousel) {

	$('.ms.main-slider.tworows .jcarousel-control a').bind('click', function() {

		var title = parseInt($(this).attr('title'));

		var index = (title - 1) * 4 + 1;

		$('.ms.main-slider.tworows .jcarousel-control a').removeClass('active');

		$($(this)).addClass('active');

		carousel.scroll($.jcarousel.intval(index));

		return false;

	});	    

};



function fbButton(url_dir,rdu) {

	$(".fb-button").append('<iframe src="http://www.facebook.com/plugins/like.php?app_id=148996522616&amp;href&amp;send=false&amp;layout=button_count&amp;width=120&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=20&amp;href='+url_dir + rdu +'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:120px; height:35px;" allowTransparency="true"></iframe>');

}



//--------------------------------------------------------------------------

$(document).ready(function() {


    if ($(".userLoginError").length > 0 )
    {   
        var hay_stack_string = ($(".userLoginError").html());
        var substr_count = hay_stack_string.split('Hesla nejsou stejná').length - 1;
        
        if (substr_count)
        {
            $(".userLoginError").html('<span>Hesla nejsou stejná</span>');
        }

        
    }
  	$(".link-newwin").attr('target','_blank');		



	$('input[type=text],[type=password]').focus(function(event){

		if ($(this).attr('value') == $(this).attr('title')) {

			$(this).attr('value','');

		}

		$(this).addClass('focus');

	});



	$('input[type=text],input[type=password]').blur(function(event){

		if ($(this).attr('value') == '') {

			$(this).attr('value',$(this).attr('title'));

		}

		$(this).removeClass('focus');

	});

	$(".small-slider .slider").jcarousel({

		scroll:5,

		dispItems:5,

		initCallback: mycarousel_initCallback_small,

		itemVisibleInCallback: { onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation_dotsfive },

		loop: false

	});



	$(".ms.main-slider.onerow .slider").jcarousel({

		scroll:4,

		dispItems:4,

		initCallback: mycarousel_initCallback_ms_main,

		itemVisibleInCallback: { onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation_dots },

		loop: false

	});



	$(".ms.main-slider.tworows .slider").jcarousel({

		scroll:4,

		dispItems:4,

		initCallback: mycarousel_initCallback_ms_main_tworows,

		itemVisibleInCallback: { onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation_dots },

/*		animationStepCallback: function() {

			alert("ano");

		},*/

		loop: false

	});



	$(".main-slider .slider").jcarousel({

		scroll:4,

		dispItems:4,

		initCallback: mycarousel_initCallback_main,

		itemVisibleInCallback: { onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation_dots },

		loop: false

	});



	$('.filter.home select').selectmenu({width:206,style:'dropdown',maxHeight:220});

	$('.filter.side select').selectmenu({width:185,style:'dropdown',maxHeight:220});



	$(".gallery a").fancybox();

	

	$('.training-topic a').click(function() {

		if ($(this).hasClass('selected')) {

			$(this).removeClass('selected')

			$(this).next().slideUp('fast');		

		} else {

			$(this).addClass('selected');

			$(this).next().slideDown('slow');		

		}

	});



	$('.training-topic .item-content').hide();	

	$('.training-topic a.selected').next().show();



	$(".table-trainings a.button-clock").click(function(){

		if ($(this).hasClass("active")) {

			$(this).removeClass("active")

		} else {

			$(this).addClass("active")

		}

	});



	// Vygenerování HTML pro kroků číslovaný seznam

	var krok = 1;

	jQuery(".content-left ol").each(function(){

		jQuery(this)

		.css("listStyleType", "none")

		.find("> li").each(function(i){

			jQuery(this).prepend('<span class="step">'+ (krok++) +'.</span>');

		});

	});



	$('#menu .heading a').click(function(){

		var anchor = jQuery(this);

		$('#menu .tab').addClass("hidden");

		$(anchor.attr("href")).removeClass("hidden");

		return false;

	});	

	

	$(".checkbox input[type='checkbox']").css("left","-10000px");

	

	$("#menu .heading a").click(function(){

		$("#menu .heading a").removeClass("active");

		$(this).addClass("active");

	});



	$("a.linkSwf").fancybox({

	    'padding'           : 0,

	    'width'				: 800,

	    'height'			: 600,

        'autoScale'     	: true,

        'transitionIn'		: 'none',

		'transitionOut'		: 'none'

	});

		

	var margTop = ($(".cont-ora-right .price").height() - $(".cont-ora-right .price .right ul").height()) / 2; 

	$(".cont-ora-right .price .right ul").css("marginTop",margTop-3);





	 var anchors = document.getElementsByTagName("a");

	 for (var i=0; i<anchors.length; i++) {

	   var anchor = anchors[i];

	   if (anchor.getAttribute("href") &&

	       anchor.getAttribute("rel") == "external")

	     anchor.target = "_blank";

	 }





	$('#form-customer #same_as').click(function() {

		if ($('#same_as').attr('checked') != 'checked') {

			$('#delivery_address').removeClass('disabled');

			$('#delivery_address input').removeAttr('disabled');

		} else {

			$('#delivery_address').addClass('disabled');

			$('#delivery_address input').attr('disabled','disabled');

		}

	});



});



// funkce pro testování - vybere pražskou pobočku

function testerChanged(kdo, kam)

{

	var val = document.getElementById(kdo).value;

	var el = document.getElementById(kam);

	var volby = el.options;

	if (val == "Pearson-VUE")

	{

		el.options.length = 0;

		el.options[0] = new Option('Praha', 'Praha');

	}

	else

	{

		el.options.length = 0;

		el.options[0] = new Option('', '');

		el.options[1] = new Option('Brno', 'Brno');

		el.options[2] = new Option('Praha', 'Praha');

	}

}
