// Scripte, die beim Laden ausgefuehrt werden - Anfang
function launchscripts() {
	if (top != self) top.location = self.location;
	Cufon.replace('h1, h2');
}
soundManager.url = '/wp-content/themes/davechimny/_components/soundmanager2/';
soundManager.useFlashBlock = false;
soundManager.debugMode = false;
soundManager.useHighPerformance = false;
soundManager.useFastPolling = false;
soundManager.waitForWindowLoad = false;
soundManager.wmode = 'opaque';
// Scripte, die beim Laden ausgefuehrt werden - Ende



// jQuery-Start-Tag - Anfang
$(function() {
// jQuery-Start-Tag - Ende



// Variablen-Definition - Anfang
var SpeedHIG = 200;
var SpeedMED = 500;
var SpeedLOW = 700;
var SpeedVLW = 1000;
// Variablen-Definition - Ende



// Ladebalken ausblenden - Anfang
$('#loading-text').css({'color':'#fff'});
$('#loading').delay(3500).animate(({'opacity':'hide'}), SpeedMED);
// Ladebalken ausblenden - Ende



// Horizontale Scrollbar abschalten - Anfang
function scrolleroff() {
	if ($(window).width() >=900) {
		$('body').css({'overflow-x':'hidden'});
	} else {
		$('body').css({'overflow-x':'auto'});
	}	
};

scrolleroff();

$(window).resize(function () {
	scrolleroff();
});
// Horizontale Scrollbar abschalten - Ende



// Twitter-Ausgabe - Anfang
$.jTwitter('DaveChimny', 1, function(data){
	$('.twitter').empty();
	$.each(data, function(i, post){
		$('.twitter').append('<small><b>Twitter</b> @<a href="http://www.twitter.com/davechimny" target="_blank">DaveChimny</a>: ' + post.text + '<br /></small>');
	});
});
// Twitter-Ausgabe - Ende



// Scrollen der Seite - Anfang
$.localScroll.hash({
	target:'body',
	axis:'yx',
	queue:true,
	hash:false,
	offset:0,
	duration:SpeedLOW,
	easing:'easeInOutExpo'
});

$('#menu, #logo, .article .content_text').localScroll({
	target:'body',
	axis:'yx',
	queue:true,
	hash:false,
	offset:0,
	duration:SpeedLOW,
	easing:'easeInOutExpo'
});
// Scrollen der Seite - Ende



// Menü-Animation - Anfang
$('#menu a').css({'margin-top':'-40px', 'opacity':'0'});

$('#menu > li').hover(function() {
	$('a',$(this)).stop().animate({
		'marginTop':'0px',
		'height':'42px',
		'opacity':'1'
	},SpeedHIG);
}, function() {
	$('a',$(this)).stop().animate({
		'marginTop':'-40px',
		'height':'80px',
		'opacity':'0'
	},SpeedLOW);
});
// Menü-Animation - Ende



// Menü ausblenden - Anfang
$(window).scroll(function() {
	if ($(window).scrollTop() >= 100) {
		$('#menu').stop().animate({'marginTop':'-42px'},SpeedLOW);
	} else {
		$('#menu').stop().animate({'marginTop':'0px'},SpeedHIG);
	}
});
// Menü ausblenden - Ende



// Artikel-Karussell-Animation - Anfang
$('.submenudiv').css({'overflow':'hidden','height':'100px'});

$('.submenudiv').mousemove(function(e) {
	var divWidth = $(this).width();
	var lastLi = $(this).find('li:last-child');
	var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth();
	var left = (e.pageX - $(this).offset().left) * (ulWidth-divWidth) / divWidth;
	$(this).scrollLeft(left);
});
$('.submenudiv').mouseleave(function() {
//	$(this).scrollLeft(0);
});


$('.submenuul li').hover(function() {
	$($(this)).siblings().stop().animate({'opacity':'0.4'}, SpeedLOW);
}, function() {
	$($(this)).siblings().stop().animate({'opacity':'1'}, SpeedLOW);
});
// Artikel-Karussell-Animation - Ende



// Artikel-Einblendung - Anfang
// $('.article').css({'display':'none'});

$('#News .article').first().animate(({'height':'show'}), 0);
$('#Biography .article').first().animate(({'height':'show'}), 0);
$('#Releases .article').first().animate(({'height':'show'}), 0);
$('#Radio .article').first().animate(({'height':'show'}), 0);
$('#Media .article').first().animate(({'height':'show'}), 0);

$('.submenudiv a').click(function() {
	var area = '#' + $($(this).attr('href')).parent().parent().attr('id');
	var showarticle = $(this).attr('href');
	if ($(window).scrollTop() != 0) {
		var scrollzeit = 500;
	} else {
		var scrollzeit = 0;
	}		
	$.scrollTo({top:'0', left:'+=0'}, scrollzeit, {easing:'easeInOutExpo', onAfter:function() {
		$('.article').css({'display':'none'});
		$(showarticle).animate(({'height':'show'}), SpeedMED);
	}});
});
// Artikel-Einblendung - Ende



// jQuery-End-Tag - Anfang
});
// jQuery-End-Tag - Ende
