function SQ_Unique(kmsession)
{
	var oXmlHttp = zXmlHttp.createRequest();
	var aParams = new Array();

	var sParam = encodeURIComponent('KM_Session');
	sParam +=  '=';
	sParam +=  encodeURIComponent(kmsession);
	aParams.push(sParam);
	alert(sParam);
	for (var i=2; i<arguments.length;) 
	{
			var sParam = encodeURIComponent(arguments[i]);
			sParam +=  '=';
			sParam +=  encodeURIComponent(arguments[i+1]);
			aParams.push(sParam);
			i++; i++;
	}
	request = 'index.php?_SQ=Y&';
	request += aParams.join('&');
	oXmlHttp.open('GET', request,true);
	/*oXmlHttp.onreadystatechange = function () {
			if(oXmlHttp.readyState == 4)
			{
				alert('reponse');
			}
	*/
	oXmlHttp.send(null);

}


function SQ_Form(form)
{
	var oXmlHttp = zXmlHttp.createRequest();
	var aParams = new Array();

	var sParam = encodeURIComponent('_SQ');
	sParam +=  '=';
	concatActionId =  '';
	sParam +=  encodeURIComponent('Y');
	aParams.push(sParam);

	for (var i=0; i<form.length;i++) 
	{			
		    zename = form.elements[i].name;
		    if(zename=="" || zename=="Jpto" || zename=="Jpmod"|| zename=="Counter"|| zename=="JpFrom") continue;
		    var sParam = encodeURIComponent(form.elements[i].name);
			sParam +=  '=';
			found =false;
			for (var j=1; j<4;) 
			{
				if(arguments[j]==form.elements[i].name)
				{
					sParam +=  encodeURIComponent(arguments[j+1]);
					found=true;
				}
				j++; j++;
			}
			
			if(!found)	sParam +=  encodeURIComponent(form.elements[i].value);
			aParams.push(sParam);
	}
	//recupération des paramètres de la fonction qui va faire le traitement sur la réponse
	var fctParam=[];
	var i=0;
	for (var indexArgument=6; indexArgument<arguments.length;indexArgument++) 
	{
		fctParam[arguments[indexArgument]]=arguments[indexArgument+1];
		i++;
	}

	//recupération du nom de la fonction
	fct=arguments[5];
	request = aParams.join('&');
	oXmlHttp.open('POST', 'index.php',true);
	oXmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	oXmlHttp.onreadystatechange = function () {
	
	
			if(oXmlHttp.readyState == 4)
			{
				fct(oXmlHttp.responseText,fctParam);
			}
	}
	
	oXmlHttp.send(request);
}

function SQ_FormGeneric(form)
{	
	var oXmlHttp = zXmlHttp.createRequest();
	var aParams = new Array();
	var FuncParams = new Array();
	FuncParams["Form"] = arguments[0];
	var sParam = encodeURIComponent('_SQ')+'='+encodeURIComponent('Y');
	aParams.push(sParam);
	for (var i=0; i<form.length;i++) 
	{			
		    zename = form.elements[i].name;
		    if(((form.elements[i].type == 'checkbox')||(form.elements[i].type == 'radio')) &&  form.elements[i].checked == false)
			{
				continue
			}
		    if(zename=="" || zename=="Jpto" || zename=="Data" || zename=="Jpmod"|| zename=="Counter"|| zename=="JpFrom") 
		    	continue;
		    if(form.elements[i].type == "select-multiple")
		    {
		    	var val = "";
		    	for (var j=0; j<=form.elements[i].length-1; j++)
				{
					if (form.elements[i].options[j].selected)
					{
						sParam = encodeURIComponent(zename)+'=';
						sParam +=  encodeURIComponent(form.elements[i].options[j].value);
						aParams.push(sParam);
					}
				}
		    	continue;
		    }
		    		
		    sParam = encodeURIComponent(zename)+'=';
			found = false;
			firstLapInAgrs=true;
			for (var j=1; j< arguments.length; j=j+2) 
			{
				if(arguments[j] == zename){
					sParam +=  encodeURIComponent(arguments[j+1]);
					found=true;
				}
				if(firstLapInAgrs==true){
					keyArg = arguments[j];
					FuncParams[keyArg] = arguments[j+1];
				}
			}
			firstLapInAgrs = false;
	    	if(!found)	sParam +=  encodeURIComponent(form.elements[i].value);
			
			aParams.push(sParam);
			
	}
	var ActionName = FuncParams["Action"];
	var FuncName =  FuncParams['AjaxFunction'];
	request = aParams.join('&');

	oXmlHttp.open('POST', 'index.php',true);
	oXmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-1');
	oXmlHttp.onreadystatechange = function () {
	
			if(oXmlHttp.readyState == 4)
			{	
				eval(FuncName+"(oXmlHttp.responseText, FuncParams)");
			}
	}
	oXmlHttp.send(request);
	
}

function SQ_FormStatistics(fct, url, SQParams)
{
	xmlHttp = zXmlHttp.createRequest();
	if (xmlHttp==null)
	{
		 alert("Browser does not support HTTP Request");
		 return;
	} 
	
	url +="?SQParams='"+SQParams+"'";
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = function () {
	    if(xmlHttp.readyState == 4)
		{
		    TreatResponseResults();
		}
	}
	xmlHttp.send(null);
}

function TreatResponseResults()
{
	 //xmlDoc=xmlHttp.responseXML;	 
	 TextDoc = xmlHttp.responseText; //alert (TextDoc);
	 var Result = TextDoc.split(',');
	 
	 for (var i=0; i<Result.length; i++) 
	 {
		 	 value = Result[i].split('=>');
		 	 
			 if (document.getElementById(value[0])!=null)
			 {
			 		document.getElementById(value[0]).innerHTML = value[1];
			    	if(document.getElementById(value[0]+'Bar')!=null){
			    	   rate = value[1].substring(0,value[1].indexOf("%"));	
			    	   if(rate > 100){ rate= 100; }
			    	   //** Modif du style.width sur Mozilla
					   try{  document.getElementById(value[0]+'Bar').style.width = rate; }
					   catch (e) 
					   {	//** Modif du style.width sur IE
					       try {   document.getElementById(value[0]+'Bar').style.width = rate+'px';  }
					       catch (e2) {
					         alert('Erreur de navigateur!');   
					       }
					    }
			    	}
		  	 } 
	 }

	//** Permettre l'affihage du tableau des statistiques:
	if (document.getElementById("loading")!=null){
		document.getElementById("loading").style.visibility="hidden";
		document.getElementById("loading").style.display="none";
	}
	if (document.getElementById("details")){
		document.getElementById("details").style.visibility="visible";
		document.getElementById("details").style.display="inline";
	}
}

