
/* ############################# CONFIG ########################### */
	dTS 	= '30px'; 				//Default Teaser Size
	dTIS	= '50px'; 				//Default Teaser Image Size
	dTLC 	= 'rgb(30,30,30)'; 		//Default Teaser Link Color
	dTO 	= 0.33;			 		//Default Teaser Opacity
	
	fTS 	= '100px'; 				//Focused Teaser Size
	fTIS 	= '100px'; 				//Focused Teaser Image Size
	fTLC 	= 'rgb(230,230,230)'; 	//Focused Teaser Link Color
	fTO 	= 1;			 		//Focused Teaser Opacity
	
	aniDur 	= 200;			//Duration of an Animation in ms
	
$(document).ready(function(){

	hideSubNav('none');
	$(".navi").mouseenter(function(){
		$(this).stop();
		$(this).fadeTo(aniDur,0);
	});
	$(".navi").mouseleave(function(){
		$(this).stop();
		$(this).fadeTo(aniDur,1);
	});
});

function checkSubject(ref, target){
	if(ref.value == 'Bewerbung'){
		document.getElementById(target).disabled = true;
		document.getElementById(target).style.borderColor = '#003300';
		document.getElementById(target).style.color = '#666666';
		
	}else{
		document.getElementById(target).disabled = false;
		document.getElementById(target).style.borderColor = '#00cc00';
		document.getElementById(target).style.color = '#ffffff';

	}
}

function expand(id){
	$("#"+id).toggle(200);
}
	
function showSubNav(targetId){
	hideSubNav('all');
	$("#"+targetId).fadeIn(aniDur);
}

function hideSubNav(besides){
	if(besides != 'educ'){
		$("#educ").fadeOut(aniDur);
		$("#educ").hide();
	}
	if(besides != 'about'){
		$("#about").fadeOut(aniDur);
		$("#about").hide();
	}
	if(besides != 'mag'){
		$("#mag").fadeOut(aniDur);
		$("#mag").hide();
	}
	if(besides != 'career'){
		$("#career").fadeOut(aniDur);
		$("#career").hide();
	}
}
	
	function newsLoop(offset){
	
		if(typeof document.getElementById('News0') != "undefined"){
			if(typeof newsLoopTO != "undefined"){window.clearTimeout(newsLoopTO)};
			
				$("#News"+offset).stop();
				$("#News"+offset).animate({height: fTS, opacity:fTO}, aniDur );
			
			if(typeof document.getElementById('NewsImg'+offset) != "undefined" && document.getElementById('NewsImg'+offset) != null ){

				$("#NewsImg"+offset).stop();
				$("#NewsImg"+offset).animate({ 
					width: fTIS,
					height: fTIS
				}, aniDur );

			}
			
			collapseBlurs(offset);
			var next = parseInt(offset)+1;
			if(next <= 4){
				while(typeof document.getElementById('News'+next) == "undefined" || document.getElementById('News'+next) == null ){
					if(next <= 4){
						next++;
						//document.write(next+'<br>');
					}else{
						next = 0;
					}
				}
				newsLoopTO = window.setTimeout("newsLoop("+next+")", 5000);
			}else{
				newsLoopTO = window.setTimeout("newsLoop(0)", 5000);
			}
		
		}
		
	}
	
 $(document).ready(function(){


	 
 
	$("#NewsTeaserBox").mouseleave(function(){
		newsLoopTO = window.setTimeout('newsLoop(0)', 1);
	});
	
	// #### EVENT HANDLER: #News0 ####
	$("#News0").mouseenter(function(){
		focusTeaser(0);
	});
	$("#News1").mouseleave(function(){
		blurTeaser(0);
	});

	// #### EVENT HANDLER: #News1 ####
	$("#News1").mouseenter(function(){
		focusTeaser(1);
	});
	$("#News1").mouseleave(function(){
		blurTeaser(1);
	});
		
	// #### EVENT HANDLER: #News2 ####
	$("#News2").mouseenter(function(){
		focusTeaser(2);
	});
	$("#News2").mouseleave(function(){
		blurTeaser(2);
	});
	
	// #### EVENT HANDLER: #News3 ####
	$("#News3").mouseenter(function(){
		focusTeaser(3);
	});
	$("#News3").mouseleave(function(){
		blurTeaser(3);
	});
		
	// #### EVENT HANDLER: #News4 ####
	$("#News4").mouseenter(function(){
		focusTeaser(4);
	});
	$("#News4").mouseleave(function(){
		blurTeaser(4);
	});

});
	
	function focusTeaser(offset){
			collapseBlurs(offset);
			window.clearTimeout(newsLoopTO);
			$("#News"+offset).stop();
			$("#News"+offset).animate({height: fTS, opacity:fTO}, aniDur );

			if(typeof document.getElementById('NewsImg'+offset) != "undefined" && document.getElementById('NewsImg'+offset) != null ){
				$("#NewsImg"+offset).stop();
				$("#NewsImg"+offset).animate({width: fTIS,height: fTIS}, aniDur );
			}
	}

	function blurTeaser(offset){
			$("#News"+offset).stop();		
			$("#News"+offset).animate({height: dTS, opacity:dTO}, aniDur );
			
			if(typeof document.getElementById('NewsImg'+offset) != "undefined" && document.getElementById('NewsImg'+offset) != null ){
				$("#NewsImg"+offset).stop();
				$("#NewsImg"+offset).animate({width: dTIS, height: dTIS}, aniDur );
			}
	}

	function collapseBlurs(active){
		for(i=0;i<5;i++){
			if(active != i){
				$("#News"+i).stop();
				$("#News"+i).animate({height: dTS, opacity:dTO}, aniDur );
				
				if(typeof document.getElementById('NewsImg'+i) != "undefined" && document.getElementById('NewsImg'+i) != null ){
					$("#NewsImg"+i).stop();
					$("#NewsImg"+i).animate({ 
						width: dTIS,
						height: dTIS
					}, aniDur );
				} // if img
				
			} // if active
		} //for
	}// collapseBlurs();


