/** Returns the pixel distance from left border of the element to left border of the window **/
function getElementLeft(p_elm) {
	var x = 5;
	var elm;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	while (elm != null) {
		x+= elm.offsetLeft;
		elm = elm.offsetParent;
	}
	return parseInt(x);
}

/** Returns the pixel width of the element **/
function getElementWidth(p_elm){
	var elm;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	return parseInt(elm.offsetWidth);
}

/** Returns the pixel distances from right border of the element to left border of window **/
function getElementRight(p_elm){
	return getElementLeft(p_elm) + getElementWidth(p_elm);
}

/** Returns the pixel distances from top border of the element to top border of the window **/
function getElementTop(p_elm) {
	var y = -5;
	var elm;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	while (elm != null) {
		y+= elm.offsetTop;
		elm = elm.offsetParent;
	}
	return parseInt(y);
}

/** Returns the pixel heght of the element **/
function getElementHeight(p_elm){
	var elm;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	return parseInt(elm.offsetHeight);
}

/** Returns the pixel distances from bottom border of the element to border top of the window **/
function getElementBottom(p_elm){
	return getElementTop(p_elm) + getElementHeight(p_elm);
}

/** Returns a style property of the elemnt , it return null if does not exist **/
function getElementProperty(p_elm, p_property){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if (elm != null){
		if(elm.style){
			elm = elm.style;
			if(elm[p_property]){
				return elm[p_property];
			} else {
				return null;
			}
		} else {
			return null;
		}
	}
}

/** Sets a property of style type of the element **/
function setElementProperty(p_elm, p_property, p_value){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if((elm != null) && (elm.style != null)){
		elm = elm.style;
		elm[ p_property ] = p_value;
	}
}