﻿//puts the focus on a field
function fieldFocus(fieldName)
{
	if(document.getElementById)
	{
		if(document.getElementById(fieldName))
		{
			//fieldColor(fieldName);
			document.getElementById(fieldName).focus();
		}
	}
}

//highlights the field (not normally needed, using colorCheckBox with onfocus)
function fieldColor(fieldName)
{
	if(document.getElementById)
	{
		if(document.getElementById(fieldName))
		{
			document.getElementById(fieldName).style.backgroundColor="#EEFFFF";
		}
	}
}

function fieldUnColor(fieldName)
{
	if(document.getElementById)
	{
		if(document.getElementById(fieldName))
		{
			document.getElementById(fieldName).style.backgroundColor="#FFFFFF";
		}
	}
}

/**
* colorTextbox
*
* Changes the color of a text box or text area
*
* @param  string  myObject  name of field
*/
function colorTextbox(myObject)
{
	fieldColor(myObject.id);
}

/**
* uncolorTextbox
*
* Changes the color of a text box or text area
* back to white
*
* @param  string  myObject  name of field
*/
function uncolorTextbox(myObject)
{
	fieldUnColor(myObject.id);
}

/* toggle item */
function toggle_item(itemId)
{
	if(document.getElementById(itemId))
  {
  	if(document.getElementById(itemId).style.visibility != 'visible')
  	{
    	document.getElementById(itemId).style.visibility = 'visible';
      document.getElementById(itemId).style.display = 'block';
    }
    else
    {
    	document.getElementById(itemId).style.visibility = 'hidden';
      document.getElementById(itemId).style.display = 'none';
    }
  }
}

function getTopPos(id)
{		
	var item = document.getElementById(id);
	var returnValue = item.offsetTop;
	while((item = item.offsetParent) != null)
	{
		if(item.tagName!='HTML')returnValue += item.offsetTop;
	}
	return returnValue;
}
	
function getWidth(id)
{
	var item = document.getElementById(id);
	returnValue = item.offsetWidth;
	return returnValue;
}

function getHeight(id)
{
	var item = document.getElementById(id);
  var returnValue = item.offsetHeight;
  return returnValue;
}
	
function getLeftPos(id)
{
	var item = document.getElementById(id);
	var returnValue = item.offsetLeft;
	while((item = item.offsetParent) != null)
	{
		if(item.tagName!='HTML')returnValue += item.offsetLeft;
	}
	return returnValue;
}

function getRightPos(id)
{
	var item = document.getElementById(id);
 	var returnValue = eval(getLeftPos(id) + getWidth(id));
 	return returnValue; 
}

function getBottomPos(id)
{
	var item = document.getElementById(id);
 	var returnValue = eval(getTopPos(id) + getHeight(id));
 	return returnValue; 
}

function set_width(id,width)
{
	if(document.getElementById(id))
	{
	  document.getElementById(id).style.width=width+'px';  
	}
}

function set_height(id,height)
{
	if(document.getElementById(id))
	{
	  document.getElementById(id).style.height=height+'px';  
	}
}
