$(function() {
//Dialog zobrazující stav kontaktního formuláře
  $("#message").delay(3000).dialog({autoOpen: true, show: "fade", hide: "fade", modal: true, resizable: false, minHeight: 30});
  setTimeout(function() {$("#message").dialog( "close" );}, 4000);
});
  
$(document).ready(function(){

//Záložky v detailu produktu
$( "#produkt-detail-tabs" ).tabs();

// Script pro inputbox
$('.loginField')
.focus(function(){
  var $this = $(this);
  if ($this.val() == $this.attr('title')) {
    $this.val('').removeClass('dimmed');
    $this.val('').addClass('written');
  }
})
.blur(function(){
  var $this = $(this);
  if ($this.val().length == 0){
    $this.val($this.attr('title')).removeClass('written');
    $this.val($this.attr('title')).addClass('dimmed');
  }
});
});
 

// Skrytí login okna při kliknutí mimo
$(document).click(function(event) {
         if ($("#loginBox").is(":visible")){ 
           if ( $(event.target).closest('#loginBox, #clickLogin').get(0) == null ) { $("#loginBox").slideUp("slow"); }
          } 
});
// Skrytí registration okna při kliknutí mimo
$(document).click(function(event) {
         if ($("#registrationBox").is(":visible")){ 
           if ( $(event.target).closest('#registrationBox, #clickRegistration').get(0) == null ) { $("#registrationBox").slideUp("slow"); }
          } 
});
// Skrytí kontakt okna při kliknutí mimo
$(document).click(function(event) {
         if ($("#contactFormBox").is(":visible")){ 
           if ( $(event.target).closest('#contactFormBox, #contactButton').get(0) == null ) { $("#contactFormBox").animate({width:'toggle'}); }
          } 
});




// Script pro otevření vyskakovacího login a registračního okna
       $(document).ready(function(){
                // Přihlašovací okno
                $("#clickLogin").click(function(){
                    if ($("#registrationBox").is(":visible")){
                          if ($("#loginBox").is(":hidden")){
                             $("#loginBox").delay(600).slideDown("slow");
                                                           }
                                else{
                                  $("#loginBox").slideUp("slow");
                                    } 
                          }
                    else  {
                          if ($("#loginBox").is(":hidden")){
                             $("#loginBox").slideDown("slow");
                                                           }
                          else{
                             $("#loginBox").slideUp("slow");
                              }
                          } 
                });
             
                // Registrační okno
                $("#clickRegistration").click(function(){
                    if ($("#loginBox").is(":visible")){
                          if ($("#registrationBox").is(":hidden")){
                             $("#registrationBox").delay(600).slideDown("slow");
                                                           }
                                else{
                                  $("#registrationBox").slideUp("slow");
                                    } 
                          }
                    else  {
                          if ($("#registrationBox").is(":hidden")){
                             $("#registrationBox").slideDown("slow");
                                                           }
                          else{
                             $("#registrationBox").slideUp("slow");
                              }
                          } 
                }); 
                
                //Kontaktní formulář
                $("#contactButton").click(function(){
                          if ($("#contactFormBox").is(":hidden")){
                             $("#contactFormBox").animate({width:'toggle'});
                                                           }
                          else{
                             $("#contactFormBox").animate({width:'toggle'});
                              }          
                });
                            
                
            }); 
            


// Script pro password field  LOGIN
 $(document).ready(function() {

	$('#loginHeslo-clear').show();
	$('#loginHeslo').hide();

	$('#loginHeslo-clear').focus(function() {
		$('#loginHeslo-clear').hide();
		$('#loginHeslo').show();
		$('#loginHeslo').focus();
	});
	$('#loginHeslo').blur(function() {
		if($('#loginHeslo').val() == '') {
			$('#loginHeslo-clear').show();
			$('#loginHeslo').hide();
		}
	});

	$('.default-value').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});

});


// Script pro password field  REGISTRACE
 $(document).ready(function() {

	$('#registrationHeslo-clear').show();
	$('#registrationHeslo').hide();

	$('#registrationHeslo-clear').focus(function() {
		$('#registrationHeslo-clear').hide();
		$('#registrationHeslo').show();
		$('#registrationHeslo').focus();
	});
	$('#registrationHeslo').blur(function() {
		if($('#registrationHeslo').val() == '') {
			$('#registrationHeslo-clear').show();
			$('#registrationHeslo').hide();
		}
	});

	$('.default-value').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});

});



