var aMenu_En_Cours='';
var gTable_En_Cours='';
var gAncienne_Table='';
function Afficher_Menu(aObjet)
{
	/*if (aObjet.id=="IMG_MENU" + gTable_En_Cours)	
	{
		window.document.all('TABLE_MENU' + gTable_En_Cours).style.display='';
		window.document.all('TABLE_MENU_TRI' + gTable_En_Cours).style.left=parseInt(window.document.all('TABLE_MENU' + gTable_En_Cours).offsetLeft) + parseInt(window.document.all('TABLE_MENU' + gTable_En_Cours).offsetWidth)-2;
		if ((gAncienne_Table!='TABLE_MENU' + gTable_En_Cours)&&(gAncienne_Table!=''))
		{
			window.document.all(gAncienne_Table).style.display='none';
			if (aMenu_En_Cours!='')
			{
				window.document.all(aMenu_En_Cours).style.display='none';
			}
		}	
		gAncienne_Table='TABLE_MENU' + gTable_En_Cours;
	}
	else
	{
		//window.document.all('TABLE_MENU_TRI' + gTable_En_Cours).style.display='';
		var aColonne=parseInt(aObjet.id.substr(0,1));
		var aObjet_New=aObjet.id.substr(4);
		if (aMenu_En_Cours!='')
		{
			window.document.all(aMenu_En_Cours).style.display='none';
		}
		aMenu_En_Cours=aObjet_New;
		window.document.all(aObjet_New).style.left=window.document.all('TABLE_MENU' + gTable_En_Cours).offsetLeft + window.document.all('TABLE_MENU' + gTable_En_Cours).offsetWidth;
		window.document.all(aObjet_New).style.display='';
	}*/
	
	
		
	if (aObjet.id=="IMG_MENU" + gTable_En_Cours)
	{	
		aObjet_Position=aObjet;
		aTop=0;
		aLeft=0;
		while(aObjet_Position.tagName!='BODY')
		{
			if(aObjet_Position.tagName!='TD')
			{ 
				aTop=aTop + aObjet_Position.offsetTop;
			}
			if(aObjet_Position.tagName!='TR')
			{
				aLeft=aLeft + aObjet_Position.offsetLeft;
			}
			aObjet_Position=aObjet_Position.parentElement;
		}
		window.document.all('TABLE_MENU' + gTable_En_Cours).style.top=aTop + window.document.all('IMG_MENU' + gTable_En_Cours).offsetHeight;
		window.document.all('TABLE_MENU' + gTable_En_Cours).style.left=aLeft;
		window.document.all('TABLE_MENU' + gTable_En_Cours).style.display='';
		if ((gAncienne_Table!='TABLE_MENU' + gTable_En_Cours)&&(gAncienne_Table!=''))
		{
			window.document.all(gAncienne_Table).style.display='none';
			if (aMenu_En_Cours!='')
			{
				window.document.all(aMenu_En_Cours).style.display='none';
			}
		}	
		gAncienne_Table='TABLE_MENU' + gTable_En_Cours;
	}
	else
	{
		var aColonne=parseInt(aObjet.id.substr(0,1));
		var aObjet_New=aObjet.id.substr(4);
		if (aMenu_En_Cours!='')
		{
			window.document.all(aMenu_En_Cours).style.display='none';
		}
		aMenu_En_Cours=aObjet_New;
		window.document.all(aObjet_New).style.top=window.document.all('TABLE_MENU' + gTable_En_Cours).offsetTop + (30 * aColonne)-30;
		window.document.all(aObjet_New).style.left=window.document.all('TABLE_MENU' + gTable_En_Cours).offsetLeft + window.document.all('TABLE_MENU' + gTable_En_Cours).offsetWidth;
		window.document.all(aObjet_New).style.display='';
	}									
}

