function replaceComboboxes(el, submit_name) {
  $('#'+el+" select").each(function(idx, combo){
    if ($(combo).hasClass('noselect')) return;
    var selectedValue = combo.options[combo.selectedIndex].innerHTML;
    var html = '<div class="input" id="'+combo.id+'">'+
                 '<input type="hidden" name="'+combo.name+'" value="'+combo.value+'" />'+
                 '<div class="field-combo">'+
                   '<div class="value">'+selectedValue+'</div>'+
                   '<div class="arrow"></div>'+
                   '<ul class="options" style="display: none">';

    $(combo).find('option').each(function(idx, option){
      html += '<li class="option" rel="'+option.value+'">'+option.innerHTML+'</li>';
    });
    html += '</ul></div></div>';

    var callback = (typeof submit_name !== "undefined" && $(combo).hasClass(submit_name)) ? function(val){
      $('#'+el+' form input').val('');
      $('#'+combo.id+' input').val(val);
      $('#'+el+' form').submit();
    } : undefined;

    $(combo).replaceWith(html);
    createComboBox(combo.getAttribute('id'), callback);
  });
}


function createComboBox(el, selectCallback){
  el = $("#"+el);
  var value = el.find('.value').eq(0);
  var arrow = el.find('.arrow').eq(0);
  var options = el.find('.options').eq(0);


  // po kliknuti na sipku oznac polozku, ktera je vypsana nahore
  var slideDown = function(event){
    // BUG FIX IE7
    // http://www.quirksmode.org/bugreports/archives/2006/01/Explorer_z_index_bug.html
    //
    // musime nadrazenemu prvku nastavit vetsi z-index, nez maji prvky v nem
    if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 7) {
      var show = options.css('display') == 'none';
      el.css({
        'z-index': show ? '3000' : '',
        position: show ? 'relative' : 'static'
      });
    }


    if (options.css('display') == 'none') {
      options.find('.option.active').removeClass('active');
      options.find('.option:contains('+value.text()+')').addClass('active');
    }
    options.slideToggle('fast');

    event.stopPropagation();
  };

  arrow.click(slideDown);
  value.click(slideDown);

  // po kliknuti kamkoliv mimo combobox zrus vyber
  $('body').click(function(e){
    if (options.css('display') == 'block') {
      var t = jQuery(e.target);
      if (t.get(0) !== arrow.get(0) && !t.hasClass('option')) {
        options.slideUp('fast');
      }
    }
  });

  // po prejizdeni mysi men aktivni polozku
  options.find('.option').mouseenter(function(){
    options.find('.option.active').removeClass('active');
    var t = $(this).addClass('active');

    // v IE8 se neprojevi zmena classu, pokud najizdim na element, ktery je polopruhledny
    // nebo na element obsazeny v polopruhlednem elementu
    //
    // na elegantni reseni tohoto problemu zatim jeste nikdo neprisel
    // https://prototype.lighthouseapp.com/projects/8886/tickets/660-ie8-does-not-fireregister-mouseover-on-semi-transparent-div
    //
    // proto pouziji svuj hack, ktery sice mirne zatizi procesor, ale aspon to funguje
    if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 8) {
      t.text(t.text());
    }

  // po kliknuti vypln hodnotu
  }).click(function(){
    options.slideUp('fast');

    var option = jQuery(this);
    var current_val = option.text();
    value.text(current_val);

    // hledame od-do
    var val = option.attr('rel');
    el.find('input').eq(0).val(val);

    if (typeof selectCallback == "function") {
      selectCallback(val);
    }
  });
}


function newsletterConfirm(btn, text) {
  // nefunguje parent('form'), asi bug v jQuery
  var email = $(btn).parent().parent().find('.email-wrapper input').val();
  return confirm(text.replace("%s", email));
}


