var openFlag;

function closeWindow()
	{
	/* var infoWindow = document.getElementById('infoWindow');
	var parent = infoWindow.parentNode;
	parent.removeChild(infoWindow);   */
	onWindowHide();
			$('#infoWindow').jqmHide();
	};
	
function onWindowShow(){openFlag = true;setTop();}	

function onWindowHide(){openFlag = false;}

function setTop() {
//        document.getElementById('infoWindow').style.top = (f_scrollTop()-100) + 'px';
}

function f_scrollTop() {
    return f_filterResults (
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    );
}

function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

// --- REGISTRACE, PRIHLASENI, ZAPOMENUTE HESLO, UCET

function openLoginWindow(referrer)
	{
		if (!referrer || referrer == 'undefined')
		{
			referrer = '/';
		}


	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/user/login/?referrer='+referrer, modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};
	
function openForceLoginWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/user/login/?force&stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};
	
function openRegisterWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/user/register/?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};
	
function openRestoreWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/user/restore/?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};
	
function openSetupWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/user/setup/?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};
	

function openForceCodeWindow()
	{

	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/magic-christmas/ajax/code.php?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};

	
function openErrorWindow(error)
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/magic-christmas/ajax/error.php?error='+error+'&stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};
	
function openDDMRulesWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/ddmRules.php?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};	
	
function openDDMResultsWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/ddmResults.php?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};	
	
function openSpisovatelRulesWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/spisovatelRules.php?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};	
	
function openSpisovatelResultsWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/spisovatelResults.php?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};	
	
function openClanekWindow(clanek)
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/ajax/spisovatelClanek.php?id='+clanek+'&stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};	
	
	
function openAuctionWindow(id)
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/magic-christmas/ajax/openAuctionWindow.php?id='+id+'&stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};
	
function openMojeDarkyWindow()
	{
	
	// just for test
		if (openFlag) $('#infoWindow').jqmHide();
		$('#infoWindow').html('');
			$('#infoWindow').jqm({ajax:'/magic-christmas/ajax/openMojeDarkyWindow.php?stamp='+ new Date().getTime(), modal:true, toTop:true});
			$('#infoWindow').jqmShow();
			onWindowShow();
	};