var $searchString = 'Vyhledávání';
var $adressString = 'Zadejte Vaší e-mailovou adresu';
$(document).ready(function(){
  
  var query = location.href.split('#');
  if(query[1] != undefined){
    if(query[1] == 'pridat-komentar'){  $(".comment-form").slideToggle('fast');
    }else{
      var $El = $(".answer-"+query[1]);
      $El.slideDown('medium');
      $El.parent().children('h3').children('span').children('a').html("&raquo; skrýt odpověď");
    }
  }
  
	$("#menu .defActive").children('a').css('background-position','bottom center');
	
	$("#menu ul li").mouseover(function(){ if(!$(this).hasClass('defActive') && !$(this).parent().hasClass('sub')){ var $el = $(this).children('a').first('a'); $(this).addClass('active'); $el.css('background-position','bottom center'); } })
	$("#menu ul li").mouseout(function(){ if(!$(this).hasClass('defActive') && !$(this).parent().hasClass('sub')){ var $el = $(this).children('a').first('a'); $(this).removeClass('active'); $el.css('background-position','top center'); } })
	$("a.nw").click(function(){ window.open($(this).attr('href')); return false; })
	$(".submit-button").mouseover(function(){ $(this).addClass('active'); })
	$(".submit-button").mouseout(function(){ $(this).removeClass('active'); })
	$("#breadcrumb li").mouseover(function(){ if(!$(this).hasClass('defActive')){ $(this).addClass('active');} })
	$("#breadcrumb li").mouseout(function(){ if(!$(this).hasClass('defActive')){ $(this).removeClass('active');} })
	$(".paging li").mouseover(function(){ if(!$(this).hasClass('defActive')){ $(this).addClass('active');} })
	$(".paging li").mouseout(function(){ if(!$(this).hasClass('defActive')){ $(this).removeClass('active');} })
	$(".fpnl a").mouseover(function(){ if(!$(this).hasClass('inactive')){$(this).addClass('active')}; })
	$(".fpnl a").mouseout(function(){ if(!$(this).hasClass('inactive')){$(this).removeClass('active')}; })
	
	$("li#blog").mouseover(function(){ $(this).children('ul').first().toggle(); })
	$("li#blog").mouseout(function(){ $(this).children('ul').first().toggle(); })
	$(".hassub").mouseover(function(){ $(this).children('ul').first().toggle(); })
	$(".hassub").mouseout(function(){ $(this).children('ul').first().toggle(); })
	
	$(".searchText").focus(function(){ var $value = $(this).attr('value'); if($searchString == $value){ $(this).attr('value',''); } })
	$(".searchText").blur(function(){ var $value = $(this).attr('value'); if($value == ''){ $(this).attr('value',$searchString); } })
	
	$(".emailAdress").focus(function(){ var $value = $(this).attr('value'); if($adressString == $value){ $(this).attr('value',''); } })
  $(".emailAdress").blur(function(){ var $value = $(this).attr('value'); if($value == ''){ $(this).attr('value',$adressString); } })
  
  $(".faq-name span a").click(function(){ var $el = $(this).parent().parent().parent().children(".faq-answer"); if($el.css('display') == 'block'){ $(this).html("&raquo; zobrazit odpověď"); $el.slideUp('medium'); }else{ $(this).html("&raquo; skrýt odpověď"); $el.slideDown('medium'); } })
  
  $(".show-advice-form").click(function(){ $("#poradna-form").slideToggle('medium'); });
  $("#poradna-form input[name=name]").focusin(function(){ var $val = $(this).val(); if($val == 'Jméno'){ $(this).val(''); } })
  $("#poradna-form input[name=name]").focusout(function(){ var $val = $(this).val(); if($val == ''){ $(this).val('Jméno'); } })
  $("#poradna-form input[name=email]").focusin(function(){ var $val = $(this).val(); if($val == 'E-mail'){ $(this).val(''); } })
  $("#poradna-form input[name=email]").focusout(function(){ var $val = $(this).val(); if($val == ''){ $(this).val('E-mail'); } })
  $("#poradna-form input[name=subject]").focusin(function(){ var $val = $(this).val(); if($val == 'Předmět'){ $(this).val(''); } })
  $("#poradna-form input[name=subject]").focusout(function(){ var $val = $(this).val(); if($val == ''){ $(this).val('Předmět'); } })
  $("#poradna-form textarea[name=message]").focusin(function(){ var $val = $(this).val(); if($val == 'Zde položte dotaz'){ $(this).val(''); } })
  $("#poradna-form textarea[name=message]").focusout(function(){ var $val = $(this).val(); if($val == ''){ $(this).val('Zde položte dotaz'); } })

  $(".comment-form input[name=name]").focusin(function(){ var $val = $(this).val(); if($val == 'Jméno'){ $(this).val(''); } })
  $(".comment-form input[name=name]").focusout(function(){ var $val = $(this).val(); if($val == ''){ $(this).val('Jméno'); } })
  $(".comment-form input[name=email]").focusin(function(){ var $val = $(this).val(); if($val == 'E-mail'){ $(this).val(''); } })
  $(".comment-form input[name=email]").focusout(function(){ var $val = $(this).val(); if($val == ''){ $(this).val('E-mail'); } })
  $(".comment-form textarea[name=text]").focusin(function(){ var $val = $(this).val(); if($val == 'Zadejte Váš komentář'){ $(this).val(''); } })
  $(".comment-form textarea[name=text]").focusout(function(){ var $val = $(this).val(); if($val == ''){ $(this).val('Zadejte Váš komentář'); } })
  
  $(".show-comment-form").click(function(){ $(".comment-form").slideToggle('medium'); })
})

