/**
* Object Positioner v 1.2
*
* © 2007 MJ Bytes Ltd
* http://www.mjbytes.com
*
* Language: Javascript
* @Last Revision: 10/May/2007
* 
*/

function Positioner()
{
	if (elements && coords)
	{
		this.canvas = new Object();
		this.getCanvasData();
		this.init();
	}
	else return false;
}

Positioner.prototype =
{
	init: function()
	{
		for (i=0; i<elements.length; i++)
		{
			if (el = this.getElement(elements[i]))
			{
				if (el.style) el = el.style;
				
				el.position = 'absolute';
				el.left = coords[i*2] + 'px';
				el.top = coords[i*2+1] + 'px';
			}
		}
	},
	
	setMargin: function(e, n)
	{
		if (el = this.getElement(e))
		{
			if (el.style) el = el.style;
			n = 15;
			el.marginTop = n + 'px';
		}
	},
	
	getElement: function(n)
	{
		return document.getElementById ? document.getElementById(n) 
				: (document.all ? document.all[n] 
				: (document.layers ? document.layers[n] : -1));
	},
	
	getCanvasData: function()
	{
		doc1 = document.documentElement;
		doc2 = document.body;

		this.canvas.width = typeof(window.innerWidth) == 'number' ? window.innerWidth 
							: (doc1 ? doc1.clientWidth 
							: (doc2 ? doc2.clientWidth : 0));
							
		this.canvas.height = typeof(window.innerWidth) == 'number' ?  window.innerHeight 
							: (doc1 ? doc1.clientHeight 
							: (doc2 ? doc2.clientHeight : 0));
	},
	
	getCanvas: function()
	{
		return this.canvas;
	},
	
	getCanvasWidth: function()
	{
		return this.canvas.width;
	},
	
	getCanvasHeight: function()
	{
		return this.canvas.height;
	},
	
	getElementHeight: function(e)
	{
		if (el = this.getElement(e))
		{
			if (el.style) el = el.style;
	
			return el.height ? el.height : (el.pixelHeight ? el.pixelHeight : null);
//			return el.pixelHeight;
/*	
			ht = 0;
			
			if (el.hasChildNodes())
			{
				for (i = 0; i < el.childNodes.length; i++)
				{
					ht += el.childNodes[i].style ? el.childNodes[i].innerHeight : 0;
				}
			}
			
			return el.style.height + ht;
			*/
		}
	}	

	
}