$(function(){
  Vycisti(1);
  $('#webdesign').addClass('selected');
  $('#webdesign span').html('&rsaquo; ');
	Cufon.replace('h2,h3,h4,.cuf-text',{hover: true });	
  
  $('#button_napiste').click(function(){
		scrollDown();
	});
	
	function Vycisti(stav) {
    if (stav != 1) {
      $('#webdesign').removeClass('selected');
		  $('#webdesign span').empty();
		  $('#box_webdesign').hide();
    }
    if (stav != 3) {
      $('#programovani').removeClass('selected');
		  $('#programovani span').empty();
		  $('#box_prog').hide();
    }
    if (stav != 2) {
      $('#letaky').removeClass('selected');
		  $('#letaky span').empty();
		  $('#box_print').hide();
    }
    Cufon.refresh();
  }
	
	$('#letaky').click(function(){
		Vycisti(2);
    $('#box_print').show(1000);
		$(this).addClass('selected');
		$('#letaky span').html('&rsaquo; ');
		return false;
	});
	$('#webdesign').click(function(){
	  Vycisti(1);
		$('#box_webdesign').show(1000);
    $('#webdesign').addClass('selected');
    $('#webdesign span').html('&rsaquo; ');
    return false;
	});
	$('#programovani').click(function(){
	  Vycisti(3);
		$('#box_prog').show(1000);
    $('#programovani').addClass('selected');
    $('#programovani span').html('&rsaquo; ');
    return false;
	});
  
  function scrollDown(){
    $('html, body').animate({
      scrollTop: $('.kontakt').offset().top
    }, 2000);
  }
  
  function scrollDown2(){
    $('html, body').animate({
      scrollTop: $('#webdesign').offset().top
    }, 1500);
  }
  
  function scrollUp2(){
    $('html, body').animate({
      scrollTop: $('#letaky').offset().top
    }, 1500);
  }
  
  $('#dialog').dialog({
			autoOpen: false,
			width: 450,
			modal: true,
			buttons: {
				"OK": function() { 
					$(this).dialog("close"); 
				} 
			}
		});
		
  $('#val_form :submit').click(function () {
		
    if ($('#val_form').valid()) {
      $('#dialog').html('<p align="center"><img src="./images/ajax-loader.gif" /></p>');
      $('#dialog').dialog("open");
      $.post('SendMail.php', $('#val_form').serialize(), function (data) {
        $('#dialog').empty();
        $('#dialog').append(data);
        
        $('#jmeno').attr('value','');
        $('#email').attr('value','');
        $('#vzkaz').attr('value','');
        
  		},'html');
    }
    return false;
  });
  

  
  $('#val_form').validate();

	
});



