// JavaScript Document
var slideCounter = 0;
var slideDirection = "right";
var currentImage = 1;

function doSlide(direction, slideDistance, slideCaller) {	
	var slideMe = document.getElementById('div_elm_8_2');
	
	if (slideCaller == true) {
		if (direction == "right" && slideDirection == "right") {
			slideCounter = slideCounter + 1;
		} else if (direction == "left" && slideDirection == "right") {
			slideCounter = slideCounter - 1;
		} else if (direction == "left" && slideDirection == "left") {
			slideCounter = slideCounter + 1;
		} else if (direction == "right" && slideDirection == "left") {
			slideCounter = slideCounter - 1;
		}
	}
	
	if (direction == "right") {
	 	slideMe.scrollLeft += 49;
	 	slideDistance = slideDistance + 49;
	 	if (slideDistance < 245) {
	 		window.setTimeout("doSlide('right', " + slideDistance + ")", 50)
	 	} else {
	 		window.clearTimeout();
	 	}
	 } else {
	 	slideMe.scrollLeft -= 49;
	 	slideDistance = slideDistance + 49;
	 	if (slideDistance < 245) {
	 		window.setTimeout("doSlide('left', " + slideDistance + ")", 50)
	 	} else {
	 		window.clearTimeout();
	 	}
	 }
}

function startSlide(countElements) {
	slideCounter = slideCounter + 1;
	
	if (slideCounter == countElements) {
		slideCounter = 0;
		
		if (slideDirection == "right") {
			slideDirection = "left";
		} else {
			slideDirection = "right";
		}
	}
	
	if (slideDirection == "right") {
		doSlide('right', 0, false);
	} else {
		doSlide('left', 0, false);
	}
	
	window.setTimeout("startSlide(" + countElements + ")", 5000);
}

function initSlide(countElements) {
	window.setTimeout("startSlide(" + countElements + ")", 5000);
}

function showWin() {
	document.getElementById("div_elm_5_2").style.visibility = "visible";
	document.getElementById("div_elm_5_3").style.visibility = "hidden";
	document.getElementById("div_elm_5_4").style.visibility = "hidden";

	document.getElementById("div_elm_5_8").style.visibility = "visible";
	document.getElementById("div_elm_5_9").style.visibility = "hidden";
	document.getElementById("div_elm_5_10").style.visibility = "hidden";

	document.getElementById("box_1").style.color = "#FAAA00";
	document.getElementById("box_2").style.color = "#B5B5B5";
	document.getElementById("box_3").style.color = "#B5B5B5";
}

function showComic() {
	document.getElementById("div_elm_5_2").style.visibility = "hidden";
	document.getElementById("div_elm_5_3").style.visibility = "visible";
	document.getElementById("div_elm_5_4").style.visibility = "hidden";
	
	document.getElementById("div_elm_5_8").style.visibility = "hidden";
	document.getElementById("div_elm_5_9").style.visibility = "visible";
	document.getElementById("div_elm_5_10").style.visibility = "hidden";
	
	document.getElementById("box_1").style.color = "#B5B5B5";
	document.getElementById("box_2").style.color = "#FAAA00";
	document.getElementById("box_3").style.color = "#B5B5B5";
}

function showVideo() {
	document.getElementById("div_elm_5_2").style.visibility = "hidden";
	document.getElementById("div_elm_5_3").style.visibility = "hidden";
	document.getElementById("div_elm_5_4").style.visibility = "visible";
	
	document.getElementById("div_elm_5_8").style.visibility = "hidden";
	document.getElementById("div_elm_5_9").style.visibility = "hidden";
	document.getElementById("div_elm_5_10").style.visibility = "visible";	
	
	document.getElementById("box_1").style.color = "#B5B5B5";
	document.getElementById("box_2").style.color = "#B5B5B5";
	document.getElementById("box_3").style.color = "#FAAA00";	
}

function emptyField() {
	document.getElementById("suche").value = "";
}

function nextImage(currentRelease, currentArticleID, articleRunNr, countImages) {
	currentImage = currentImage + 1;
	
	if (currentImage > countImages) {
		currentImage = 1;
	}
	
	getImage(currentRelease, currentArticleID, articleRunNr, countImages);
}

function prevImage(currentRelease, currentArticleID, articleRunNr, countImages) {
	currentImage = currentImage - 1;
	
	if (currentImage < 1) {
		currentImage = countImages;
	}
	
	getImage(currentRelease, currentArticleID, articleRunNr, countImages);
}

function getImage(currentRelease, currentArticleID, articleRunNr, countImages) {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	
	catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}

		catch (E) {
			xmlhttp = false;
 		}
 	}
 	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
 	}
	
	if (xmlhttp) {
		xmlhttp.open("GET", "image.asp?currentImage=" + currentImage + "&currentRelease=" + currentRelease + "&currentArticleID=" + currentArticleID + "&articleRunNr=" + articleRunNr, true);
		
		xmlhttp.onreadystatechange =
			function() {
				if (xmlhttp.readyState == 4) {
					splitArray = xmlhttp.responseText.split("<SPLIT>");
					document.getElementById("div_elm_20_1_5").innerHTML = splitArray[0];
					document.getElementById("div_elm_20_1_6").innerHTML = splitArray[1];
					document.getElementById("div_elm_20_1_7_3").innerHTML = splitArray[2];
					document.getElementById("div_elm_20_1_7_4").innerHTML = "Bild " + currentImage + " / " + countImages;
					tb_init('a.thickbox, area.thickbox, input.thickbox');
				}
 			}
		xmlhttp.send(null);		
	}	
}

