var p_comments = {
	STATIC:{
		"trim":function(string){
			return string.replace(/(^\s*)|(\s*$)/g,'');
		} 
	},
	uiDef:{
		selectors:{
			/** pour le showHide avec jQuery **/
			"#drop_d_formRegisterComment":function(o){
				
				var divFormComment = document.getElementById("d_formRegisterComment");
				divFormComment.style.display = "none";	
			
				o.onclick = function(){
					document.location.href = "#footer";
					var id = $(this).attr("id");
					$("#"+id.substr(5, id.length)).toggle("slow");
					$(this).toggleClass("close");  
					var textarea = document.getElementById("areaComment");
					textarea.focus();
					$('#content a.widget.showHide').hide('slow');					
					return false;			
				}	
			},
			"#valider_comment":function(o){
				o.onclick = function(){
					var textarea = document.getElementById("areaComment");					
					if(p_comments.STATIC.trim(textarea.value)==""){
						alert("Ecrivez votre commentaire !");
						var textarea = document.getElementById("areaComment");
						textarea.focus();						
						return false;
					}
				}
			},
			"#missedComments":function(o){
				o.onchange = function(){
					document.location.href = o.value;
				}
			},
			"#d_commentaires":function(o){
				
				function updateComments(){					
					$("#d_commentaires").load($("#lastComments").attr("href")).fadeIn("slow");
				}				
				window.setInterval(updateComments,5000);
				updateComments();		
				/*$.ajax({
				  type: "GET",
				  url: $("#lastComments").attr("href"),
				  data: "name=John&location=Boston",
				  ifModified:true,
				  success: function(msg){
				   $("#d_commentaires").html(msg);
				   alert(msg);
				  }
				});*/
			}		
		}
	}
};
uiBuilder.register(p_comments.uiDef);

