$(document).ready(function()
  {
    // vyber okna
    $('.kalkulator-typy a').click(function() {

      var typ   = $(this).attr('rel');
      var title = $(this).attr('title');
      var image = $(this).children('img').attr('src');

      $('#typ_okna').attr('value', typ);
      $('#produkt-popis').text(title);

      $('#produkt-img').hide(100);
      $('#produkt-img').attr('src', image).show(200);
          
      return false;
    });

    // vyber barva i na obrazku
    $('.barva img').click(function() {
      $(this).parents('.barva').children('input').attr('checked', 'checked');

      return false;
    });

    // na obrazku barvy prstik a nazev barvy
    $('.barva img').hover(function() {
      var barva = $(this).parents('.barva').children('input').attr('value');

      $(this).css('cursor', 'pointer');
      $(this).attr('title', barva);
    });

    // prstik na radio buttonech
    $('.option-barva1 *').hover(function() {
      $(this).css('cursor', 'pointer');
    });
    $('.option-barva2 *').hover(function() {
      $(this).css('cursor', 'pointer');
    });
    
    //$('.option-barva2 input').attr('type', 'input');
    // vsechny checkboxy na radio
    $('.option-barva2 input[type="checkbox"]').each (function() {
      this.type = 'radio';
    });

    // kontrolovat radio a prepinat ho jako checkboxy
    $('.option-barva1 p').click(function() {
      $(this).children('input').attr('checked', 'checked');
    });
    $('.option-barva2 p').click(function() {
      if ($(this).children('input').hasClass('checked')) {
        $(this).children('input').removeAttr('checked');
        $(this).children('input').removeClass('checked');
      } else {
        $(this).children('input').attr('checked', 'checked');
        $(this).children('input').addClass('checked');
      }
    });
    

    // lokalita
    var $textik = "Vyplňte prosíme lokalitu"

    if (!$(this).attr("value")) {
      $(this).attr("value", $textik);
    }

    $("#lokalita").blur(function () {
      if (!$(this).attr("value")) {
        $(this).attr("value", $textik);
      }
    })
    $("#lokalita").focus(function () {
      if ($(this).attr("value") == $textik) {
        $(this).attr("value", "");
      }
    })

  });