/**
 *  Statistiques sur les Taux de transformation
**/
function showTransDetails(Response, FuncParams)
{
	eval(Response);
	ActionName = FuncParams["Action"];
	TransDetailsTD = "TransDetailsTd"+ActionName;
	TransLinkDiv   = "TransLinkDiv"+ActionName;
	
	var GlobalTD =  document.getElementById(TransDetailsTD);
	GlobalTD.style.padding = "0" ;
	var newa =  document.createElement("A");
	newa.setAttribute("href","javascript:hideTransDetails('"+ActionName+"');");
	//newa.setAttribute("class",'reportSubLink');
	newa.className= 'reportSubLink';
	
	var img = document.createElement("IMG");
	    img.src = "M/i/link_up.png";
	    img.border = "0";
    	//img.align = "absmiddle";
	newa.appendChild(img);
	newa.appendChild(document.createTextNode(" Réduire détails des liens"));
	var tbl = document.createElement("TABLE");
	tbl.setAttribute("border", "0"); 
	tbl.setAttribute("cellspacing", "0"); 
	tbl.setAttribute("cellpadding", "2"); 
	tbl.setAttribute("width", "100%"); 
	var tbody = document.createElement("TBODY") ;
	var tr   = document.createElement('TR')  ;
	var td   = document.createElement('TD')  ;
	td.colSpan = "3";
	with(td.style)	{
		width = '100%'; textAlign = 'left'; fontWeight='bold'; padding='1 0 1 4';
	}
	td.appendChild(newa);
	tr.appendChild(td);
	tbody.appendChild(tr);
	
	for(var indice=0; indice< maxIndice ; indice++)
	{
		tr    = document.createElement('TR')  ;
	    td1   = document.createElement('TD')  ;
	    td1.className = 'lefthiddenBox';
	    td1.setAttribute("width","82%");
	    td1.setAttribute("align","left");
	    //td1.setAttribute("class","hiddenLineLeft");
	
		
	    td2   = document.createElement('TD');
	    td2.className = 'hiddenBox';
	    td2.setAttribute("width","8%");
	    td2.setAttribute("align","left");
	   // td2.setAttribute("class", "hiddenLine"); 
	   

	    td3   = document.createElement('TD');
	    td3.className = 'hiddenBox';
	   //  td3.setAttribute("class", "hiddenLine"); 
	    td3.setAttribute("width","10%");
	    td3.setAttribute("align","left");
	   
	    
		
	   // td1.appendChild(document.createTextNode(TextResponse[indice+'.0']))  ;
	    var urlLink =  document.createElement("A");
		urlLink.className =  "mailReportSubLink";
		//urlLink.setAttribute("href","javascript:submitF('Valid','Event','ContactList','Criteria','URLTRANS','Tracker','LIEN_0','Url','http%3A%2F%2Flocalhost%3A8080%2Frootkermeetv7%2FC%2Fkmdemov7%2F%3FIdNode%3D358');");    
		urlLink.setAttribute("href", URLDecode(TextResponse[indice+'.3']));    
	    urlLink.appendChild(document.createTextNode(TextResponse[indice+'.0']))  ;
	    td1.appendChild(urlLink)  ;
	    
	    td2.appendChild(document.createTextNode(TextResponse[indice+'.1']))   ;
	    //** Barres de progression :
	    var percent = document.createElement('div');
		    percent.className = 'percentage';
		    percent.innerHTML = ' &nbsp; ';
		    percent.appendChild(document.createTextNode(TextResponse[indice+'.2']));
	   td3.appendChild(percent); 
	   var empty = document.createElement('div');
		   empty.className = 'emptyBar';
		   empty.setAttribute("align", "left"); 
	   var progress = document.createElement('div');
	  	   
	  	   var currWidth = TextResponse[indice+'.2'].substring(0,TextResponse[indice+'.2'].indexOf(' %'))  ;
	  	   currWidth = Math.round(currWidth) ;
	  	   progress.style.width = currWidth+'px';
	  	   progress.style.height = "11px";
	  	   progress.style.backgroundColor = "#8CAABC";
   	  	   progress.innerHTML = "&nbsp;";
	  	   progress.style.fontSize = "1px";
	  	   progress.style.lineHeight = "0.";
	  	   empty.appendChild(progress); 
	  	   td3.appendChild(empty); 
	    
	    tr.appendChild(td1);
	    tr.appendChild(td2);
	    tr.appendChild(td3);
	    tbody.appendChild(tr);
	}
   	tbl.appendChild(tbody);
   	GlobalTD.appendChild(tbl);
   	   
   	document.getElementById(TransLinkDiv).style.display = "none" ;
   	
}

function URLDecode (encodedString)
		{
		  var output = encodedString;
		  var binVal, thisString;
		  var myregexp = /(%[^%]{2})/;
		  while ((match = myregexp.exec(output)) != null
		             && match.length > 1
		             && match[1] != '') {
		    binVal = parseInt(match[1].substr(1),16);
		    thisString = String.fromCharCode(binVal);
		    output = output.replace(match[1], thisString);
		  }
		  return output;
		}
function hideTransDetails(ActionName)
{
  
	if(document.getElementById("TransDetailsTd"+ActionName)!=null)
	{
		TransLinkDiv = document.getElementById("TransLinkDiv"+ActionName);
		TransDetailsTD  = document.getElementById("TransDetailsTd"+ActionName);
		TransDetailsTD.style.padding = "1 0 1 2";
		TransDetailsTD.innerHTML = '<div id="TransLinkDiv'+ActionName+'" style="display: inline;">'+TransLinkDiv.innerHTML+'</div>';
	}
	
}

function MoveNode(Response, FuncParams)
{
	eval(Response);
	if(document.getElementById(idRowToMoveDown)!=null){
		RowToMoveDown = document.getElementById(idRowToMoveDown);
	}
	if(document.getElementById(idRowToMoveUp)!=null){
		RowToMoveUp = document.getElementById(idRowToMoveUp);
	}
    /*
    var i=0;
	for(var sibling = RowToMoveUP.firstChild ; sibling != null; sibling = sibling.nextSibling){
		alert("Sibling n°"+i+"  "+sibling.innerHTML);
		i++;
	} */
	
	if(idRowToMoveDown=="row1" && idRowToMoveUp == "row"+RowNumber){
		var RowToXJ=RowToMoveUp;
		var nbLines =2;
	}
	else if(idRowToMoveUp == "row"+RowNumber) {
		var RowToXJ=RowToMoveDown;
	}
	else{
		var RowToXJ=RowToMoveUp;
	}
	for(j=0; j<RowToXJ.childNodes.length; j++) {
		if(RowToXJ.childNodes[j]!=null)
		{
			if(!RowToXJ.childNodes[j].length)
			{
				var lin1 = RowToXJ.childNodes[j].getElementsByTagName('img');
				if(lin1[0])
				{
					if(lin1[0].id.indexOf("IMGUP_")!=-1){
						x=j;
						if(nbLines==2){
							RowToXJ = RowToMoveDown;
						}
					}
					if(lin1[0].id.indexOf("IMGDOWN_")!=-1){
						y=j;
					}
				}
			}
		}
	}
	
	IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all) ? 1 : 0 ;
	if(IE) {  a=1; }
	else {  a=3;  }
	for(i=a; i<RowToMoveUp.childNodes.length; i++) {
		 	
			if(i==x || i==y) {
				if(i==x && idRowToMoveDown == "row1")  
					continue ;
				else if(i==y && idRowToMoveUp == "row"+RowNumber) 
					continue ;
				var links1 = RowToMoveUp.childNodes[i].getElementsByTagName('a');
				var links2	= RowToMoveDown.childNodes[i].getElementsByTagName('a');
				chaine1 = changeLinkParamValue(links1[0], links2[0], "6") ;
				chaine2 = changeLinkParamValue(links2[0], links1[0], "6") ;
				links1[0].href = "javascript:SQ_FormGeneric("+chaine1+") ; ";
				links2[0].href = "javascript:SQ_FormGeneric("+chaine2+") ; ";
				continue;
			}
			else{
				var TempoBox = RowToMoveUp.childNodes[i].innerHTML ;
				RowToMoveUp.childNodes[i].innerHTML = RowToMoveDown.childNodes[i].innerHTML ;
				RowToMoveDown.childNodes[i].innerHTML = TempoBox ;
			}
	}
	//** Cas particuliers:
	//(1) Deux lignes exactement dans la liste:
	if(idRowToMoveDown=="row1" && idRowToMoveUp == "row"+RowNumber){
		var linkUp  =  RowToMoveUp.childNodes[x].getElementsByTagName('a');
		var linkDown =  RowToMoveDown.childNodes[y].getElementsByTagName('a') ;
		StrParams = changeLinkParamValue(linkUp[0], linkDown[0], "6") ;
		StrParams2 = changeLinkParamValue(linkDown[0], linkUp[0], "6") ;
		linkUp[0].href = "javascript:SQ_FormGeneric("+StrParams+") ; ";
		linkDown[0].href = "javascript:SQ_FormGeneric("+StrParams2+") ; ";
		
		var tempXidUp = RowToMoveUp.childNodes[x].getElementsByTagName('img')[0].id;
		var tempYIdDown = RowToMoveDown.childNodes[y].getElementsByTagName('img')[0].id;
		
		RowToMoveDown.childNodes[y].getElementsByTagName('img')[0].id = tempXidUp.replace('UP','DOWN');
		RowToMoveUp.childNodes[x].getElementsByTagName('img')[0].id= tempYIdDown.replace('DOWN','UP');
	}
	//(2) 1ère ligne
    else if(idRowToMoveDown=="row1") { 
		var linkUp =  RowToMoveUp.childNodes[x].getElementsByTagName('a');
		var linkDown =  RowToMoveUp.childNodes[y].getElementsByTagName('a');
		StrParams = changeLinkParamValue(linkUp[0],linkDown[0], "6") ;
		linkUp[0].href = "javascript:SQ_FormGeneric("+StrParams+") ; ";
		
		//** Cahngement des id des images:
		var TempY = RowToMoveUp.childNodes[y].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveUp.childNodes[y].getElementsByTagName('a')[0].innerHTML = RowToMoveDown.childNodes[y].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveDown.childNodes[y].getElementsByTagName('a')[0].innerHTML = TempY ;
		
		var newYnode = RowToMoveUp.childNodes[y].getElementsByTagName('img')[0].id;		
		RowToMoveUp.childNodes[x].getElementsByTagName('img')[0].id= newYnode.replace('IMGDOWN_','IMGUP_')	;	
		
	}
	//(3) Dernière ligne à remonter:
	else if(idRowToMoveUp == "row"+RowNumber) {
		var linkDown =  RowToMoveDown.childNodes[y].getElementsByTagName('a') ;
		var linkUp =  RowToMoveDown.childNodes[x].getElementsByTagName('a') ;
		StrParams = changeLinkParamValue(linkDown[0], linkUp[0], "6") ;
		linkDown[0].href = "javascript:SQ_FormGeneric("+StrParams+") ; ";
		
		//** Cahngement des id des images:
		var TempY = RowToMoveUp.childNodes[x].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveUp.childNodes[x].getElementsByTagName('a')[0].innerHTML = RowToMoveDown.childNodes[x].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveDown.childNodes[x].getElementsByTagName('a')[0].innerHTML = TempY ;
		
		var newXnode = RowToMoveDown.childNodes[x].getElementsByTagName('img')[0].id;		
		RowToMoveDown.childNodes[y].getElementsByTagName('img')[0].id = newXnode.replace('IMGUP_','IMGDOWN_')	;
		
	}
	else if(idRowToMoveUp != "row"+RowNumber && idRowToMoveDown!="row1")
	{
		//** Changement des id des images:
		var TempX = RowToMoveUp.childNodes[x].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveUp.childNodes[x].getElementsByTagName('a')[0].innerHTML = RowToMoveDown.childNodes[x].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveDown.childNodes[x].getElementsByTagName('a')[0].innerHTML = TempX ;
		
		var TempY = RowToMoveUp.childNodes[y].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveUp.childNodes[y].getElementsByTagName('a')[0].innerHTML = RowToMoveDown.childNodes[y].getElementsByTagName('a')[0].innerHTML ;
		RowToMoveDown.childNodes[y].getElementsByTagName('a')[0].innerHTML = TempY ;
	}
	
	//** Initialisation de la liste des noeuds:
	NodeListObj.initNodeList();

}

