$(document).ready(function() {
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
	
	topMenu();
	
	$("#search").click(function() { this.value = ""; });
	$("#_ctl4_identifiant").click(function() { this.value = ""; });
	$("#_ctl4_password").click(function() { this.value = ""; });
	
	/* HOME PAGE TABS */

		$(".tabHP").hover(function(){
			var strTab = $(this).id();
			$("#"+strTab).fadeOut("fast");
			$("#"+strTab+"Hover").fadeIn("fast");
			},
			function(){}

		);
	
		$(".tabHPHover").hover(function(){},
			function(){
			var strTabHover = $(this).id();
			var strTab = strTabHover.substring(0,4);
			$("#"+strTabHover).fadeOut("fast");
			$("#"+strTab).fadeIn("fast");
		});
		
		$(".tabHPHover").click(function(){
			var strTab =  $(this).id().substring(0,4);
			var strLinkTxt = $("#"+strTab+">div>a").href();
			goToURL(strLinkTxt);	
		});	

});

function goToURL(strURL) {
var newWin = window.open(strURL,'_blank');
newWin.focus();
}

function topMenu() {
	function fixTagsA(container) {
		width = 0;
		
		allTagsA = document.getElementById(container).getElementsByTagName("a");
		for (var i=0; i<allTagsA.length; i++)
			if(allTagsA[i].offsetWidth > width)
				width = allTagsA[i].offsetWidth;
		
		for (var i=0; i<allTagsA.length; i++) allTagsA[i].style.width = (width-50)+"px";
		document.getElementById(container).style.width = width+"px";
	}
	
	allTagsUL = document.getElementById("topNavList").getElementsByTagName("ul");
	for (var i=0; i<allTagsUL.length; i++) {
		fixTagsA(allTagsUL[i].id);
		lastUL = allTagsUL[i].id;
	}
	
	var navItems = document.getElementById("topNavList").getElementsByTagName("li");
	for (var i=0; i<navItems.length; i++) {
		if(navItems[i].className == "navLiLevelOne")  {
			
		    navItems[i].onmouseover = function() {
				var navItemsUL = this.getElementsByTagName("ul");
				
				for (var j=0; j<navItemsUL.length; j++)
					if(navItemsUL[j].id == lastUL) { // ALIGN RIGHT LAST MENU
						widthMenu = this.offsetWidth;
						
						navItemsUL[j].style.left = ''+(widthMenu-width)+'px'; // WIDTH SUBMENU - WIDTH MENU - PADDING
					} else
						navItemsUL[j].style.left = '0';
				
				this.className += ' over';
			}
			navItems[i].onmouseout=function() {
				var navItemsUL = this.getElementsByTagName("ul");
				for (var j=0; j<navItemsUL.length; j++)
					navItemsUL[j].style.left = '-9999px';
				this.className = "navLiLevelOne";
			}
		}
	}
}

/*---------------------------------------------
function doPopUp(xPopup, xUrl,xWidth,xHeight,xScroll)
---------------------------------------------*/
function doPopUp(xPopup, xUrl,xWidth,xHeight,xScroll) {
  var xParameters = 'SCROLLBARS='+ xScroll +',WIDTH='+ xWidth +',HEIGHT='+ xHeight +',TOOLBAR=NO,LOCATION=NO,DIRECTORIES=NO,STATUS=NO,MENUBAR=NO,RESIZABLE=NO,COPYHISTORY=YES';
  var WinPop = window.open(xUrl, xPopup, xParameters);
  WinPop.focus();
}
