function setModule(module) {
	document.getElementById("module").value = module;
}
function setActionType(actiontype) {
	document.getElementById("actiontype").value = actiontype;
}
function checkEmpty(id, msg) {
	if(document.getElementById(id).value=="")
		return msg+"<br />";
	else
		return "";	
}
function setAjaxMsg(msg, css) {
	$("msg").innerHTML=msg;
	$("msg").addClassName(css);
	window.setTimeout(function(){
		$("msg").innerHTML="";
		$("msg").removeClassName(css);
	},4000);
	
}
function simpleIsEmpty(id) {
	if($(id).value=="")
		return true;
	else
		return false;	
}

function simpleIsEmptyOption(id) {
	if($(id).options[$(id).selectedIndex].value=="-1")
		return true;
	else
		return false;
}

function afficher(fromVal)
{
	var from = document.getElementById("from");
	var dir = document.getElementById("dir");
	var dummy = document.getElementById("dummy"); // Le formulaire
	
	from.value=fromVal;
	if (dir.value == "ASC" )
		dir.value = "DESC";
	else 
		dir.value = "ASC";
	dummy.submit();
}
 
function gotoRow(paginationListe)
{
	var from = document.getElementById("from");
	var dir = document.getElementById("dir");
	var dummy = document.getElementById("dummy"); // Le formulaire
	
	from.value=paginationListe.value;
	if (dir.value == "ASC" )
		dir.value = "DESC";
	else 
		dir.value = "ASC";
	dummy.submit();
}

function goTo(module, actiontype)
{
	
	document.getElementById("module").value = module;
	document.getElementById("actiontype").value = actiontype;
	document.getElementById("OrderBy").value = "";
	document.getElementById("dir").value = "";
	document.getElementById("from").value = "";
	var dummy = document.getElementById("dummy"); // Le formulaire

	dummy.method='post';
	
	//alert(dummy.method);
	
	dummy.submit();
}

function goToParam(module, actiontype, param)
{
	//alert("index.php?module="+module+"&actiontype="+actiontype+"&"+param);
	window.location.replace("index.php?module="+module+"&actiontype="+actiontype+"&"+param);
}

function confirmDelete(id_field, id_value, module, actiontype, goTo)
{
	//getUI();
	if(confirm('Confirmez-vous la suppression ?'))
	{
		$('module').value=module;
		$('actiontype').value=actiontype;
		$('goto').value=goTo;
		$(id_field).value=id_value;
		$('dummy').submit();
		
	}
	//closeUI();
}

function confirmDeleteCMS(id_field, id_value, module, actiontype, mode, domElement)
{
	//getUI();
	if(confirm('Confirmez-vous la suppression ?'))
	{
		new Ajax.Request('index.php?module='+module+'&actiontype='+actiontype+'&'+id_field+'='+id_value+'&mode='+mode, {
		  method: 'get',
		  onComplete: function(transport) {
		  	$(domElement).remove();
			setAjaxMsg('Article supprimé','true');
		  }
		});
	}
	//closeUI();
	

	
}

function cancelDelete()
{
	Element.hide('bgPopupMsg');Element.hide('popupMsg');
}

function setId(id, value)
{
	document.getElementById(id).value = value;
}

function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

// get user interface
function getUI() {
	$('blockUI').show();
}
function closeUI() {
	$('blockUI').hide();
}
function open_popup(nom_de_la_page, nom_interne_de_la_fenetre, height, width, scrollbars, menubar, resizable)
{
	window.open(nom_de_la_page, nom_interne_de_la_fenetre, config='height='+height+', width='+width+', toolbar=no, menubar='+menubar+', scrollbars='+scrollbars+', resizable='+resizable+', location=no, directories=no, status=no')
}