function changeLinkParamValue(Link, Link2, ParamPos)
{
	
	ParamPos = ParamPos.split(',') ;	//alert(ParamPos);
	var HrefParams = Link.href.substring(Link.href.indexOf("(")+1, Link.href.indexOf(")") );
	var	ParamsAr = HrefParams.split(',');
	var HrefParams2 = Link2.href.substring(Link2.href.indexOf("(")+1, Link2.href.indexOf(")") );
	var	ParamsAr2 = HrefParams2.split(',') ;
	for(var i in ParamPos){
		pos = ParamPos[i];
		ParamsAr[pos] = ParamsAr2[pos] ;
	}
	HrefParams = ParamsAr.join(',') ;

	return HrefParams;
}

function MoveBlock(Response, FuncParams)
{
	eval(Response);
	if(idRowToMoveDown==null && idRowToMoveUp==null){
		return;
	}
	
	IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all) ? 1 : 0 ;
	if(document.getElementById(idRowToMoveDown)!=null) {
		var RowToMoveDown = document.getElementById(idRowToMoveDown);
	}
	if(document.getElementById(idRowToMoveUp)!=null) {
		var RowToMoveUp = document.getElementById(idRowToMoveUp);
	}
	
	if(document.getElementById(idSubRowToMoveUp)!=null && document.getElementById(idSubRowToMoveDown)!=null) {
		
		var SubRowToMoveUp = document.getElementById(idSubRowToMoveUp);
		var SubRowToMoveDown = document.getElementById(idSubRowToMoveDown);
		//** IE 
		if(IE){
			for(k=0; k<SubRowToMoveUp.childNodes.length; k++) {
				var TempoBox = SubRowToMoveUp.childNodes[k].innerHTML ;
					SubRowToMoveUp.childNodes[k].innerHTML = SubRowToMoveDown.childNodes[k].innerHTML ;
					SubRowToMoveDown.childNodes[k].innerHTML = TempoBox ;
			}
		}
		else{
			//** Mozilla:
			var TempInner = SubRowToMoveUp.innerHTML ;
			SubRowToMoveUp.innerHTML = SubRowToMoveDown.innerHTML ;
			SubRowToMoveDown.innerHTML = TempInner ;
		}
	}
	//** Recherche de la position des images(flèches):
	var x ;
	for(j=0; j<RowToMoveUp.childNodes.length; j++) 
	{
		if(RowToMoveUp.childNodes[j]!=null)
		{
			var lin1 = RowToMoveUp.childNodes[j].getElementsByTagName('img');
			for(k=0; k<lin1.length; k++)
			{
				var arrow = lin1[k].getAttribute('arrow');
				if(arrow=="UP" ||  arrow=="DOWN")
					x = j;
			}
		}
	}
	if(IE) { a=1;}
	else { a=3;}
	
	for(i=a; i<RowToMoveUp.childNodes.length; i++) 
	{
		if(i==x) {
			//** Flèches en haut:
			var links = RowToMoveUp.childNodes[i].getElementsByTagName('a');
			var links2	= RowToMoveDown.childNodes[i].getElementsByTagName('a');
			chaine1 = changeLinkParamValue(links[0], links2[0], "6,8") ;
			chaine2 = changeLinkParamValue(links2[0], links[0], "6,8") ;
			
			links[0].href = "javascript:SQ_FormGeneric("+chaine1+") ; " ;
			links2[0].href = "javascript:SQ_FormGeneric("+chaine2+") ; " ;
			//** Flèches en bas:
			if(links[1]!=null) {
				if(links2[1]==null)
					var TempLink = links[0] ;
				else TempLink = links2[1] ;
				chaine3 = changeLinkParamValue(links[1], TempLink, "6,8") ;
			}
			if(links2[1]!=null){
				if(links[1]==null) 
					var TempLink = links2[0] ;
				else TempLink = links[1] ;
				chaine4 = changeLinkParamValue(links2[1], TempLink, "6,8") ;
				links2[1].href = "javascript:SQ_FormGeneric("+chaine4+") ; ";
			}
			if(links[1]!=null) {
				links[1].href = "javascript:SQ_FormGeneric("+chaine3+") ; ";
			}
			
			continue;
		}
		else{
			var TempoBox = RowToMoveUp.childNodes[i].innerHTML ;
			RowToMoveUp.childNodes[i].innerHTML = RowToMoveDown.childNodes[i].innerHTML ;
			RowToMoveDown.childNodes[i].innerHTML = TempoBox ;
		}
	}
	idBlockToMoveDown = document.getElementById(idRowToMoveDown).getAttribute('idblock');
	idBlockToMoveUp = document.getElementById(idRowToMoveUp).getAttribute('idblock');
	
	document.getElementById(idRowToMoveDown).setAttribute('idblock',idBlockToMoveUp);
	document.getElementById(idRowToMoveUp).setAttribute('idblock',idBlockToMoveDown);
	//** Initialisation de la liste des blocks:
	blockObj.initBlockList();
}

