$(document).ready(function(){
	$(".content-post").hide();
	
	$("h2.content-header").click(function(event){
		$(".content-post").not($(this).next()).hide("fast");
		$(this).next().slideToggle("fast");
		return false;
	});
	
	$("#dialog").dialog({
		autoOpen: false,
		modal: true,
		title: "Login",
		width: 300,
		draggable: false,
		resizable: false,
		show: "blind",
		hide: "blind",
		buttons: {
			"Login": function() {
				var bValid = true;
				bValid = bValid && checkRegexp(name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter.");
				bValid = bValid && checkRegexp(password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9");

				if (bValid) {
					//do something.
					$(this).dialog("close");
				}
			},
			Cancel: function() {
				$(this).dialog("close");
			}
		}
	});
	
	$("#login-button").bind('click', function(event) {
		$("#dialog").dialog("open");
		return false;
	});
});
