/*################################################################################
	D E B U G
################################################################################*/

var debugModus = 0	; // Debugmodus EIN = 1 || AUS = 0

function debug(txt)
{
	if(!debugModus || typeof(console) != "object") { return; }
	else { console.log(txt); }
}
debug("debugModus = false");


/*################################################################################
	$$$
################################################################################*/

// get Elements by Name

function $$$(obj)
{
	var obj = document.getElementsByName(obj);
	obj = (obj.length==1)?obj[0]:obj;
	return obj;
}


/*################################################################################
	F U N C T I O N S
################################################################################*/        

function FFmac() {
	
	var deviceAgent = navigator.userAgent.toLowerCase();
	var FF = deviceAgent.match("firefox");
	var mac = deviceAgent.match("macintosh");
		
		//console.log(deviceAgent);
		if (FF && mac) {
			//console.log("Firefox under Mac");
		}
}

function oldBrowserAlert() {
	
	$("a.continue").click( function() {
		$("div#oldBrowser").css("display","none");	
	});
	
	$("div#oldBrowser").css("display","none");
	
	var deviceAgent = navigator.userAgent.toLowerCase();
	var safariV506 = deviceAgent.match("version/5.0.6");
	var safariV4 = deviceAgent.match("version/4");
	var safari = deviceAgent.match("safari");
	
	var FF = deviceAgent.match("firefox");
	var versionTemp = ($.browser.version).split('.');
	var version = parseInt(versionTemp[0]);
		
		//console.log(deviceAgent);
		//console.log(version);
		
		if (safariV506 && safari) {
			//console.log("Safari 5.0.6");
			$("div#oldBrowser").css("display","block");
		}
		
		if (FF && version < 5) {
				$("div#oldBrowser").css("display","block");
				
		}
}

function viewPortWidthHeight() {
	var browserWidth = $(window).width();
	var browserHeight = $(window).height();
	
	$("div#viewPort").css("height", browserHeight-34);
	$("div#viewPort").css("width", browserWidth-34);
};

function b() {
	var contentHeight = $("#viewPort #contentContainerHome").height();
	var viewPortHeight = $("#viewPort").height();
	var headerNavHeight = ((viewPortHeight-contentHeight)/2);
	var navHeight = $("#viewPort div#navigationContainer").height();
	var headerHeight = $("#viewPort div#header").height();
	var spacerHeight = $("#viewPort div#spacerTop").height();
	var spacerheightFinal = (viewPortHeight-contentHeight-navHeight-headerHeight)/2
	
	$("#viewPort div#spacerTop").css("height", spacerheightFinal);
	$("#viewPort div#spacerBottom").css("height", spacerheightFinal);
	//$("#viewPort #navigationContainer").css("height", headerNavHeight);
	//$("#viewPort #header").css("height", headerNavHeight);
	var spacerHeight = $("#viewPort div#spacerTop").height();
	//console.log((headerHeight)+(spacerHeight));
	$("#viewPort div.fixedFirstSlide").css("top", headerHeight+spacerHeight);
};

function navHover() {
	$("#viewPort a.navLink")
	.css("backgroundPosition", "0 55")
	.mouseover(function(){
		startColor = $(this).css("color");
		$(this).stop().animate(
			{backgroundPosition: "0 0",
			color: '#000'}, 
			{duration:200})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition: "0 55",
			color: startColor}, 
			{duration:200})
		})	
}

function containerWidth() {
	var amount = $("#viewPort div.project").length;
	var width = amount*335;
	var margin = ((amount-1)*3);
	$("#viewPort div.contentContainerProjekte").css("width", width+margin+122);	
}

function containerWidth2() {
	slides = 0;
	$('#viewPort div.oneSlide').each(function(yeah){
		slides = slides+$(this).width();
		//console.log(slides);
		var amount = $("#viewPort div.oneSlide").length;
		//console.log(slides);
		
		$("#viewPort div.contentContainerProjekte2").css("width", slides+102+(amount*3)+30);
	});
}

function TeamPhotoSlide() {
	$("#viewPort a.karrer").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 430}, 
			{duration:600})
	});
	
	$("#viewPort a.steiner").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 650}, 
			{duration:600})
	});
	
	$("#viewPort a.jenny").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 920}, 
			{duration:600})
	});
	
	$("#viewPort a.knill").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 1300}, 
			{duration:600})
	});
	
	$("#viewPort a.wolf").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 1750}, 
			{duration:600})
	});
	
	$("#viewPort a.stieger").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 2630}, 
			{duration:600})
	});
	
	$("#viewPort a.lopez").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 3060}, 
			{duration:600})
	});
	
	$("#viewPort a.tan").click(function() {
		$("#viewPort div#overscroll").stop().animate(
			{scrollLeft: 2220}, 
			{duration:600})
	});
}

$(document).ready(function() {
	
	/*
	viewPortWidthHeight();
	b();
	navHover();
	containerWidth();
	containerWidth2();
	TeamPhotoSlide();
	$.preloadCssImages();
	$('#viewPort #overscroll').overscroll().bind('overscroll:dragstart', function(){ $("#overscroll").addClass("grab"); });
	$('#viewPort #overscroll').overscroll().bind('overscroll:dragend', function(){ $("#overscroll").removeClass("grab"); });
	*/
});


$(window).resize(function() {
	
	viewPortWidthHeight();
	b();
	
});