/** 
 *  Changement de la case à cocher
**/
function SwitchMenu(Response, FuncParams)
{
	eval(Response);
	var selectBoxParentId = "IsMenu"+IdRowSelected;
	if(document.getElementById(selectBoxParentId)!=null) {
		var SelectBoxParent = document.getElementById(selectBoxParentId);
		var images = SelectBoxParent.getElementsByTagName('img');
		if(images.length>0){
			switch(mode){
				 case "on" : images[0].src = "M/i/CaseBlancheCochee.gif"; 
				 			 if(document.getElementById("MenuIcon"+IdNodeWorkOn)!=null){
					 			 var MenuIcon = document.createElement("img");
						 			 MenuIcon.setAttribute('border','0');
						 			 MenuIcon.setAttribute('height','12');
						 			 MenuIcon.setAttribute('width','16');
						 			 MenuIcon.setAttribute('src','M/i/IsMenu.gif');
					 			 document.getElementById("MenuIcon"+IdNodeWorkOn).appendChild(MenuIcon);
				 			 }
							 break;
				case "off" : images[0].src = "M/i/CaseVideBlanche.gif"; 
							 if(document.getElementById("MenuIcon"+IdNodeWorkOn)!=null){
					 			 document.getElementById("MenuIcon"+IdNodeWorkOn).innerHTML="";
				 			 }
							 break;
				   default : break;
			}
		}
	}
}

function changeMenuSelection(Response, FuncParams)
{
	var selectedBox = FuncParams['MenuKey'];
	if(selectedBox==null) 	selectedBox="Published";
	var form = FuncParams["Form"];
	var IsClick = FuncParams["IsClick"];
	//** Seulement si on clique sur un lien actif:
	if(IsClick =='Y'  &&  selectedBox==LireCookie("selectedBox"))
	 	return;
	 	
	var kmSession = form.KM_Session.value;
	var IdEvent = form.IdEvent.value;
    EcrireCookie("selectedBox", selectedBox) ;  
    EcrireCookie("kmSession", kmSession);  
    EcrireCookie("IdEvent", IdEvent) ;  
    
	//** Modification du statut des onglets:
  	if(document.getElementById(selectedBox)!=null){
  		ids = new Array();
  		ids[0] = 'Properties';
  		ids[1] = 'Dependant';
  		ids[2] = 'Available';
  		ids[3] = 'Published';
  		ids[4] = 'GlobalFunct';
  		ids[5] = 'Preview';
  		for(k=0 ; k < ids.length ;k++){
  			if(document.getElementById(ids[k])!=null) {
  				document.getElementById(ids[k]).style.backgroundImage = 'url("/M/i/norm_right.gif")' ;
  				document.getElementById(ids[k]).firstChild.style.backgroundImage = 'url("/M/i/norm_left.gif")' ;
  				if(document.getElementById(ids[k]+'Cont')!=null)
  					document.getElementById(ids[k]+'Cont').style.display = 'none';
  			}
  		}
		currentLI = document.getElementById(selectedBox);
  		currentLI.style.backgroundImage = 'url("/M/i/norm_right_on.gif")' ;
   		currentLI.firstChild.style.backgroundImage = 'url("/M/i/norm_left_on.gif")';
  	}
  	//** Cacher la division séléctionnée:
  	if(document.getElementById(selectedBox+'Cont')!=null){
  		
  		var showndiv =  document.getElementById(selectedBox+'Cont');
  		showndiv.style.display = 'inline' ;
  		if(selectedBox=='Preview')
	  		 //popUp(Response);
	  		 window.open(Response,'_blank');
	  	else   showndiv.innerHTML = ""+Response;
  		
  	}
  	if(selectedBox=="Published")
  	{
  		blockObj = new JSDragDropBlock();
		blockObj.setBlockListId('PublishedCont');
		//blockObj.setMenuKey('Published');
		blockObj.initBlockList();
  	}
	if(selectedBox=="GlobalFunct")
  	{
  		blockObj = new JSDragDropBlock();
		blockObj.setBlockListId('GlobalFunctCont');
		blockObj.initBlockList();
  	}
  	
	if(selectedBox=="Dependant")
  	{
  		NodeListObj = new JSDragDropNode();
		NodeListObj.setNodeDivId('DependantCont');
		//NodeListObj.setMenuKey('Dependant');
		NodeListObj.initNodeList();
  	}
  	

}

function removeChildNodes(ctrl)
{
  while (ctrl.childNodes[0])
  {
    ctrl.removeChild(ctrl.childNodes[0]);
  }
}

function setNewTreeView(Response, FuncParams)
{
	if(document.getElementById('theTreeMenu')!=null){
  		document.getElementById('theTreeMenu').innerHTML = Response ;
	    treeObj.initTree();
	}
	
}

function switchFieldLines(Response, FuncParams)
{
	eval(Response);
	if(document.getElementById(arrowUpId)!=null) 
		var imgUp = document.getElementById(arrowUpId);
	if(document.getElementById(arrowDownId)!=null) 
		var imgDown = document.getElementById(arrowDownId);
	
	lineDown = imgDown.parentNode;
	while(lineDown.tagName!='TR'){
		/*if(lineDown.tagName=='TD'){
			fixedDown = lineDown;
			fixedDown.setAttribute('id','noMove'+arrowDownId);
		}*/
		lineDown = lineDown.parentNode;
	}
	
	lineUp = imgUp.parentNode;
	while(lineUp.tagName!='TR'){
		if(lineUp.tagName=='TD'){
			fixedUp = lineUp;
			fixedUp.setAttribute('id','noMove'+arrowUpId);
		}
		lineUp = lineUp.parentNode;
	}
	
	for(i=0; i<lineUp.childNodes.length; i++) 
	{
		if(lineUp.childNodes[i].id == 'noMove'+arrowUpId) {
				continue;
		}
		var TempoBox = lineUp.childNodes[i].innerHTML ;
		lineUp.childNodes[i].innerHTML = lineDown.childNodes[i].innerHTML ;
		lineDown.childNodes[i].innerHTML = TempoBox ;
	}
	
}

function setNewOrderBlockNodeVersionEdit(Response,FuncParams)
{
	var divId = FuncParams['DivId'];
	if(document.getElementById(divId)!=null)
	{
  		var showndiv =  document.getElementById(divId);
  		showndiv.innerHTML = Response;
  		try{  DNDObj.initBlockList();}
  		catch(err){	return; }
  	}
}


function setNewMediaListOrder(Response,FuncParams)
{
	var divId = FuncParams['DivId'];
	if(document.getElementById(divId)!=null)
	{
  		var showndiv =  document.getElementById(divId);
  		showndiv.innerHTML = Response;
  		try{  NodeListObj.initNodeList();}
  		catch(err){	NodeListObj = null; }
  	}
}

function setNewFieldDataList(Response,FuncParams)
{

	var divId = FuncParams['DivId'];
	if(document.getElementById(divId)!=null && Response!='')
	{
  		var showndiv =  document.getElementById(divId);
  		showndiv.innerHTML = Response;
  		try{  DNDObj.initBlockList();	}
  		catch(err){	DNDObj = null; }
  	}

}

