function Element(elementName, parentWindow, showErrors){
	this.name = elementName;
	this.parentWindow = parentWindow;
	this.showErrors = (showErrors != null) ? showErrors : false;
	
	//Get the actual element reference
	this.obj = this.getElement();
	
	/*Get the elements style properties, if showErros is set to true then an 
	alert box will be displayed to state that there was a problem in trying
	to acqurie the style properties.  If an error occurs the style properties
	will be set to 'null'*/
	try{
		this.style = this.getElementStyle();
	}
	catch(e){
		(showErrors == true) ? alert("Error occured when trying to acquire the style properties of: \"" + elementName + "\""): //Do Nothing;
		this.style = null;
	}
}

function getBrowser(){
	var browser;
	
	if(document.all)
		browser = "IE"; 
	else if(document.getElementById) 
		browser = "W3C"; 
	else if(document.layers)
		browser = "NS4"; 
	
	return browser;
}

Element.prototype.getElement = function(){
	var epre, epost;
	var obj
	
	switch(getBrowser()){
		case "W3C":
			epre = 'document.getElementById("';
			epost = '")';
			break;

		case "NS4":
			epre = 'document.';
			epost = '';
			break;
			
		case "IE":
			epre = 'document.all.';
			epost = '';
			break;
	}
	
	if(this.parentWindow == true){
		epre = "opener." + epre;
	}

	//Try to get element using browser specific methods
	//in the event of failure use W3C method
	try{
		obj = eval(epre + this.name + epost);
		if(obj == null){
			throw("Invalid Reference");
		}
	}
	catch(e){
		(this.showErrors) ? alert(e.description + " :\"" + this.name + "\"") : //Do Nothing;
		obj = eval('document.getElementById("' + this.name + '")');
	}
	
	return obj;
}

Element.prototype.getElementStyle = function(){
	var spre, spost;
	var obj;
	
	switch(getBrowser()){
		case "W3C":
			spre = 'document.getElementById("';
			spost = '").style';
			break;
			
		case "NS4":
			spre = 'document.';
			spost = '';
			break;
			
		case "IE":
			spre = 'document.all.';
			spost = '.style';
			break;
	}

	//Try to get element using browser specific methods
	//in the event of failure use W3C method
	try{
		obj = eval(spre + this.name + spost);
		if(obj == null){
			throw("Invalid Reference");
		}
	}
	catch(e){
		(this.showErrors) ? alert(e.description + " :\"" + this.name + "\"") : //Do Nothing;
		obj = eval('document.getElementById("' + this.name + '").style');
	}
	
	return obj;
}

Element.prototype.getX = function(){
	return this.style.left;
}

Element.prototype.getY = function(){
	return this.style.top;
}

Element.prototype.moveTo = function(x, y){
	this.style.left = x;
	this.style.top = y;
}

Element.prototype.getUnit = function(strUnit){
	var unit;
	
	//The input string is a CSS value such as '12px', this function
	//will return the 'px' part of the unit
	unit = strUnit.substr((strUnit.length)-2,2);
	return unit;
}

Element.prototype.moveBy = function(x, y){
	var oldx, oldy, unitList, strReplace;
	var count;
	
	oldx = this.getX();
	oldy = this.getY();

	rExp = eval("/" + this.getUnit(oldx) + "/gi");
	oldx = Number(oldx.replace(rExp, ""));
	
	rExp = eval("/" + this.getUnit(oldy) + "/gi");
	oldy = Number(oldy.replace(rExp, ""));
		
	this.style.left = oldx + x;
	this.style.top = oldy + y;
}

Element.prototype.changePositionType = function(newType){
	this.style.position = newType;
}

Element.prototype.changeVisible = function(status){
	this.style.visibility = status;
}

Element.prototype.changeDisplay = function(status){
	this.style.display = status;
}

Element.prototype.changeBackgroundColor = function(color){
	this.style.backgroundColor = color;
}

Element.prototype.changeBackgroundImage = function(imageSrc){
	this.style.backgroundImage = imageSrc;
}

Element.prototype.changeClass = function(className){
	this.obj.className = className;
}