/*V7.3*/
//
// Francois Simard
//  08/02/2002
// CROSS-BROWSER FUNCTIONS. THIS FILE IS USED BY OTHER SCRIPTS AND TK'S :
var isMac = (navigator.userAgent.indexOf('Mac') != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf('Opera') != -1) ? true : false;
var mac4  = (isMac && document.all && navigator.appVersion.indexOf('MSIE 4.5') != -1) ? true : false;


// FOR IE 4 and up
// Write to the document the given string. Has to be called before the onload event or this function will overwrite the whole page
function WC(content)
{
  document.body.insertAdjacentHTML('beforeEnd', content);
};

// Create Div
function CD(eleName, zID, dWidth, visibleVal)
{
  document.body.insertAdjacentHTML('beforeEnd', "<DIV id=\""+eleName+"\" STYLE=\"position:absolute;visibility:"+visibleVal+";z-index:"+zID+";left:0;top:0;\">&nbsp;</DIV>");
  return eleName;
}

// ChangeDivContent - Overwrite the div content with the given string
// ind being the Div ID (or layer tag for netscape) and newContent is the html code to put in the div
function CDC(ind, newContent)
{
  var obj = document.getElementById(ind);
  //obj = eval("document.all."+ind);
  obj.innerHTML = newContent;
};

// SetVisibility - Set the div Visibility
// divnum : Div (layer) ID
// vis : Either 'visible' or 'hidden'
function SV(divNum, vis)
{
  //eval('document.all.'+divNum+'.style.visibility = "'+ vis + '"');
  document.getElementById( divNum ).style.visibility = vis;
};

// SetVisibility - Set the div display
// divnum : Div (layer) ID
// vis : Either 'none' or ''
function SD(divNum, display)
{
  //eval('document.all.'+divNum+'.style.display = "'+ display + '"');
  document.getElementById( divNum ).style.display = display;
  
};

// IsVisible True if the div Visibility property is set to visible
function isV(lName)
{
  //var vis = eval("document.all."+lName+".style.visibility");
  var vis = document.getElementById( divNum ).style.visibility;
  if(vis == 'visible')
    return true;
  else
    return false;
}

// GetLeft - Return the LEFT value of a div
function GL(divNum)
{
  //return eval('document.all.'+divNum+'.style.pixelLeft');
  return document.getElementById( divNum ).style.pixelLeft;
  
};

// GetTop - Return the TOP value of a div (or an element in IE)
// Same as GetLeft
function GT(divNum)
{
  //return eval('document.all.'+divNum+'.style.pixelTop');
  return document.getElementById( divNum ).style.pixelTop;
};

// SetLayerSize - Set the width and height of a div
// divNum: div ID
function SLS(divNum, wVal, hVal)
{
  //eval('document.all.'+divNum+'.style.width  = wVal');
  //eval('document.all.'+divNum+'.style.height = hVal');
  var Obj = document.getElementById( divNum );
  Obj.style.width  = wVal;
  Obj.style.height = hVal;  
};

// SetIndex - Set the index of a div
// Property z-index is used to place a layer on top of another one
function SI(divNum, val)
{
  //eval('document.all.'+divNum+'.style.zIndex = ' + val);
  var Obj = document.getElementById( divNum );
  Obj.style.zIndex  = val;
};

// MoveDivR - Move a given div
function MDR(divNum, topVal, leftVal)
{
  //eval('document.all.'+divNum+'.style.top = '+ topVal);
  //eval('document.all.'+divNum+'.style.left = '+ leftVal);
  var Obj = document.getElementById( divNum );
  Obj.style.top  = topVal;
  Obj.style.left = leftVal;
};

// Returns the Object. If it does'nt exist, you get undefined
// so in your code, you can do : if( ItemExist("divName"))...
function ItemExist(dId)
{
  //return eval('document.all.' + dId);
  var Obj = document.getElementById( dId );
  
  if ( Obj )
    return true;
    
  return false;
  
};

// Check if an image exist.
function ImageExist(dId)
{
  //return eval('document.all.' + dId);
  return ItemExist( dId );
};