function MoveFormFieldsList(Response,FuncParams)
{
	eval(Response);
	var RowToMoveUp = document.getElementById(idRowToMoveUp);
	var RowToMoveDown = document.getElementById(idRowToMoveDown);
	
	var tempRowToMoveUp   = RowToMoveUp.innerHTML;
	var tempRowToMoveDown = RowToMoveDown.innerHTML;
	
	var tdToMoveUp = RowToMoveUp.getElementsByTagName('td');
	var tdToMoveDown = RowToMoveDown.getElementsByTagName('td');
	
	//Localisation des flèches
	if(idRowToMoveDown=="Row_0" && idRowToMoveUp == "Row_"+idRowNumber){
		var RowToXJ=tdToMoveUp;
		var nbLines =2;
		
	}
	else if(idRowToMoveUp == "Row_"+idRowNumber) {
		
		var RowToXJ=tdToMoveDown;
	}
	else{
		var RowToXJ=tdToMoveUp;

	}
	for(j=0; j<RowToXJ.length; j++) {
		if(RowToXJ[j]!=null)
		{
			if(!RowToXJ[j].length)
			{
				var lin1 = RowToXJ[j].getElementsByTagName('img');
				if(lin1[0])
				{
					/*if(lin1.length>1)
					{
						if(lin1[0].id.indexOf("IMGDOWN_")!=-1 && lin1[1].id.indexOf("IMGUP_")!=-1)
						{
							x=j;
							if(nbLines==2){
								RowToXJ = tdToMoveDown;
							}
						}
						if(lin1[0].id.indexOf("IMGUP_")!=-1 && lin1[1].id.indexOf("IMGDOWN_")!=-1)
						{
							y=j;
							if(nbLines==2){
								RowToXJ = tdToMoveDown;
							}
						}
					}
					else
					{*/
						if(lin1[0].id.indexOf("IMGUP_")!=-1)
						{
							x=j;
							if(nbLines==2){
								RowToXJ = tdToMoveDown;
							}
						}
						if(lin1[0].id.indexOf("IMGDOWN_")!=-1)
						{
							y=j;
						}
					/*}
				}
				if(nbLines==2)
				{
					if(RowToXJ[j].innerHTML.indexOf("Down")!=-1 && RowToXJ[j].innerHTML.indexOf("IMGDOWN_")==-1)
					{
						y=j;
					}
					if(RowToXJ[j].innerHTML.indexOf("Up")!=-1 && RowToXJ[j].innerHTML.indexOf("IMGUP_")==-1)
					{
						x=j;
					}
				}*/
				}
			}
		}
	}
	
	for(i=0; i<tdToMoveUp.length; i++) 
	{
		if(idRowToMoveDown=='Row_0' && i==x)
		{
				var indexUid = 0;
				var HrefParamsToMoveUp   = tdToMoveUp[i].innerHTML.substring(tdToMoveUp[i].innerHTML.indexOf("(")+1, tdToMoveUp[i].innerHTML.indexOf(")") );
				var HrefParamsToMoveDown = tdToMoveDown[y].innerHTML.substring(tdToMoveDown[y].innerHTML.indexOf("(")+1,tdToMoveDown[y].innerHTML.indexOf(")") );
				var	ParamsUp   = HrefParamsToMoveUp.split(',');
				var	ParamsDown = HrefParamsToMoveDown.split(',');
				var tempParamsUp = ParamsDown;
				//Find WHAT
				indexUid = array_search(ParamsUp,"'WHAT'");
				tempUid = ParamsUp[indexUid+1];
				ParamsUp[indexUid+1] = ParamsDown[indexUid+1];
				ParamsDown[indexUid+1] = tempUid;
				
				ParamsUp = ParamsUp.join(',') ;
				ParamsDown = ParamsDown.join(',');
				tdToMoveUp[i].innerHTML   = tdToMoveUp[i].innerHTML.replace(HrefParamsToMoveUp,ParamsUp);
		}
		
		else if(idRowToMoveUp == 'Row_'+idRowNumber && i==y)
		{
			var indexUid = 0;
			if(idRowToMoveDown=='Row_0')
			{
				var	ParamsUp = tempParamsUp;
			}
			else
			{
				var HrefParamsToMoveUp   = tdToMoveDown[x].innerHTML.substring(tdToMoveDown[x].innerHTML.indexOf("(")+1,tdToMoveDown[x].innerHTML.indexOf(")") );

				var	ParamsUp   = HrefParamsToMoveUp.split(',');
			}
			var HrefParamsToMoveDown = tdToMoveDown[i].innerHTML.substring(tdToMoveDown[i].innerHTML.indexOf("(")+1,tdToMoveDown[i].innerHTML.indexOf(")") );
			var	ParamsDown = HrefParamsToMoveDown.split(',');
			
			//Find WHAT
			indexUid = array_search(ParamsUp,"'WHAT'");
			tempUid = ParamsUp[indexUid+1];
			ParamsUp[indexUid+1] = ParamsDown[indexUid+1];
			ParamsDown[indexUid+1] = tempUid;
			
			ParamsUp = ParamsUp.join(',') ;
			ParamsDown = ParamsDown.join(',');
			tdToMoveDown[i].innerHTML = tdToMoveDown[i].innerHTML.replace(HrefParamsToMoveDown,ParamsDown);
			
		}
		else
		{
			if(tdToMoveUp[i].innerHTML.indexOf("javascript")!=-1)
			{
				if(tdToMoveUp[i].getElementsByTagName('a').length>0)
				{
					var linkUp = tdToMoveUp[i].getElementsByTagName('a');
					var linkDown = tdToMoveDown[i].getElementsByTagName('a');
					for(indexLink=0; indexLink<linkUp.length; indexLink++)
					{
						var indexUid = 0;
						var HrefParamsToMoveUp   = linkUp[indexLink].href.substring(linkUp[indexLink].href.indexOf("(")+1,linkUp[indexLink].href.indexOf(")") );
						var HrefParamsToMoveDown = linkDown[indexLink].href.substring(linkDown[indexLink].href.indexOf("(")+1,linkDown[indexLink].href.indexOf(")") );
						var	ParamsUp   = HrefParamsToMoveUp.split(',');
						var	ParamsDown = HrefParamsToMoveDown.split(',');
						
						//Find WHAT
						indexUid = array_search(ParamsUp,"'WHAT'");
						tempUid = ParamsUp[indexUid+1];
						ParamsUp[indexUid+1] = ParamsDown[indexUid+1];
						ParamsDown[indexUid+1] = tempUid;
						
						ParamsUp = ParamsUp.join(',') ;
						ParamsDown = ParamsDown.join(',');
						
						linkUp[indexLink].href   = linkUp[indexLink].href.replace(HrefParamsToMoveUp,ParamsUp);
						linkDown[indexLink].href = linkDown[indexLink].href.replace(HrefParamsToMoveDown,ParamsDown);
					}
				}
				else
				{
					var temp = tdToMoveUp[i].innerHTML;
					tdToMoveUp[i].innerHTML = tdToMoveDown[i].innerHTML;
					tdToMoveDown[i].innerHTML = temp;
					
					var indexUid = 0;
					var HrefParamsToMoveUp   = tdToMoveUp[i].innerHTML.substring(tdToMoveUp[i].innerHTML.indexOf("(")+1, tdToMoveUp[i].innerHTML.indexOf(")") );
					var HrefParamsToMoveDown = tdToMoveDown[i].innerHTML.substring(tdToMoveDown[i].innerHTML.indexOf("(")+1,tdToMoveDown[i].innerHTML.indexOf(")") );
					var	ParamsUp   = HrefParamsToMoveUp.split(',');
					var	ParamsDown = HrefParamsToMoveDown.split(',');
					
					
					//Find UID
					indexUid = array_search(ParamsUp,"'UID'");
					tempUid = ParamsUp[indexUid+1];
					ParamsUp[indexUid+1] = ParamsDown[indexUid+1];
					ParamsDown[indexUid+1] = tempUid;
					
					ParamsUp = ParamsUp.join(',') ;
					ParamsDown = ParamsDown.join(',');
					tdToMoveUp[i].innerHTML   = tdToMoveUp[i].innerHTML.replace(HrefParamsToMoveUp,ParamsUp);
					tdToMoveDown[i].innerHTML = tdToMoveDown[i].innerHTML.replace(HrefParamsToMoveDown,ParamsDown);
				}
			}
			else
			{
				var tempTdToMoveUp = tdToMoveUp[i].innerHTML;
				tdToMoveUp[i].innerHTML = tdToMoveDown[i].innerHTML;
				tdToMoveDown[i].innerHTML = tempTdToMoveUp;
			}
		}
	}
	DNDObj.initBlockList();

}

function array_search (array,val)
{
	for (var i = 0; i < array.length; i++)
	{
		if (array[i] == val)
		{
			return i;
		}
	}
}

function SetNewOrderFormFieldsList(Response,FuncParams)
{
	var divId = FuncParams['DivId'];
	if(document.getElementById(divId)!=null && Response!='')
	{
  		var showndiv =  document.getElementById(divId);
  		showndiv.innerHTML = Response;
  		try{  DNDObj.initBlockList();	}
  		catch(err){	DNDObj = null; }
  	}
}