function showNavigation(navigation, point) {
	document.getElementById("div_navigation_dummy_1").style.visibility = "visible";
	document.getElementById("div_navigation_dummy_2").style.visibility = "visible";
		
	document.getElementById("ul_elm_3_1_1").style.color = "#323232";
	document.getElementById("ul_elm_3_1_2").style.color = "#323232";
	document.getElementById("ul_elm_3_1_3").style.color = "#323232";
	document.getElementById("ul_elm_3_1_4").style.color = "#323232";
	document.getElementById("ul_elm_3_1_5").style.color = "#323232";
	document.getElementById("ul_elm_3_1_6").style.color = "#323232";
	document.getElementById("ul_elm_3_1_7").style.color = "#323232";

	document.getElementById("ul_elm_3_1_1").style.backgroundColor = "";
	document.getElementById("ul_elm_3_1_2").style.backgroundColor = "";
	document.getElementById("ul_elm_3_1_3").style.backgroundColor = "";
	document.getElementById("ul_elm_3_1_4").style.backgroundColor = "";
	document.getElementById("ul_elm_3_1_5").style.backgroundColor = "";
	document.getElementById("ul_elm_3_1_6").style.backgroundColor = "";
	document.getElementById("ul_elm_3_1_7").style.backgroundColor = "";
	
	document.getElementById("div_navigation_1").style.visibility = "hidden";
	document.getElementById("div_navigation_2").style.visibility = "hidden";
	document.getElementById("div_navigation_3").style.visibility = "hidden";
	document.getElementById("div_navigation_4").style.visibility = "hidden";
	document.getElementById("div_navigation_5").style.visibility = "hidden";
	
	if (navigation != "none") {		
		document.getElementById(navigation).style.visibility = "visible";
	}
	
	if (point != "none") {
		document.getElementById(point).style.color = "#FFFFFF";
		document.getElementById(point).style.backgroundColor = "#E6001E";
	} else {
		document.getElementById("div_navigation_dummy_1").style.visibility = "hidden";
		document.getElementById("div_navigation_dummy_2").style.visibility = "hidden";
	}
}

function checkWin() {
	ok = true;
	if (document.form_wettbewerb.name.value == "") {
		ok = false;
		document.form_wettbewerb.name.style.background = "#E6001E";
	} else {
		document.form_wettbewerb.name.style.background = "#FFFFFF";
	}

	if (document.form_wettbewerb.betrieb.value == "") {
		ok = false;
		document.form_wettbewerb.betrieb.style.background = "#E6001E";
	} else {
		document.form_wettbewerb.betrieb.style.background = "#FFFFFF";
	}

	if (document.form_wettbewerb.telefon.value == "") {
		ok = false;
		document.form_wettbewerb.telefon.style.background = "#E6001E";
	} else {
		document.form_wettbewerb.telefon.style.background = "#FFFFFF";
	}

	if (document.form_wettbewerb.email.value == "" || document.form_wettbewerb.email.value.indexOf('@') == -1 || document.form_wettbewerb.email.value.indexOf('.') == -1) {
		ok = false;
		document.form_wettbewerb.email.style.background = "#E6001E";
	} else {
		document.form_wettbewerb.email.style.background = "#FFFFFF";
	}

	if (ok) {
		document.form_wettbewerb.submit();
	}	
}

function checkAbo() {
	ok = true;
	if (document.form_abo.firma.value == "") {
		ok = false;
		document.form_abo.firma.style.background = "#E6001E";
	} else {
		document.form_abo.firma.style.background = "#FFFFFF";
	}

	if (document.form_abo.anrede.value == "") {
		ok = false;
		document.form_abo.anrede.style.background = "#E6001E";
	} else {
		document.form_abo.anrede.style.background = "#FFFFFF";
	}

	if (document.form_abo.vorname.value == "") {
		ok = false;
		document.form_abo.vorname.style.background = "#E6001E";
	} else {
		document.form_abo.vorname.style.background = "#FFFFFF";
	}

	if (document.form_abo.name.value == "") {
		ok = false;
		document.form_abo.name.style.background = "#E6001E";
	} else {
		document.form_abo.name.style.background = "#FFFFFF";
	}

	if (document.form_abo.adresse.value == "") {
		ok = false;
		document.form_abo.adresse.style.background = "#E6001E";
	} else {
		document.form_abo.adresse.style.background = "#FFFFFF";
	}

	if (document.form_abo.ort.value == "") {
		ok = false;
		document.form_abo.ort.style.background = "#E6001E";
	} else {
		document.form_abo.ort.style.background = "#FFFFFF";
	}

	if (document.form_abo.land.value == "") {
		ok = false;
		document.form_abo.land.style.background = "#E6001E";
	} else {
		document.form_abo.land.style.background = "#FFFFFF";
	}

	if (document.form_abo.telefon_g.value == "") {
		ok = false;
		document.form_abo.telefon_g.style.background = "#E6001E";
	} else {
		document.form_abo.telefon_g.style.background = "#FFFFFF";
	}

	if (document.form_abo.email.value == "" || document.form_abo.email.value.indexOf('@') == -1 || document.form_abo.email.value.indexOf('.') == -1) {
		ok = false;
		document.form_abo.email.style.background = "#E6001E";
	} else {
		document.form_abo.email.style.background = "#FFFFFF";
	}

	if (ok) {
		return true;
	} else {
		return false;
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
