	
	function getNextSibling(node, type){
		
		var childCount = node.parentNode.childNodes.length;
		
		for (i=0; i<= childCount; i++) {
			
			var node = node.nextSibling;
			
			if (node == null) {
				return null;
				break;
			} else {
				
				if (node.nodeName.toLowerCase() == type.toLowerCase()) {
					
					return node;
					
				}
				
			}
			
		}
		
		return null;
		
	}
	
	
	function getChild(parent, tagname, classname) {
		
		var nodes = parent.childNodes;
		tagname = tagname.toLowerCase();
		
		for (x in nodes) {
			
			if (nodes[x].nodeType == 1 && nodes[x].tagName.toLowerCase() == tagname) {
				
				if (!classname) {
					return nodes[x];
					break;
				} else if(nodes[x].className == classname) {
					return nodes[x];
					break;
				}
				
			}
			
		}
		
	}
	
	function getChildNodes(parent, tagname, classname) {
		
		var result = new Array();
		var nodes = parent.childNodes;
		tagname = tagname.toLowerCase();
		
		for (x in nodes) {
			
			if (nodes[x].nodeType == 1 && nodes[x].tagName.toLowerCase() == tagname) {
				
				if (!classname) {
					result.push(nodes[x]);
				} else if(nodes[x].className == classname) {
					result.push(nodes[x]);
				}
				
			}
			
		}
		
		return result;
		
	}
	
	
	function getInt(str) {
		
		return parseInt(str.replace('px',''));
		
	}
	
	function roundNumber(num, dec) {
		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}
	
	
	// pokusit se predelat do prototypu Array....
	function arrayRemove(array, val) {
		
		var result = new Array();
		
		for (x in array) {
			
			if (array[x] != val) {
				result[x] = array[x];
			}
			
		}
		
		return result;
		
	}
	
	function arrayRemoveByKey(array, key) {
		
		var result = new Array();
		
		for (x in array) {
			
			if (x != key) {
				result[x] = array[x];
			}
			
		}
		
		return result;
		
	}
	
	function arrayContains(array, val) {
		
		for (x in array) {
			if (array[x] == val) {
				return true;
				break;
			}
		}
		
		return false;
	}
	
	
      function getElementsByClassName(classname, node) {
	      	
	      if (!node) node = document.getElementsByTagName("body")[0];
	      
	      var a = [];
	      var re = new RegExp('\\b' + classname + '\\b');
	      var els = node.getElementsByTagName("*");
	      
	      for (var i = 0, j = els.length; i < j; i++) {
		      if (re.test(els[i].className)) {
			      a.push(els[i]);
		      }
	      }
	      
	      return a;
      }
      
      
	function stripHTML(str) {
		// What a tag looks like
		var matchTag = /<(?:.|\s)*?>/g;
		// Replace the tag
		return str.replace(matchTag, "");
	};
	
	
	
	
	function Tparams(loadData) {
		
		this.params = new Object();
		
		this.load = function (data) {
			
			var x;
			data = data.split(';');
			
			for (x in data) {
				
				var param = data[x].split(':');
				this.params[param[0]] = param[1];
				
			}
			
		}
		
		this.build = function() {
			
			var x;
			var result = '';
			
			for (x in this.params) {
				
				result += x + ':' + this.params[x] + ';'; 
				
			}
			
			
			if (result.length > 0) {
				return result.substr(0, result.length -1);
			} else {
				return '';
			}
			
		}
		
		
		// constructor
		if (loadData) {
			this.load(loadData);
		}
		
		
	}
	
	
	
	
	function appendNode(node) {
		
		var pos = document;
		while (pos && pos.lastChild && pos.lastChild.nodeType == 1) pos = pos.lastChild;
		pos.parentNode.appendChild(node);
		
	}
	
	
	function addEvent(type, callback, node) {
		
		if (!node) { var node = document }
		
		if (document.addEventListener) {
			node.addEventListener(type, callback, false);
		} else if (document.attachEvent) {
			node.attachEvent('on'+type, callback, true);
		}
		
	}
	
	function deleteEvent(type, callback, node) {
		
		if (!node) { var node = document }
		
		if (document.removeEventListener) {
			node.removeEventListener(type, callback, false);
		} else if (document.detachEvent) {
			node.detachEvent('on' + type, callback);
		}
		
	}
	
	
	
	function parseIntEx(i, scale) {
		
		if (!parseInt(scale, 10)) {
			scale = 10;
		}
		
		var res = parseInt(i, scale);
		
		if (isNaN(res)) {
			return 0;
		} else {
			return res;
		}
		
	}
	
	
	function getClearDiv() {
		
		var div = document.createElement('div');
		div.className = 'clear';
		
		var nbsp = document.createTextNode('\u00a0');
		div.appendChild(nbsp);
		
		return div;
		
	}
	
	
	function roundNearest(num, acc){
		if ( acc < 0 ) {
			return Math.round(num*acc)/acc;
		} else {
			return Math.round(num/acc)*acc;
		}
	}
	
	function Tqueue(values) {
		
		var thisObj = this;
		this.queue = new Array();
		var val;
		
		if (values.charAt(0) == ';') values = values.substr(1);
		if (values.charAt(values.length-1) == ';') values = values.substr(0, values.length-1);
		
		
		if (values != '') {
			
			values = values.split(';');
			
			for (val in values) {
				this.queue.push(values[val]);
			}
			
		}
		
		
		this.add = function(val) {
			
			if (!arrayContains(this.queue, val)) {
				
				this.queue.push(val);
				
			}
			
			return build();
			
		}
		
		
		this.remove = function(val) {
			
			this.queue = arrayRemove(this.queue, val);
			return build();
			
		}
		
		this.contains = function(val) {
			
			return arrayContains(this.queue, val);
			
		}
		
		
		function build() {
			
			var val = '';
			var result = '';
			
			for (val in thisObj.queue) {
				result += thisObj.queue[val] + ';';
			}
			
			return result;
			
		}
		
	}
	