function Test_Menu()
{
	if(window.document.activeElement!=null)
	{	
		if((window.document.elementFromPoint(event.clientX,event.clientY).id.indexOf('MENU')==-1)&&(window.document.activeElement.id.indexOf('MENU')==-1))
		{
			if(window.document.all('TABLE_MENU' + gTable_En_Cours)!=null)
			{ 	
				if (aMenu_En_Cours!="")	
				{
					window.document.all(aMenu_En_Cours).style.display='none';
				}
				window.document.all('TABLE_MENU' + gTable_En_Cours).style.display='none';
			}
		}
	}
}

var gSeparateur=" ";
function Execute_Tri_Chaine(wOrdre,wTable,wCol)
{
	var i;
	var wNumPremier;
	var LigneEnCours;
	var wTemp;
	wTable=window.document.all(wTable);
	wNbLigne=wTable.children[0].children.length;
	wNbColonne=wTable.children[0].children[1].children.length;
	wLigneEnCours=1;
	wLigneInsert=1;
	while (wLigneEnCours!=wNbLigne)
	{	
		wNumPremier=wLigneEnCours;
		wNumPremierDepart=wLigneEnCours;
		for (i=wLigneEnCours+1 ;i < wNbLigne; i++)
		{
			if (wOrdre=="ASC")
			{
				if (wCol==0)
				{
					if (wTable.children[0].children[i].children[wCol].innerText < wTable.children[0].children[wNumPremier].children[wCol].innerText)
					{
						wNumPremier=i;
					}
				}
				else
				{
					wCh1=wTable.children[0].children[wNumPremier].children[wCol].innerText;
					wCh2=wTable.children[0].children[i].children[wCol].innerText;
					while (wCh1.indexOf(gSeparateur)!=-1)	
					{
						wCh1=wCh1.replace(gSeparateur,"");
					}
					while (wCh2.indexOf(gSeparateur)!=-1)	
					{
						wCh2=wCh2.replace(gSeparateur,"");
					}
					wCh1=wCh1.replace(",",".");
					wCh2=wCh2.replace(",",".");
					if (wCh1=='')
					{
						wCh1=-0.00000000001;
					}
					if (wCh2=='')
					{
						wCh2=-0.00000000001;
					}
					if (parseFloat(wCh2) < parseFloat(wCh1))
					{
						wNumPremier=i;
					}
				}
			}	
 			else
 			{
 				if (wCol==0)
				{
 					if (wTable.children[0].children[wNumPremier].children[wCol].innerText < wTable.children[0].children[i].children[wCol].innerText)
					{
						wNumPremier=i;
					}
				}
				else
				{
					wCh1=wTable.children[0].children[wNumPremier].children[wCol].innerText;
					wCh2=wTable.children[0].children[i].children[wCol].innerText;
					while (wCh1.indexOf(gSeparateur)!=-1)	
					{
						wCh1=wCh1.replace(gSeparateur,"");
					}
					while (wCh2.indexOf(gSeparateur)!=-1)	
					{
						wCh2=wCh2.replace(gSeparateur,"");
					}
					wCh1=wCh1.replace(",",".");
					wCh2=wCh2.replace(",",".");
					if (wCh1=='')
					{
						wCh1=-0.00000000001;
					}
					if (wCh2=='')
					{
						wCh2=-0.00000000001;
					}
					if (parseFloat(wCh1) < parseFloat(wCh2))
					{
						wNumPremier=i;
					}
				}
			}
		}
		if (wNumPremier!=wNumPremierDepart)
		{
			wTR=wTable.insertRow(wLigneInsert);
			wTR.className=wTable.children[0].children[wNumPremier + 1].className;
			wLigneInsert++;
			for (i=0;i<wNbColonne;i++)
			{
				wTD=wTR.insertCell();
				wTD.align=wTable.children[0].children[wNumPremier + 1].children[i].align;
				wTD.insertAdjacentHTML("AfterBegin" ,wTable.children[0].children[wNumPremier + 1].children[i].innerHTML);	
			}	
			wTable.deleteRow(wNumPremier + 1);
		}
		else
		{
			wLigneInsert++;
		}
		wLigneEnCours++;
	}
}
var gListeCharge=',';
function Charge_Liste(aObjet)
{
	var i=0;
	var wLstElement;
	if(gListeCharge.indexOf("," + window.document.all(aObjet).id + ",")==-1)
	{
		for (i=0;i<=window.document.all(aObjet).children[0].children[0].children.length-1;i++)
		{
			wLstElement = window.document.createElement("OPTION");
			if (i==0)
			{
				wLstElement.text = window.document.all(aObjet).children[0].children[0].children[i].innerText.substr(window.document.all("TABLE_MENU" + aObjet).innerText.length);	
				wLstElement.text=wLstElement.text.substr(wLstElement.text.indexOf(" ")+2);
			}
			else
			{
				wLstElement.text = window.document.all(aObjet).children[0].children[0].children[i].innerText;
			}	
			window.document.all('1LST_MENU_TRI_DYN' + aObjet).options.add(wLstElement);	
		}
		gListeCharge=gListeCharge + window.document.all(aObjet).id + ",";
	}
}

