// JavaScript Document

function getObj(objectId)
{
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId);
	}
	else if (document.all && document.all(objectId)) {  
		return document.all(objectId);
	} 
	else if (document.layers && document.layers[objectId]) { 
		return document.layers[objectId];
	} else {
		return false;
	}
}
function getObjStyle(objectId)
{
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	}
	else if (document.all && document.all(objectId)) {  
		return document.all(objectId).style;
	} 
	else if (document.layers && document.layers[objectId]) { 
		return document.layers[objectId];
	} else {
		return false;
	}
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findHeight(obj)
{
	var curheight = 0;
	if (obj.offsetParent)
	{
		//curheight = 100;
		while (obj.offsetParent)
		{
			curheight += obj.offsetHeight;
			obj = obj.offsetParent;
		}
	}
	else if (obj.height)
		curheight +=obj.height;
	return curheight;
}

function findWidth(obj)
{
	var curwidth = 0;
	if (obj.offsetParent)
	{
		//curheight = 100;
		while (obj.offsetParent)
		{
			curwidth += obj.offsetWidth;
			obj = obj.offsetParent;
		}
	}
	else if (obj.width)
		curwidth +=obj.width;
	return curwidth;
}


function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function copyToList(from,to)
{
  fromList = eval('document.forms[0].' + from);
  toList = eval('document.forms[0].' + to);
  if (toList.options.length > 0 && toList.options[0].value == 'temp')
  {
    toList.options.length = 0;
  }
  var sel = false;
  for (i=0;i<fromList.options.length;i++)
  {
    var current = fromList.options[i];
    if (current.selected)
    {
      sel = true;
      if (current.value == 'temp')
      {
        alert ('You cannot move this text!');
        return;
      }
      txt = current.text;
      val = current.value;
      toList.options[toList.length] = new Option(txt,val);
      fromList.options[i] = null;
      i--;
    }
  }
  if (!sel) alert ('You haven\'t selected any options!');
}

function setSelectedIndex(obj, id)
{
	for (i=0;i<obj.options.length;i++)
	{
		if (obj.options[i].value == id)
		{
			obj.options[i].selected = true;
		}
		else
		{
			obj.options[i].selected = false;
		}
	}	
}
