function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.hover(function() {
    	carousel.options.smer = 'right';
        carousel.options.animation = 800;
        carousel.options.auto = 0.00001;
        carousel.startAuto();
    }, function() {
    	carousel.stopAuto();
    	carousel.options.auto = 0;
    });

    carousel.buttonPrev.hover(function() {
        carousel.options.smer = 'left';
        carousel.options.animation = 800;
        carousel.options.auto = 0.00001;
        carousel.startAuto();
    }, function() {
    	carousel.stopAuto();
    	carousel.options.auto = 0;
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.options.auto = 0;
    }, function() {
    	carousel.options.auto = 0;
    });
};


$(document).ready(function() { 
  
 
 //$("#ask_form").validate();
 //$("#loginf").validate();
 
 $('#toplink').click(function(){
 	$.scrollTo( "#top", 600);
 });
 
 
 $('.fldrname').click(function(){
 	var rel = $(this).attr("rel");
 	$(".fldr_data").hide();
 	$(".fldr"+rel).show();
 	$.scrollTo( "#fldrname"+rel, 800);
 });
   		
   
 function showMsg(div,width,height,time){
 	tb_show('', '#TB_inline?reload=false&height='+height+'&width='+width+'&inlineId='+div+'&modal=true', null, true)
	setTimeout(function(){tb_remove(false)}, time);
 }
 
 function str_replace(haystack, needle, replacement) {
    var temp = haystack.split(needle);
    return temp.join(replacement);
 }
 
 $("#close_tb").click(function(){
 	self.parent.tb_remove('true');
 });
   
 
 $('.c2v').click(function(){
	var rel = $(this).attr("rel");
	if($("#lng").val()=='en'){var conf = 'Are you sure you want to vote for this movie?';}
	if($("#lng").val()=='fr'){var conf = '&Ecirc;tes-vous s&ucirc;r de vouloir voter pour ce film?';}
	
	if(!confirm(html_entity_decode(conf))){
		return false;
	}
	
	$(".vbtns").html('&nbsp;');
	$(".votebtn"+rel).load("ajx_vote_hlasovani.php?vote=" + rel, {limit: 25}, function(){
		alert('thank you');
	});
  });
  
  
  mainmenu();
     
 
});
//konec onload


function html_entity_decode(str) {
  var ta=document.createElement("textarea");
  ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
  return ta.value;
}

function add_cis(cis_name){
 	tb_show('Přidat záznam do číselníku', 'ciselnik.php?fn='+cis_name+'&amp;keepThis=true&amp;TB_iframe=true&amp;reload=false&amp;height=auto&amp;width=auto', null);
}

function ed_cis(cis_name){
 	$("#sel_"+cis_name+" option:selected").each(function () {
 	    tb_show('Upravit záznam v číselníku', 'ciselnik.php?fn='+cis_name+'&amp;id_cis_'+cis_name+'='+$(this).val()+'&amp;keepThis=true&amp;TB_iframe=true&amp;reload=false&amp;height=auto&amp;width=auto', null);
 	});
}


function del_cis(cis_name){
    
    if (!confirm('Opravdu chcete tento záznam vymazat?')){
 		return false;   
    }
    
    $("#sel_"+cis_name+" option:selected").each(function () {
 	  var sel = $(this).val();
 	  
 	  $.ajax({
 	  	type: "GET",
 	  	url: "ajx_ciselnik.php?fn="+cis_name+"&akce=del&id_cis_"+cis_name+"="+sel,
 	  	success: function(){
 	  		$("#sel_"+cis_name).removeOption(/./).ajaxAddOption("ajx_ciselnik.php?fn="+cis_name+"&amp;id_cis_"+cis_name+"="+sel, {}, false, function(){
 	     	//$("#sel_"+cis_name+" option:contains('vyberte')").attr("selected", true);
 	    });
   	   }
     }); 	    
 	});
 
 }
 
 
 
 
 
 
 function get_cis(cis_name,matches){
 
    $("#sel_"+cis_name+" option:selected").each(function () {
   	var idz = $(this).val();
   	//var inputs = ['kp_jmeno', 'kp_email', 'kp_telefon'];
   	var inputs = matches.split(';');
   	
   	$.ajax({
   	 type: "GET",
   	 url: "ajx_cis_data.php",
   	 data: "fn="+cis_name+"&id_cis_"+cis_name+"="+idz+"&m="+matches,
   	 dataType: "xml",
   	 success: function(xml){
		$("element", xml).each(function(){
			
			var ele = this;
			
     		$.each(inputs,function(index,value){
             	$("#inp_"+value).val($(value, ele).text());    		
    		});
			
		});
   	   }
     });   	
    }); 
 }
 
 



function switch_img(id_katalog,imgnr){
	$('#foto').fadeOut("fast");
	setTimeout(function(){
		$('.preload').show();
		setTimeout(function(){
		$("#detail_foto").load("ajx_switchimg.php?id_katalog="+id_katalog+"&imgnr="+imgnr);}
		, 400); $.scrollTo( "#detail_foto", 600);
	}, 400);
}

function switch_img2(id_katalog,imgnr){
	$('#info').hide();
	$('#foto').fadeOut("fast");
	setTimeout(function(){
		$('.preload').show();
		setTimeout(function(){
		$("#detail_foto").load("ajx_detail_gallery.php?id_katalog="+id_katalog+"&imgnr="+imgnr); }
		, 400);
	}, 400);
}


function mainmenu(){
$(".katmenu ul ").css({display: "none"}); // Opera Fix
$(".katmenu li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible"}).show(500);
		//$(document).find('.jcarousel-container:first').css({visibility: "hidden"});
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		//$(document).find('.jcarousel-container:first').css({visibility: "visible"});
		});
}

