jQuery.easing.def = "easeOutQuart";


function resetBody () {
	document.getElementById('newBody').style.background = "none";
}

function loadImage (projectName, number, pages) {
		checkforIndex = true;
		
		uno = document.getElementById('holder').style.zIndex; uno = parseInt(uno);
		due = document.getElementById('holder2').style.zIndex; due = parseInt(due);
				
		if (uno > due) { 
			 nextDiv = 2; IndexNextDiv = 2; higehestZ = uno;
		} else { 
			 nextDiv = ""; IndexNextDiv = "";  higehestZ = due; 
		}
		
		$("#holder"+nextDiv).load(pfadzusatz+"content/images/images.php", {project:projectName, num:number, hold:nextDiv, zusatz:pfadzusatz});
		switchOpacity(number, pages, "img");

}

function switchOpacity(number, pages, container) {
		
				
		for (i=0; i <= pages; i++) {
		$("#"+container+i).animate({opacity: 1}, { duration: 100 });
			}
		
		$("#"+container+number).animate({opacity: 0.5}, { duration: 100 });

}

function loadHell (projectName, number) {
	document.getElementById('newBody').style.background = "url("+pfadzusatz+"gfx/sfhBg.jpg) no-repeat right bottom #fff";
	$("#projectInfo").load(pfadzusatz+"content/portfolio/info.php", {project: "soundsfromhell", num: 1, sprache:langSprache})
	$("#projectInfo").animate({width: "show"}, { duration: 800 });
	
	$("#player").animate({width: "show"}, { duration: 800 });
	$("#player").load(pfadzusatz+"content/projekte/soundfromhell/player.php", {zusatz:pfadzusatz});
	hell = true;
}


function switchZindex (projectName, number) {
	resetBody();
	document.getElementById('holder').style.visibility = "visible";
	document.getElementById('holder2').style.visibility = "visible";

	if (checkforIndex == true) {
			document.getElementById('holder'+IndexNextDiv).style.zIndex = higehestZ+1;
			$("#projectInfo").load(pfadzusatz+"content/portfolio/info.php", {project: projectName, sprache: langSprache, num: number});
			$("#projectInfo").animate({width: "show"}, { duration: 800 })

	}
}

function loadSubnavi (projectName, pages, number) {
		switchOpacity(number, 9, "project");

		hell = false;
		$("#projectInfo").animate({width: "hide"},800);
		$("#player").animate({width: "hide"},800);
		
		
		$("#pages").load(pfadzusatz+"content/portfolio/portfolio.php", {project: projectName, num: pages}, function(){
   			$("#img1").animate({opacity: 0.5}, { duration: 100 });
 		});
 		
 		if (projectName == "segelfliegeninnsbruck") { writeName = "segelfliegen innsbruck"; }
 		else if (projectName == "akupunkturinnsbruck") { writeName = "akupunktur innsbruck"; }
 		else {writeName = projectName}
 		
 		if(langSprache == "en" && projectName == "freiraum") writeName = "space";
 		if(langSprache == "en" && projectName == "leitsysteme") writeName = "way finding systems";
 		if(langSprache == "en" && projectName == "segelfliegeninnsbruck") writeName = "gliding innsbruck";
 		if(langSprache == "en" && projectName == "akupunkturinnsbruck") writeName = "acupuncture innsbruck";
 		if(langSprache == "en" && projectName == "segelflieger") writeName = "gliders";
 		
		document.getElementById('block1').innerHTML = writeName;
		
		
		if (projectName == "soundsfromhell") {
			loadHell (projectName, 1);
		} else {
			loadImage (projectName, 1, pages);
		}
		
		

}


$("span:last-child").hide("fast", function () {
        // use callee so don't have to name the function
        $(this).prev().hide("fast", arguments.callee); 
      });



function openCloseHome (openClose) {
	//	 $("#fullImage").fadeTo("slow", 0);
	//	 $("#fullImage2").fadeTo("slow", 0, openBoxes());
		 
	$("#persoenliches").animate({width: "toggle"}, { duration: 800 })
	$("#info").animate({width: "toggle"}, { duration: 800 })
	$("#image").animate({width: "toggle"}, { duration: 800 })
}

function gotoHome (openClose) {
	document.getElementById("fullImage").style.display = "none";
	document.getElementById("fullImage2").style.display = "none";
	
	$("#projectInfo").animate({width: "hide"}, { duration: 800 });
	$("#player").animate({width: "hide"}, { duration: 800 });
	$("#pages").html("");

	resetBody();

}

window.onresize = function() {

  checkHeight ();
if (hell == true) {
	document.getElementById('newBody').style.background = "url("+pfadzusatz+"gfx/sfhBg.jpg) no-repeat right bottom #fff";

}


}

function openCloseTwitter(openClose) {
	$("#twitterBox").animate({width: "toggle"}, { duration: 800 })
}


function checkHeight () {
windowHeight = $(window).height();

if (windowHeight > 850) {
	$("#navigation").animate({bottom: "200px"}, { duration: 800 })
	$("#grabNavigation").animate({top: "300px"}, { duration: 800 })
} else if (windowHeight < 710){
	$("#navigation").animate({bottom: "0px"}, { duration: 800 })
	$("#grabNavigation").animate({top: "284px"}, { duration: 800 })
} else {
	$("#navigation").animate({bottom: "100px"}, { duration: 800 })
	$("#grabNavigation").animate({top: "300px"}, { duration: 800 })

}
}

function startUp () {

checkHeight ();

      
checkforIndex = false;
document.getElementById('holder').style.zIndex = 2;
document.getElementById('holder2').style.zIndex = 1;
document.getElementById('holder').style.visibility = "hidden";
document.getElementById('holder2').style.visibility = "hidden";


}