function updateCountdownPopis() {
	var remaining = 1000 - $('#popis_cs').val().length;
	$('#countdown_popis_cs').text(remaining);
}

function changeObjekt(target, query) {
	var query = query+'='+$('#objekt_id option:selected').val()+'&editace_text='+$('#editace_text').val();
	var target = target+'?'+query;
	window.location.href = target;
}

$(function(){
	$('#search_query_1').focus();
	$("#tabs").tabs();  
	$('#subscribe').tinyscrollbar();
	$('.monalisa a').lightbox();
	$('.media-grid a').lightbox();
	$('#popis_cs').change(updateCountdownPopis);
	$('#popis_cs').keyup(updateCountdownPopis);
	$('#detail-kontakt').click(function() { 
		htmlObjektKontakty(); 
	});
	$("#text_cs").cleditor({
          width:        855, // width not including margins, borders or padding
          height:       250, // height not including margins, borders or padding
          controls:     // controls to add to the toolbar
                        "bold italic underline strikethrough subscript superscript " +
                        "style removeformat | bullets numbering | " +
                        "alignleft center alignright justify | undo redo | " +
                        "rule link unlink | cut copy paste pastetext | source",
         styles:       // styles in the style popup
                        [["odstavec", "<p>"], 
                        ["Hlavička 3", "<h3>"],  ["Hlavička 4","<h4>"]],
          useCSS:       false, // use CSS to style HTML when possible (not supported in ie)
          bodyStyle:    // style to assign to document body contained within the editor
                        "margin:4px; font: 10pt sans-serif; cursor:text"
	});
	$('.popup').click(function() { 
		return !window.open(this.href);
	});	
	$('.prodlouzit').click(function() {
		var item = this.id;
		item = item.substring(5,100)
  		$('#prodlouzit_'+item).toggle('slow');
  		$(this).toggleClass("prodlouzit_down");
	});	

	$('#mapa-slovensko-odkaz').click(function() {
  		$('#cesko').toggle();
  		$('#slovensko').fadeToggle("slow", "linear");
	});		
	
	$('#mapa-cesko-odkaz').click(function() {
  		$('#slovensko').toggle();
  		$('#cesko').fadeToggle("slow", "linear");
	});		

  	$.datepicker.regional['cs'] = {
		closeText: 'Hotovo',
		prevText: 'Předchozí',
		nextText: 'Další',
		currentText: 'Dnes',
		monthNames: ['Leden','Únor','Březen','Duben','Květen','Červen', 'Červenec','Srpen','Září','Říjen','Listopad','Prosinec'],
		monthNamesShort: ['Le','Ún','Bř','Du','Kv','Čn', 'Čc','Sr','Zá','Ří','Li','Pr'],
		dayNames: ['Neděle','Pondělí','Úterý','Středa','Čtvrtek','Pátek','Sobota'],
		dayNamesShort: ['Ne','Po','Út','St','Čt','Pá','So',],
		dayNamesMin: ['Ne','Po','Út','St','Čt','Pá','So'],
		weekHeader: 'Sm',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''
	};   
	$.datepicker.setDefaults($.datepicker.regional['cs']);
	$( ".datepicker" ).datepicker($.datepicker.regional["cs"]);

});
