function ajaxShowPic(picname) {
	//console.log("ajaxShowPic");
	if ($('ajaxpicture') != null && $$('div#picture div')[0].getStyle('display')!="none" ) {
		$('title').scrollTo();	 
		Effect.SlideUp( $('ajaxpicture').parentNode.parentNode, { afterFinish: function() { 
			del();
			showAjaxLoad(picname);
			update(picname) ;
			} });
	} else {
		showAjaxLoad(picname);
		$('title').scrollTo();
		update(picname);
	}
}

function idealWidth(){
	bildbreite = 166;
	screenbreite=screen.width;
	//console.log("Available Width: " + screen.availWidth);
	browserbreite = document.documentElement.clientWidth;
	
	if ( browserbreite > 1024 && screenbreite > 1024 ) {
		berechnung = Math.floor(browserbreite/bildbreite);
		
		//console.log("Browserfenster: " + browserbreite + "px");
		//console.log("Anzahl moeglicher Bilder pro Zeile: " + berechnung + "px");
		
		if ( berechnung >= 12 ) {
			//console.log("Anzahl Bilder = " + 12);
			if ( $('calendar').getWidth() != (12*bildbreite) ) {
				//console.log("changing...");
				$('calendar').setStyle({ width : 12*bildbreite + 'px' });
			}
		} else if ( berechnung >= 8 ) {
			//console.log("Anzahl Bilder = " + 8);
			if ( $('calendar').getWidth() != (8*bildbreite) ) {
				//console.log("changing...");
				$('calendar').setStyle({ width : 8*bildbreite + 'px' });
			}
		} else {
			//console.log("Anazhal Bilder = " + 6);
			if ( $('calendar').getWidth() != (6*bildbreite) ) {
				//console.log("changing...");
				$('calendar').setStyle({ width : 6*bildbreite + 'px' });
			}
		}
		//console.log("Neue Breite = " + $('calendar').getWidth() +"px" );
	} 
}

function resize() {
	breite=screen.width;
	hoehe=screen.height;
	if ( (breite>=1280) ) {
		//location.href="startseite.htm";
		self.resizeTo(1024,768);
	}
}

function showAjaxLoad(picname) {
	$('ajaxload_' + picname).show();
}

function hideAjaxLoad(picname) {
	$('ajaxload_' + picname).hide();
}

function update(picname) {
	//console.log("update");
	$('preview_' + picname).hide();
		
	new Ajax.Updater({ success: $('picture') }, "showPic.php",{
	  parameters: { picture: picname }
	});	
	
	$('preview_' + picname).show();
}

function del() {
	//console.log("del");
	new Ajax.Updater({ success: $('picture') }, "showPic.php");
	$('picture').style.display="none";
}
function ajaxDeletePic(picname) {
	//console.log("ajaxDeletePic");
	$('title').scrollTo();
	Effect.SlideUp( $('ajaxpicture').parentNode.parentNode, {afterFinish: function() { del() } });
}

