var GuestbookId = "content"
var GuestbookName = "Guestbook"
var GuestbookStyle = false;
//var GuestbookServerPage = "webiris/Modules/Guestbook/AjaxServer/index.aspx";
var GuestbookServerPage = "/webiris/AjaxServer/index.aspx";
function Guestbook_init(ajaxIndex)
{
	if (GuestbookStyle == false) {
		GuestbookStyle = true;
		addStyle(ajaxObjects[ajaxIndex].response); 
	}
	clearAjaxSession(ajaxIndex); 

	Guestbook_listAjax();
}

function Guestbook_showForm(ajaxIndex)
{
	gid(GuestbookId).innerHTML = ajaxObjects[ajaxIndex].response; 
	clearAjaxSession(ajaxIndex); 
}

function Guestbook_showList(ajaxIndex)
{
    var R = document.getElementById(GuestbookId);
	R.style.display="block";
	R.style.visibility = "visible";
    R.innerHTML = ajaxObjects[ajaxIndex].response;
}

function Guestbook_initAjax()
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = GuestbookServerPage;
	ajaxObjects[ajaxIndex].onLoading = showWaitMessage(" ");	// Action when AJAX is loading the file
	ajaxObjects[ajaxIndex].setVar('module', GuestbookName);
	ajaxObjects[ajaxIndex].setVar('func', 'init');
	ajaxObjects[ajaxIndex].onCompletion = function(){ Guestbook_init(ajaxIndex); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

function Guestbook_formAjax()
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = GuestbookServerPage;
	ajaxObjects[ajaxIndex].onLoading = showWaitMessage(" ");	// Action when AJAX is loading the file
	ajaxObjects[ajaxIndex].setVar('module', GuestbookName);
	ajaxObjects[ajaxIndex].setVar('func','form');
	ajaxObjects[ajaxIndex].onCompletion = function(){ Guestbook_showForm(ajaxIndex); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

function Guestbook_listAjax()
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = GuestbookServerPage;
	ajaxObjects[ajaxIndex].onLoading = showWaitMessage(" ");	// Action when AJAX is loading the file
	ajaxObjects[ajaxIndex].setVar('module', GuestbookName);
	ajaxObjects[ajaxIndex].setVar('func', 'list');
	ajaxObjects[ajaxIndex].onCompletion = function(){ Guestbook_showList(ajaxIndex); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

function Guestbook_saveAjax(autore, email, messaggio)
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = GuestbookServerPage;
	ajaxObjects[ajaxIndex].onLoading = showWaitMessage(" ");	// Action when AJAX is loading the file
	ajaxObjects[ajaxIndex].setVar('module', GuestbookName);
	ajaxObjects[ajaxIndex].setVar('func','save');
	ajaxObjects[ajaxIndex].setVar('a',autore);
	ajaxObjects[ajaxIndex].setVar('e',email);
	ajaxObjects[ajaxIndex].setVar('m',messaggio);
	ajaxObjects[ajaxIndex].onCompletion = function(){ Guestbook_showList(ajaxIndex); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