function UpdatingStatus(Response,FuncParams)
{
	//alert(Response);
	if(Response!=""){
		eval(Response);
		for(var idRow in RowsToUpdate)
		{
			Newvalues = RowsToUpdate[idRow];
			if(document.getElementById(idRow)){	//alert(idRow);
				var currentRow = document.getElementById(idRow);
				$('TD[@id*=Col_]', currentRow).each(
					function()
					{
						CurrTDId = this.id ;
						CurrTD = this ;//alert(CurrTDId);
						if(State == 0)
						{
							if(CurrTDId =='Col_1')  CurrTD.innerHTML = Newvalues[0];
							if(CurrTDId =='Col_9') CurrTD.innerHTML = Newvalues[7];
							if(CurrTDId =='Col_11') CurrTD.innerHTML = Newvalues[8];
						}
						if(CurrTDId =='Col_3')  CurrTD.innerHTML = Newvalues[1];
						if(CurrTDId =='Col_4')  CurrTD.innerHTML = Newvalues[2];
						if(CurrTDId =='Col_5')  CurrTD.innerHTML = Newvalues[3];
						if(CurrTDId =='Col_6')  CurrTD.innerHTML = Newvalues[4];
						if(CurrTDId =='Col_7')  CurrTD.innerHTML = Newvalues[5];
						if(CurrTDId =='Col_8')  CurrTD.innerHTML = Newvalues[6];
					}
				);
			}
		}
	}
}

function UpdatingReportDownloadStatus(Response,FuncParams)
{
	if(Response.indexOf("||")==-1)
	{
		valueResponse = Response.split("|");
		var NewContent = document.getElementById(valueResponse[0]);
		NewContent.innerHTML = valueResponse[1];
	}
	else
	{
		textResponse = Response.split("||");
		for(i=0; i<textResponse.length; i++)
		{
			valueResponse = textResponse[i].split("|");
			IdRowToChange = valueResponse[0];
			ValueToChange = valueResponse[1].split("#");
			var RowToChange = document.getElementById(IdRowToChange);
			var tds = RowToChange.getElementsByTagName('td');
			tds[2].innerHTML = ValueToChange[2];
			tds[3].innerHTML = ValueToChange[3];
			tds[4].innerHTML = ValueToChange[4];
		}
	}
}

function SQTestSend(Response,FuncParams)
{
	message = Response.replace("&eacute;","é")
	alert(message);
	var WaitImg = document.getElementById(FuncParams['Wait']);
	var btn     = document.getElementById(FuncParams['btnTestSend']);
	
	document.getElementById(FuncParams['btnTestSend']).style.visibility = "Visible";
	document.getElementById(FuncParams['btnTestSend']).style.display = "inline";
	document.getElementById(FuncParams['Wait']).innerHTML = " ";
}

function ChangeBtnOnLoadingImg(btnTestSend, Wait)
{

	var WaitImg = document.getElementById(Wait);
	var btn     = document.getElementById(btnTestSend);
	btn.style.visibility = "Hidden";
	btn.style.display = "none";
	WaitImg.innerHTML = "<img align='absmiddle' src=\"M/i/wait.gif\" >";
	SQ_FormGeneric(Valid,"Event","TestSend","_SQ","Y","IsTest","Y","AjaxFunction","SQTestSend","btnTestSend",btnTestSend,"Wait",Wait);
	
	if(document.Valid.TestRecipient.value!=""){
		var sendButton = document.getElementById("btnRealSend");
		sendButton.style.display =  "none";
		
		var sendButton2 = document.getElementById("btnRealSend2");
		sendButton2.style.display =  "inline";
	}
	else{
		alert("Vous devez saisir l'email du destinataire de test")
	}
	
}

