$(document).ready(
				  function(){
					  
					  
					  // Scroll tagboard
	var tagboard_value_scroll = 100;
	var tagboard_current_scroll = 0;
	var content_tagboard = document.getElementById("messaggi");

	$("#messaggi").animate({scrollTop:-100},"fast");
    $("#tagboard .top").css("display","none");
	if(tagboard_current_scroll+109>= content_tagboard.scrollHeight){
		
		$("#tagboard .bottom").css("display","none");
		
		}
	$("#tagboard .top").click(function(){
									   
			tagboard_current_scroll -= tagboard_value_scroll;
			$("#messaggi").animate({scrollTop:tagboard_current_scroll},"fast");
		    
			if(tagboard_current_scroll <= 0 ){
			
			$(this).css("display","none");
			
			}
									
					$("#tagboard .bottom").css("display","block");
						  
									  });		
	
		$("#tagboard .bottom").click(function(){
		//	content.scrollTop+=10;
			tagboard_current_scroll += tagboard_value_scroll;

			$("#messaggi").animate({scrollTop:tagboard_current_scroll},"fast");
		
		
			
			$("#tagboard .top").css("display","block");
			
	if(tagboard_current_scroll+109 >= content_tagboard.scrollHeight){
				
			$(this).css("display","none");
				
				}

	
							   
									   });
		// Invio form
		$("#add-msg-tagboard").submit(function(){
										msg =   $("#add-msg-tagboard [name ='msg']").val(); 
										var option = {
											success:function(result){
												
												 if(result == "error_loging"){
													 location.href = patch_no_loging;
													 }else{
												    $.get(patch+"modules/tagboard.php",{op:"refresh",game:$("#add-msg-tagboard [name ='game']").val()},function(result){
																		
																		$("#tagboard #messaggi").html(result);						
																			 $("#tagboard #messaggi").animate({scrollTop:0},"fast");
													 $("#add-msg-tagboard [name ='msg']").attr("disabled","disabled");
													 $("#add-msg-tagboard .submit").attr("disabled","disabled");
													 for(var i=10;i!=0;i--){
													 setTimeout('$("#add-msg-tagboard [name =\'msg\']").val("Aspetta : '+i+'");',(10-i)*1000);
														 }
													 setTimeout('$("#add-msg-tagboard [name =\'msg\']").attr("disabled","");$("#add-msg-tagboard [name =\'msg\']").val("");$("#add-msg-tagboard .submit").attr("disabled","");',10000);
													 tagboard_current_scroll = 0;
													 
													 $("#tagboard .top").css("display","none");			
													 if(content_tagboard.scrollHeight>109){
				
$("#tagboard .bottom").css("display","block");					
				}
													 
													 
																													  });
													
												
													 }
											}
										}
										
										if(msg!=""){
											
											
										$(this).ajaxSubmit(option);
										
										
										}
										
										return false;
										
										});
					  
					  
					  
					  }
				  );