/******************************************************************
 * dhtmlAPI.js                                                    *
 *                                                                *
 * General purpose DHTML function library                         *
 ******************************************************************/

// function to retrive x coordinate of mouse
function getMouseLeft(evt)
{
	if(document.all)
		return window.event.clientX + document.body.scrollLeft;
	else if(document.getElementById || document.layers)
		return evt.pageX; 
}

// function to retrive x coordinate of mouse
function getMouseTop(evt)
{
	if(document.all)
		return window.event.clientY + document.body.scrollTop;
	else if(document.getElementById || document.layers)
		return evt.pageY; 
}

// Function to get object reference to the given object
function getObj(obj)
{
	if (document.layers) 
	{
		if (typeof obj == "string") 
		{
			return document.layers[obj]
		} 
		else 
		{
			return obj
		}
	}
	if (document.all) 
	{
		if (typeof obj == "string") 
		{
			return document.all(obj)
		} 
		else 
		{
			return obj
		}
	}
	if (document.getElementById) 
	{
		if (typeof obj == "string") 
		{
			return document.getElementById(obj)
		} 
		else 
		{
			return obj
		}
	}
	return null	
}

// position an object at a specific pixel coordinate
function shiftTo(obj, x, y) 
{
	obj = getObj(obj)
	
	if (obj.moveTo) 
	{
		obj.moveTo(x,y)
	} 
	else if (typeof obj.style.left != "undefined") 
	{
		obj.style.left = x
		obj.style.top = y
	}
}


// Function to clip rectangular area of given object
function clipRectangle(obj, clipTop, clipRight, clipBottom, clipLeft)
{
	obj = getObj(obj);

	if(document.all || document.getElementById)
	{
		clipString = "rect(" + clipTop + " " + clipRight + " ";
		clipString = clipString + clipBottom + " " + clipLeft + ")";
		obj.style.clip = clipString;
	}
	else if(document.layers)
	{
		obj.clip.bottom = clipBottom;
		obj.clip.top = clipTop;
		obj.clip.right = clipRight;	
		obj.clip.left = clipLeft;
	}

}

// Function to show object
function showObj(obj)
{
	obj = getObj(obj);
	if(document.all || document.getElementById)
		obj.style.visibility = "visible";
	else if (document.layers)
		obj.visibility = "show";	
}

// Function to hide object
function hideObj(obj)
{
	obj = getObj(obj);
	if(document.all || document.getElementById)
		obj.style.visibility = "hidden";
	else if (document.layers)
		obj.visibility = "hide";	
}

// Function to write text in div
function printHTML(obj, textToWrite)
{
	obj = getObj(obj);
	if(document.all || document.getElementById)
	{
		obj.innerHTML = textToWrite;
	}
	else if (document.layers)
	{
		obj.document.open();
		obj.document.write(textToWrite);
		obj.document.close();		
	}
}















