//  DHTMLapi.js custom  API For cross-platform
//  Object positioning 

//  Global variables
var isNav;
var isNav6;
var isIE;
var coll = "";
var styleObj = "";
if (parseInt(navigator.appVersion) >= 4 )
	{
		if (navigator.appName == "Netscape")
		{
			if(parseInt(navigator.appVersion) >= 5 )
			{
				 isNav6 = true;
				 coll = "getElementById(\"";
				 styleObj = "\")";
			}else{
				 isNav = true;
				 }
		}else{
		
			isIE = true;
			coll = "all.";
			styleObj = ".style";
		}
	}
//  Convert object name string or object reference into valid object reference
function getObject(obj){
	var theObj;
	if (typeof obj =='string'){
		
		theObj = eval("document." + coll + obj + styleObj);

	}else{
		theObj = obj;
	}
	return theObj;
}
//  Convert object name string or object reference into valid object reference

function getContentObject(obj){
	var ContentObj;
	
	if (typeof obj =="string"){
		ContentObj = eval("document." + coll + obj);
		
	}else{
		ContentObj = obj;
	}
	return ContentObj;
}
// Positioning an object at a specific pixel coordinate
function shiftTo(obj, x, y)
{
	var theObj = getObject(obj);

	if (isNav)
	{
		theObj.moveTo(x,y);
	}else{
	    if (isNav6){
			theObj.style.left = x +"px";
			theObj.style.top = y+"px";
		 }else{
			theObj.pixelLeft = x;
			theObj.pixelTop = y;
		}
	}
}
// Moving an object by  x and/or y pixel
function shiftBy(obj, deltaX, deltaY)
{
	var theObj = getObject(obj);
	if (isNav)
	{
		theObj.moveBy(deltaX,deltaY);
	}else{
	    if (isNav6){
			theObj.style.left = parseInt(theObj.style.left) + deltaX +"px";
			theObj.style.top = parseInt(theObj.style.top) + deltaY; +"px";
		 }else{
			theObj.pixelLeft += deltaX;
			theObj.pixelTop += deltaY;
		}
	}
}

// Setting the z order of an object
function setZIndex(obj, zOrder){
	var theObj = getObject(obj);
	theObj.zIndex = zOrder;
}
// Setting the background color of an object
function setBGColor(obj, color)
{
	var theObj = getObject(obj);
	if (isNav){
			theObj.bgColor = color;
	}else{
		if (isNav6)
			{
			theObj.style.bgColor = color;
		}else{
			theObj.backgroundColor = color;
		}
	}
}
// Setting the visibility of an object to visible
function show(obj){
	if (isNav6){
		var theObj = getObject(obj);
		theObj.style.visibility ="visible";
	}else{
		var theObj = getObject(obj);
		theObj.visibility = "visible";
	}
}
// Setting the visibility of an object to hidden
function hide(obj){
	if (isNav6){
		var theObj = getObject(obj);
		theObj.style.visibility ="hidden";
	}else{
		var theObj = getObject(obj);
		theObj.visibility = "hidden";
	}
}
// Retriving the x coordinate of a positionable object
function getObjectLeft(obj){
	var theObj = getObject(obj);
	if (isNav){
		return theObj.left;
	}else{
		if(isNav6)
		{
			return parseInt(theObj.style.left);
		}else{
			return theObj.pixelLeft;
		}
	}
}

// Retrieving the y coordinate of a positionable object
function getObjectTop(obj){
	var theObj = getObject(obj);
	if (isNav){
		return theObj.top;
	}else{
		if(isNav6)
		{
			return parseInt(theObj.style.top);
		}else{
			return theObj.pixelTop;
		}
	}
}

// Utility function returns rendered height of object content in pixels

function getObjHeight(obj){
	if (isNav){
		var theObj = getObject(obj);
		return theObj.clip.height;
	}else{
		if(isNav6){
			var theObj = getObject(obj);
			return parseInt(theObj.style.height);
		}else{
			var theObj = getContentObject(obj);
			return theObj.clientHeight;
		}
	}
}

// Utility function returns rendered width of object content in pixels

function getObjWidth(obj){
	if (isNav){

		var theObj = getObject(obj);
		return theObj.clip.width;
	}else{
		if(isNav6){
			var theObj = getObject(obj);
			return parseInt(theObj.style.width);
		}else{
			var theObj = getContentObject(obj);
			return theObj.clientWidth;
		}
	}
}


// Utility function returns the available content width space in browser window

function getInsideWindowWidth(){
	if (isNav){
		return parseInt(window.innerWidth);
	}else{
		if(isNav6){
			return parseInt(window.innerWidth);
		}else{	
			return document.body.clientWidth;
		}	
	}
}
// Utility function returns the available content height space in browser window

function getInsideWindowHeight(){
	if (isNav){
		return parseInt(window.innerHeight);
	}else{
		if(isNav6){
			return parseInt(window.innerHeight);
		}else{
			return document.body.clientHeight;
		}
	}
}