$(document).ready(function(){
	
	$("#content div").hide();
	
	var teamNavElem = $("#navigation li#team.active ul li").length;
	var portfNavElem = $("#navigation li#portfolio.active ul li").length;

	$("#navigation li.active ul").css({ height : 0 });
	
	$("#navigation li#team.active ul").animate({ 
		height: (teamNavElem * 20) + "px",
		//height: 400 + "px",
		opacity: "show"
	}, 1000 );
	
	$("#navigation li#portfolio.active ul").animate({ 
		height: (portfNavElem * 20) + "px",
		//height: 140 + "px",
		opacity: "show"
	}, 1000 );
	
	$("#navigation li.on ul, #navigation li.active ul").addClass("expand");
	
	$("#content div#flash").show();

	$("#content #radicalsolutions, #content #radicalsolutions div.de").show();
	$("#content #radicalsolutions #teaser").animate({ marginLeft: "50px", opacity: "show" }, 1000 );
	$("#content #radicalsolutions #intro").animate({ marginLeft: "50px", opacity: "show" }, 1700 );
	$("#content #radicalsolutions #row1").animate({ marginLeft: "50px", opacity: "show" }, 2050 );
	$("#content #radicalsolutions #row2").animate({ marginLeft: "50px", opacity: "show" }, 2400 );
	$("#content #radicalsolutions #row3").animate({ marginLeft: "50px", opacity: "show" }, 3100 );
	
	$("#content #startTeaser, #content #startTeaser div.de").fadeIn(2000);
	$("#content #presse").fadeIn(1000);
	$("#content #presse, #content #presse div").fadeIn(1500);

	$('#footer_nav span').click(function(){
		if($(this).attr('rel') == 'EN') {
			$(this).attr('rel', 'DE');
			$(this).text('Deutsch');
			$('#content .de').each(function(){
				$(this).hide(); 
			});
			$('#content .en').each(function(){
				$(this).show(); 
			});
		} else {
			$(this).attr('rel', 'EN');
			$(this).text('English');
			$('#content .de').each(function(){
				$(this).show(); 
			});
			$('#content .en').each(function(){
				$(this).hide(); 
			});
		}
	});
	
/* ********* animation for team site's ********* */	
	
	if($("#content").hasClass('')){
		$("#content div#cv").animate({ 
			marginLeft: "50px",
			opacity: "show"
		}, 2500 );

		$("#content div#job").animate({ 
			marginLeft: "-100px",
			opacity: "show"
		}, 1700 );
		
		$("#content div#links").animate({ 
			marginLeft: "-100px",
			opacity: "show"
		}, 1400 );
		
		$("#content div#clip").animate({ 
			marginLeft: "-100px",
			opacity: "show"
		}, 1000 );
	} else if($("#content").hasClass('switched')){
		$("#content div#cv").animate({ 
			marginLeft: "-100px",
			opacity: "show"
		}, 2500 );

		$("#content div#job").animate({ 
			marginLeft: "30px",
			opacity: "show"
		}, 1700 );
		
		$("#content div#links").animate({ 
			marginLeft: "50px",
			opacity: "show"
		}, 1400 );
		
		$("#content div#clip").animate({ 
			marginLeft: "50px",
			opacity: "show"
		}, 1000 );
	};
	
	
/* ********* animation for contact site ********* */

	$("#content #imprint").show();
	$("#content div#imprint div#1").animate({ 
		marginLeft: "-50px",
		opacity: "show"
	}, 2000 );
	$("#content div#imprint div#2").animate({ 
		marginLeft: "-50px",
		opacity: "show"
	}, 1500 );
	$("#content div#imprint div#3").animate({ 
		marginLeft: "-50px",
		opacity: "show"
	}, 1000 );
	
	$("#content #imprint_full").show();
	$("#content div#imprint_full div#1").animate({ marginLeft: "50px", opacity: "show" }, 650 );
	$("#content div#imprint_full div#2").animate({ marginLeft: "50px", opacity: "show" }, 1000 );
	$("#content div#imprint_full div#3").animate({ marginLeft: "50px", opacity: "show" }, 1350 );
	$("#content div#imprint_full div#4").animate({ marginLeft: "50px", opacity: "show" }, 1700 );
	$("#content div#imprint_full div#5").animate({ marginLeft: "50px", opacity: "show" }, 2050 );
	$("#content div#imprint_full div#6").animate({ marginLeft: "50px", opacity: "show" }, 2400 );
	
	$("#content #contact").show();
	$("#content div#contact div#info").animate({ 
		marginLeft: "80px",
		opacity: "show"
	}, 1500 );
	$("#content div#contact div#office").animate({ 
		marginLeft: "80px",
		opacity: "show"
	}, 2000 );
	$("#content div#contact div#map").animate({ 
		marginLeft: "80px",
		opacity: "show"
	}, 1000 );
	
	$("#content div#copy").fadeIn(2500);
	
	
/* ********* other animations ********* */	
	
	if($("#content div#infotext").hasClass('switched')){
		$("#infotext").animate({ 
			marginLeft: "-50px",
			opacity: "show"
		}, 1500 );
	} else {
		$("#infotext").animate({ 
			marginLeft: "55px",
			opacity: "show"
		}, 1500 );
	};
	
	
	$("#content div#portfolioText").animate({ 
		marginLeft: "50px",
		opacity: "show"
	}, 1500 );
	
	$("#content #topIntro").animate({ 
		marginLeft: "50px",
		opacity: "show"
	}, 1500 );
	
	$("#content #topLinks").fadeIn(2500);
	

/* ********* home (index.html) animations ********* */	
	
	$("#content #ausnahmezustand").animate({ 
		marginLeft: "50px",
		opacity: "show"
	}, 1700 );
	$("#content #missionStatement").animate({ 
		marginLeft: "50px",
		opacity: "show"
	}, 1700 );
	$("#content #galerie").animate({ 
		marginLeft: "50px",
		opacity: "show"
	}, 1700 );
	$("#content #lgvSpots").animate({ 
		marginLeft: "50px",
		opacity: "show"
	}, 1700 );
	
/* ********* team intro-site animations ********* */	
	
	$("#content #uniKrems").fadeIn(2500);
	$("#content #setTele").fadeIn(2500);
	$("#content #koop_kRose").fadeIn(2500);

	mailto();
	highlight(words);
	killhighlight(words);
	
});


