//Zobrazi layer FORMULAR pomoci AJAX - START
function ajaxShowLayerWindow(formName, parameters)
{
	try
	{
		//Zavre pripadne okno, pokud se volalo ajaxShowLayerWindow z existujiciho formulare
		top.CloseLayerWindow();
		
		if(!isObj(parameters)) parameters='';
		
		//synchronous call
		var oDivForm = getObj('divLayerWindow');
		if(isObj(oDivForm))
		{
			var res = Chvalburg.Core.AJAX.ShowLayerWindow(formName,parameters).value;
			var resArr = res.split('~#split#~');
			if(resArr.length==2)
			{
				oDivForm.innerHTML = resArr[0];
				eval(resArr[1]);
				
				setLayerBoxBackLevelAuto('up');
				oDivForm.style.zIndex=toInt(mLBoxBack.style.zIndex)+1;
			}
		}
	}catch(e)
	{
		window.location=window.location;
	}
	return;
	
	// asynchronous call 
	//nastavi pozadi na DEFAULT 0
	setLayerBoxBackLevel(0);
	//Zobrazi PROGRESS
	showLayerBox(msg(10),msg(11),200);
	Chvalburg.Core.AJAX.ShowLayerWindow(formName,parameters,ajaxShowLayerWindow_callback);  // asynchronous call

}
function ajaxShowLayerWindow_callback(res)
{
    //Skryje PROGRESS, pokud je BACK na 100 tak i pozadi
    hideLayerBox();
    
    var oDivForm = getObj('divLayerWindow');
    if(isObj(oDivForm))
    {
        if(!isObj(res.value)) return;
        var resArr = res.value.split('~#split#~');
        if(resArr.length==2)
        {
            oDivForm.innerHTML = resArr[0];
            eval(resArr[1]);

            setLayerBoxBackLevelAuto('up');
            oDivForm.style.zIndex=toInt(mLBoxBack.style.zIndex)+1;
            
        }
    }
}
//Zobrazi formular pomoci AJAX - END

