function browseIt()
{
	this.ver = navigator.appVersion.toLowerCase();
	this.verNum = parseInt(this.ver);
	this.agent = navigator.userAgent.toLowerCase();
	this.dom = (document.getElementById ? 1 : 0);
	this.opera = (this.agent.indexOf("opera") > -1 && this.dom ? 1 : 0);
	this.opera7 = (this.opera && this.verNum >= 7);
	this.opera9 = (this.opera && this.verNum >= 9);
	this.ie = (this.ver.indexOf("msie") > -1 && this.dom && !this.opera ? 1 : 0);
	this.ieVer = 0;
	if (this.ie) {
		var pos = this.ver.indexOf("msie");
		if (pos != -1)
			this.ieVer = parseInt(this.ver.substr(pos + 5));
	}
	this.ie6 = (this.ie && (this.ieVer >= 6));
	this.ie6only = (this.ie && (this.ieVer >= 6) && (this.ieVer < 7));
	this.ie7 = (this.ie && (this.ieVer >= 7));
	this.macOS = (this.agent.indexOf("mac") > -1);
	this.mac = (this.macOS && this.verNum >= 7 ? 1 : 0);
	this.moz = (this.agent.indexOf("gecko") > -1);
	this.ns6 = (this.dom && this.agent.indexOf("netscape") > -1 && this.verNum >= 5 ? 1 : 0);
	this.ff = (this.agent.indexOf("firefox") > -1);
	this.b = (this.ie || this.ns6 || this.opera7 || this.mac || this.moz || this.dom);

	return this;
}

//var px = window.opera ? "" : "px";
var b = new browseIt();

function trim(s, p)
{
	if (typeof s != 'string')
		return s;
	return s.replace(p ? p : /^\s*|\s*$/g, '');
}

function stripTags(str)
{
	return str.replace(/(<([^>]*)>)/g, '');
}

function checkAll(val, p)
{
	if (typeof p == 'string')
		p = document.getElementById(p);
	if (!p)
		p = document.body;

	var arr = p.getElementsByTagName('INPUT');
	for (var i = 0; i < arr.length; i++) {
		if (arr[i].type == 'checkbox')
			arr[i].checked = val;
	}
}

function checkDate(month, day, year)
{
	if (month < 1 || month > 12) return false;
	if (day < 1 || day > 31) return false;
	switch (month) {
	case 4:
	case 6:
	case 9:
	case 11:
		if (day > 30) return false;
		break;
	case 2:
		if (year % 4) {
			if (day > 28) return false;
		} else {
			if (day > 29) return false;
		}
		break;
	}

	return true;
}

function frPr()
{
	if (parent && parent != window)
		parent.location.href = window.location.href;
}

function toggleDisplay(tag, value, cont)
{
	if (!cont)
		cont = document;
	var sel = document.getElementsByTagName(tag);
	for (var i = 0; i < sel.length; i++)
		sel[i].style.visibility = value;
}

// Aliases
function dce(tag) {
	return document.createElement(tag);
}
function dct(text) {
	return document.createTextNode(text);
}
function dge(id) {
	return document.getElementById(id);
}

// Searches items in array with geiven property equal to searchVal
function getItemIndex(searchVal, indexCompare, arr) {
	var len = arr.length;
	for (var i = 0; i < len; i++) {
		if (arr[i][indexCompare] == searchVal) {
			return i;
		}
	}
	return -1;
}

// Searches array for element
function arrayPos(element, arr) {
	var len = arr.length;
	for (var i = 0; i < len; i++) {
		if (arr[i] == element) {
			return i;
		}
	}
	return -1;
}

// Util func - clears elements in container and destroys circular reference links
function peUtilClearContainer(container) {
	if (typeof(container.childNodes) != 'undefined') {
		while (container.childNodes.length) {
			if (typeof(container.firstChild.controller) != 'undefined')
				container.firstChild.controller = null;
			peUtilClearContainer(container.firstChild);
			var tmp = container.firstChild;
			container.removeChild(tmp);
			tmp = null;
			delete tmp;
		}
	}
}

// Compares str1 with str2, returns -1 (str1 lower), 0 (equal), +1 (str1 bigger)
function strCmp(str1, str2) {
	if (str1 == str2)
		return 0;
	var arr = new Array(str1, str2);
	arr.sort();
	if (arr[0] == str1)
		return -1;
	else
		return 1;
}

// Compares str1 with str2, returns -1 (str1 lower), 0 (equal), +1 (str1 bigger)
function striCmp(str1, str2) {
	str1 = '' + str1;
	str2 = '' + str2;
	if (str1 == str2)
		return 0;
	str1 = str1.toLowerCase();
	str2 = str2.toLowerCase();
	var arr = new Array(str1, str2);
	arr.sort();
	if (arr[0] == str1)
		return -1;
	else
		return 1;
}

// Notifiers
UTIL_LOADED = true;
UTIL_READY = true;

function DBG(elem)
{
	var str = '';

	for (var i in elem) {
		str += i + ': ' + elem[i] + '; ';
	}

	alert(str)
}