// Check screen size
function getScreenWidth()
{
   var getWidth = 0;

   //Non-IE
   if (typeof(window.innerWidth) == 'number')
   {
      getWidth = window.innerWidth;
   }
   //IE 6+ in 'standards compliant mode'
   else if (document.documentElement && document.documentElement.clientWidth)
   {
      getWidth = document.documentElement.clientWidth;
   }
   //IE 4 compatible
   else if (document.body && document.body.clientWidth)
   {
      getWidth = document.body.clientWidth;
   }
   return getWidth;
}

function getScreenHeight()
{
   var getHeight = 0;

   //Non-IE
   if (typeof(window.innerHeight) == 'number')
   {
      getHeight = window.innerHeight;
   }
   //IE 6+ in 'standards compliant mode'
   else if (document.documentElement && document.documentElement.clientHeight)
   {
      getHeight = document.documentElement.clientHeight;
   }
   //IE 4 compatible
   else if (document.body && document.body.clientHeight)
   {
      getHeight = document.body.clientHeight;
   }
   return getHeight;
}
function stringWidth(string, fontFamily, fontSize, fontWeight, fontStyle, fontVariant)
{
   var width = 0;
   var testDiv = null;

   if (!fontFamily) fontFamily = 'Arial,Helvetica';

   if (!fontSize) fontSize = '1em';

   //creer le div du texte de cet item
   testDiv = document.createElement('div');
   testDiv.style.position = "absolute";
   testDiv.style.width = "auto";
   testDiv.style.fontFamily = fontFamily;
   testDiv.style.fontSize = fontSize;
   // font-weight peut être normal | bold | bolder | lighter | inherit
   if (typeof(fontWeight) != 'undefined' && fontWeight != '') testDiv.style.fontWeight = fontWeight;
   // font-style peut être italic | oblique | normal | inherit
   if (typeof(fontStyle) != 'undefined' && fontStyle != '') testDiv.style.fontStyle = fontStyle;
   testDiv.innerHTML = string;
   document.body.appendChild(testDiv);
   width = testDiv.clientWidth;
   document.body.removeChild(testDiv);
   return width;
};

function stringHeight(string, fontFamily, fontSize, fontWeight, fontStyle, fontVariant)
{
   var height = 0;
   var testDiv = null;

   if (!fontFamily) fontFamily = 'Arial,Helvetica';

   if (!fontSize) fontSize = '8pt';

   //creer le div du texte de cet item
   testDiv = document.createElement('div');
   testDiv.style.position = "absolute";
   testDiv.style.width = "auto";
   testDiv.style.fontFamily = fontFamily;
   testDiv.style.fontSize = fontSize;
   // font-weight peut être normal | bold | bolder | lighter | inherit
   if (typeof(fontWeight) != 'undefined' && fontWeight != '') testDiv.style.fontWeight = fontWeight;
   // font-style peut être italic | oblique | normal | inherit
   if (typeof(fontStyle) != 'undefined' && fontStyle != '') testDiv.style.fontStyle = fontStyle;
   testDiv.innerHTML = string;
   document.body.appendChild(testDiv);
   height = testDiv.clientHeight;
   document.body.removeChild(testDiv);
   return height;
};
//==============================================================================
//  Routines de détermination du type de navigateur
//==============================================================================

   IsIE = typeof document.all != 'undefined' && typeof document.getElementById != 'undefined' && typeof window.opera == 'undefined';

   IsMozilla = typeof document.all == 'undefined' && typeof document.getElementById != 'undefined' && typeof window.opera == 'undefined';

   IsOpera = typeof window.opera != 'undefined';

   IsSafari = false;
function preventDefault(evt)
{
   if (IsIE)
   {
      if (!window.event)
      {
         evt = window.event;
      }
      evt.returnValue = false;
   }
   else
   {
      evt.preventDefault();
   }
};

function stopPropagation(evt)
{
   if (IsIE)
   {
      if (!window.event) evt = window.event;
      evt.cancelBubble = true;
   }
   else evt.stopPropagation();
};

function cancelSelection()
{
   if (IsIE)
   {
      document.body.onselectstart = new Function("return false;");
      document.body.ondragstart = new Function("return false;");
      document.body.ondrag = new Function("return false;");
      document.body.ondragend = new Function("return false;");
   }
   else
   {
      document.onmousedown = function() {return false;}
   }
};

function getRealPos(elem, topOuLeft) {
	pos = 0;

	while (elem!=null) {
	 	pos += elem["offset" + topOuLeft];
		elem = elem.offsetParent;
	}

	return pos;
};
