UI = new Object();
UI.pb = function(elem, ev) {
	if(window.__uiPrepostBack) {
		window.__uiPrepostBack();
	}
	var id = '';
	if(typeof(elem)=='string') {
		id = elem;
	} else {
		id = elem.id;
	}
	var pos = UI.scrollBarPos();
	var frm = document.forms[0];
	frm.__uipos.value=pos.x+','+pos.y;
	frm.__uievent.value=id+':'+ev;
	frm.submit();
}

UI.confirm = function(txt) {
	return window.confirm(txt);
}
UI.open = function(url, name, attrs) {
	window.open(url, name, attrs);
	return;
}
UI.alert = function(txt) {
	return window.alert(txt);
}
UI.setFocusOn = function(id) {
	var el = UI.getElementById(id);
	if(el && el.focus) {
		try {
			el.focus();
		} catch(Exception) {
		}
		if(el.select) {
			try {
				el.select();
			} catch(Exception) {
			}
		}
	}
}
UI.getKeyFrom = function(ev) {
	if (window.event) {
		return window.event.keyCode;
	} else if (ev) {
		return ev.which;
	}
	return null;
}
UI.getElementById = function(id) {
	return UI._getElementByIdRec(id,window.document);
}
UI.elem = UI.getElementById;
UI._getElementByIdRec = function(id, doc) {
	if (doc.getElementById) {
		var o = doc.getElementById(id);
		if(o) {
			return o;
		}
	}
	if (doc.all) {
		var o = doc.all[id];
		if(o) {
			return o;
		}
	}
	if(doc.layers) {
		for (var i=0; i<doc.layers.length; i++) {
			o = UI._getElementByIdRec(id, doc.layers[i].document);
			if(o) {
				return o;
			}
		}
	}
	return null;
}
UI.dbg = function(val) {
	if (UI.dbg.win == null || UI.dbg.win.closed){
	    UI.dbg.win = window.open('','debugWin','toolbar=no,scrollbars=yes,width=700,height=600');
		UI.dbg.win.document.writeln('<pre style=\"font-size: 10px\">');
	}
	UI.dbg.win.document.writeln(val);
	UI.dbg.win.scrollBy(0, 1000);
}
UI.dbg.win = null;


UI.windowSize = function() {
	var pos = new Object();
	if (navigator.appName == "Microsoft Internet Explorer") {
		if (document.documentElement && document.documentElement.offsetHeight)	{
			// IE6 in standards compliant mode, some properties of document.body are reassigned to document.documentElement.
			pos.x = document.documentElement.offsetWidth;
			pos.y = document.documentElement.offsetHeight;
		} else {
			pos.x = document.body.offsetWidth;
			pos.y = document.body.offsetHeight;
		}
	} else {
		pos.x = window.innerWidth;
		pos.y = window.innerHeight;
	}
	return pos;
}

UI.scrollBarPos = function() {
	var pos = new Object();
	if (navigator.appName == "Microsoft Internet Explorer") {
		if (document.documentElement && document.documentElement.scrollTop)	{
			// IE6 in standards compliant mode, some properties of document.body are reassigned to document.documentElement.
			pos.x = document.documentElement.scrollLeft;
			pos.y = document.documentElement.scrollTop;
		} else {
			pos.x = document.body.scrollLeft;
			pos.y = document.body.scrollTop;
		}
	} else {
		pos.x = window.pageXOffset;
		pos.y = window.pageYOffset;
	}
//	scrollingDetector();
	return pos;
}
UI.scrollTo = function(x,y) {
	window.scrollTo(x,y);
}
/*
	function scrollingDetector(){
	if (navigator.appName == "Microsoft Internet Explorer"){
	alert("You've scrolled to " + document.body.scrollTop + " pixels.");
	}
	else{alert ("You've scrolled to " + window.pageYOffset + " pixels.");}
	
	}
*/


