/******************************************************************************************
* JAVASCRIPT GLOBALS FUNCTIONS
******************************************************************************************/
function getObj(id, framename)
{
 if (framename && top[framename]) { myDocument = top[framename].document; } else { myDocument = document; }
 
 if (myDocument.getElementById)
 {
  myObj = myDocument.getElementById(id);
 }
 else if (myDocument.all)
 {
  myObj = myDocument.all[id];
 }
 else if (myDocument.layers)
 {
  myObj = myDocument.layers[id];
  myObj.style = myDocument.layers[id];
 }
 return myObj;
}

function getObjValue(id, framename)
{
 if (myObj = getObj(id, framename))
 {  
  if (myObj.value) { return myObj.value; } // Input type
  if (myObj.options) { return myObj.options[myObj.selectedIndex].value; } // Select type
  if (myObj.innerHTML) { return myObj.innerHTML } // All other types (DIV/SPANs/etc)
 }
 else
 {
  return false;
 }
}

function getFrame(framename)
{
 if (framename && top[framename])
 {
  return top[framename];
 }
 else
 {
  return false;
 }
}

function getTop(myObj)
{
 var top=0;
 while (myObj != document.body)
 {
  top += myObj.offsetTop;
  myObj = myObj.offsetParent;
 } 
 return top;
}

function getLeft(myObj)
{
 var left=0;
 while (myObj != document.body)
 {
  left += myObj.offsetLeft;
  myObj = myObj.offsetParent;
 } 
 return left;
}

function getPageDimension()
{
 var dimension = new Array(2);
 if(typeof(window.innerWidth)=='number')
 {
  //Non-IE
  dimension['width'] = window.innerWidth;
  dimension['height'] = window.innerHeight;
 }
 else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
 {
  //IE 6+ in 'standards compliant mode'
  dimension['width'] = document.documentElement.clientWidth;
  dimension['height'] = document.documentElement.clientHeight;
 }
 else if(document.body && ( document.body.clientWidth || document.body.clientHeight))
 {
  //IE 4 compatible
  dimension['width'] = document.body.clientWidth;
  dimension['height'] = document.body.clientHeight;
 }
 return dimension;
}

function showAttributes(myObj)
{
 var output;
 for (var key in myObj)
 {
  output += key + '=>' + myObj[key] + '\n';
 }
 alert(output);
}

function mouseCoords(e)
{
 if(e.pageX || e.pageY){
  return {x:e.pageX, y:e.pageY};
 }
 return {
  x:e.clientX + document.body.scrollLeft - document.body.clientLeft,
  y:e.clientY + document.body.scrollTop  - document.body.clientTop
 };
}

function createMethodReference(object, method)
{
 if (!(method instanceof Function))
 {
  method = object[method];
 }
 return function()
 {
  method.apply(object,arguments);
 }
}

function createEventListenerMethodReference(object, methodName)
{
 return function (event)
 {
  object[methodName].call(object, event || window.event);
 };
}


/******************************************************************************************
* AJAX CLASS
******************************************************************************************/
function Ajax()
{
 var ajaxObj;
 try
 {
  // Firefox, Opera 8.0+, Safari
  ajaxObj=new XMLHttpRequest();
 }
 catch (e)
 {
  // Internet Explorer
  try
  {
   ajaxObj=new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
   ajaxObj=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
 return ajaxObj;
}

function showAttributes(myObj)
{
 var output;
 for (var key in myObj)
 {
  output += key + '=>' + myObj[key] + '\n';
 }
 alert(output);
}

/******************************************************************************************
* DEBUG
******************************************************************************************/
function debug(message)
{
 var myDate = new Date();
 with (getObj('debugoutput'),targetframe)
 {
  innerHTML = myDate.getTime()+'<br>';
  innerHTML += message; 
 }
}