var MyUtils = {
	selected : function(element, html) {
		elt = $(element)
		if (elt == null)
			elt = element;
		elt.className = 'active';
		Element.select(elt, 'div.container').invoke('show');
	},
	deselected : function(element, html) {
		elt = $(element)
		if (elt == null)
			elt = element;
		elt.className = 'inactive';
		Element.select(elt, 'div.container').invoke('hide');
	},
	validate : function(element, html) {
		elt = $(element)
		if (elt == null)
			elt = element;
		
		htmltxt = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n';
		htmltxt += '<html>\n';
		htmltxt += elt.innerHTML;
		htmltxt += '\n</html>';

		new Ajax.Request(
				'http://harliane.harlie.fr/validate.php',
				{
					method : 'post',
					parameters : {
						html : htmltxt
					},
					onSuccess : function(transport, json) {
						var v = (json ? Object.inspect(json) : "no JSON object");
						if (v == "'VALID'"){
							$("valid_html").show();
						}
						
					}
				});
	}
}

Element.addMethods(MyUtils);

function showMenu(id) {
	$$('li.active').invoke('deselected');
	$(id).selected();
}

function logout() {
	new Ajax.Request('http://harliane.harlie.fr/index.php', {
		method : 'post',
		parameters : {
			submit_logout : 'Logout'
		},
		onSuccess : function(transport, json) {
			document.location.href = "index.php";
		}
	});
}

function validateHtml() {
}


function validate() {
	$("valid_html").hide();
	$$('html').invoke('validate');
}

function getHtml() {
	$$('html').invoke('validate');
}
