/*
 * DON'T REMOVE THE FOLLOWING LICENSE
 *           INFORMATION!
 * ----------------------------------
 * Copyright by
 * Dennis Ritz
 * Author: Dennis Ritz
 * dennis.ritz@gmx.net
 * 2007-2008
 * ----------------------------------
 */
function Browser() {
	var DOM 	= (document.getElementById) ? true : false;
	var ALL    = (document.all) ? true : false;
	
	var isMozilla = false;
	var isIE = false;
	var isOpera = false;
	var isMobile = false;

	
	this.maxZIndex = 200000;
	
	this.init = function init() {
		var agent = navigator.userAgent.toLowerCase();
		isMozilla = ((agent.indexOf("mozilla") != -1) && (agent.indexOf("compatible") == -1));
		isIE = (agent.indexOf("msie") != -1);
		isOpera = (agent.indexOf("opera") != -1);
		isMobile = (agent.indexOf("mobile") != -1);
	}
	
	this.getElementById = function xgetElementById(p_id) {
		return document.getElementById(p_id);
	}
	
	this.getElementsByTagName = function xgetElementsByTagName(p_tagname) {
		return document.getElementsByTagName(p_tagname);
	}
	
	this.createElement = function createElement(p_elementTag, p_id, p_name, p_className){
		if(typeof p_name == "undefined") p_name="";
		if(DOM){
	    	var element = document.createElement(p_elementTag);
	        	element.name = p_name;
	    }else if(ALL) {
	    	var element = document.createElement('<'+p_elementTag+' name="'+p_name+'">');
	    }else{
	    	alert("Your browser doesn't support 'DOM', please see documentation for supported browsers");
	    }
	    if(typeof p_id != "undefined" && p_id != "") element.id = p_id;
	    if(typeof p_className != "undefined" && p_className != "") element.className = p_className;
	    return element;
	}
	
	this.setScript = function setScript(p_type,p_id,p_text) {
		//if(!isMobile) {
			var newScript = Browser.createElement("script",p_id+"ODS");
			newScript.type = p_type;
			newScript.text = p_text;
			Browser.getElementsByTagName("head")[0].appendChild(newScript);
		//} else {
		//	Browser.getElementsByTagName("body")[0].innerHTML += '<script id="'+p_id+'ODS" type="'+p_type+'">'+p_text+'<\/script>';
		//}
	}
	
	this.createTextNode = function createTextNode(p_text) {
		return document.createTextNode(p_text);
	}
	
	this.getHeight = function getHeight(p_element) {
		var height = 0;
		height = p_element.offsetHeight;
		
		if(typeof height == "string") {
			var posPX = height.indexOf("px");
			if(posPX > 0) height = height.substr(0,posPX);
			height = parseInt(height);
		}
		return height;		
	}
	
	this.setHeight = function setHeight(p_element,p_height) {
		p_element.style.height = p_height + "px";
	}	
	
	this.getWidth = function getWidth(p_element) {
		var width = 0;
		width = p_element.offsetWidth;
		
		if(typeof width == "string") {
			var posPX = width.indexOf("px");
			if(posPX > 0) width = width.substr(0,posPX);
			width = parseInt(width);
		}
		return width;
	}
	
	this.setWidth = function setWidth(p_element,p_width) {
		p_element.style.width = p_width + "px";
	}	
	
	this.getTop = function getTop(p_element) {
		var top = 0;
		top = p_element.offsetTop;
		
		if(typeof top == "string") {
			var posPX = top.indexOf("px");
			if(posPX > 0) top = top.substr(0,posPX);
			top = parseInt(top);
		}
		return top;		
	}	
	
	this.setTop = function setTop(p_element,p_top) {
		p_element.style.top = p_top + "px";
	}	
	
	this.getLeft = function getLeft(p_element) {
		var left = 0;
		left = p_element.offsetLeft;
		
		if(typeof left == "string") {
			var posPX = left.indexOf("px");
			if(posPX > 0) left = left.substr(0,posPX);
			left = parseInt(left);
		}
		return left;		
	}
	
	this.setLeft = function setLeft(p_element,p_left) {
		p_element.style.left = p_left + "px";
	}
	
	this.getVisibility = function getVisibility(p_element) {
		alert(p_element.style.visibility);
	}
	
	this.setVisibility = function setVisibility(p_element,p_on) {
		if (p_on) {
			p_element.style.visibility = "visible";
		} else {
			p_element.style.visibility = "hidden";
		}
	}
	
	this.getDisplay = function getDisplay(p_element) {
		if(p_element.style.display == "none") {
			return false;
		} else {
			return true;
		}
	}
	
	this.setDisplay = function setDisplay(p_element,p_on) {
		if (p_on) {
			p_element.style.display = "block";
		} else {
			p_element.style.display = "none";
		}
	}
	
	this.setZIndexToMax = function setZIndexToMax(p_element,p_add) {
		var add;
		if(typeof p_add != "undefined" && p_add < 0){
			var add = p_add;
		} else {
			add = 0;
		}
		p_element.zIndex = ""+(this.zIndexMax+add);	
	}
	this.init()
}
var Browser = new Browser();