var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;
var isIE = 0;
var isNS = 0;

if(document.getElementById){
	isID = 1;
	isDHTML = 1;
}
else{
	if(document.all){
		isAll = 1;
		isDHTML = 1;
	}
	else{
		browserVersion = parseInt(navigator.appVersion);
		if((navigator.appName.indexOf('Netscape') != -1 && browserVersion == 4)){
			isLayers = 1;
			isDHTML = 1;
		}
	}
}
if(navigator.appName.indexOf('Netscape' != -1)){ isNS = 1; }
else{
	if(navigator.appName.indexOf('Microsoft Internet Explorer' != -1)){ isIE = 1; }
}

function findDOM(objID, withStyle){
	
	if(withStyle == 1){
		if(isID){
			return document.getElementById(objID).style;
		}
		else{
			if(isAll){
				return document.all[objID].style;
			}
			else{
				if(isLayers){
					return document.layers[objID];
				}
			}
		}
	}
	else{
		if(isID){
			return document.getElementById(objID);
		}
		else{
			if(isAll){
				return document.all[objID];
			}
			else{
				if(isLayers){
					return document.layers[objID];
				}
			}
		}
	}
	
}

function findWidth(objID){
	
	var dom = findDOM(objID, 0);
	if(dom.offsetWidth){
		return dom.offsetWidth;
	}
	if(dom.clip.width){
		return dom.clip.width;
	}
	
	return null;
	
}

function findHeight(objID){
	
	var dom = findDOM(objID, 0);
	if(dom.offsetHeight){
		return dom.offsetHeight;
	}
	if(dom.clip.height){
		return dom.clip.height;
	}
	
	return null;
	
}

function findLeft(objID){
	
	var domStyle = findDOM(objID, 1);
	var dom = findDOM(objID, 0);
	
	if(domStyle.left){
		return domStyle.left;
	}
	if(domStyle.pixelLeft){
		return domStyle.pixelLeft;
	}
	if(dom.offsetLeft){
		return dom.offsetLeft;
	}
	
	return null;
	
	
}

function findTop(objID){
	
	var domStyle = findDOM(objID, 1);
	var dom = findDOM(objID, 0);
	
	if(domStyle.top){
		return domStyle.top;
	}
	if(domStyle.pixelTop){
		return domStyle.pixelTop;
	}
	if(dom.offsetTop){
		return dom.offsetTop;
	}
	
	return null;
	
	
}

function findRight(objID){
	
	var domStyle = findDOM(objID, 1);
	var dom = findDOM(objID, 0);
	
	if(domStyle.left){
		return (domStyle.left+domStyle.clip.width);
	}
	if(domStyle.pixelLeft){
		return (domStyle.pixelLeft+domStyle.offsetWidth);
	}
	if(dom.offsetLeft){
		return (dom.offsetLeft+dom.offsetWidth);
	}
	
	return null;
	
	
}

function findBottom(objID){
	
	var domStyle = findDOM(objID, 1);
	var dom = findDOM(objID, 0);
	
	if(domStyle.top){
		return (domStyle.top+domStyle.clip.height);
	}
	if(domStyle.pixelTop){
		return (domStyle.pixelTop+domStyle.offsetHeight);
	}
	if(dom.offsetTop){
		return (dom.offsetTop+dom.offsetHeight);
	}
	
	return null;
	
}

function setClip(objID, clipTop, clipRight, clipBottom, clipLeft){
	
	var dom = findDOM(objID, 1);
	
	if(dom.clip.left){
		dom.clip.top = clipTop;
		dom.clip.right = clipRight;
		dom.clip.bottom = clipBottom;
		dom.clip.left = clipLeft;
	}
	
	dom.clip = 'rect(' + clipTop + ' ' + clipRight + ' ' + clipBottom + ' ' + clipLeft + ')';
	
}

function findClipArray(clipStr){
	
	var clip = new Array();
	var i;
	
	i = clipStr.indexOf('(');
	clip[0] = parseInt(clipStr.substring(i+1, clipStr.length), 10);

	i = clipStr.indexOf(' ', i+1);
	clip[1] = parseInt(clipStr.substring(i+1, clipStr.length), 10);

	i = clipStr.indexOf(' ', i+1);
	clip[2] = parseInt(clipStr.substring(i+1, clipStr.length), 10);

	i = clipStr.indexOf(' ', i+1);
	clip[3] = parseInt(clipStr.substring(i+1, clipStr.length), 10);
	
	return clip;
	
}

