var active = 'fdat';
var language = 'de';
function imgExchange(img1, img2, sel) {
	if($(sel).attr("src") == img2)
		$(sel).attr("src", img1);
	else
		$(sel).attr("src", img2);
}
function switch2English() {
	if(language == 'en') {
		$('.de').hide();
		$('.en').show();
	}
}

function languageSwitch() {
	if(language == 'de') {
		$('.de').hide();
		language = 'en';
		$('.en').show();
	}
	
	else {
		$('.en').hide();
		language = 'de';
		$('.de').show();
	}
}

$.preload = function() { 

	$.each(arguments,function(e) {
		$(new Image()).load(function() {
		}).attr('src',this);
	});
}

$.preload(
	"img/back_stripe_black.png",
	"img/funkdat.png", "img/funkdat_hoover.png",
	"img/work.png", "img/work_hoover.png",
	"img/contact.png", "img/contact_hoover.png",
	"img/blog.png", "img/blog_hoover.png", "wallofdeath.png"
);

function activate(id) {
	$('#' + active + '-content').fadeOut(500);
	$('#' + active).animate({width:'hide'},500, function() {
		$('#' + id).animate({width:'show'},500, function() {
			$('#' + id + '-content').load('pages/' + id + '.html', function() {
				switch2English();
				$('#' + id + '-content').fadeIn(500);
			});
			active = id;
		});
	});
}




$(document).ready(function() {
	/* MOUSEOVER EFFECTS */
	$('.nav-fd').mouseover(function() {
		imgExchange("img/funkdat_hoover.png", "img/funkdat.png", this);
	});
	$('.nav-fd').mouseout(function() {
		imgExchange("img/funkdat_hoover.png", "img/funkdat.png", this);
	});
	
	$('.nav-w').mouseover(function() {
		imgExchange("img/work_hoover.png", "img/work.png", this);
	});
	$('.nav-w').mouseout(function() {
		imgExchange("img/work_hoover.png", "img/work.png", this);
	});
	
	$('.nav-c').mouseover(function() {
		imgExchange("img/contact_hoover.png", "img/contact.png", this);
	});
	$('.nav-c').mouseout(function() {
		imgExchange("img/contact_hoover.png", "img/contact.png", this);
	});
	
	$('.nav-b').mouseover(function() {
		imgExchange("img/blog_hoover.png", "img/blog.png", this);
	});
	$('.nav-b').mouseout(function() {
		imgExchange("img/blog_hoover.png", "img/blog.png", this);
	});
	
	
	/* CLICK EFFECTS */
	$('.nav-fd').click(function() {
		activate('fdat');
	});
	
	$('.nav-w').click(function() {
		activate('work');
	});
	
	$('.nav-c').click(function() {
		activate('contact');
	});
	
	$('.nav-b').click(function() {
		activate('blog');
	});
	
	$('#lang').click(function() {
		languageSwitch();
	});
});

