bGblPageLoaded = false;


// ************************************************
// Gestion des Cookies
// ************************************************
function CreateCookie(sName, sValue, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var sExpires = "; expires=" + date.toGMTString();
	}
	else var sExpires = "";
	document.cookie = sName + "=" + sValue + sExpires + "; path=/";
}

function ReadCookie(sName) {
	var nameEQ = sName + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function EraseCookie(Name) {
	CreateCookie(sName, "" , -1);
}


// ************************************************
// Gestion des Cookies GetXmlHttpObject
// ************************************************
var xmlHttp;

function GetXmlHttpObject() {
  var xmlHttpObject = null;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttpObject = new XMLHttpRequest();
  }
  catch (e) {
    // Internet Explorer
    try {
      xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttpObject;
}

// ************************************************
// Gestion du curseur
// ************************************************
function positionX(e) {
  if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
    posX = e.pageX;
  } else {
    if(document.documentElement.clientWidth > 0) {
      posX = event.x + document.documentElement.scrollLeft;
    } else {
      posX = event.x + document.body.scrollLeft;
    }
  }
  return posX;
}

function positionY(e) {
  if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
    posY = e.pageY;
  } else {
    if(document.documentElement.clientWidth > 0) {
      posY = event.y + document.documentElement.scrollTop;
    } else {
      posY = event.y + document.body.scrollTop;
    }
  }
  return posY;
}

function findPos(sId, curleft, curtop, curwidth, curheight) {
  obj = document.getElementById(sId)
  curleft   = 0;
  curtop    = 0;
  curwidth  = 0;
  curheight = 0;
  if (obj.offsetParent) {
    curleft   = obj.offsetLeft
    curtop    = obj.offsetTop
    curwidth  = obj.clientWidth
    curheight = obj.clientHeight
    while (obj = obj.offsetParent) {
      curleft   += obj.offsetLeft
      curtop    += obj.offsetTop
    }
  }
  return [curleft, curtop, curwidth, curheight];
}

function ObjInside(sId, iPosX, iPosY) {
  aObjImg = findPos(sId);
  if((iPosX >= (aObjImg[0])) && (iPosX <= (aObjImg[0] + aObjImg[2])) && (iPosY >= (aObjImg[1])) && (iPosY <= (aObjImg[1] + aObjImg[3]))) {
    return true; }
  else { return false; }
}

// ************************************************
// Gestion CSS
// ************************************************
function FakeLinkHover(obj, bValue) {
  if(bValue ==  true) {
    obj.style.color= "#E0DEDE";
  }
  else {
    obj.style.color= "#999999";
  }
}

function SetBackgroundColor(sId, sColor) {
  document.getElementById(sId).style.backgroundColor = sColor;
}


