var contentWidth = 800;
var minWinWidth = 820;

var scrollTimer;
totImprWidth = 743;
hiddenWidthNeg = 744 - totImprWidth;
step = 6;
interval = 25;

var myImages = new Array();


//zentrieren:

function calculateLeftmargin() {
	if(window.innerWidth) {
		width = window.innerWidth;		
	}
	else if(document.body) {
		width = document.body.offsetWidth;
	}
	
	if(width < minWinWidth) {
		width = minWinWidth;
	}
	leftmargin = (width-contentWidth)/2;		
	leftmargin -= 10; //scrollbar
	return(leftmargin);
}

function setLeftmargin() {
	leftMargin = calculateLeftmargin();
	document.getElementById("mainbox").style.left = leftMargin;
	document.getElementById("mainbox").style.display = "";
}

//zentrieren ende


function naviOver(i,thecolor) {	
	document.getElementById(i).src = "img/navimg/naviquot_"+thecolor+".gif";
}

function naviOut(i) {
	thisFilename = extractFilename();
	
	if(i != thisFilename) {
		document.getElementById(i).src = "img/layout/spacer.gif";
	}	
}

function tlineOver(i,thecolor) {
	document.getElementById("tlinequot"+i).src = "img/navimg/tlinequot_"+thecolor+".gif";
}

function tlineOut(i,indexEvent) {
	if(i != indexEvent) {
		document.getElementById("tlinequot"+i).src = "img/layout/spacer.gif";
	}
}

function preloadImages() {
    for (i=0;i<preloadImages.arguments.length;i++) {
        myImages[i] = new Image();
        myImages[i].src = preloadImages.arguments[i];
    }
}


function tlineNavigate(targetUrl) {
	window.location.href = targetUrl+".php";
};


function extractFilename() {
	var thisUrl = window.location.href;
	urlArray = thisUrl.split("/");
	arrayLength = urlArray.length - 1;
	
	var thisFilename = urlArray[arrayLength];
	filenameArray = thisFilename.split(".");
	thisFilename = filenameArray[0];
	
	if(!thisFilename || (thisFilename == "index_neu")) {
		thisFilename = "index";
	}
	
	if((thisFilename == "kontakt_ok") || (thisFilename == "kontakt_error")) {
		thisFilename = "kontakt";
	}
	
	if(thisFilename == "index") {
		thisFilename = "aktuell";
	}
		
	return(thisFilename);
}


function makeNav1Active() {
	thisFilename = extractFilename();
	if(thisFilename.indexOf("kunstbrotzeit") == -1) {
		document.getElementById(thisFilename).src = "img/navimg/naviquot_"+thecolor+".gif";	
	}
}

function makeTlineActive(k,thecolor) {
	if(k) {
		document.getElementById("tlinequot"+k).src = "img/navimg/tlinequot_"+thecolor+".gif";
	}
}


function bigImpr(filename) {
    imgWindow = window.open("bigimg.html?filename="+filename,"bigImgWin","width=20,height=20,top=50,left=100,scrollbars=no");
    imgWindow.focus();
}

//----------------------------------------

/*
function popNewsletter(inout) {
	address = document.forms["optinout"].elements[0].value;
	if(address && (address!="Ihre E-Mailadresse")) {
		var url = "http://www.247hosting.at/newsletter/komitee/optinout.php?inOut="+inout+"&address="+address;
		window.open(url,"optWin","width=250,height=200,top=50,left=100,scrollbars=no");
	}
	else {
		alert("Bitte geben Sie eine Adresse ein.");
	}
}
*/

function openDisclaimer() {
	disclaimer = window.open("disclaimer.html","disclWin","width=650,height=450,top=50,left=100,scrollbars=yes");
    disclaimer.focus();
}

function openEvent(elementID) {
    window.open("event_details.php?elementID="+elementID,"eventWin","width=410,height=470,top=50,left=100,scrollbars=yes");
}

/* scroll: */

function resizeImprBox() {	
	document.getElementById("imprboxinner").style.width = totImprWidth;
	
	if(hiddenWidthNeg > 0) {
		document.getElementById("scrollButtonRight").src = "img/layout/arr_right_inact.gif";
	}
}

function scrollRighty() {
	left = document.getElementById("imprboxinner").style.left;

	if(left=="") {
		left = 0;
		document.getElementById("scrollButtonLeft").src = "img/layout/arr_left_inact.gif";
	}
	else {
		document.getElementById("scrollButtonLeft").src = "img/layout/arr_left_act.gif";
		leftArray = left.split("p");
		left = leftArray[0];
	}
	if(left>(hiddenWidthNeg)) {
		document.getElementById("scrollButtonLeft").style.cursor = "pointer";
		left = left - step;
		document.getElementById("imprboxinner").style.left = left+"px";
		scrollTimer = setTimeout("scrollRighty()",interval);
	}
	else {
		document.getElementById("scrollButtonRight").src = "img/layout/arr_right_inact.gif";
	}
}

function scrollLefty() {
	left = document.getElementById("imprboxinner").style.left;

	if(left=="") {
		left = 0;
	}
	else {
		document.getElementById("scrollButtonLeft").src = "img/layout/arr_left_act.gif";
		leftArray = left.split("p");
		left = leftArray[0];
	}
	
	left = parseInt(left);
	
	if(left < 0) {
		document.getElementById("scrollButtonRight").style.cursor = "pointer";
		left = left + step;
		document.getElementById("imprboxinner").style.left = left+"px";
		scrollTimer = setTimeout("scrollLefty()",interval);
		document.getElementById("scrollButtonRight").src = "img/layout/arr_right_act.gif";
	}
	else {
		document.getElementById("scrollButtonLeft").src = "img/layout/arr_left_inact.gif";
	}
}

function scrollStop() {
	clearTimeout(scrollTimer);
}
