/*
  Website MVO

  Copyright (C) 2006 Pyrrhon Software GbR

  Lutz und Arnd Ißler GbR
  Paul-Klee-Str. 54
  47877 Willich
  GERMANY

  Web:    www.pyrrhon.com
  Email:  info@pyrrhon.com

  Permission granted to use this file only on the server of MVO.
*/

function resize() {
	var w = $(window).width();
	var h = $(window).height();
	boxHeight = h-190;
	if (document.getElementById("messageContentMask")) {
		// Forum
		document.getElementById("contentBox").style.height = boxHeight+"px";
		contentHeight = boxHeight-30;
		trackHeight = contentHeight-2*16;
		document.getElementById("contentMask").style.top = "30px";
		document.getElementById("contentMask").style.height = contentHeight+"px";
		document.getElementById("scrollTrack").style.height = trackHeight+"px";
		document.getElementById("contentBox").style.width = "100%";
		document.getElementById("messageContentMask").style.height = contentHeight+"px";
		document.getElementById("messageScrollTrack").style.height = trackHeight+"px";
		document.getElementById("scrollUp").style.top = "30px";
		document.getElementById("scrollTrack").style.top = "46px";
		// Init scrollbars
		// speed, dragTop, dragHeight, trackHeight, trackObj, upObj, downObj, dragObj, contentMaskObj, contentObj
		new ScrollObj(6,46,100,trackHeight,"scrollTrack","scrollUp","scrollDown","scrollDrag","contentMask","content");
		new ScrollObj(6,46,100,trackHeight,"messageScrollTrack","messageScrollUp","messageScrollDown","messageScrollDrag","messageContentMask","messageContent");
	} else {
		if (document.getElementById("contentBox")) {
			// Content
			if (document.getElementById("content").offsetHeight>boxHeight) {
				document.getElementById("contentBox").style.height = boxHeight+"px";
			} else {
				document.getElementById("contentBox").style.height = document.getElementById("content").offsetHeight+"px";
			}
			contentHeight = boxHeight;
			trackHeight = contentHeight-2*16;
			document.getElementById("contentMask").style.height = contentHeight+"px";
			document.getElementById("scrollTrack").style.height = trackHeight+"px";
			// Init scrollbar
			// speed, dragTop, dragHeight, trackHeight, trackObj, upObj, downObj, dragObj, contentMaskObj, contentObj
			new ScrollObj(6,16,100,trackHeight,"scrollTrack","scrollUp","scrollDown","scrollDrag","contentMask","content");
		}
		if (document.getElementById("quote")) {
			document.getElementById("quote").style.left = (w+600-300)/2+"px";
			document.getElementById("quote").style.visibility = "visible";
		}
	}
}

function hideContent(background) {
	cb = document.getElementById("contentBox");
	if (cb) {
		cb.style.visibility = "hidden";
	}
	document.getElementById("body").style.backgroundImage = "url("+background+")";
}

function showContent(background) {
	cb = document.getElementById("contentBox");
	if (cb) {
		cb.style.visibility = "visible";
	}
	document.getElementById("body").style.backgroundImage = "url("+background+")";
}

function showImage(fn, width, height) {
	window.open(fn, "mvoImage", "width="+width+",height="+(height+50));
}

window.onscoll = function() {
	scrollTo(pageXOffset,0);
};
window.onresize = resize;

$(function() {
	// Attach event handlers
	$("#contentSwitch")
		.click(function() {
			$("#contentBox").hide();
		})
		.hover(
			function() {
				$("img", this).toggle();
			},
			function() {
				$("img", this).toggle();
			}
		);
	$("#backgroundSwitch")
		.click(function() {
			$("#contentBox").show();
		})
		.hover(
			function() {
				$(this).attr("src", "/elements/arrow_red_right.png");
				$(document).pngFix();
			},
			function() {
				$(this).attr("src", "/elements/arrow_black_right.png");
				$(document).pngFix();
			}
		);
	$("#quoteSwitch")
		.click(function() {
			$(this).parents("div").find("div").load("/"+lang+"/quote", {}, function() {
				$("#quoteSwitch").css("bottom", "");
				$("#quoteSwitch").css("bottom", "3px");
			});
		})
		.hover(
			function() {
				$(this).attr("src", "/elements/arrow_red_right.png");
				$(document).pngFix();
			},
			function() {
				$(this).attr("src", "/elements/arrow_white.png");
				$(document).pngFix();
			}
		);
	$("a.gallery").lightBox({
		overlayBgColor: '#000',
		overlayOpacity: 0.6,
		imageLoading: '/elements/lightbox-ico-loading.gif',
		imageBtnClose: '/elements/close.gif',
		imageBtnPrev: '/elements/prev.gif',
		imageBtnNext: '/elements/next.gif',
		imageBlank: '/elements/lightbox-btn-blank.gif',
		containerResizeSpeed: 1
	});
	// Fix PNGs in IE6
	$(document).pngFix();
});

$(window).load(function() {
	resize();
	// Show content box
	$("#contentBox").css("visibility", "visible");
	$("#backgroundBox").css("visibility", "visible");
});
