$(function() {
	$.datepicker.regional['cs'] = {
                closeText: 'Zavřít',
                prevText: 'Předchozí',
                nextText: 'Další',
                currentText: 'Hoy',
                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").live('hover', function(){
        $(this).datepicker();
    });


	//Confirmation dialog
	$('a.confirm_dlg').live('click', function(e) {
        e.preventDefault();

        if (confirm( $(this).data('confirm') )) {
            $.get(this);
        }
    });


	//Toggle box
	$('.toggle_box').live('click', function(e) {
		$('#'+$(this).data('element')).slideToggle(500);

		return false;
	});


	//Carousel item
	$('.jcarousel-item a').live('click', function(e) {
		$('.jcarousel-item a').removeClass('active');
		$(this).addClass('active');

		$('a[rel="colorbox"]').css('display', 'none');
		$('a#img_'+$(this).attr('rel')).css('display', 'block');

		return false;
	})



	//formSearch
	$('form.form_search_big select[name="type"]').live('change', function() {
		var value = $(this).val();

		$('table.subtype').hide();

		$('table#subtype'+value).show();
	});


	//formOrdering
	$('form.form_ordering select[name="items"]').live('change', function() {
		$('form.form_ordering').submit();
	});


	//formOrdering
	$('a.a_order').live('click', function(e) {
		e.preventDefault();

		$('form.form_ordering input[name="o_dir"]').val($(this).attr('rel'));
		$('form.form_ordering').submit();
	});
	
	
	//form spam
	$('input[data-spam2]').each(function() {
        $(this).val( $(this).data('spam2') ).hide();
    });
	
	//form spam2
	$('input[data-spam]').each(function() {
        $(this).val( $(this).data('spam') ).closest('tr').hide();
    });
});


function showAddress(address, title, zoom, id, icon_ext, width, height) {
	var map = new GMap2(document.getElementById("map_canvas"));
  var geocoder = new GClientGeocoder();
  var WINDOW_HTML = '<div style="font-size:11px;"><strong>'+title+'</strong><br />'+address+'<\/div>';

  map.addControl(new GSmallMapControl());

  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        //alert(address + " not found");
      } else {
        map.setCenter(point, zoom);

        if(icon_ext != "") {
          var myIcon = new GIcon(G_DEFAULT_ICON);
          myIcon.image = "/images/articles/icons/"+id+"."+icon_ext;
  		    myIcon.iconSize = new GSize(width, height);
  		    myIcon.iconAnchor = new GPoint(width/2, height);
  		    myIcon.shadow = "";

      		// Set up our GMarkerOptions object
      		markerOptions = { icon:myIcon };

      		var marker = new GMarker(point, markerOptions);

        } else {
          var marker = new GMarker(point);
        }

        map.addOverlay(marker);
        GEvent.addListener(marker, "click", function() {
        	marker.openInfoWindowHtml(WINDOW_HTML);
	      });
      }
    }
  );
}
