//Menüs auf und zuklappen


function toggle(id){
	ul = "ul_" + id;
	ulElement = document.getElementById(ul);
	if (ulElement){
		if (ulElement.className == 'closed'){
				ulElement.className = "open";
				
			}else{
				ulElement.className = "closed";
			}
		}
	}


//  Bilder Projekte wechseln
function change(folder, file) {	

	if(typeof img == "undefined")
		var img = new Image();
		
	img.src = 'newSourceURL';
	img.src = folder+'/'+file+'.jpg?nc='+Math.ceil(Math.random()*10000);

	img.onload = function () {
		document.getElementById('shootingImage').style.backgroundImage = 'url('+img.src+')';
		setLayers(img);	
	};

	return img;
}

function setLayers(img){
	
	// center element
	$("#ansichten").animate({marginLeft: -1*(img.width+30)/2}, "fast");
	var tm = ($(window).height()/2)-(img.height/2)-50
	//alert(tm)
	$("#ansichten").animate({top: '50%'}, "fast");
	$("#ansichten").animate({marginTop: -1*(img.height/2)-50}, "fast");

	if(img.width < 400){ //hochkant
		if(window.navigator.userAgent.indexOf("MSIE") > -1 && window.navigator.userAgent.indexOf("MSIE 8.0") == -1) // wenn Internetexplorer:
			document.getElementById('imageFinder').style.paddingTop = '471px';
		else // sonst
			document.getElementById('imageFinder').style.paddingTop = '479px';
		$("#shootingImage").animate({width: img.width}, "fast");
		$("#shootingImage").animate({height: '523px'}, "fast");
		//document.getElementById('ansichten').style.top = '10px';	
	}
	else{ // querkant
		if(window.navigator.userAgent.indexOf("MSIE") > -1 && window.navigator.userAgent.indexOf("MSIE 8.0") == -1) // wenn Internetexplorer:
			document.getElementById('imageFinder').style.paddingTop = '287px';
		else // sonst
			document.getElementById('imageFinder').style.paddingTop = '295px';
		$("#shootingImage").animate({width: img.width}, "fast");
		$("#shootingImage").animate({height: '338px'}, "fast");
		//document.getElementById('ansichten').style.top = '30px';
	}
}


//Shootingstar ein- und ausblenden
function closeStar() {	
	$("div#ansichten").slideUp("slow",function(){
	  document.getElementById('hide').style.display='none';
	});
}

function showStar(param) {
	//alert(window.navigator.userAgent)
	if ( param !== undefined ) {
		jsvz = param
		//alert(jsvz);
		$.get('shootingstar.php', { path: param},function(data){
  			//alert("Data Loaded: " + data);
			$('#shootingstarloader').html(data);
			
				if(typeof img == "undefined")
					var img = new Image();
			
				img.src = jsvz+'/'+1+'.jpg?nc='+Math.ceil(Math.random()*10000);
	
				img.onload = function () {
					//alert(img.width+" "+img.src);
					document.getElementById('shootingImage').style.backgroundImage = 'url('+img.src+')';
					setLayers(img);
					document.getElementById('hide').style.display='block';
					$('#hide').click(function() { closeStar()});

					$("div#ansichten").slideDown("normal");
					
				};
		});
	} else {
	
		if(typeof img == "undefined")
			var img = new Image();
			
		img.src = jsvz+'/'+1+'.jpg?nc='+Math.ceil(Math.random()*10000);
	
		img.onload = function () {
			//alert(img.width+" "+img.src);
			document.getElementById('shootingImage').style.backgroundImage = 'url('+img.src+')';
			setLayers(img);
			document.getElementById('hide').style.display='block';
			$('#hide').click(function() { closeStar(); });

			//$("div#hide").fadeIn("fast",function(){
			  $("div#ansichten").slideDown("normal");
			//});
		};
	}
	
}