//Provede logout pomoci AJAX - START
function ajaxLogout()
{
	try
	{
		Chvalburg.Core.AJAX.Logout(ajaxLogout_callback);  // asynchronous call
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}
function ajaxLogout_callback(res)
{
	try
	{
		window.location=window.location;
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}
//Provede logout pomoci AJAX - END

function ajaxNavigate(navigateAction)
{
	try
	{
		//Zavre pripadne okno, pokud se volalo ajaxShowLayerWindow z existujiciho formulare
		top.CloseLayerWindow();
		
		//showLayerBox(msg(10),msg(11),200);
		//Chvalburg.Core.AJAX.Navigate(navigateAction,ajaxNavigate_callback);  // asynchronous call
		
		var res = Chvalburg.Core.AJAX.Navigate(navigateAction);  // synchronous call
		ajaxNavigate_callback(res);	    
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}
function ajaxNavigate_callback(res)
{
	try
	{
	  hideLayerBox();
	  if(!isObj(res.value)) return;
	  eval(res.value);
	}catch(e)
	{
		window.location=window.location;
	}
}
//Provede navigaci pomoci AJAX - END


//Inicializace TOPU - EVAL pro MSG apod - START
function ajaxInitializeTop()
{
	try
	{
		javascript:document.getElementById('hid').style.display='none';
		msgCache = {'0':['']};
		Chvalburg.Core.AJAX.InitializeTop(ajaxInitializeTop_callback);  // asynchronous call
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}
function ajaxInitializeTop_callback(res)
{
    if(!isObj(res.value)) return;
    eval(res.value);
    //Zavola obsah mainu jako dhtml
    ajaxNavigateHtmlElement('','','');
}
//Inicializace TOPU - EVAL pro MSG apod - END


//Zobrazi formular pomoci AJAX - START
function ajaxNavigateHtmlElement(elementId, pageName, parameters)
{
	try
	{
		//Zavre pripadne okno, pokud se volalo ajaxShowLayerWindow z existujiciho formulare
		top.CloseLayerWindow();
		
		// asynchronous call
		//showLayerBox(msg(10),msg(11),200);
		//Defaultne tdMain
		//if(elementId=='') elementId = 'tblMaintdMain';
		//Chvalburg.Core.AJAX.NavigateHtmlElement(elementId,pageName,parameters,ajaxFillHtmlElement_callback);  // asynchronous call
		
		// synchronous call
		//Defaultne tdMain
		if(elementId=='') elementId = 'tblMaintdMain';
		var res = Chvalburg.Core.AJAX.NavigateHtmlElement(elementId,pageName,parameters);
		ajaxFillHtmlElement_callback(res);
		
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}
function ajaxFillHtmlElement2(elementId, fillAction, fillValue)
{
	try
	{
    //Zavre pripadne okno, pokud se volalo ajaxShowLayerWindow z existujiciho formulare
    top.CloseLayerWindow();

    // asynchronous call
    //showLayerBox(msg(10),msg(11),200);
    //Chvalburg.Core.AJAX.FillHtmlElement2(elementId,fillAction,fillValue,ajaxFillHtmlElement_callback);  // asynchronous call

    // synchronous call
    var res = Chvalburg.Core.AJAX.FillHtmlElement2(elementId,fillAction,fillValue);
    ajaxFillHtmlElement_callback(res);

	}catch(e)
	{
		window.location=window.location;
	}
	return;
}
function ajaxFillHtmlElement_callback(res)
{
	try
	{
		hideLayerBox();
		if(!isObj(res.value)) return;
		var resArr = res.value.split('~#split#~');
		if(resArr.length==2)
		{
			var oElement = getObj(resArr[0]);
			if(isObj(oElement))
			{
				oElement.style.visibility = 'visible';
				oElement.style.display = 'block';
				oElement.innerHTML = resArr[1];
			}
		}
		//Zobrazeni alertu
		if(resArr.length==3)
		{
			var oElement = getObj(resArr[0]);
			if(isObj(oElement))
			{
				oElement.style.visibility = 'visible';
				oElement.style.display = 'block';
				oElement.innerHTML = resArr[1];
				//Provede eval
				eval(resArr[2]);
			}
		}
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}
//Zobrazi formular pomoci AJAX - END




//GELERY PREVIEW
function ShowLayerWindowGaleryDetail(innerHTML)
{
	try
	{
		//Zavre pripadne okno, pokud se volalo ajaxShowLayerWindow z existujiciho formulare
		top.CloseLayerWindow();
		
		var oDivForm = getObj('divLayerWindow');
		if(isObj(oDivForm))
		{
		//Skryje PROGRESS, pokud je BACK na 100 tak i pozadi
		hideLayerBox();
		
		    oDivForm.innerHTML = '\r\n' + 
		        '<table oncontextmenu="return true;" border="0" cellpadding="0" cellspacing="0" style="width:100%">' + '\r\n' + 
		        '<tr>' + '\r\n' + 
		        '<td class="dlwTitleBar"><span style="font-weight: bold; font-size: 11px; color: #FFFFFF;">Detail</span></td>' + '\r\n' + 
		        '<td class="dlwTitleBarButton"> <img onclick="top.CloseLayerWindow();" src="img/close.gif"/></td>' + '\r\n' + 
		        '</tr>' + '\r\n' + 
		        '<tr>' + '\r\n' + 
		        '<td colspan="2">' + '\r\n' + 
		        innerHTML + '\r\n' + 
		        '</td>' + '\r\n' + 
		        '</tr>' + '\r\n' + 
		        '</table>';
		
		
		    //Nastavi pozadi a vlastni z-index
		    setLayerBoxBackLevelAuto('up');
		    oDivForm.style.zIndex=toInt(mLBoxBack.style.zIndex)+1;
		
		
		    //Neni potreba zvetsi se podle oImage.width = pageWidth() - 30;
		    //oDivForm.style.width = '98%';
		
		
		    var oImage = getObj('imagedetail');
		    if(isObj(oImage))
		    {
		        //Velikost v galerii je vzdy tato
		        oImage.width = 1024;
		        //oImage.height = 768;
		
		        //Sam se roztahne podle obrazku
		        oDivForm.style.width = '1038px';
		        //oDivForm.style.height = '788px';
		
			//Vycentrovat
		    	var tp=posTop()+((pageHeight()-768)/2)-12;
		    	var lt=posLeft()+((pageWidth()-1024)/2)-12;
		    	oDivForm.style.top=(tp<0?0:tp)+'px';
		    	oDivForm.style.left=(lt<0?0:lt)+'px';
		
		        /*Zobrazi*/
		        oDivForm.style.visibility = 'visible';
		    }
		}
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}

function ShowLayerWindowGaleryDetail1(innerHTML,formTitle,oImageWidth)
{
	try
	{
		//Zavre pripadne okno, pokud se volalo ajaxShowLayerWindow z existujiciho formulare
		top.CloseLayerWindow();
		
		var oDivForm = getObj('divLayerWindow');
		if(isObj(oDivForm))
		{
		//Skryje PROGRESS, pokud je BACK na 100 tak i pozadi
		hideLayerBox();
		
		    oDivForm.innerHTML = '\r\n' + 
		        '<table oncontextmenu="return true;" border="0" cellpadding="0" cellspacing="0" style="width:100%">' + '\r\n' + 
		        '<tr>' + '\r\n' + 
		        '<td class="dlwTitleBar"><span style="font-weight: bold; font-size: 11px; color: #FFFFFF;">' + formTitle + '</span></td>' + '\r\n' + 
		        '<td class="dlwTitleBarButton"> <img onclick="top.CloseLayerWindow();" src="img/close.gif"/></td>' + '\r\n' + 
		        '</tr>' + '\r\n' + 
		        '<tr>' + '\r\n' + 
		        '<td colspan="2">' + '\r\n' + 
		        innerHTML + '\r\n' + 
		        '</td>' + '\r\n' + 
		        '</tr>' + '\r\n' + 
		        '</table>';
		
		
		    //Nastavi pozadi a vlastni z-index
		    setLayerBoxBackLevelAuto('up');
		    oDivForm.style.zIndex=toInt(mLBoxBack.style.zIndex)+1;
		
		
		    //Neni potreba zvetsi se podle oImage.width = pageWidth() - 30;
		    //oDivForm.style.width = '98%';
		
		
		    var oImage = getObj('imagedetail');
		    if(isObj(oImage))
		    {
		        //Velikost v galerii je vzdy tato
		        oImage.width = oImageWidth;
		        //oImage.height = 239;
		
		        //Sam se roztahne podle obrazku
		        oDivForm.style.width = (oImage.width + 15) + 'px';
		        //oDivForm.style.height = '259px';
		
			//Vycentrovat
		    	var tp=70;
		    	var lt=posLeft()+((pageWidth()-oImage.width)/2)-12;
		    	oDivForm.style.top=(tp<0?0:tp)+'px';
		    	oDivForm.style.left=(lt<0?0:lt)+'px';
		
		        /*Zobrazi*/
		        oDivForm.style.visibility = 'visible';
		    }
		}
	}catch(e)
	{
		window.location=window.location;
	}
	return;
}