function mailto(){
	$('a.mailto').each(function() {
	var mailto = $(this).attr('rel');
	$(this).text(mailto + '@mediaconsult.tv');
	$(this).attr('href', 'mailto:'+mailto+'@mediaconsult.tv');
	});
}

function highlight(words) {	
	$("ul.subNav li").removeClass('active');
	if(words == "cuesta"){
		$("#cuesta").addClass('active');
	} else if(words == "moser"){
		$("#moser").addClass('active');
	} else if(words == "gneisz") {
		$("#gneisz").addClass('active');  
	} else if(words == "handler") {
		$("#handler").addClass('active');	  
	} else if(words == "ildiko") {
		$("#ildiko").addClass('active');	  
	} else if(words == "pollach") {
		$("#pollach").addClass('active');	  
	} else if(words == "hanke") {
		$("#hanke").addClass('active');	  
	} else if(words == "jaeger") {
		$("#jaeger").addClass('active');	  
	} else if(words == "jakubuff") {
		$("#jakubuff").addClass('active');	  
	} else if(words == "kranewitter") {
		$("#kranewitter").addClass('active');	  
	} else if(words == "mandl") {
		$("#mandl").addClass('active');	  
	} else if(words == "messinger") {
		$("#messinger").addClass('active');	  
	} else if(words == "penninger") {
		$("#penninger").addClass('active');	  
	} else if(words == "rose") {
		$("#rose").addClass('active');	  
	}
}

function killhighlight(words){
	$("#"+words).removeClass('active');
}
