﻿var Langue;

<!-- MENU -->

var csmo;
var idSel = 0;
var idShow = 0;
var openPage = 1;

function gmi(){
	try{
		return this.document.getElementById('HeaderMenuCtl_txtMenu').value;
	}catch(e){
		alert(e);
	}
}

function gmis(){
	try{
		return this.document.getElementById('HeaderMenuCtl_txtMenuSel').value;
	}catch(e){
		alert(e);
	}
}

function mov(o){
	
	try{

		bHideMenu = 0;

		var isChild = 0;
		
		if ( o.id.indexOf('cim') != -1 )
		{
			isChild = 1;
		} else {
			csmo = o;
			HideAllMenu();
		}
		
		var id = o.id.replace('cim', '');
		id = id.replace('im', '');
		
		if (HavePage(id)==1){
		  o.style.cursor = 'pointer';
		}
		else{
		  o.style.cursor = 'default';
		}
		
		if (idSel == 0){
			idSel = gmi();
		}

		if(id != idSel){
			o.src=o.src.replace('c10', 'c75')
			
			ChangeBorder(o, 0);
			
		}
		
		var sm = GetSubMenu(id);

		
		if (sm != null){

			var oDiv = document.getElementById('dsm' + id)
			
			if (oDiv == null){
				oDiv = document.createElement("div");
				oDiv.id = 'dsm' + id;
				oDiv.innerHTML = sm;
				oDiv.style.position="absolute";
				oDiv.style.display = 'none';
				oDiv.style.zIndex=999;
				//oDiv.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(", strength=3, color=gray, direction=135")';
				document.form1.appendChild(oDiv);
			}

			var mw;
			
			try
			{
			mw = parseFloat(oDiv.children[0].style.width.replace('px', ''))-14;
			}
			catch(ediv)
			{
			  mw = parseFloat(oDiv.childNodes[0].style.width.replace('px', ''))-14;
			}

			var ml = 0;

			if (isChild == 0){
			
				ml = getX(o.parentNode);
			
				if (document.body.clientWidth > ml + mw){
					oDiv.style.left = ml+'px';
				}
				else{
					oDiv.style.left = ml - (ml + mw - document.body.clientWidth) +'px';
				}
				
				oDiv.style.top = (getY(o.parentNode)+o.parentNode.offsetHeight)+'px';
				
			}else{
			
				ml = (getX(o.parentNode)+o.parentNode.offsetWidth);
			
				if (document.body.clientWidth > ml + mw){
					oDiv.style.left = ml+'px';
				}
				else{
					oDiv.style.left = ml - (ml + mw - document.body.clientWidth) +'px';
				}

				oDiv.style.top = getY(o.parentNode)+'px';

			}
			
			//oDiv.style.display = 'inline';
			oDiv.style.display = 'block';

		}
	
	}catch(e){
		alert(e);
	}
	
}

function mou(o){
	
	try{

		var id = o.id.replace('cim', '');
		id = id.replace('im', '');

		//var idSel = gmi();
		if(id != idSel){
			o.src=o.src.replace('c75', 'c10')

			ChangeBorder(o, 1);

			SelMenu();

		}

		TmrHideMenu();

	}catch(e){
		alert(e);
	}
}

function mcl(o){

	try{

		var id = o.id.replace('cim', '');
		id = id.replace('im', '');
		
		//if(idShow != id || GetSID() == id){
		
			if ( HavePage(id) == 1 )
			{	

				var oSel = document.getElementById('im' + idSel);
				if (oSel == null){
					oSel = document.getElementById('cim' + idSel);
				}
				if (oSel != null){
				  oSel.src=oSel.src.replace('c100', 'c10')
				  ChangeBorder(oSel, 1);
				}
				
				o.src=o.src.replace('c75', 'c10')
				
				if (csmo != null){
					if (csmo.src.indexOf('c100') == -1){
					  csmo.src=csmo.src.replace('c10', 'c100')
					  csmo.src=csmo.src.replace('c75', 'c100')
					}
					idSel = csmo.id.replace('cim', '');
					idSel = idSel.replace('im', '');
				}
				
				this.document.getElementById('HeaderMenuCtl_txtMenu').value = id;
				this.document.getElementById('HeaderMenuCtl_txtMenuSel').value = idSel;
			
				bHideMenu = 1;
				HideMenu();

        if (openPage == 1) {
          wait(1, 1);
				  this.document.getElementById('fraContenu').src = 'frmOpen.aspx?ID=' + id;
				}
				idShow = id;

//     		if (id == 1) {
//		      this.document.getElementById('tblMain').width = '725px';
//		      this.document.getElementById('fraContenu').width = '723px';
//		    }
//		    else {
//		      this.document.getElementById('tblMain').width = '80%';
//		      this.document.getElementById('fraContenu').width = '100%';
//		      this.document.getElementById('tblMain').height = document.body.clientHeight * 0.9;
//		      this.document.getElementById('trFra').height = (document.body.clientHeight * 0.9) ;
//		      this.document.getElementById('fraContenu').height = (document.body.clientHeight * 0.9) ;
//		    }

			//}
		}

	}catch(e){
		alert(e);
	}

}


