﻿/*--
Copyright © 1998, 2009, Oracle and/or its affiliates.  All rights reserved.
--*/

function IsFF3()
{
	if (this.navigator)
	{
		if (this.navigator.userAgent)
		{
			if (this.navigator.userAgent.indexOf("Firefox/3")>0)
			{
				return true;
			}
		}
	}
	return false;
}

//
// Browser-independent object access (NS4, IE5+, Mozilla)
//

function getDIV(id)
{
	try
	{
		if(document.all)
		{
			return document.all(id);
		}
		else if (document.getElementById)
		{
			return document.getElementById(id);
		}
		else if (document.layers)
		{
			var obj = document.layers.screen.document.layers[id];
			if(!obj)
			{
				obj = document.layers[id];
			}
			return obj;
		}
		return 0;
	}
	catch (error)
	{
		return (null);
	}
}

function getDIVstyle(id)
{
	try
	{
		if(document.all)
		{
			return (document.all(id).style);
		}
		else if (document.getElementById)
		{
			if (document.getElementById(id).style != null)
			{
				return (document.getElementById(id).style);
			}
		}
		else if (document.layers)
		{
			var obj = document.layers.screen.document.layers[id];
			if(!obj)
			{
				obj = document.layers[id];
			}
			return (obj);
		}
		return 0;
	}
	catch (error)
	{
		//alert ("##### ERROR #####:\n" + error + "\n\n##### CALLER #####" + getDIVstyle.caller);
		return (null);
	}
}

function shiftTo(id, x, y)
{
  var obj = getDIVstyle(id);
  if(obj.moveTo)
  {
    obj.moveTo(x,y);
  }
  else
  {
    obj.left = x + "px";
    obj.top = y + "px";
  }
}

/**
 * #####################
 * # START NEW CONTENT #
 * #####################
*/

function getUniWidth(id)
{
	try {
		var cObj = getDIV(id);
		var w;
		if (id.style.width)
		{
			w = parseInt(id.style.width);
		}
		else if (id.style.pixelWidth)
		{
			w = id.style.pixelWidth;
		}
		else if (id.offsetWidth)
		{
			w = id.offsetWidth;
		}
		else if (document.defaultView && document.defaultView.getComputedStyle)
		{
			w = document.defaultView.getComputedStyle(cObj ,'').getPropertyValue('width');
		}
		if (typeof w == "string")
		{
			w = parseInt(w);
		}
		return w;
	}
	catch (error)
	{
		return (null);
	}		
}

function getUniHeight(id)
{
	try {
		var cObj = getDIV(id);
		var w;
		if (id.style.height)
		{
			w = parseInt(id.style.height);
		}
		else if (id.style.pixelHeight)
		{
			w = id.style.pixelHeight;
		}
		else if (id.offsetHeight)
		{
			w = id.offsetHeight;
		}
		else if (document.defaultView && document.defaultView.getComputedStyle)
		{
			w = document.defaultView.getComputedStyle(cObj ,'').getPropertyValue('height');
		}
		if (typeof w == "string")
		{
			w = parseInt(w);
		}
		return w;
	}
	catch (error)
	{
		return (null);
	}
}

function getClientWidth(id)
{
	try {
		var cObj = getDIV(id);
		if (cObj.clientWidth)
		{
			return cObj.clientWidth
		}
		else
		{
			return parseInt(cObj.width);
		}
	}
	catch (error)
	{
		return id.offsetWidth;
	}
}

function getClientHeight(id)
{
	try {
		var cObj = getDIV(id);
		if (cObj.clientHeight)
		{
			return cObj.clientHeight
		}
		else
		{
			return parseInt(cObj.height);
		}
	}
	catch (error)
	{
		return id.offsetHeight;
	}
}

/**
 * ###################
 * # END NEW CONTENT #
 * ###################
*/

function getObjHeight(id)
{
  var obj = getDIV(id);
  if(obj.clip)
  {
    return obj.clip.height;
  }
  else
  {
    return obj.offsetHeight;
  }
}

function getObjWidth(id)
{
  var obj = getDIV(id);
  if(obj.clip)
  {
    return obj.clip.width;
  }
  else
  {
    return obj.offsetWidth;
  }
}

function getObjLeft(id)
{
	try
	{
		var obj = getDIVstyle(id);
		if(obj.pixelLeft)
		{
			return obj.pixelLeft;
		}
		else
		{
			return parseInt(obj.left);
		}
	}
	catch (error)
	{
		return parseInt(id.offsetLeft);
	}
}

function getObjTop(id)
{
	try
	{
		var obj = getDIVstyle(id);
		if(obj.pixelTop)
		{
			return obj.pixelTop;
		}
		else
		{
			return parseInt(obj.top);
		}
	}
	catch (error)
	{
		return parseInt(id.offsetTop);
	}
}


function getInsideWindowWidth()
{
  if(window.innerWidth)
  {
    return window.innerWidth;
  }
  else
  {
    return document.body.clientWidth;
  }
}

function getInsideWindowHeight()
{
  if(window.innerHeight)
  {
    return window.innerHeight;
  }
  else
  {
    return document.body.clientHeight;
  }
}

function getScrollLeft()
{
  if(window.pageXOffset || window.pageXOffset==0)
  {
    return window.pageXOffset;
  }
  else
  {
    return document.body.scrollLeft;
  }
}

function getScrollTop()
{
  if(window.pageYOffset || window.pageYOffset==0)
  {
    return window.pageYOffset;
  }
  else
  {
    return document.body.scrollTop;
  }
}

function show(id)
{
  var obj = getDIVstyle(id);
  obj.visibility = "visible";
}

function hide(id)
{
  var obj = getDIVstyle(id);
  obj.visibility = "hidden";
}