function SetGraphCamembert(Response,FuncParams)
{
	Graphs = Response.split("#");
	//alert(Response);
	var graph = document.getElementById("Graph");
	graph.style.display = "none";
	graph.style.display = "inline";
	if(FuncParams['ViewType'].indexOf("Default") == -1)
	{
		for(i=0; i<Graphs.length-1; i++)
		{
			countItemOfLegend = Graphs[i].split('||'); //Récupération du nombre de ligne
			heigth = 150 + countItemOfLegend[1]*13
			if(i==0)
			{
				var table = document.getElementById("table_3");
				table.style.visibility = "visible";
				var so = new SWFObject("M/javascript/AmChart/Pie/Pie.swf", "ampie", "760", heigth, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/AmChart/Pie/");
				so.addVariable("settings_file", escape("M/javascript/AmChart/Pie/Pie.xml"));
				so.addVariable("data_file", escape(countItemOfLegend[0]));
				so.addVariable("preloader_color", "#999999");
				so.write("flashcontent3");
			}
			else
			{
				var table = document.getElementById("table_"+i);
				table.style.visibility = "visible";
				var so = new SWFObject("M/javascript/AmChart/Pie/Pie.swf", "ampie", "760", heigth, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/AmChart/Pie/");
				so.addVariable("settings_file", escape("M/javascript/AmChart/Pie/Pie.xml"));
				so.addVariable("data_file", escape(countItemOfLegend[0]));
				so.addVariable("preloader_color", "#999999");
				so.write("flashcontent"+i);
			}
		}
	}
	else
	{
		for(i=1; i<Graphs.length; i++)
		{
			countItemOfLegend = Graphs[i-1].split('||')
			heigth = 150 + countItemOfLegend[1]*13
			if(i==1)
			{
				var table = document.getElementById("table_1");
				table.style.visibility = "visible";
				var so = new SWFObject("M/javascript/AmChart/Pie/Pie.swf", "ampie", "760", heigth, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/AmChart/Pie/");
				so.addVariable("settings_file", escape("M/javascript/AmChart/Pie/Pie.xml"));
				so.addVariable("data_file", escape(countItemOfLegend[0]));
				so.addVariable("preloader_color", "#999999");
				so.write("flashcontent1");
			}
			else
			{
				var table = document.getElementById("table_"+i);
				table.style.visibility = "visible";
				var so = new SWFObject("M/javascript/AmChart/Pie/Pie.swf", "ampie", "760", heigth, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/ampie/");
				so.addVariable("settings_file", escape("M/javascript/AmChart/Pie/Pie.xml"));
				index = i-1;
				so.addVariable("data_file", escape(countItemOfLegend[0]));
				so.addVariable("preloader_color", "#999999");
				so.write("flashcontent"+i);
			}
		}
	}
}

function SetGraphBarre(Response,FuncParams)
{
	Graphs = Response.split("#");
	var graph = document.getElementById("Graph");
	graph.style.display = "inline";
	var color = new Array();
	color[0]="#AABCFF";
	color[1]="#00BCFF";
	color[2]="#CDBCFF";
	color[3]="#AACCBB";
	if(FuncParams['ViewType'].indexOf("Default") == -1)
	{
		for(i=0; i<Graphs.length-1; i++)
		{
			DataGraph = Graphs[i].split("||");
			left = 100;
			if(left>27)
			{
				left = 100 + DataGraph[2]*2; //Récupération de la taille maximum des libellés
			}
			if(DataGraph[1] ==1){
				width = 40;
			}
			else{
				width = 80;
			}
			height = 160;
			if(DataGraph[1] > 2)
			{
				height = height = (140*(DataGraph[1]))/3;//140 + (DataGraph[1]) * 25;
			}
			if(i==0)
			{
				var table = document.getElementById("table_3");
				table.style.visibility = "visible";
				table.style.dispaly = "inline";
				var so = new SWFObject("M/javascript/AmChart/Column/Column.swf", "amcolumn", "760", height, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/AmChart/Column/");
				so.addVariable("chart_settings", escape("<settings><type>bar</type><data_type>xml</data_type><text_color>#000000</text_color><legend><enabled>false</enabled></legend><export_as_image><file>M/javascript/AmChart/Column/export.php</file><target></target><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></export_as_image><error_messages><enabled></enabled><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></error_messages><context_menu><!-- <menu function_name='printChart' title='Print chart'></menu> --><default_items><zoom>false</zoom><print>true</print></default_items></context_menu><column><width>"+width+"</width><spacing>-30</spacing><grow_time>6</grow_time><grow_effect>elastic</grow_effect><alpha>70</alpha><balloon_text><![CDATA[{series}: <b>{value}</b>]]></balloon_text><gradient>horizontal</gradient><bullet_offset></bullet_offset></column><plot_area><margins><left>"+left+"</left><bottom>40</bottom></margins></plot_area><grid><category><color>#000000</color><alpha>0</alpha></category><value><color>#000000</color></value></grid><values><category><enabled></enabled><frequency></frequency><start_from></start_from><rotate></rotate></category><value><enabled></enabled><reverse></reverse><min>0</min><max></max></value></values><balloon><enabled></enabled><text_size>13</text_size></balloon><graphs><graph><gradient_fill_colors>"+color[i]+", #000000</gradient_fill_colors></graph></graphs></settings>"));
				so.addVariable("data_file", escape(DataGraph[0]));
				so.addVariable("preloader_color", "#000000");
				so.write("flashcontent3");
			}
			else
			{
				var table = document.getElementById("table_"+i);
				table.style.visibility = "visible";
				table.style.dispaly = "inline";
				var so = new SWFObject("M/javascript/AmChart/Column/Column.swf", "amcolumn", "760", height, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/AmChart/Column/");
				so.addVariable("chart_settings", escape("<settings><type>bar</type><data_type>xml</data_type><text_color>#000000</text_color><legend><enabled>false</enabled></legend><export_as_image><file>M/javascript/AmChart/Column/export.php</file><target></target><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></export_as_image><error_messages><enabled></enabled><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></error_messages><context_menu><!-- <menu function_name='printChart' title='Print chart'></menu> --><default_items><zoom>false</zoom><print>true</print></default_items></context_menu><column><width>"+width+"</width><spacing>-30</spacing><grow_time>6</grow_time><grow_effect>elastic</grow_effect><alpha>70</alpha><balloon_text><![CDATA[{series}: <b>{value}</b>]]></balloon_text><gradient>horizontal</gradient><bullet_offset></bullet_offset></column><plot_area><margins><left>"+left+"</left><bottom>40</bottom></margins></plot_area><grid><category><color>#000000</color><alpha>0</alpha></category><value><color>#000000</color></value></grid><values><category><enabled></enabled><frequency></frequency><start_from></start_from><rotate></rotate></category><value><enabled></enabled><reverse></reverse><min>0</min><max></max></value></values><balloon><enabled></enabled><text_size>13</text_size></balloon><graphs><graph><gradient_fill_colors>"+color[i]+", #000000</gradient_fill_colors></graph></graphs></settings>"));
				
				so.addVariable("data_file", escape(DataGraph[0]));
				so.addVariable("preloader_color", "#000000");
				so.write("flashcontent"+i);
			}
		}
	}
	else
	{
		for(i=1; i<Graphs.length; i++)
		{
			DataGraph = Graphs[i-1].split("||")
			left = 100;
			if(left>27)
			{
				left = 100 + DataGraph[2]*2; //Récupération de la taille maximum des libellés
			}
			if(DataGraph[1] ==1){
				width = 40;
			}
			else{
				width = 80;
			}
			height = 160;
			if(DataGraph[1] > 2)
			{
				height = height = (140*(DataGraph[1]))/3;//140 + (DataGraph[1]) * 25;
			}
			if(i==1)
			{
				var table = document.getElementById("table_1");
				table.style.visibility = "visible";
				table.style.dispaly = "inline";
				var so = new SWFObject("M/javascript/AmChart/Column/Column.swf", "amcolumn", "760", height, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/AmChart/Column/");
				so.addVariable("chart_settings", escape("<settings><type>bar</type><data_type>xml</data_type><text_color>#000000</text_color><legend><enabled>false</enabled></legend><export_as_image><file>M/javascript/AmChart/Column/export.php</file><target></target><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></export_as_image><error_messages><enabled></enabled><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></error_messages><context_menu><!-- <menu function_name='printChart' title='Print chart'></menu> --><default_items><zoom>false</zoom><print>true</print></default_items></context_menu><column><width>"+width+"</width><spacing>-10</spacing><grow_time>6</grow_time><grow_effect>elastic</grow_effect><alpha>70</alpha><balloon_text><![CDATA[{series}: <b>{value}</b>]]></balloon_text><gradient>horizontal</gradient><bullet_offset></bullet_offset></column><plot_area><margins><left>"+left+"</left><bottom>40</bottom></margins></plot_area><grid><category><color>#000000</color><alpha>0</alpha></category><value><color>#000000</color></value></grid><values><category><enabled></enabled><frequency></frequency><start_from></start_from><rotate></rotate></category><value><enabled></enabled><reverse></reverse><min>0</min><max></max></value></values><balloon><enabled></enabled><text_size>13</text_size></balloon><graphs><graph><gradient_fill_colors>"+color[0]+", #000000</gradient_fill_colors></graph></graphs></settings>"));
				so.addVariable("data_file", escape(DataGraph[0]));
				so.addVariable("preloader_color", "#000000");
				so.write("flashcontent1");
			}
			else
			{
				var table = document.getElementById("table_"+i);
				table.style.visibility = "visible";
				table.style.dispaly = "inline";
				var so = new SWFObject("M/javascript/AmChart/Column/Column.swf", "amcolumn", "760", height, "8", "#E5EEF5");
				so.addVariable("path", "M/javascript/AmChart/Column/");
				index = i-1;
				so.addVariable("chart_settings", escape("<settings><type>bar</type><data_type>xml</data_type><text_color>#000000</text_color><legend><enabled>false</enabled></legend><export_as_image><file>M/javascript/AmChart/Column/export.php</file><target></target><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></export_as_image><error_messages><enabled></enabled><x></x><y></y><color></color><alpha></alpha><text_color></text_color><text_size></text_size></error_messages><context_menu><!-- <menu function_name='printChart' title='Print chart'></menu> --><default_items><zoom>false</zoom><print>true</print></default_items></context_menu><column><width>"+width+"</width><spacing>-10</spacing><grow_time>6</grow_time><grow_effect>elastic</grow_effect><alpha>70</alpha><balloon_text><![CDATA[{series}: <b>{value}</b>]]></balloon_text><gradient>horizontal</gradient><bullet_offset></bullet_offset></column><plot_area><margins><left>"+left+"</left><bottom>40</bottom></margins></plot_area><grid><category><color>#000000</color><alpha>0</alpha></category><value><color>#000000</color></value></grid><values><category><enabled></enabled><frequency></frequency><start_from></start_from><rotate></rotate></category><value><enabled></enabled><reverse></reverse><min>0</min><max></max></value></values><balloon><enabled></enabled><text_size>13</text_size></balloon><graphs><graph><gradient_fill_colors>"+color[index]+", #000000</gradient_fill_colors></graph></graphs></settings>"));
				so.addVariable("data_file", escape(DataGraph[0]));
				so.addVariable("preloader_color", "#000000");
				so.write("flashcontent"+i);
			}
		}
	}
}



function MoveItemFromGlobalContent(Response,FuncParams)
{
	eval(Response);
	
	var RowToMoveUp	  = document.getElementById(idRowToMoveUp);
	var RowToMoveDown = document.getElementById(idRowToMoveDown);
	
	var tdToMoveUp	 = RowToMoveUp.getElementsByTagName('td');
	var tdToMoveDown = RowToMoveDown.getElementsByTagName('td');
	
	for(var i=0;i<tdToMoveDown.length;i++)
	{
		LinkToMoveUp   = tdToMoveUp[i].getElementsByTagName('a');
		LinkToMoveDown = tdToMoveDown[i].getElementsByTagName('a');
		
		for(var indexLink=0;indexLink< Math.max(LinkToMoveDown.length,LinkToMoveUp.length);indexLink++)
		{
			if(indexLink<LinkToMoveUp.length)
			{
				ImgToMoveUp	  = LinkToMoveUp[indexLink].getElementsByTagName('img');
			}
			if(indexLink<LinkToMoveDown.length)
			{
				ImgToMoveDown = LinkToMoveDown[indexLink].getElementsByTagName('img');
			}
			
			if(ImgToMoveDown.length==0 && ImgToMoveUp.length==0)
			{
				if(indexLink<LinkToMoveUp.length)
				if(LinkToMoveUp[indexLink].innerHTML.indexOf("Supprimer")!=-1)
				{
					continue;
				}
				if(indexLink<LinkToMoveDown.length)
				if(LinkToMoveDown[indexLink].innerHTML.indexOf("Supprimer")!=-1)
				{
					continue;
				}
				else
				{
					temp = LinkToMoveUp[indexLink].innerHTML;
					LinkToMoveUp[indexLink].innerHTML = LinkToMoveDown[indexLink].innerHTML;
					LinkToMoveDown[indexLink].innerHTML = temp;
				}
			}
		}
		findUp = false;
		findDown = false;
		for(var indexDownDelLink=0;indexDownDelLink < LinkToMoveDown.length;indexDownDelLink++)
		{
			if(LinkToMoveDown[indexDownDelLink].innerHTML.indexOf("Supprimer")!=-1)
			{
				findUp = true;
				break;
			}
		}
		for(var indexUpDelLink=0;indexUpDelLink < LinkToMoveUp.length;indexUpDelLink++)
		{
			if(LinkToMoveUp[indexUpDelLink].innerHTML.indexOf("Supprimer")!=-1)
			{
				findDown = true;
				break;
			}
		}
		
		if(findDown==true && findUp==true)
		{
			temp = LinkToMoveUp[indexUpDelLink].href;
			LinkToMoveUp[indexUpDelLink].href = LinkToMoveDown[indexDownDelLink].href;
			LinkToMoveDown[indexDownDelLink].href = temp;
		}
	}
	DNDObj.initBlockList();
}

function DragDropItemFromGlobalContent(Response,FuncParams)
{
	var divId = FuncParams['DivId'];
	if(document.getElementById(divId)!=null && Response!='')
	{
  		var showndiv =  document.getElementById(divId);
  		showndiv.innerHTML = Response;
  		try{  DNDObj.initBlockList();	}
  		catch(err){	DNDObj = null; }
  	}
}

function MoveItemFromUserScreenEdit(Response,FuncParams)
{
	if(document.getElementById("DragDropItemFromUserScreenEdit")!=null && Response!='')
	{
  		var showndiv =  document.getElementById("DragDropItemFromUserScreenEdit");
  		showndiv.innerHTML = Response;
  		try{  DNDObj.initBlockList();	}
  		catch(err){	DNDObj = null; }
  	}
}

function SetLineGraphCopaCopa(Response,FuncParams)
{
	var table = Response.split('|');
	var so = new SWFObject("M/javascript/AmChart/Line/Line.swf","Line" ,table[2], table[3],'8', '#FFFFFF');
	so.addVariable('path', 'M/javascript/AmChart/Line/');
	// Settings_Mode = 'chart_settings' || 'settings_file'
	//so.addVariable('settings_file', escape(table[1]));
	so.addVariable('chart_settings', escape(table[1]));
	// Data_Mode = 'chart_data' || 'data_file'
	so.addVariable('data_file',escape(table[0]));
	so.addVariable('preloader_color','#FFFFFF');
	so.addParam("wmode", "opaque");
	so.addVariable("loading_settings", "Chargement en cours ...");
	so.addVariable("loading_data", "Chargement en cours ...");
	so.addVariable("preloader_color", "#999999");
	document.getElementById("LineCopaGraph").innerHTML	 = "<img src=M/i/wait.gif>";
	so.write('LineCopaGraph');
}

function GetFieldHistory(Response,FuncParams)
{
	//Ajout du scroll-bar
	document.getElementById("block_nllayer").style.height = 250;
	document.getElementById("block_nllayer").style.overflow = "auto";
	
	document.getElementById("block_nllayer").innerHTML = Response;
	document.all.block_nllayer.style.background = 'white';
	document.getElementById("nllayer").style.display = "inline";
}

function closeHistoryLayer()
{
	document.getElementById("nllayer").style.display = "none";
}

function closeLayer(Response,FuncParams)
{
	
  	if(document.getElementById("nllayer")!=null) {
  		document.getElementById("nllayer").style.display = 'none' ;
  	}
}

function JSMoveFormElement(Response,FuncParams)
{
  	return true;
}

function ShowErrorValue(Response,FuncParams)
{
	//Ajout du scroll-bar
	document.getElementById("block_nllayer").style.overflow = "auto";
	
	document.getElementById("block_nllayer").innerHTML = Response;
	document.all.block_nllayer.style.background = 'white';
	document.getElementById("nllayer").style.display = "inline";
}

function MoveEbadgeItemFromUserScreenEdit(Response,FuncParams)
{
	if(document.getElementById("DragDropEbadgeItemFromUserScreenEdit")!=null && Response!='')
	{
  		var Ebadgeshowndiv =  document.getElementById("DragDropEbadgeItemFromUserScreenEdit");
  		Ebadgeshowndiv.innerHTML = Response;
  		try{  EbadgeDNDObj.initBlockList();	}
  		catch(err){	EbadgeDNDObj = null; }
  	}
}

function closeDetailLayer(Response,FuncParams)
{
	eval(Response);
	document.getElementById("nllayer").style.display = "none";
	if(Response)
	{
		document.getElementById("IdBtnImport").style.display = "none";
		document.getElementById("IdBtnImportAfter").style.display = "none";
		document.getElementById("IdBtnOk").style.display = "inline";
		document.getElementById("IdBtnOkAfter").style.display = "inline";
	}
}

function changeIcon(id)
{
	var img = document.getElementById(id);
    if(img.src.indexOf("down")!=-1)
    {
    	img.src = "M/i/link_Up.gif";
    }
    else
    {
    	img.src = "M/i/link_down.gif";
    }
}

function UpdatingStatusImportList(Response,FuncParams)
{
	if(Response!=""){
		tableResponse = Response.split('#');
		for(var indexResponse=0; indexResponse<tableResponse.length; indexResponse++)
		{
			NewValues = tableResponse[indexResponse].split("|");
			idRow = NewValues[0];
			if(document.getElementById(idRow)){	//alert(idRow);
				var currentRow = document.getElementById(idRow);
				$('TD[@id*=Col_]', currentRow).each(
					function()
					{
						CurrTDId = this.id ;
						CurrTD = this ;//alert(CurrTDId);
						
						if(CurrTDId =='Col_2'){
							val = NewValues[1].split('==');
							CurrTD.innerHTML = val[1];
						}
						if(CurrTDId =='Col_3'){
							val = NewValues[2].split('==');
							CurrTD.innerHTML = val[1];
						}
						if(CurrTDId =='Col_4'){
							val = NewValues[3].split('==');
							CurrTD.innerHTML = val[1];
						}
						if(CurrTDId =='Col_5'){
							val = NewValues[4].split('==');
							CurrTD.innerHTML = val[1];
						}
						if(CurrTDId =='Col_6'){
							val = NewValues[5].split('==');
							CurrTD.innerHTML = val[1];
						}
						if(CurrTDId =='Col_7'){
							val = NewValues[6].split('==');
							CurrTD.innerHTML = val[1];
						}
						if(CurrTDId =='Col_8'){
							val = NewValues[7].split('==');
							CurrTD.innerHTML = val[1];
						}
					}
				);
			}
		}
	}
}

function setNewMediaBlockListOrder(Response,FuncParams)
{
	var divId = FuncParams['DivId'];
	if(document.getElementById(divId)!=null)
	{
  		var showndiv =  document.getElementById(divId);
  		showndiv.innerHTML = Response;
  		try{  blockObj.initBlockList();}
  		catch(err){	blockObj = null; }
  	}
}

function SetNewOrderFormList(Response,FuncParams)
{
	var divId = FuncParams['DivId'];
	if(document.getElementById(divId)!=null && Response!='')
	{
  		var showndiv =  document.getElementById(divId);
  		showndiv.innerHTML = Response;
  		try{  DNDObj.initBlockList();	}
  		catch(err){	DNDObj = null; }
  	}
}