// browerspecifications
browser			= (navigator.appName)?navigator.appName:null;
isIE = isFirefox = isOpera = false; 

if(browser!="Netscape" && browser!="Microsoft Internet Explorer"){
	var isOpera	= true; // because "Opera" is editable
}else if(document.all){
	var isIE = true;
}else if(browser=="Netscape"){
	var isFirefox = true;
}else{
	var isFirefox = true; // ... till other browser are implemented!
}

// returns the position left and top of an element
function getPosition(id) {

	var pos		= { left:0, top:0 };

	if(document.getElementById(id).offsetHeight){
		elem = document.getElementById(id);
		while(elem!=null){
			pos.left += elem.offsetLeft;
			elem   = elem.offsetParent;
		}
	}

	if(document.getElementById(id).offsetWidth){
		elem = document.getElementById(id);
		while(elem!=null){
			pos.top += elem.offsetTop;
			elem   = elem.offsetParent;
		}
	}

	return pos;
}

// returns the dimension height and width of an element
// Attention: Firefox has no value for height and width is the element has %-properties
function getDimension(id){

	var dimension		= { width:0, height:0 };

	if(document.getElementById(id).offsetHeight){
		dimension.height = document.getElementById(id).offsetHeight;
	}

	if(document.getElementById(id).offsetWidth){
		dimension.width = document.getElementById(id).offsetWidth;
	}

	return dimension;
}

// returns the dimension height and width of the viewport of the browser
function getBodyDimension(){

	var dimension		= { width:0, height:0 };

	if(isIE){
		dimension.height = myDocument().offsetHeight;
		dimension.width  = myDocument().offsetWidth;
	}else{
		dimension.height = window.innerHeight;
		dimension.width  = window.innerWidth;
	}

	/*
	-> following exceptions in width and height are in used for the frameset
	- Firefox needs -20px height to disable the vertical scrollbar
	- Opera needs -20px height to disable the vertical scrollbar
	- all browsers needs -20px width
	- IE only hides the horizontal scrollbar
	- Firefox doesn't hide scrollbars
	- Opera doesn't hide scrollbars
	*/
	
	dimension.height -= (isFirefox)?20:0;
	dimension.height -= (isOpera)?20:0;
	dimension.width  -= 20;


	return dimension;
}

// returns the dimension height and width of the viewport + scrollarea of the browser
function getBodyDimensionWithScrollDimension(){

	var dimension		= { width:0, height:0 };

	dimension.height = getBodyDimension().height+getScrollDimension().height;
	dimension.width = getBodyDimension().width+getScrollDimension().width;

	return dimension;

}

// returns the dimension height and width of the scrollarea of the browser
function getScrollDimension(){

	var dimension		= { width:0, height:0 };

	if(myDocument()){
		dimension.height = myDocument().scrollHeight;
		dimension.width	 = myDocument().scrollWidth;
	}

	var bodyDimensionHeight = getBodyDimension().height;
	var bodyDimensionWidth = getBodyDimension().width;

	if(dimension.height<=bodyDimensionHeight){
		dimension.height = 0;
	}else{
		dimension.height = dimension.height-bodyDimensionHeight;
	}

	if(dimension.width<=bodyDimensionWidth){
		dimension.width = 0;
	}else{
		dimension.width = dimension.width-bodyDimensionWidth;
	}

	return dimension;
}

// returns the current dimension height and width of the scrollarea, the user has scrolled
function getCurrentScrollDimension(){

	var dimension		= { width:0, height:0 };

	if(isIE){
		dimension.height = myDocument().scrollTop;
		dimension.width = myDocument().scrollLeft; 
	}else{
		dimension.height = window.pageYOffset;
		dimension.width  = window.pageXOffset;
	}

	return dimension;

}

// returns the documentElement in compatmode or other way the body
function myDocument(){ 
	return ((document.compatMode != "BackCompat")? document.documentElement : document.body);
}