// Get Screen Available Height
// (if the user resize his browser window, this value changes)
function GSH()
{
  return document.body.clientHeight;
};

// Get Screen Available Width
function GSW()
{
  return document.body.clientWidth;
};

//Event Stuff

//Get the Mouse X Pos
// ev is the event object from Netscape.
function GMouseX(ev)
{
  return event.x + document.body.scrollLeft;
};

//Get the Mouse Y Pos
// ev is the event object from Netscape.
function GMouseY(ev)
{
  return event.y + GST();
};

// Get Scroll Top (Used by GmouseY)
// If the user scroll down, this value is incremented
function GST()
{
  return document.body.scrollTop;
};

// Get Scoll Left
function GSL()
{
  return document.body.scrollLeft;
};

// Get the element name from the event Object
function GE()
{
  return window.event.srcElement.name;
};

// Get the Left value IE ONLY
// In IE, when you get the position of an object, it is relative to it's parent element
// for example, if an image is in a table, is left value will be the amount of pixels between the
// table border and it's borders.
function GetRealLeft(zName)
{
  return GetRealLeftByObject( document.getElementById( zName ) );
	/*
	var xPos = (isMac) ? document.all[zName].clientLeft : document.all[zName].offsetLeft;
	tempEl = document.all[zName].offsetParent;
	var c = 0;
  while (tempEl != null)
    {
      if(tempEl.tagName == "TABLE")
        c++;
      xPos  += (isMac) ? tempEl.clientLeft : tempEl.offsetLeft;
      tempEl = tempEl.offsetParent;
    }
  if(c > 2 )
    xPos++;
     
  return xPos;
  */
};

// Get the Top value IE ONLY
// Same as GetRealLeft but for Top position
function GetRealTop(zName)
{
  return GetRealTopByObject( document.getElementById( zName ) );
  /*
  var yPos = (isMac) ? document.all[zName].clientTop : document.all[zName].offsetTop;
	tempEl = document.all[zName].offsetParent;
	var c = 0;
  while (tempEl)
    {
      if(tempEl.tagName == "TABLE")
    	  c++;
      yPos  += (isMac) ? tempEl.clientTop : tempEl.offsetTop;
    	tempEl = tempEl.offsetParent;
    }
  if(c > 2)
    yPos++;
    
  return yPos;
  */
};

// 2 functions for netscape 6 only when getting left and top value of an image.
// Get the image Left value
function GetRealImgLeft(zName)
{
  return GetRealLeftByObject( document.getElementById( zName ) );
  /*
	var xPos = (isMac) ? document.images[zName].clientLeft : document.images[zName].offsetLeft;
	tempEl = document.images[zName].offsetParent;
	var c = 0;
  	while (tempEl)
    	{
    	  if(tempEl != null && tempEl.tagName == "TABLE")
    	    c++;
    	  xPos  += (isMac) ? tempEl.clientLeft : tempEl.offsetLeft;
    	  tempEl = tempEl.offsetParent;
    	}
   if(c > 2)
    xPos++;
   return xPos;
   */
};

// Get the image Top value IE and NS6+ ONLY
function GetRealImgTop(zName)
{
  return GetRealTopByObject( document.getElementById( zName ) );
  
  /*
  var yPos = (isMac) ? document.images[zName].clientTop : document.images[zName].offsetTop;
  tempEl = document.images[zName].offsetParent;
  var c = 0;
 	while (tempEl != null)
    {
      if(tempEl.tagName == "TABLE")
    	  c++;
      yPos  += (isMac) ? tempEl.clientTop : tempEl.offsetTop;
    	tempEl = tempEl.offsetParent;
    }
   if(c > 2)
    yPos++;
   return yPos;
   */
};

function GetImageWidth(ele)
{
  return GetWidth(ele);
}

// Get the width of a div
function GetWidth(ele)
{
  //return eval('document.all.'+ele+'.offsetWidth');
  return document.getElementById( ele ).offsetWidth;
};

function GetImageHeight(ele)
{
  return GetHeight(ele);
}

// Get the height of a div
function GetHeight(ele)
{
  //return eval('document.all.'+ele+'.offsetHeight');
  return document.getElementById( ele ).offsetHeight;
};