 $(document).ready(function(){
	// jQuery on document ready function
	
	// LOGIN BLOCK TOP LEFT
	// hides both label since javascript is enabled. Show label only if JS is disabled
	$("#login label").css({ display:"none" });

	$("#username, #password").each(function() {
		// assigns onfocus and onblur code
		$(this).focus(function () { $(this).removeClass($(this).attr("id")+"bg"); });
		$(this).blur(function () { if ($(this).val() == "") $(this).addClass($(this).attr("id")+"bg"); });
		
		// assigns background classes to login fields username et pwd
		if ($(this).val() == "") $(this).addClass($(this).attr("id")+"bg");
	});
	
	// assigns default value "Mots clés" in search text field
	var keywordslabel = "Mots-clés";
	var forumsearchlabel = "Recherche dans le forum";
	$("#keywords").val(keywordslabel);
	$("#keywords").focus(function () { $("#keywords").val(""); });
	$("#keywords").blur(function () { if ($("#keywords").val() == "") $("#keywords").val(keywordslabel); });

	$("#forumsearch").val(forumsearchlabel);
	$("#forumsearch").focus(function () { $("#forumsearch").val(""); });
	$("#forumsearch").blur(function () { if ($("#forumsearch").val() == "") $("#forumsearch").val(forumsearchlabel); });

	// assigns odd-even classes for forum block at the right
	// keeps markup clean
	$("ul.threads li:even").addClass("even");
	$("ul.threads li:odd").addClass("odd");

	$("table.forum tr:even").addClass("even");
	$("table.forum tr:odd").addClass("odd");

	// preload rollover images for submit type=image
	$(".submit").each(function() {
		src = $(this).attr("src").split('-off').join('-on');
		jQuery("<img>").attr("src", src);
	});
	
	// adds rollover behavior for submit type=image
	$(".submit").hover(function(){$(this).attr("src", $(this).attr("src").split('-off').join('-on'))}, function(){$(this).attr("src", $(this).attr("src").split('-on').join('-off'))});

	// on a list (ul.side or ul.blocks), assigns first and last classes to li elements
	// css2 peudoclass :first-child is set, but non supporting browsers will still be ok (ie6)
	$("ul.blocks li:first").addClass("first");
	$("ul.blocks li:last").addClass("last");
	
	$("ul.side li:first").addClass("first");
	$("ul.side li:last").addClass("last");
	
	$("ul.side#swide li:last").removeClass("last");
	
	$("ul.table li:first").addClass("first");
	$("ul.table li:last").addClass("last");
	
	// append shadow to right side of nav
	$("#menu").prepend('<div id="menushadow"></div>');

 });
 
 function GetXmlHttpObject() {
	var xmlHttp=null;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) { // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function showLayer(layerId,show) {
	if (document.getElementById && document.getElementById(layerId)) { objLayer = document.getElementById(layerId); } else if (document.all && document.all[layerId]) { objLayer = document.all[layerId]; } else if (document.layers && document.layers[layerId]) { objLayer = document.layers[layerId]; } else { objLayer = null; }
	if (objLayer !== null) { objLayer.style.display = (show == 1) ? 'block' : 'none'; }
}

