/*################################################################################
	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 = true");


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

// 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 LinksShow() {
	$("img#centralwayLogo").mouseenter(function(){
		$("div.linksContainer").fadeIn("slow");
	});
	
	$("div.logoContainer").mouseleave(function(){
		$("div.linksContainer").fadeOut("slow");
	});	
}

function test() {
	$("div.linksContainer").delay(2000).fadeOut("slow")	
}

function goToAnchor() {
	location.href = "#home";
}

function fadeInPage() {
	$("section#mainContainer").css("display","block");	
}

function animateScroll() {
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});	
}

function showJobsBox() {
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|android)/);
	
	if (!agentID) {
		var widthJobsBox = $("section.jobsBox").width();
		var width = $(window).width();

		$("section.jobsBox").css("left",(width-widthJobsBox)/2);
		
		$(window).resize(function() {
			var widthJobsBox = $("section.jobsBox").width();
			var width = $(window).width();
		
			$("section.jobsBox").css("left",(width-widthJobsBox)/2);			
		});
	}
	
	$("a.jobLink").click(function() {
		var scrollTop = $(window).scrollTop();
		currentID = $(this).attr('id');
		
		$("section.jobsBox").addClass("bounceOutLeft");
		$("section#" + currentID + "Container").removeClass("bounceOutLeft");
		$("section#" + currentID + "Container").removeClass("notActive2");
		$("section#" + currentID + "Container").addClass("bounceInLeft");
		$("section#" + currentID + "Container").css("top",scrollTop);
	});
	
	$("div.closeButton").click(function() {
		$("section#" + currentID + "Container").removeClass("bounceInLeft");
		$("section#" + currentID + "Container").addClass("bounceOutLeft");
	});
}

function set_height() {
	var windowHeight = $(window).height();
	var boxHeight = $("section#homeContainer").outerHeight();
	var cableHeight = (windowHeight-boxHeight)/2;
	
	console.log(windowHeight);
	console.log(boxHeight);
	console.log(cableHeight);
	
	$("div.cable").css("height", cableHeight);
}

$(document).ready(function(e) {
	//LinksShow();
	//test();
	//animateScroll();
	//fadeInPage();
	//showJobsBox();
	//goToAnchor();
	//set_height();
});

$(window).resize(function() {
	set_height();
});


