
function uiWnd (obj, cnt, wndW, wndH, onOpen, onClose)
{
	obj.dialog('destroy');
	obj.dialog({
		autoOpen:false,
		dialogClass:'flora',
		modal:true,
		width:wndW,
		height:wndH,
		minWidth:wndW,
		minHeight:wndH,
		maxWidth:wndW,
		maxHeight:wndH,
		resizable:false,
		stack:true,
		overlay:false,
		open:function(type, data){
			$('.ui-dialog-titlebar').hide();
			$('.ui-dialog-container').find('#'+obj.attr('id')).css('display', '');
			$('.ui-dialog').css('height', wndH + 'px');
			
			if (cnt)
				obj.html(cnt.html());
			if (onOpen)
				onOpen(obj);
		},
		close:function(type, data){
			if (onClose)
				onClose(obj);
		}
	});
}

function uiWndOpen (obj)
{
	obj.dialog('open');
}

function uiWndClose (obj)
{
	obj.dialog('close');
}

function urlPath (href)
{
	var url = href;
	var pos = url.lastIndexOf('/');
	if (pos != -1)
		url = url.substr(0, pos);
	return url;	
}

function currentPath ()
{
	return urlPath(window.location.href);
}

function setOpMode (op, id)
{
	$('input[id="opm"]').each(function(){$(this).val(op);});
	$('input[id="eid"]').each(function(){$(this).val(id);});
}

function followUrl (url)
{
	if (window.location.replace)
		window.location.replace(url);
	else
		window.location.href = url;
}

function goToUrl (url)
{
	window.location.href = url;
}

function reloadUrl ()
{
	followUrl(window.location.href);
}

function pageWidth() 
{
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 

function pageHeight() 
{
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 

