// JavaScript Document

function getElementPosition() {
		var offsetTrail = this;
		var offsetLeft = 0;
		var offsetTop = 0;
		while (offsetTrail) {
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		return {left:offsetLeft, top:offsetTop};
}

function getElementsByClassName(rel,scope){
    var col=[];
	var sc=scope || document;
    var tCol=sc.getElementsByTagName('*');
    for(var ii=0;ii<tCol.length;ii++)
        if(tCol[ii].className==rel)
            col.push(tCol[ii])
    return col;
}  
function getElementsByRelName(rel){
    var col=[];
    var tCol=document.getElementsByTagName('*');
    for(var ii=0;ii<tCol.length;ii++)
        if(tCol[ii].rel==rel || tCol[ii].getAttribute('rel')==rel)
            col.push(tCol[ii])
    return col;
}
function cancelEvent(e){
	if(e && e.preventDefault)
		e.preventDefault();
	else if(window.event)
		window.event.returnValue=false;
}
function stopEvent(e){
	if(e && e.stopPropagation)
		e.stopPropagation();
	else if(window.event)
		window.event.cancelBubble=true;
}
function getCSS(o,prop){ 
    if(window.getComputedStyle){ 
        return document.defaultView.getComputedStyle(o,null).getPropertyValue(prop); 
    }else{ 
        var re = /(-([a-z]){1})/g; 
        if (prop == 'float') prop = 'styleFloat'; 
        if (re.test(prop)) { 
            prop = prop.replace(re, function () { 
                return arguments[2].toUpperCase(); 
            }); 
        } 
        return o.currentStyle[prop] ? o.currentStyle[prop] : null; 
    } 
}  
function getPos(e){
    var ev=e || window.event;
    var obj=ev.target || ev.srcElement;
    obj.style.position='relative'; 
    posX=ev.layerX || ev.offsetX || 0;
    posY=ev.layerY || ev.offsetY || 0;
    return {x:posX,y:posY}
}  
function clearSelection() {
	var sel ;
	if(document.selection && document.selection.empty){
		document.selection.empty() ;
	} else if(window.getSelection) {
		sel=window.getSelection();
	if(sel && sel.removeAllRanges)
		sel.removeAllRanges() ;
	}
}
function getNextHighestDepth(){
    var tCol=document.getElementsByTagName('*');
    var z=0;
        for(var i=0,l=tCol.length;i<l;i++){
            if(tCol[i].style.zIndex>z){
                z=tCol[i].style.zIndex;
            }
            
        }
    return ++z;
}
