var width, height, scrolltop;

function get_window_size() {
	if( typeof( window.innerWidth ) == 'number' ) {
		width=window.innerWidth;
		height=window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientHeight) {
		//IE6 standards compliant mode
		// muss vor der DOM-compliant-Prüfung ausgeführt werden: body.clientHeight gibt Höhe der gesamten Seite aus
		width=document.documentElement.clientWidth;
		height=document.documentElement.clientHeight;
	} else if(document.body && document.body.clientHeight) {
	    //DOM compliant
		width=document.body.clientWidth;
		height=document.body.clientHeight;
	} else {
		// IE + HTML4.0Trans: sonst funktioniert nichts...
		width=document.body.clientWidth;
		height=document.body.clientHeight;
	}
}

function get_scroll_position() {
	//Aktuelle Scrollposition bestimmen und das Vollbild-div an diese Stelle verschieben
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrolltop=window.pageYOffset;
	} else if(document.body && document.body.scrollTop) {
	//DOM compliant
	scrolltop=document.body.scrollTop;
	} else if(document.documentElement && document.documentElement.scrollTop) {
		//IE6 standards compliant mode
		scrolltop = document.documentElement.scrollTop;
	} else {
		// IE + HTML4.0Trans: sonst funktioniert nichts...
		scrolltop=document.body.scrollTop;
	}
}
			
//gallery version
function showImageFullSize(image_name, accesskey) {
	get_window_size();
	$.ajax({
		type: 'POST',
		url: '/gallery_image_fullsize.php',
		data: {image_name: image_name, accesskey: accesskey, width: width, height: height},
		error: function() {	},
		success: function(response) {
			UnTip();
			get_scroll_position();
			$("body").css("overflow", "hidden"); // Funktioniert im IE7 bei XHTML nicht
			$("#div_vollbild").css("top", scrolltop+"px");
			$("#div_vollbild").html(response);
			$("#div_vollbild").fadeIn("fast");
			$("#alttext").css("margin-left", (-$("#alttext").outerWidth()/2)+"px"); //muss irgendwie nach fadeIn stehen - sonst ist width 0
		}
	});
}

function showImageFullsizeSingle(image_name, prev_width, prev_height) {
	get_window_size();
	$.ajax({
		type: 'POST',
		url: '/gallery_image_fullsize_single.php',
		data: {image_name: image_name, width: width, height: height, prev_width: prev_width, prev_height: prev_height},
		error: function() {	},
		success: function(response) {
			UnTip();
			get_scroll_position();
			$("body").css("overflow", "hidden"); // Funktioniert im IE7 bei XHTML nicht
			$("#div_vollbild").css("top", scrolltop+"px");
			$("#div_vollbild").html(response);
			$("#div_vollbild").fadeIn("fast");
		}
	});
}

function closeFullscreen() {
	$("#div_vollbild").fadeOut("fast");
	$("body").css("overflow", "scroll");
}

function set_image_timeout(next_bild, div_id) {
	setTimeout(function() {$('#'+div_id).html(next_bild)}, 2500);
}

$(document).ready(function () { //The fullscreen container should have the body as its parent node so we can position it absolute to the body
	if($("#div_vollbild").length==0) {$("body").append("<div id=\"div_vollbild\"></div>");}
});