//FCE
function isEmail(elem){
	var emailExpression = /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/;
	if(elem.match(emailExpression)){
		return true;
	}else{
		return false;
	}
}

function proved_md5()
  {
  	try
  	{
  		objektHeslo       = document.getElementById('authHeslo');
  		objektHash        = document.getElementById('authHash');
  		objektHash.value  = MD5(objektHeslo.value);
  		objektHeslo.value = "";
  		return true;
  	}
  	catch(e)
  	{ 
  		alert("Nelze se přihlásit. Prosím kontaktujte uživatelskou podporu.");
  		return false;
  	}
}


function video_slideshow(id, pic, max) {

    var pic_next = (pic < max) ? (pic + 1) : 1; 
    $(id + ' a').not('#video' + pic).hide();
    $('#video' + pic_next).show();
    $('#video' + pic).fadeOut(700, function() {
        $(this).hide().css('z-index', (parseInt($(this).css('z-index')) - 10));
        setTimeout(function() {video_slideshow(id, pic_next, max);}, 10000);
    });
}


//man 
$(document).ready(function(){
  
    if ($('#video-box').length) {
        setTimeout(function() {video_slideshow('#video-box', 1, $('#video-box a').length);}, 10000);
    }
    if ($('#video-box-sp').length) {
        setTimeout(function() {video_slideshow('#video-box-sp', 1, $('#video-box-sp a').length);}, 10000);
    }

    //form
    $("input").click(function () { 
       $(this).attr({ value: ""});  
       return false;
    });   

    $("textarea").click(function () {
       $(this).text("");  
       return false;
    });

$("form#kontaktni-formular").submit(function(){
  
  if ((($("input#jmeno_zprava_navstevnika").attr("value")!='Jméno, Příjmení')) && (($("input#jmeno_zprava_navstevnika").attr("value")!=''))) {
    
    if ((($("input#email_zprava_navstevnika").attr("value")!='Email')) && (($("input#email_zprava_navstevnika").attr("value")!='')) && (isEmail($("input#email_zprava_navstevnika").attr("value")))) {
      
      if ((($("textarea#prispevek_zprava_navstevnika").attr("value")!='Vaše zpráva')) && (($("textarea#prispevek_zprava_navstevnika").attr("value")!=''))) {
        return true;
      } else {
        alert ("Zadejte prosím Vaši zprávu.");
        return false;
      }
    } else {
      alert("Zadejte prosím platnou Vaši e-mailovou adresu.");
      return false;  
    }
  } else {
    alert("Zadejte prosím Vaše jméno");
    return false;
  }
  
  
});     
     
//menu
  $("#blokL1 img, #hlavniMenu img, #prvniCastMenu img").hover(function() {
     if ($(this).attr("src").indexOf("_hover")>0) {
      $(this).attr("src", $(this).attr("src").split("_hover.").join("."));
     } else { 
       $(this).attr("src", $(this).attr("src").split(".").join("_hover."));
     }
    }, function() {
     if ($(this).attr("src").indexOf("_hover")>0) {
      $(this).attr("src", $(this).attr("src").split("_hover.").join("."));
     } else { 
       $(this).attr("src", $(this).attr("src").split(".").join("_hover."));
     }
    });

//gallery    
    $("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").prettyPhoto({
							animationSpeed: 'normal',
							padding: 40, 
							opacity: 0.35, 
							showTitle: true,
							allowresize: true,
							counter_separator_label: '/' 
						});
						
    var max_tvar = 1;
    $('#plus, #minus').click(function() {
        
        var tvar = parseInt($('#tvare')[0].className.replace('tvar_', ''));
        var direction = this.id;
        $('#tvare').fadeOut(150, function() {
            if (direction == 'plus') {
                this.className = 'tvar_' + ((tvar < max_tvar) ? ++tvar : 1);
            }
            else {
                this.className = 'tvar_' + ((tvar > 1) ? --tvar : max_tvar);                
            }
            $(this).fadeIn(150);
        });               
        return false;
    }); 

    $('#menu-media li').mouseover(function() {
        $('#menu-media li').removeClass('active');
        var css = this.className.replace(/.*([0-9])+.*/i, '$1');
        $(this).addClass('active');
        $('#logo')[0].className = 'logo' + css; 
    });
  
  
  });



