// =============================================================================
// SPOE-Alterlaa
// -----------------------------------------------------------------------------
// VERSION: 1.0.0
// -----------------------------------------------------------------------------
// Autor:				Michael Grath
// Copyright:			Michael Grath
// Erstellt am: 		01.09.2007
// Letzte Änderung am:	07.04.2009
// =============================================================================

function sendMail() {
  document.ContactForm.submit();
}

// -----------------------------------------------------------------------------
// PinkieBox Erweiterung
// -----------------------------------------------------------------------------
function getPinkieBoxRequestObject() {
	var req = null;
	try {
		req = new XMLHttpRequest();
	}
	catch (ms) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (nonms) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (failed) {
				req = null;
			}
		}
	}
	if (req == null)
		alert("Error creating request object!");
	return req;
}
function initPinkieBox(dest, objId, value) {
	var http = getPinkieBoxRequestObject();
	http.open("GET", window.location.href.substring(0, window.location.href.lastIndexOf("/")) + dest + "?IMAGE=" + encodeURIComponent(value), true);
 	http.onreadystatechange = function() {
 		if (http.readyState == 4)
 			if (http.responseText != "") {
				var response = http.responseText;
 				imageWidth = http.responseText.substr(0, response.indexOf("x"));
 				imageHeight = http.responseText.substr(response.indexOf("x")+1, (response.length - response.indexOf("x") - 1));
				imageHeight = parseInt(imageHeight) + parseInt(40);
				screenWidth = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
				screenHeight = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
				xPos = (screenWidth - imageWidth) * 0.5;
				yPos = (screenHeight - imageHeight) * 0.5;
				document.getElementById(objId).style.width=imageWidth+"px";
				document.getElementById(objId).style.height=imageHeight+"px";
				document.getElementById(objId).style.left=xPos+"px";
				document.getElementById(objId).style.top=yPos+"px";
				document.getElementById(objId+"_close").style.left=(imageWidth-19)+"px";
				document.getElementById(objId+"_close").style.top=(imageHeight-24)+"px";
			}
 	}
	http.send(null);
}

function openPinkieBox(objId, imgSrc) {
	document.getElementById(objId + "_img").src = imgSrc;
	initPinkieBox("/ajax/getPinkieBoxDimension.php", objId, imgSrc);
	document.getElementById('pinkiecurtain').style.visibility = 'visible';
	document.getElementById(objId).style.visibility = 'visible';
}
function closePinkieBox(objId) {
	document.getElementById('pinkiecurtain').style.visibility='hidden';
	document.getElementById(objId).style.visibility='hidden';
}

// -----------------------------------------------------------------------------
// Dia-Show Funktionen
// -----------------------------------------------------------------------------
function OpenDiaShow(winurl) {
  DiaShowWindow = window.open(winurl, "Diashow", "width=520, height=335");
  DiaShowWindow.focus();
}

function OpenSurvey(winurl) {
  SurveyWindow = window.open(winurl, "Umfrage", "width=750, height=500");
  SurveyWindow.focus();
}

function prevpic() {
	actualpic--;
	if (actualpic < 1)
		actualpic = countpics;
	document.getElementById("pic").src = slideshow[actualpic-1].path;
	var kommentar = document.createTextNode(slideshow[actualpic-1].bildtext);
	document.getElementById("bildtext").replaceChild(kommentar, document.getElementById("bildtext").firstChild);
}

function nextpic() {
	actualpic++;
	if (actualpic > countpics)
		actualpic = 1;
	document.getElementById("pic").src = slideshow[actualpic-1].path;
	var kommentar = document.createTextNode(slideshow[actualpic-1].bildtext);
	document.getElementById("bildtext").replaceChild(kommentar, document.getElementById("bildtext").firstChild);
}

function pic(path, bildtext) {
	this.path = path;
	this.bildtext = bildtext;
}