function findClipTop(objID){
	
	var dom = findDOM(objID, 1);
	if(dom.clip.top){
		return dom.clip.top;
	}
	if(dom.clip != null){
		var clip = findClipArray(dom.clip);
		return clip[0];
	}
	
	return null;
	
}

function findClipRight(objID){
	
	var dom = findDOM(objID, 1);
	if(dom.clip.right){
		return dom.clip.right;
	}
	if(dom.clip != null){
		var clip = findClipArray(dom.clip);
		return clip[1];
	}
	
	return null;
	
}

function findClipBotom(objID){
	
	var dom = findDOM(objID, 1);
	if(dom.clip.botom){
		return dom.clip.botom;
	}
	if(dom.clip != null){
		var clip = findClipArray(dom.clip);
		return clip[2];
	}
	
	return null;
	
}


function findClipLeft(objID){
	
	var dom = findDOM(objID, 1);
	if(dom.clip.left){
		return dom.clip.left;
	}
	if(dom.clip != null){
		var clip = findClipArray(dom.clip);
		return clip[3];
	}
	
	return null;
	
}

function findClipWidth(objID){
	
	var dom = findDOM(objID, 1);
	if(dom.clip.width){
		return dom.clip.width;
	}
	if(dom.clip != null){
		var clip = findClipArray(dom.clip);
		return (clip[1] - clip[3]);
	}
	
	return null;
	
}

function findClipHeight(objID){
	
	var dom = findDOM(objID, 1);
	if(dom.clip.height){
		return dom.clip.height;
	}
	if(dom.clip != null){
		var clip = findClipArray(dom.clip);
		return (clip[2] - clip[0]);
	}
	
	return null;
	
}

function moveObjectTo(objID, numLeft, numTop){
	
	var domStyle = findDOM(objID, 1);
	domStyle.left = numLeft;
	domStyle.top = numTop;
	
}

function moveObjectBy(objID, deltaX, deltaY){
	
	var domStyle = findDOM(objID, 1);
	var dom = findDOM(objID, 0);
	
	if(domStyle.pixelLeft){
		domStyle.pixelLeft += deltaX;
		domStyle.pixelTop += deltaY;
	}
	else{
		if(dom.offsetLeft != null){
			var plusLeft = dom.offsetLeft;
			var plusRight = dom.offsetTop;
			domStyle.left = deltaX + plusLeft;
			domStyle.top = deltaY + plusTop; 
		}
		else{
			dom.moveBy(deltaX, deltaY);
		}
	}
	
}


function findLivePageHeight(){
	
	if( typeof( window.innerWidth ) == 'number' ){
		return window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		return document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		return document.body.clientHeight;
	}
	
	return null;
	
}

function findLivePageWidth(){
	
	if( typeof( window.innerWidth ) == 'number' ){
		return window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		return document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		return document.body.clientWidth;
	}
	
	return null;
	
}

function scrollPageTo(x, y){

	if(isIE){
		document.body.scrollLeft = x;
		document.body.scrollTop = y;
		return;
	}
	else{
		scrollTo(x, y);
		return;
	}
	
}


function findXCoord(evt){
	
	if(evt.x) return evt.x;
	if(evt.pageX) return evt.pageX;
	
}


function findYCoord(evt){
	
	if(evt.y) return evt.y;
	if(evt.pageY) return evt.pageY;
	
}

function changeWindowSize(windowWidth, windowHeight){
	
	if(window.outerWidth){
		resizeTo(windowWidth, windowHeight);
	}
	
}

function magnifyWindowSize(dWindowWidth, dWindowHeight){
	
	if(window.outerWidth){
		resizeBy(dWindowWidth, dWindowHeight);
	}
	
}

function fillScreen(){

	if(window.outerWidth){
		windowWidth = screen.width;
		windowHeight = screen.height;
		moveTo(0, 0);
		resizeTo(windowWidth, windowHeight);
	}
	
}


function setClass(objID, newClass){
	
	var dom = findDOM(objID, 0);
	dom.className = newClass;
	
}

function setVisibility(objID, state){
	
	var dom = findDOM(objID, 1);
	dom.visibility = state;
	
}


