function _foreachInArray(tab, id) {
	for ( var i = 0; i < tab.length; i++) {
		if (tab[i] == id) {
			document.getElementById(tab[i]).style.display = "block";
		} else {
			document.getElementById(tab[i]).style.display = "none";
		}
	}
	return true;
}

function ShowthemeDesc(id) {
	var themes = new Array("all", "det");
	_foreachInArray(themes, id);

	return true;
}

function ShowthemeTableRights(id) {
	var tab = new Array("rights");
	_foreachInArray(tab, id);

	return true;
}

function ShowReportScale(id) {
	var scale = new Array("display_scale", "");
	_foreachInArray(scale, id);

	return true;
}

function ShowReportSdi(id) {
	var sdi = new Array("display_sdi", "");
	_foreachInArray(sdi, id);

	return true;
}

function ShowSuppInfo(id) {
	var themes = new Array("mass_delete", "mass_modify");
	if ('mass_modify' == id) {
		document.getElementById('mass_modify').style.visibility = "visible";
		document.getElementById('transfert').style.visibility = "visible";
		document.getElementById('mass_delete').style.visibility = "hidden";
	} else {
		document.getElementById('mass_modify').style.visibility = "hidden";
		document.getElementById('transfert').style.visibility = "hidden";
		document.getElementById('mass_delete').style.visibility = "visible";
	}
	return true;
}

function ChangeLocation(box) {
	val = box.options[box.selectedIndex].value;
	if (val != -1)
		window.open(val, '_self');
	return true;
}

var urlobj;

function BrowseServer(url, obj) {
	urlobj = obj;
	OpenServerBrowser(url, screen.width * 0.7, screen.height * 0.7);
}

function OpenServerBrowser(url, width, height) {
	var iLeft = (screen.width - width) / 2;
	var iTop = (screen.height - height) / 2;
	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes";
	sOptions += ",width=" + width;
	sOptions += ",height=" + height;
	sOptions += ",left=" + iLeft;
	sOptions += ",top=" + iTop;
	var oWindow = window.open(url, "BrowseWindow", sOptions);
}

function SetUrl(url, width, height) {
	document.getElementById(urlobj).value = url;
	oWindow = null;
}

$(document).ready(function() {

	/** minimum Menu compatibility for IE 7 - very ugly but IE 7 sucks */
	if ($.browser.msie && parseInt($.browser.version, 10) === 7) {
		$("li.menu").css("margin", "0");
		$("li.menu").css("padding", "0");
		$("li.sub_menu").css("position", "relative");
	}

	$(".quickbox").hover(function() {
		$(".quickbox").children("ul").show();
	}, function() {
		$(".quickbox").children("ul").hide();
	});

	if (screen.width < 1200) {
		$("#l21_logo").remove();
		$("ul.containermenu").css('margin', '0 auto');
	}

	$("a.out").attr("target", "_blank");
	$("div#aide").css('display', 'none');

	$("a.aide-ancre").click(function() {
		$("div#aide").slideToggle("slow");
		return false;
	});
	
	$(".toggle_title a").click(function() {
		
		if($(this).parent().next().css('display')=='none') {
			$(this).addClass("open");
			$(this).parent().next().slideDown();
		} else {
			$(this).removeClass("open");
			$(this).parent().next().slideUp();
		}
		
		return false;
	});
});
