wsoll = 0;
hsoll = 0;
wist = 0;
hist = 0;
// Bilder vorladen
closePicb = new Image();
closePicb.src = "images/close_ajax_gallery.png";
bgPic = new Image();
bgPic.src = "images/hidden_bg.png";

function showPic(pic, width, height, title) {
	document.getElementById('gallery').style.display = 'block';
	document.getElementById('gallery').innerHTML = '<div id="bildrahmen"><a href="'+pic+'" target="_blank"><img src="'+pic+'" style="width: 0px; height: 0px;" id="ajaxGalleryPic" alt="'+title+'" title="'+title+'" /></a><br /><b>'+title+'</b><div class="close"><a href="#" onClick="closePic();return false;"><img src="images/close_ajax_gallery.png" alt="schlie&szlig;en" title="schlie&szlig;en" class="closeAjaxPic" /></a></div></div>';
	window.setTimeout('initAjaxPic();', 1000);
	if(screen.availHeight<(height+380)) {
		width = width/height*(screen.availHeight-380);
		height = screen.availHeight-380;
	}
	if(screen.availWidth<(width+50)) {
		height = height/width*(screen.availWidth-50);
		width = screen.availWidth-50;
	}
	document.getElementById('bildrahmen').style.top = ((screen.availHeight-240)/2-height/2)+'px';
	wsoll = width;
	hsoll = height;
}

function showAjax(url, width, height) {
	document.getElementById('gallery').style.display = 'block';
	document.getElementById('gallery').innerHTML = '<div id="bildrahmen"><div id="ajaxGalleryPic" style=\"overflow: auto;\"></div><div class="close"><a href="#" onClick="closePic();return false;"><img src="images/close_ajax_gallery.png" alt="schlie&szlig;en" title="schlie&szlig;en" class="closeAjaxPic" /></a></div></div>';
	getPageAjax('p=0&page='+url, 'ajaxGalleryPic');
	window.setTimeout('initAjaxPic();', 1000);
	if(screen.availHeight<(height+380)) {
		width = width/height*(screen.availHeight-380);
		height = screen.availHeight-380;
	}
	if(screen.availWidth<(width+50)) {
		height = height/width*(screen.availWidth-50);
		width = screen.availWidth-50;
	}
	document.getElementById('bildrahmen').style.top = ((screen.availHeight-240)/2-height/2)+'px';
	wsoll = width;
	hsoll = (height-20);
}

function initAjaxPic() {
	wist += wsoll/20;
	hist += hsoll/20;
	if(wist>=wsoll || hist>=hsoll) {
		hist = hsoll;
		wist = wsoll;
	}
	else {
		window.setTimeout('initAjaxPic();', 10);
	}
	document.getElementById('ajaxGalleryPic').style.width = wist+'px';
	document.getElementById('ajaxGalleryPic').style.height = hist+'px';
	document.getElementById('bildrahmen').style.width = wist+'px';
	document.getElementById('bildrahmen').style.height = (hist+20)+'px';
}

function resetAjaxPic() {
	wist -= wsoll/20;
	hist -= hsoll/20;
	if(wist<=0 || hist<=0) {
		hist = 0;
		wist = 0;
		window.setTimeout("document.getElementById('gallery').style.display = 'none';", 100);
	}
	else {
		window.setTimeout('resetAjaxPic();', 100);
	}
	document.getElementById('ajaxGalleryPic').style.width = wist+'px';
	document.getElementById('ajaxGalleryPic').style.height = hist+'px';
	document.getElementById('bildrahmen').style.width = wist+'px';
	document.getElementById('bildrahmen').style.height = hist+'px';
}

function closePic() {
	//resetAjaxPic();
	document.getElementById('ajaxGalleryPic').style.width = '0px';
	document.getElementById('ajaxGalleryPic').style.height = '0px';
	document.getElementById('bildrahmen').style.width = '0px';
	document.getElementById('bildrahmen').style.height = '0px';
	document.getElementById('gallery').style.display = 'none';
	hist = 0;
	wist = 0;
}