/*
 *	STRIWENSKO LIBRARY HTML ELEMENT CLASS
 *  v 1.2
 */
if(typeof SW_LIB == "undefined") var SW_LIB = new Object();
SW_LIB.HTML_ELEMENT = new Object();

Object.extend = function(destination, source) {
	for (var property in source)
		destination[property] = source[property];
	return destination;
};

	var HTML_Element = {}

	HTML_Element.setOpacity = function(value){
		var ie = (document.all) ? 1 : 0;
		var p = (ie) ? "filter" : "MozOpacity";
		
		/* n is the element node
		   v is the opacity value, from 0 to 100. */
		
		//function op(n,v){
			value = (ie) ? "alpha(opacity="+value+")" : value/100;
			this.style[p] = value;
		/*}
		this.style.opacity = (value == 1 || value === '') ? '' :
		  (value < 0.00001) ? 0 : value;
		  /**/
	}
	HTML_Element.visible = function(_className){
		return this.style.display != 'none';
	}
	HTML_Element.toggle = function(_className){
		this.style.display = this.visible() ? 'none' : '';
	}
	HTML_Element.show = function(_showEnable){
		this.style.display = (_showEnable!=false)? '' : 'none';
	}
	HTML_Element.hide = function(_className){
		this.style.display = 'none';
	}
	HTML_Element.remove = function(_className){
		this.parentNode.removeChild(this);
		return this;
	}
	HTML_Element.setClassName = function(_className){
		this.className = _className;
		return this;
	}
	HTML_Element.getClassName = function(_className){
		return this.className;
	}
	HTML_Element.removeClassName = function(){
		this.className = '';
		return this;
	}
	HTML_Element.setWidth = function(_width){
		// Doesnt Include Padding nor Border
		this.style.width = _width+"px";
	}
	HTML_Element.setHeight = function(_height){
		// Doesnt Include Padding nor Border
		this.style.height = _height+"px";
	}
	HTML_Element.getWidth = function(){
		var currentWidth = this.offsetWidth;	
		if(isNaN(currentWidth)){
			return 0;
		}
		return currentWidth;
		// It considers Padding in It but not border
		//return this.clientWidth;
	}
	HTML_Element.getHeight = function(){
		var currentHeight = this.offsetHeight;	
		if(isNaN(currentHeight)){
			return 0;
		}
		return currentHeight;
		// It considers Padding in It but not border
		//return this.clientHeight;
	}
	HTML_Element.setX = function(_x){
		this.style.left = _x + 'px';
	}
	HTML_Element.setY = function(_y){
		this.style.top = _y + 'px';
	}
	HTML_Element.getX = function(){
		var currentX = Number(this.offsetLeft);
		return currentX;
	}
	HTML_Element.getY = function(){
		var currentY = Number(this.offsetTop);
		return currentY;
	}
	function HTML(element) {
		if ((typeof element) == "string")
		{
			if(document.getElementById(element)){
				element = document.getElementById(element);
			}else{
				return null;	
			}
		}
		return Object.extend(element,HTML_Element);
	}
	function SWF(movieName) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		}
		else {
			return document[movieName];
		}
	}
	
	
	
	function easeNone (t, b, c, d){
		return c*t/d + b;
	}
	function easing(initVal, endVal, speed){
		var newVal_Inc = Math.round((endVal-initVal)/speed);
		// No Move Detect
		if(newVal_Inc==0){
			// Finish Easing
			if(initVal!=endVal){
				return (initVal<endVal)? (initVal+1):(initVal-1);
			}
		}
		return newVal_Inc;
	}