var ie6 = (window.ActiveXObject && !window.XMLHttpRequest && document.compatMode);
var ie7 = (window.ActiveXObject && window.XMLHttpRequest);
jQuery(function($) {
	if (!isAccueil || (!ie6 && !ie7))
		return;
	var ul = 'div#um-menu-vertical ul';
	var hoverImage = $('body').css('background-image');
	$(ul + ' li').css({
		'font-size': '1px',
		'line-height': '1px',
		'position': 'relative',
		'width': '193px'
	});
	$(ul + ' a').css({
		'font-size': '11px',
		'line-height': 'normal',
		'width': '172px'
	});
	if (ie6) { $(ul + ' li').hover(
		function() {
			$(this.getElementsByTagName('a')[0]).css({
				'background': '#797070 ' + hoverImage + ' repeat-y',
				'text-decoration': 'none'
			});
			$(this).css('background-color', '#fff');
		},
		function() {
			$(this.getElementsByTagName('a')[0]).css({
				'background': '',
				'text-decoration': ''
			});
			$(this).css('background-color', '');
		}
	)};
});
function umInitMenu() {
	if (!document.getElementById || !document.getElementsByTagName)
		return;
	if (isAccueil)
		return;
	function getToRightNode(ref) {
		if (!ref.childNodes || typeof ref.childNodes.length != 'number')
			return false;
		for (var i = 0; i < ref.childNodes.length; i++)
			if (Number(ref.childNodes[i].nodeType) == 3)
				return i;
		return false;
	}
	var menuId = 'um-menu-vertical';
	var ulClassName = 'um-deuxieme-niveau';
	var ulToOpenHolderId = 'um-menu-ouvert';
	var currentPageHolderId = 'um-menu-pointeur';
	var currentPageClassName = 'um-menu-pointeur';
	var ulToOpenId = '';
	var ulToOpenIdHolder = document.getElementById(ulToOpenHolderId);
	if (ulToOpenIdHolder && getToRightNode(ulToOpenIdHolder) !== false) {
		ulToOpenId = ulToOpenIdHolder.childNodes[getToRightNode(ulToOpenIdHolder)].nodeValue.replace(/\s/g,'');
		ulToOpenIdHolder.style.display = 'none';
	}
	var currentPageId = '';
	var currentPageHolder = document.getElementById(currentPageHolderId);
	if (currentPageHolder && getToRightNode(currentPageHolder) !== false) {
		currentPageId = currentPageHolder.childNodes[getToRightNode(currentPageHolder)].nodeValue.replace(/\s/g,'');
		currentPageHolder.style.display = 'none';
	}
	var currentPage = document.getElementById(currentPageId);
	var ulToOpen = document.getElementById(ulToOpenId);
	var menu = document.getElementById(menuId);
	if (!menu)
		return;
	for (var i = 0, ul; ul = menu.getElementsByTagName('ul')[i]; i++)
		if (ul.className && ul.className == ulClassName)
			ul.style.display = 'none';
	if (ulToOpen)
		ulToOpen.style.display = '';
	if (currentPage)
		currentPage.className += (' ' + currentPageClassName);
}
function umOuvreMenu(ul) {
	var menu = document.getElementById(ul);
	menu.style.display = (menu.style.display == '' ? 'none' : '');
	if (menu.blur) menu.blur();
	return false;
}
jQuery(function($) {
	if (!ie6 || !isAccueil)
		return;
	var ul = '#um-menu-drop-down';
	$(ul).css('margin-bottom','-1px');
	$(ul + ' li li').css('height', '1px');
	$(ul + ' li li a').css('width', '164px');
	$(ul + ' > li[id!="um-menu-drop-down-langues"]').hover(
		function() {
			this.getElementsByTagName('ul')[0].style.display = 'block';
			$(this).css({'border-bottom-color': '#fff', 'border-top-color': '#fff'});
		},
		function() {
			this.getElementsByTagName('ul')[0].style.display = '';
			$(this).css({'border-bottom-color': '#4f6a9f', 'border-top-color': '#526da2'});
		}
	);
	$('#um-menu-drop-down-premier').hover(
		function() {
			$(this).css('border-left', '1px solid #fff');
		},
		function() {
			$(this).css('border-left', '');
		}
	);
});
if (isAccueil) { jQuery(function($) {
	var url = 'images-legendes.html';
	var selector = '.image-legende';
	$('<div title="buffer" />')
		.load(url+' '+selector, function() {
		var i = Math.floor(Math.random() *
			$(selector,this).length);
		var legend = $('.legende:eq('+i+')',this);
		$('#um-image-phare')
			.html($('.image:eq('+i+')',this).html())
			.append(($.trim(legend.text()).length || 0) ?
			'<div id="um-image-phare-legende">'+legend.html()+'</div>':
			'<div title="legend has no content" style="display:none" />')
			.css('visibility','visible');
		$(this).remove();
	});
})};
jQuery(function($) {

	if (!ie6 || !isAccueil)
		return;
	var ul = '#um-menu-drop-down-langues';
	$(ul).css('margin-right','1px');
	$(ul).css('margin-bottom','-1px');
	$(ul + ' li').css('margin-right','1px');
	$(ul + ' li').css('height', '1px');
	$(ul + ' li a').css('width', '164px');
	$(ul).hover(
		function() { // in
			this.getElementsByTagName('ul')[0].style.display = 'block';
			$(this).css({'border-bottom-color': '#fff', 'border-top-color': '#fff', 'border-right-color': '#fff' });
		},
		function() { // out
			this.getElementsByTagName('ul')[0].style.display = '';
			$(this).css({'border-bottom-color': '#4f6a9f', 'border-top-color': '#526da2', 'border-right-color': ''});
		}
	);
});