var IE = document.all ? true : false

String.prototype.pad = function(l, s, t){
	return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
		+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
		+ this + s.substr(0, l - t) : this;
};

function byId(id) {

	return document.getElementById(id);

}

function getX(e) {

        return IE ? event.clientX : e.pageX;

}

function getY(e) {

        return IE ? event.clientY : e.pageY;

}

function go2(url) {

	document.location.href = url;

}

function xmlhttp () {

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	return http_request;

}

function makeActive(id) {
        var item = parent.frames['leftMenu'].document.getElementById('menu');
        var elements = item.getElementsByTagName('li');

        for (i = 0; i < elements.length; i++) {
                elements[i].type = 'circle';
        }

        parent.frames['leftMenu'].document.getElementById(id).type='disc';
}

function xwin(url, name, width, height, features){
	var l = (window.screen.availWidth) ? (window.screen.availWidth - width)/2 : 0;
	var t = (window.screen.availHeight) ? (window.screen.availHeight - height)/2 : 0;
	if (typeof(features) == 'string')
		features = ',' + features;

	var w = window.open(url, name, 'top=' + t + ',left=' + l + ',height=' + height + ',width=' + width + ', scrollbars=auto' + features);
	if (!w) return;
	w.resizeTo(width, height);
	return w;
}

function sortField(file, field, mode) {
	window.location.href = file + '.php?sortField=' + field + '&sortMode=' + mode;
}

function deleteItem(file, id) {
	if (confirm ('Are you sure?'))
		window.location.href = file + '.php?deleteId=' + id;
}

function checkAll (object) {
	var elems = object.form.elements;
	for (var i = 0; i < elems.length; i++) {
		var elem = elems[ i ];
		if (elem.type == 'checkbox' && elem != this) {
			elem.checked = object.checked;
		}
	}
}

function debugElement(elem) {
	str = "";
	j = 0;
	for (i in elem) {
		//str+="<center><big>" + i + "</big></center><br/>\n";
		str+=i + "\n";
		j++;
		if (j==20) {
			//document.write(str);
			alert(str);
			str="";
			j = 0;
		}
	}
}

