 $(function() { 
	 
	 	$('.treemenu1 a').click(function(){ 
	 		alert ('menu will be activate after pay subscription');
	 		
	 	});
	 	
		$('.notices_sminiatury ul li:first-child a img').css('opacity',0.5);
		 
		$(".notices_sminiatury a").click(function(){
	 
			$('.notices_sminiatury a img').css('opacity',1); 
			$(this).children().css('opacity',0.5);
	 
			var sciezka = $(this).attr("href");
			var tytul = $(this).attr("title");
	 
			$(".duzy").attr({ src: sciezka, alt: tytul }); 
	 
			return false;
		});
	 
 
 
 $('#form').submit(function() {
 var $this = $(this); 
 
 $('.blad, .komunikat').remove();
 if ($this.find('input[name=subject]').val() && $this.find('textarea').val()) {
	 
 $.post($this.attr('action'), $this.serialize(), function(dane) { 
	 
 $this.find('input[name=subject], textarea').val('');

 
 $('<p class="komunikat">' + $(dane).text() + '</p>')
  

 
 .insertBefore($this)
 
 .fadeOut(8000, function() { 
	 
 $(this).remove();
 });
 });
 } else {
	  
	 alert('You need to fill all fields');
 
 }
 return false;
 }); 
 
 
 
 $("div.showmessage").click(
		 function() { 
			 
				if($('#reply').css('display') == 'block') {
					
					$('#reply').toggle();
				} 
			
			 $(this).next("div#showtresc").toggle('slow');
			 
			 //var messageId = $('#messageId').val();
			//$.get('ajax/message.php', {messageId:messageId,status:'read'}, function (dane) {  
					
			//	});
			 
		 });
 
	$("ul#lista li").children("p#repl").click(function(){
		
		var receiver = $(this).next("span").text();
		var od =  $(this).next("span").next("input").val();
		$('#formusers').val(receiver);
		$('#users').val(od);
		$('#reply').toggle('slow');
		 
		return false;
	});
	
	$('.pay_method').click(function(){
	
		$('div#przelew').toggle();
	 
	});
	
	$('.pay_hidde').click(function(){
		
		if($('#przelew').css('display') == 'block') {
		
			$('div#przelew').toggle(); 
		}
	});
	
	$('#emailForm').submit(function(){
		
		var $this = $(this);
		
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 
		var emailVal = $('#sender').val();
		var trescVal = $('#tresc').val();
		
		if(trescVal == '' || emailVal == ''){
		
			alert('You need to fill all fields');
			return false;
		
		} else if (!emailReg.test(emailVal) ){ 
			
			alert('You have to specify the email!');
			return false;
		}
		
		 $.post($this.attr('action'), $this.serialize(), function(dane) { 
			 
			 $this.find('textarea').val('');

			 
			 $('<p class="komunikat">' + $(dane).text() + '</p>') 
			 

			 
			 .insertBefore($this)
			 
			 .fadeOut(8000, function() {
				 
			 $(this).remove();
			 }); 
			 });
		
		
		return false;
	}); 
	
	$("ul#lista li").children("p#del").click(function(){
		
		 var messageId = $(this).next("span").text();
		$.get('ajax/message.php', {messageId:messageId,del:'one'}, function (dane) {}) ;
		
		$(this).parents("div#conten").toggle('slow');
		$('#reply').css('display', 'none'); 
		return false;
		
	});
	
	$('div#delmessage').children('p').click(function(){ 
		
		 var messageId = $('#del').val();
		$.get('ajax/message.php', {del:'all'}, function (dane) {});
		
		$(this).parents("div#showmessage").toggle('slow');
		$('#reply').css('display', 'none'); 
		
		
	});
	
	$('#notice').submit(function(){ 
		
		var temat = $('#title').val();
		var ed = tinyMCE.get('tnotice');
		var tresc = tresc = ed.getContent();
		
		if(temat == '') {
		
			alert('You have to specify the title!'); 
			return false;
		}
		
		if(tresc == ''){
			
			alert('You have to specify the content!');
			return false;
		}

	});
	
 
 });
