function trasa(id) {
	var punktstartowy = eval("punktstartowy"+id+"");
		eval ("map.setCenter(new GLatLng("+punktstartowy+"), 13)");
}

function xhrRequest(type) {
	var xhrSend;
	if (!type) {
		type = 'text';
	}
	if (window.ActiveXObject) {
		try {
			xhrSend = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhrSend = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} else if (window.XMLHttpRequest) {
		xhrSend = new XMLHttpRequest();
		if (xhrSend.overrideMimeType) {
			xhrSend.overrideMimeType('text/' + type);
		}
	}
	return (xhrSend);
}



function film(url) {
		reqType = "text";
	var xhrRec = xhrRequest(reqType);
	var loading = '<img src="images/wczytywanie.gif" align="center">';
		document.getElementById('photo').innerHTML = loading;
		xhrRec.open('GET', url, true);
		xhrRec.onreadystatechange = function() {
			if (xhrRec.readyState == 4 && xhrRec.status == 200) {
				document.getElementById('photo').innerHTML = xhrRec.responseText;
				xhrRec = null;
			} else if (xhrRec.readyState == 4 && xhrRec.status == 404) {
				document.getElementById('photo').innerHTML = xhrRec.responseText;
				xhrRec = null;
			}
		};
		xhrRec.send(null);
}


function foto(url) {
		reqType = "text";
	var xhrRec = xhrRequest(reqType);
	var loading = '<img src="images/wczytywanie.gif" align="center" style="margin-bottom: 110px">';
		document.getElementById('photo').innerHTML = loading;
		xhrRec.open('GET', url, true);
		xhrRec.onreadystatechange = function() {
			if (xhrRec.readyState == 4 && xhrRec.status == 200) {
				document.getElementById('photo').innerHTML = xhrRec.responseText;
				xhrRec = null;
			} else if (xhrRec.readyState == 4 && xhrRec.status == 404) {
				document.getElementById('photo').innerHTML = xhrRec.responseText;
				xhrRec = null;
			}
		};
		xhrRec.send(null);
}


function panorama(url,autor) {
	var panoram = '<APPLET archive="js/ptviewer.jar" code=ptviewer.class width=350 height=238 mayscript=true onmouseover="Tip(\''+autor+'\');" ><param name=cursor value="MOVE"><PARAM name=file value="'+url+'"><PARAM name=auto		value="0.1"><PARAM name=pan			value="0"><PARAM name=fov			value="40"><PARAM name=hsEnableVisibleOnly			value="true"><param name=showToolbar value="true"><param name=imgLoadFeedback value="true"></APPLET>';
	document.getElementById('photo').innerHTML = panoram;
}





function menu(url) {
		reqType = "text";
	var xhrRec = xhrRequest(reqType);
	var loading = '<img src="images/wczytywanie.gif" align="center">';
		document.getElementById('menu').innerHTML = loading;
		xhrRec.open('GET', url, true);
		xhrRec.onreadystatechange = function() {
			if (xhrRec.readyState == 4 && xhrRec.status == 200) {
				document.getElementById('menu').innerHTML = xhrRec.responseText;
				xhrRec = null;
			} else if (xhrRec.readyState == 4 && xhrRec.status == 404) {
				document.getElementById('menu').innerHTML = xhrRec.responseText;
				xhrRec = null;
			}
		};
		xhrRec.send(null);
}




function txt(url,pid,trasa) {
		reqType = "text";
	var xhrRec = xhrRequest(reqType);
		var loading = '<img src="images/wczytywanie.gif" style="margin-top: 110px; margin-left: 116px">';
		document.getElementById('textcontainer').innerHTML = loading;
		xhrRec.open('GET', url+ "&dummy=" + new Date().getTime(), true);
		xhrRec.onreadystatechange = function() {
			if (xhrRec.readyState == 4 && xhrRec.status == 200) {
				document.getElementById('textcontainer').innerHTML = xhrRec.responseText;
				CSBfleXcroll('mycustomscroll');
				if (pid)
				{
					clearButtonId(eval(""+trasa-1+""));
					foto('inc/s_foto.php?id='+trasa+'');					
					menu('inc/s_menu.php?id='+trasa+'');	
					goInText(pid,trasa);
				}
				xhrRec = null;
			} else if (xhrRec.readyState == 4 && xhrRec.status == 404) {
				document.getElementById('textcontainer').innerHTML = xhrRec.responseText;
				xhrRec = null;
			}
		};
		xhrRec.send(null);
    }
