/**************************************************
 ___________________
|Function Prototypes|
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
float getPos(element Name,'X' or 'Y');
void moveElement(string element Name, float X, float Y, bool relative or not)
float mouse[1](e Event);
mixed getStyle(element Name, style[such as width or zIndex])
****************************************************/


function getPos(elmntName,w){		
    var elmnt = findElmnt(elmntName);	x=elmnt.offsetLeft;
	y=elmnt.offsetTop;
	if(w=='x'){
		return x;
	} else {
		return y;
	}
}
function moveElement(elmntName, x, y,rel){		
    var elmnt = findElmnt(elmntName);	if (!elmnt) {
        return;
    }
    if (elmnt.style) {
        elmnt = elmnt.style;
    }    
    var pixels = document.childNodes ? 'px' : 0;
    if (typeof (x) == 'number') {
        elmnt.left = (x + (rel ? 0 : parseInt(elmnt.left))) + pixels;
    }

    if (typeof (y) == 'number') {
        elmnt.top = (y + (rel ? 0 : parseInt(elmnt.top))) + pixels;
    }
}
function findElmnt(elmntName) {
	elmntDoc = window.document;
	 if (elmntDoc.getElementById && elmntDoc.getElementById(elmntName)) {
        return elmntDoc.getElementById(elmntName);
    }
    if (elmntDoc[elmntName]) {
        return elmntDoc[elmntName];
    }

    if (elmntDoc.all && elmntDoc.all[elmntName]) {
        return elmntDoc.all[elmntName];
    }

   

    for (var x = 0; x < elmntDoc.forms.length; x++) {
        if (elmntDoc.forms[x][elmntName]) {
            return elmntDoc.forms[x][elmntName];
        }
    }

    for (var x = 0; x < elmntDoc.anchors.length; x++) {
        if (elmntDoc.anchors[x].name == elmntName) {
            return elmntDoc.anchors[x];
        }
    }

    for (var x = 0; document.layers && x < elmntDoc.layers.length; x++) {
        var elmnt = findObj(elmntName, null, elmntDoc.layers[x].document);

        if (elmnt) {
            return elmnt;
        }
    }

    if (window[elmntName]) {
        return window[elmntName];
    }
    return null;
}
function mouse(e) {
    if (!e) {
        e = window.event;
    }
    if (!e || ( typeof (e.pageX) != 'number' && typeof (e.clientX) != 'number')) {
        return [0, 0];
    }
    if (typeof (e.pageX) == 'number') {
        var xPos = e.pageX;
        var yPos = e.pageY;
    } else {
        var xPos = e.clientX;
        var yPos = e.clientY;
        if (!((window.navigator.userAgent.indexOf('Opera')
                  + 1) || (window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1) || window.navigator.vendor
                 == 'KDE')) {
            if (document.documentElement
                && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
                xPos += document.documentElement.scrollLeft;

                yPos += document.documentElement.scrollTop;
            } else if (document.body && (document.body.scrollTop || document.body.scrollLeft)) {
                xPos += document.body.scrollLeft;

                yPos += document.body.scrollTop;
            }
        }
    }
    return [xPos, yPos];
}
function getSize() {
	var w=0;
	var h=0;
	if (document.documentElement && (window.document.documentElement.clientWidth || window.document.documentElement.clientHeight)) {
        w = window.document.documentElement.clientWidth;
        h = window.document.documentElement.clientHeight;
    } else if (window.document.body && (window.document.body.clientWidth || window.document.body.clientHeight)) {
        w = window.document.body.clientWidth;
        h = window.document.body.clientHeight;
    }
    return [w, h];
}
function getScroll() {
	var x=y=0;
	if (typeof (window.pageYOffset) == 'number') {
        y = window.pageYOffset;
        x = window.pageXOffset;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        y = document.documentElement.scrollTop;
        x = document.documentElement.scrollLeft;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        y = document.body.scrollTop;
        x = document.body.scrollLeft;
    }
    return [x, y];
}
function getStyle( elmntName, oStyle, oFrame ) {
	if( elmntName == 'document' ) {
		var theBody = oFrame ? oFrame.document : window.document;
		if( theBody.documentElement && theBody.documentElement.style && theBody.documentElement.style.backgroundColor ) { return theBody.documentElement.style.backgroundColor; }
		if( theBody.body && theBody.body.style && theBody.body.style.backgroundColor ) { return theBody.body.style.backgroundColor; }
		if( theBody.documentElement && theBody.documentElement.style && theBody.documentElement.style.background ) { return theBody.documentElement.style.background; }
		if( theBody.body && theBody.body.style && theBody.body.style.background ) { return theBody.body.style.background; }
		if( theBody.bgColor ) { return theBody.bgColor; }
		return '#ffffff';
	}
	var selectedClass = findeElmnt( elmntName,false,false ); if( !selectedClass ) { return null; } if( selectedClass.style && oStyle != 'clip' ) { selectedClass = selectedClass.style; }
	switch( oStyle ) {
		case 'visibility':
			return ( ( selectedClass.visibility && !( selectedClass.visibility.toLowerCase().indexOf( 'hid' ) + 1 ) ) ? true : false );
		case 'left':
			return ( parseInt( selectedClass.left ) ? parseInt( selectedClass.left ) : 0 );
		case 'top':
			return ( parseInt( selectedClass.top ) ? parseInt( selectedClass.top ) : 0 );
		case 'zIndex':
			return ( isNaN( selectedClass.zIndex ) ? 0 : selectedClass.zIndex );
		case 'background':
			return ( selectedClass.bgColor ? selectedClass.bgColor : selectedClass.background-color ? selectedClass.background-color : selectedClass.background );
		case 'display':
			return ( selectedClass.display ? selectedClass.display : '' );
		case 'size':
			if( typeof( selectedClass.pixelWidth ) != 'undefined' ) { return [selectedClass.pixelWidth,selectedClass.pixelHeight]; }
			if( typeof( selectedClass.width ) != 'undefined' ) { return [parseInt(selectedClass.width),selectedClass.parseInt(height)]; }
			if( selectedClass.clip && typeof( selectedClass.clip.bottom ) == 'number' ) { return [selectedClass.clip.right,selectedClass.clip.bottom]; }
			return [0,0];
		case 'clip':
			if( selectedClass.clip ) { return selectedClass.clip; }
			selectedClass = ( selectedClass.style && selectedClass.style.clip ) ? selectedClass.style.clip : 'rect()';
			selectedClass = selectedClass.substr( selectedClass.indexOf( '(' ) + 1 ); var theClip = new Object();
			for( var x = 0, y = ['top','right','bottom','left']; x < 4; x++ ) {
				theClip[y[x]] = parseInt( selectedClass ); if( isNaN( theClip[y[x]] ) ) { theClip[y[x]] = 0; }
				selectedClass = selectedClass.substr( selectedClass.indexOf( ( selectedClass.indexOf( ' ' ) + 1 ) ? ' ' : ( selectedClass.indexOf( '	' ) + 1 ) ? '	' : ',' ) + 1 );
			} return theClip;
		default:
			return null;
	}
}
function changeSize(elmntName,w,h){
	var elmnt = findElmnt(elmntName);
    if (!elmnt) {
        return;
    }
    if (elmnt.style) {
        elmnt = elmnt.style;
    }
    var elmntPixel = document.childNodes ? 'px' : 0;
    if (elmnt.resizeTo) {
        elmnt.resizeTo(w, h);
    }
    elmnt.width = w + elmntPixel;
    elmnt.pixelWidth = w;
    elmnt.height = h + elmntPixel;
    elmnt.pixelHeight = h;
}
function changeZIndex(elmntName,index) {
	var elmnt = findElmnt(elmntName);
	elmnt = elmnt.style;
	elmnt.zIndex = index;
}
function changeDisplay(elmntName,dType){
	var elmnt = findElmnt(elmntName);   
	if( elmnt.style ) {
		elmnt = elmnt.style;
	} 
	if(!elmnt){
			return 0;
	}
	if( typeof( dType ) == 'string' ) {
		dType = dType.toLowerCase();
	}
	elmnt.display = ( dType == 'none' ) ? 'none' : ( dType == 'block' ) ? 'block' : ( dType == 'inline' ) ? 'inline' : '';
}
function swapDisplay(elmntName)
{
		
	var elmnt = findElmnt(elmntName);  
	if( elmnt.style ) {
		elmnt = elmnt.style;
	} 

	if(elmnt.display =="none")
	{
		changeDisplay(elmntName,"block");
	} else {
		changeDisplay(elmntName,"none");
	}
}
function changeOpacity(elmntName,opacity){
		var elmnt = findElmnt(elmntName);   
	if( elmnt.style ) {
		elmnt = elmnt.style;
	} 
	if(!elmnt){
		return 0;
	}
	elmnt.filters.alpha.opacity=opacity;
}

function is_ie()
{
	if(navigator.appName.indexOf("Microsoft")!=-1)
		return true;
	else
		return false;
}