function Remettre_Selection(aType)
{
	switch (aType)
	{
		case "GLSTOP" :
			window.parent.document.all('TAB_OP').style.display='none';
			window.parent.document.all('TAB_SELECTION').style.display='none';
			window.parent.document.all('TAB_OP_PAGE').style.display='none';
			window.parent.document.all('TAB_PHOTOS').style.display='none';
			window.parent.document.all('TAB_CALENDRIER_OP').style.display='none';
			window.parent.document.all('TAB_ONGLET').style.display='';
			break;
		case "GLSTPROSACT" :
			window.parent.document.all('TAB_PROS_ACT').style.display='none';
			window.parent.document.all('TAB_PROS_ACT_PAGE').style.display='none';
			window.parent.document.all('TAB_SELECTION').style.display='none';
			window.parent.document.all('TAB_ONGLET').style.display='';
			break;
		case "GLSTARTACT" :
			window.parent.document.all('TAB_ART_ACT').style.display='none';
			window.parent.document.all('TAB_ART_ACT_PAGE').style.display='none';
			window.parent.document.all('TAB_SELECTION').style.display='none';
			window.parent.document.all('TAB_ONGLET').style.display='';
			break;
		case "GLSTPROMOACT" :
			window.parent.document.all('TAB_PROMO_ACT').style.display='none';
			window.parent.document.all('TAB_PROMO_ACT_PAGE').style.display='none';
			window.parent.document.all('TAB_SELECTION').style.display='none';
			window.parent.document.all('TAB_ONGLET').style.display='';
			break;
		case "PERNOD" :
			window.parent.document.all('TAB_PERNOD_PROMO').style.display='none';
			window.parent.document.all('TAB_PERNOD_PROMO_PAGE').style.display='none';
			window.parent.document.all('TAB_SELECTION').style.display='none';
			window.parent.document.all('TAB_ONGLET').style.display='';
			break;
		case "ANALYSE_PRIX" :
			window.parent.document.all('TAB_ANALYSE_PRIX').style.display='none';
			window.parent.document.all('TAB_ANALYSE_PRIX_PAGE').style.display='none';
			window.parent.document.all('TAB_SELECTION').style.display='none';
			window.parent.document.all('TAB_ONGLET').style.display='';
			break;
		case "ANALYSE_PRIXMINIMAXI" :
			window.parent.document.all('TAB_ANALYSE_PRIXMINIMAXI_IMG').style.display='none';
			window.parent.document.all('TAB_ANALYSE_PRIXMINIMAXI_PRIX').style.display='none';
			window.parent.document.all('TAB_ANALYSE_PRIXMINIMAXI').style.display='none';
			//window.parent.document.all('TAB_ANALYSE_PRIXMINIMAXI_PAGE').style.display='none';
			window.parent.document.all('TAB_SELECTION').style.display='none';
			window.parent.document.all('TAB_ONGLET').style.display='';
			break;
	}
}


