// JavaScript Document

/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

/* -------------------------- */
/* POST AJAX DATA */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function ajaxPostData(formID, url, containerID)
{	
	var form = document.getElementById(formID);
	var fieldcount = form.elements.length-1;
	var container = document.getElementById(containerID);
	
	container.innerHTML = "<p align=\"center\"><img src=\"/images/icons/loading.gif\" /></p>";
	
	var params = "&";
	
	for (i=0; i<=(fieldcount); i++)
	{
		params = params + form.elements[i].name + "=" + form.elements[i].value + "&";
	}
	
	nocache = Math.random();

	params = params + "nocache="+nocache;
	
	http.open('POST', url, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.send(params);
	
	// Load the specified <div> container with the result
	http.onreadystatechange = function()
	{
		if (http.readyState == 4 && http.status == 200)
		{
			container.innerHTML = http.responseText;
		}
	}
}

function ajaxGetGuestbook(page, url, containerID)
{	
	var container = document.getElementById(containerID);
	
	var params = "page="+page+"&";
	
	nocache = Math.random();

	params = params + "nocache="+nocache;
	
	http.open('POST', url, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.send(params);
	
	// Load the specified <div> container with the result
	http.onreadystatechange = function()
	{
		if (http.readyState == 4 && http.status == 200)
		{
			container.innerHTML = http.responseText;
		}
	}
}