function ValidSearchForm(){
  var $value = $(".searchText").attr('value');
  var $spm = $(".spmCatch").attr('value');
  if($spm != ''){ return false }
  if($value == '' || $value == $searchString){ return false; }
}

function ValidatePoradnaForm(){
  var $response = $("#poradna-form-response");
  var $jmeno = $("#poradna-form input[name=name]").val();
  var $email = $("#poradna-form input[name=email]").val();
  var $predmet = $("#poradna-form input[name=subject]").val();
  var $zprava = $("#poradna-form textarea[name=message]").val();
  var $vek = $("#poradna-form select[name=age]").val();
  var $region = $("#poradna-form select[name=region]").val();
  var $spm = $("#poradna-form input[name=spmCatch]").val();
  if($jmeno == '' || $jmeno == 'Jméno'){ $response.html('Není vyplněno pole <strong>Jméno</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($email == '' || $email == 'E-mail'){ $response.html('Není vyplněno pole <strong>E-mail</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($predmet == '' || $predmet == 'Předmět'){ $response.html('Není vyplněno pole <strong>Předmět</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($zprava == '' || $zprava == 'Zde položte dotaz') { $response.html('Nebyl položen žádný <strong>dotaz</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($vek == '' || $vek == '0') { $response.html('Není vybrán Váš <strong>věk</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($region == '' || $region == '0') { $response.html('Není vybrán Váš <strong>region</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($spm != ''){ return false; }
}

function ValidateCommentForm(){
  var $response = $("#comment-form-response");
  var $jmeno = $(".comment-form input[name=name]").val();
  var $email = $(".comment-form input[name=emaile]").val();
  var $text = $(".comment-form textarea[name=text]").val();
  var $spm = $(".comment-form input[name=spmCatch]").val();
  if($jmeno == '' || $jmeno == 'Jméno'){ $response.html('Není vyplněno pole <strong>Jméno</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($email == '' || $email == 'E-mail'){ $response.html('Není vyplněno pole <strong>E-mail</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($text == '' || $text == 'Zadejte Váš komentář') { $response.html('Nenapsal/a jste žádný <strong>komentář</strong>.'); $response.removeClass('green-bg-1'); $response.addClass('red-bg-1'); $response.show(); return false; }
  if($spm != ''){ return false; }
}