function insertSwitch(toShow){

	document.getElementById('news').style.display = 'none';
	document.getElementById('termin').style.display = 'none';
	document.getElementById('video').style.display = 'none';
	document.getElementById('standort').style.display = 'none';
	document.getElementById('galerie').style.display = 'none';
	
	document.getElementById(toShow).style.display = 'block';

}

function getTooltip(ref){
	$('#'+ref).fadeIn("fast");
}

function hideTooltip(ref){
	$('#'+ref).fadeOut("fast");
}

function openShop(){
	window.open('shop.php', "Zweitfenster", "width=800,height=600,left=100,top=100,scrollbars=no");
}

function openPlayer(file, name, width, height){
	//window.open(file, name, "width="+width+",height="+height+",left=100,top=100,scrollbars=yes,location=no,status=no");
	newWindow = window.open(file, name, "width=1,height=1,left=100,top=100,scrollbars=yes,location=no,status=no");
}

function navigate(to){
	if(to != 'nochange'){
		window.location.href = to.toLowerCase() + '/';
	}
}

function clearField(ref, vorbeleg){
	if(ref.value == vorbeleg){
		ref.value = '';
	}
}

function openImageDetails(id, width, height){
	srcstring 	= 'galerie_details.php?id='+id+'&offset=0';
	winWidth 	= parseInt(width)+100;
	winHeight 	= parseInt(height)+200;
	if(winHeight > screen.height){
		winHeight = screen.height;
	}
	optsstring	= "width="+winWidth+",height="+winHeight+",left=100,top=0,scrollbars=yes,resizable=yes";
	
	window.open(srcstring, "Zweitfenster", optsstring);
}

function increaseCart(item, price){

	var priceNew = price.split(',');
	priceNew = priceNew.join('.');

	if(	document.shop.order.value == ''){
		summ = 0.0;
	}
		
	summ += parseFloat(priceNew);

	var output = summ;
	
	output = output.toString(10);
	output = output.split('.');

	if(output[1] != undefined){
		if( output[1].substr(2,2) == '' || output[1].substr(2,2) == '00'){
				output[1]+='0';
		}
	}
	
	output = output.join(',');
	
	if(summ<100){
		output = output.substr(0,5);
	}else{
		output = output.substr(0,6)
	}

	document.getElementById('summDisplay').innerHTML = '';
	document.getElementById('summDisplay').innerHTML = output+'€';
	
	document.shop.order.value += '1x '+item+' \\\\ '+price+'€\n';
	document.shop.summe.value = output+'€';
}