function sendRequest(service, method, url, content, destination) {
	var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
	if(!xmlhttp) {
		alert("Nepodarilo sa nadviazať spojenie so serverom!");
	}
	xmlhttp.open(method, url);
	xmlhttp.onreadystatechange = function() {
		service(xmlhttp, destination);
	};
	xmlhttp.setRequestHeader("Cache-Control", "no-cache");
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1250");
	xmlhttp.send(content);
	return false;
}

function loadData(xmlhttp, destination) {
	if(xmlhttp.readyState == 4) {
		if(xmlhttp.status == 200) {
			var result = xmlhttp.responseText;
			destination.innerHTML = result;
			document.getElementById("preloaderPlace").innerHTML = "";
			initPage();
		}
	}
	else document.getElementById("preloaderPlace").innerHTML = '<img src="http://images.crystalgroup.sk/preloader.gif" /> pracujem...';
}

function getX() {
	var scrollX = 0;
	var mouseX = window.event.clientX;
	if(document.documentElement.scrollLeft != undefined) scrollX = document.documentElement.scrollLeft;
	else if(document.body.scrollLeft != undefined) scrollX = document.body.scrollLeft;
	return mouseX+scrollX;
}

function getY() {
	var scrollY = 0;
	var mouseY = window.event.clientY;
	if(document.documentElement.scrollTop != undefined) scrollY = document.documentElement.scrollTop;
	else if(document.body.scrollTop != undefined) scrollY = document.body.scrollTop;
	return mouseY+scrollY;
}

function initPreloader() {
	document.getElementById("preloaderPlace").style.left = getX()+10+"px";
	document.getElementById("preloaderPlace").style.top = getY()+10+"px";
}

function initPage() {
	if(document.getElementById("legalform") != undefined) changeLegalForm(document.getElementById("legalform"));
	if(document.getElementById("tld") != undefined) changeTLD(document.getElementById("tld"));
}