function genererME(i, op){
  openPage = op;
  var o = document.getElementById('im'+i);
  mov(o);
  mcl(o);
  //mou(o);
  openPage = 1;
}

function UnselMenu(){
  if (idSel > -1){
    var oSel = document.getElementById('im' + idSel);
	  if (oSel == null){
		  oSel = document.getElementById('cim' + idSel);
	  }
	  oSel.src=oSel.src.replace('c100', 'c10')
	  ChangeBorder(oSel, 1);
	  idSel=-1;
	}
}

function SelMenu(){
  if (idSel > 0){
	  var oSel = document.getElementById('im' + idSel);
	  if (oSel.src.indexOf('c100') == -1) {
		  oSel.src=oSel.src.replace('c10', 'c100');
		  oSel.src=oSel.src.replace('c75', 'c100');
	  }
	  ChangeBorder(oSel, 0);
	 }
}

function getY( o )
{

	try{

		var ret = 0;
		while( o != null ) {
			ret += o.offsetTop;
			o = o.offsetParent;
		}
		return ret;
	
	}catch(e){
		alert(e);
	}
	
}
function getX( o )
{

	try{

		var ret = 0;
		while( o != null ) {
			ret += o.offsetLeft;
			o = o.offsetParent;
		}
		return ret;
	
	}catch(e){
		alert(e);
	}
}

var bHideMenu = 0;

function TmrHideMenu(){
	
	try{
	
		bHideMenu = 1;
		window.setTimeout("HideMenu()", 1000);
	
	}catch(e){
		alert(e);
	}
	
}

function HideMenu(){

	try{

		if (bHideMenu == 1){
			HideAllMenu();
		}
	
	}catch(e){
		alert(e);
	}
	
}

function ChangeBorder(o, isDashed) {
  
	if (isDashed == 1){
	
		var nomClass = '';
			
		if (o.id.indexOf('cim') != -1){
			nomClass = 'lshc';
		}else{
			nomClass = 'lsvc';
		}
	
		try{ o.parentNode.previousSibling.className = nomClass;}catch(e2){
			try{o.parentNode.parentNode.previousSibling.cells[0].className = nomClass;}catch(e3){
			}
		}
		try{ o.parentNode.nextSibling.className = nomClass;}catch(e2){
			try{o.parentNode.parentNode.nextSibling.cells[0].className = nomClass;}catch(e3){
			}
		}
	}
	else
	{
		try{ o.parentNode.previousSibling.className='lsvoc';}catch(e2){
			try{ o.parentNode.parentNode.previousSibling.cells[0].className='lshoc';}catch(e3){
			}
		}
		try{ o.parentNode.nextSibling.className = 'lsvoc';}catch(e2){
			try{ o.parentNode.parentNode.nextSibling.cells[0].className='lshoc';}catch(e3){
			}
		}
	}
}

function ChangeSM(m){
  if( m == 'L' ){
    document.getElementById('imgL').style.display = '';
    document.getElementById('HeaderMenuCtl_imgU').style.display = 'none';
  }
  if( m == 'U' ){
    document.getElementById('imgL').style.display = 'none';
    document.getElementById('HeaderMenuCtl_imgU').style.display = '';
  }
}

function wait(show, AutoHide)
{
  if (show == 1)
  {
    var oImg = document.getElementById('imgwait');
    oImg.style.display = '';
    oImg.style.left = (document.body.offsetWidth / 2) - 75 + 'px';
    oImg.style.top = (document.body.offsetHeight / 2) - 50 + 'px';
    if (AutoHide == 1){
      window.setTimeout('wait(0);', 2000);
    }
  }
  else
  {
    document.getElementById('imgwait').style.display = 'none';
  }
}

<!-- MENU FIN -->
