var agent = navigator.userAgent.toLowerCase();
var w3c = document.getElementById ? true : false;
var iex = (navigator.appName == 'Microsoft Internet Explorer') ? true : false;
function getStyle(nom){
	return w3c ? document.getElementById(nom).style : iex ? document.all[nom].style : false;
}
function getObj(nom){
	return w3c ? document.getElementById(nom) : iex ? document.all[nom] : false;
}
Menu = function(nom,left,top){
	this.name = nom;
	this.timer = null;
	this.obj = nom+'Object';
	eval(this.obj+'=this');
}
Menu.prototype.montrer = function(nomSubMenu){
	menuCourant = this.name;
// alert(menuCourant);
	objMenuCourant = getStyle(this.name);
	objDysplayMenu = getObj(nomSubMenu);
	clearTimeout(this.timer);
	var windowWidth = iex ? document.body.clientWidth : window.innerWidth;

/*
//	var offset = Math.floor((windowWidth-770)/2);
//	if(offset < 0){
		offset = 0;
//	}
	var psoitionHaut = objDysplayMenu.offsetTop ? (objDysplayMenu.offsetTop + objDysplayMenu.offsetHeight + 1): 203;
	var psoitionGauche = objDysplayMenu.offsetLeft;
	if (psoitionGauche == 0) {
	 if (objDysplayMenu.offsetParent.offsetParent.offsetLeft == 0) { // opera
	 	psoitionGauche = objDysplayMenu.offsetParent.offsetLeft;
		psoitionHaut = objDysplayMenu.offsetParent.offsetTop+objDysplayMenu.offsetParent.offsetHeight+6;
	 } else { //konqueror + ie
	 	psoitionGauche = objDysplayMenu.offsetParent.offsetLeft+offset;
		psoitionHaut = iex ? 205 : 218;
alert(psoitionGauche+"  "+psoitionHaut);
	 }
	}
//	objMenuCourant.left = psoitionGauche+"px";
//	objMenuCourant.top = psoitionHaut+"px";
// alert(objMenuCourant);
*/

if (this.name=="searchkey") {
  objMenuCourant.height = "auto";
  return;
}

  if (menuCourant.substr(0,2)=="sm") {
    var pLeft=getPageOffsetLeft(objDysplayMenu)-2;
    var pTop=getPageOffsetTop(objDysplayMenu)+25;
    var pwidth=100;
    if (pLeft+pwidth>windowWidth) {
      pLeft = windowWidth-pwidth;
    }
    objMenuCourant.left = pLeft+"px";
    objMenuCourant.top = pTop+"px";
  } else {
     objMenuCourant.height = 'auto';
    }

  objMenuCourant.visibility = 'visible';
}

Menu.prototype.cacher = function(){
	this.timer = setTimeout(this.obj+'.cacheLe()',500);
}

Menu.prototype.cacheLe = function(){
	var objMenuCourant = getStyle(this.name);
if (this.name=="searchkey") {
objMenuCourant.height = "200px";
return;
}

	objMenuCourant.visibility = 'hidden';
	if (this.name.substr(0,2)!="sm") {
		objMenuCourant.height = '1px';
	}
}
cacheLes = function(){
	if(menuCourant != null){
		Menus[menuCourant].cacheLe();
		menuCourant = null;
	}
}
creerMenu = function(nom,left){
	Menus[nom] = new Menu(nom);
}

function getPageOffsetLeft(elt) 
{
  var x;
  x = elt.offsetLeft;
  if (elt.offsetParent != null)
    x += getPageOffsetLeft(elt.offsetParent);
  return x;
}


function getPageOffsetTop(elt) 
{
  var y;
  y = elt.offsetTop;
  if (elt.offsetParent != null)
    y += getPageOffsetTop(elt.offsetParent);
  return y;
}



Menus = new Object();
var menuCourant = null;
creerMenu('sm1');
creerMenu('sm2');
creerMenu('sm3');
creerMenu('sm4');
creerMenu('sm5');
creerMenu('sm6');
creerMenu('sm7');
creerMenu('sm8');
creerMenu('screensize');
creerMenu('screencolor');
creerMenu('browser');
creerMenu('browserver');
creerMenu('os');
creerMenu('osver');
creerMenu('continent');
creerMenu('country');
creerMenu('visitlengthbytime');
creerMenu('visitlengthbypageview');
creerMenu('javascript');
creerMenu('searchkey');