/* namespace, predevsim pro praci s google maps */
PST = {
  createGoogleMap: function(id, markers) {
    PST.map = new google.maps.Map(document.getElementById(id), {
      zoom: 7,
      center: new google.maps.LatLng(49.77417, 15.5896),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    PST.infowindow = new google.maps.InfoWindow();
  },

  // prida ikonku do mapy, vyzaduje Shadowbox v pripade ze se v html nachazi obrazky!
  createMarker: function(coords, html, title, icon_url){
    coords = coords.split(',');

    var marker = new google.maps.Marker({
      position: new google.maps.LatLng(parseFloat(coords[0]), parseFloat(coords[1])),
      map: PST.map,
      icon: new google.maps.MarkerImage(
        icon_url,
        new google.maps.Size(13,14)
      ),
      flat: true,
      title: title
    });

    google.maps.event.addListener(marker, 'click', function() {
      PST.infowindow.setContent(html);
      PST.infowindow.open(PST.map, marker);

      // otevreme obrazky ve shadowboxu
      var images = jQuery("a[rel^='shadowbox']");
      // oprava bugu shadowboxu + chrome - shadowbox se sice zobrazi ale nevrati false
      images.click(function(){ return false; });
      if (images.length > 0) {
        Shadowbox.clearCache(); // FIXME: cache se nemaze
        Shadowbox.setup(images);
      }
    });
  }
};


// overeni podporovaneho prohlizece
(function() {
	if (jQuery.jCookie('skipUnsupported') == "true") return false;

	var b = jQuery.browser;
	var allowed =
		b.mozilla || b.chrome || b.opera || b.safari ||
		(b.msie && parseInt(b.version) >= 7);

	if (!allowed) {
    Shadowbox.init({
      skipSetup: true
    });

		$(document).ready(function(){
      var text = '<p>Váš prohlížeč bohužel nepatří mezi podporované prohlížeče. Některé sekce se nemusí zobrazit správně a mohou se vyskytnout různé komplikace. <strong>Doporučujeme proto používat jeden z následujících internetových prohlížečů</strong>:</p>'+
                '<ul>'+
                '<li><a href="http://www.google.cz/chrome" title="Google Chrome">Google Chrome</a></li>'+
                '<li><a href="http://www.mozilla-europe.org/cs/firefox/" title="Mozilla Firefox">Mozilla Firefox</a></li>'+
                '<li><a href="http://www.opera.com/" title="Opera">Opera</a></li>'+
                '<li><a href="http://www.apple.com/safari/" title="Apple Safari">Apple Safari</a></li>'+
                '<li><a href="http://www.microsoft.com/cze/windows/internet-explorer/" title="Microsoft Internet Explorer">Microsoft Internet Explorer verze 7 a vyšší</a></li>'+
                '</ul>'+
                '<p>Děkujeme za pochopení.</p>'+
                '<p>Pokud si stránky přesto chcete prohlédnout, <a href="#" onclick="Shadowbox.close();jQuery.jCookie(\'skipUnsupported\',\'true\');return false;">pokračujte zde</a>.</p>';
      var title = "Váš prohlížeč není podporován";

      // anglicka verze
      if ($("#main.locale-en").length > 0) {
        text = '<p>Your browser is not a supported browser. Some sections may not appear correctly and you may experience various complications. <strong>We recommend using one of these browsers</strong>:</p>'+
                '<ul>'+
                '<li><a href="http://www.google.cz/chrome" title="Google Chrome">Google Chrome</a></li>'+
                '<li><a href="http://www.mozilla-europe.org/en/firefox/" title="Mozilla Firefox">Mozilla Firefox</a></li>'+
                '<li><a href="http://www.opera.com/" title="Opera">Opera</a></li>'+
                '<li><a href="http://www.apple.com/safari/" title="Apple Safari">Apple Safari</a></li>'+
                '<li><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx" title="Microsoft Internet Explorer">Microsoft Internet Explorer version 7 or higher</a></li>'+
                '</ul>'+
                '<p>Thank you for your understanding.</p>'+
                '<p>If you still want to see the site, <a href="#" onclick="Shadowbox.close();jQuery.jCookie(\'skipUnsupported\',\'true\');return false;">click here</a>.</p>';
        title = "Your browser is not supported";
      }

			var open = function(){
				Shadowbox.open({
					content:
						'<div class="unsupported-browser">'+
            text+
						'</div>',
					player:     "html",
					title:      title,
					height:     300,
					width:      500
				});
			};

			// pockame az se nacte shadowbox
			setTimeout(open, 100);
		});
	}
})();