$(function() {
  $('.target-blank').click(function (e) {
    window.open(this.href);
    return false;
  });
});

jQuery(document).ready(function() {
  if ($('#rizek-glider').length) {
     $('#toprounds').corner('5px tl tr "cc:#F8F6F7"');
     $('#bottomrounds').corner('5px bl br "cc:#F8F6F7"');
}

function logo_anim_complete(){
	 $('#banner-footer a').hide();
}
	
  $('#banner-footer a').click(function (e) {
$(".banner-cnt").stop().animate({height:'530'},{queue:false, duration:600,complete:logo_anim_complete});
	return false;
  });
  
  /*
  $('#banner-footer a').mouseover(function (e) {
	this.stop().animate({height:'100'},{queue:false, duration:600});

  });  */
  

  //moodal win
  
  $('.fialova a#chcitaky').click(function (e) {
    e.preventDefault();
  	$('#dialog').modal();
  	this.hide();
  });
  
  $('.fialova a.chcitaky').click(function (e) {
    e.preventDefault();
  	$('#dialog').modal();
  	this.hide();
  });
  
  //external hrefs
  $('#content a').filter(function() {   
    return this.hostname && this.hostname !== location.hostname && $(this).attr('class')!='lightwindow';   
  }).addClass('external').click(function() {   
    window.open(this.href);
    return false;
  });
  
  $('#prehled a').click(function() { 
    window.open(this.href,'_self');
    //alert(this.href);
  }); 
  
  $('.prehled a').click(function() { 
    window.open(this.href,'_self');
    //alert(this.href);
  }); 
  
  $('#detail a').click(function() { 
    window.open(this.href,'_self');
    //alert(this.href);
  });  
  
  $('.detail a').click(function() { 
    window.open(this.href,'_self');
    //alert(this.href);
  });  
  
  //ajax form
	$("#z_submit").click(function(){					   				   
		$(".error").hide();
    //getUrchinTracker("/registrace-dm");
    _gaq.push(['_trackEvent', 'Formulare', 'Registrace DM', $(this).attr('id')]);
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var emailToVal = $("#z_email").val();
		if(emailToVal == '') {
			$("#emailTo").after('<span class="error">Prosím, vložte emailovou adresu, na kterou chcete zpravodaj zasílat.</span>');
			hasError = true;
		} else if(!emailReg.test(emailToVal)) {	
			$("#emailTo").after('<span class="error">Prosím, vložte email ve správném formátu.</span>');
			hasError = true;
		}
		
		if(hasError == false) {
			$(this).hide();
			$("#sendEmail li.buttons").append('<img src="/fileadmin/virtua_sys/img/loading.gif" alt="Odesílám" id="loading" />');
			
			$.post("/fileadmin/virtua_sys/inc/regmail.php",
   				{ z_email: emailToVal },
   					function(data){
						  $("#zpravodaj").slideUp("normal", function() {
							 $("#zpravodaj").before('<p>'+data+'</p>');											
						  });
              //alert("Data Loaded: " + data);
   					}
				 );
		}
		
		return false;
	});
}); 
