/*
 * main.js
 * created by Raffael Hannemann (raffael@rhcreativity.de) on
 * Tuesday, 2011-01-26 for EberleBau-Landau.de.
 */

$(document).ready(function(){
	$('#right > img').wrap('<div id="awards"></div>');
	$('#awards').append('<img src="/design/images/mittelstandspreis.gif" class="current" title="" />');
	
	var zeitStart = 2000;
	var zeit	  = 4000;
	$('#go-home-hint').hide();
	window.setTimeout(function(){switchToNextAward(zeit)},zeitStart);
	
	
	var zeitBisHinweisAusgeblendetWird = 3000;
	window.setTimeout(function(){blendeHomeHinweisEin();},500)
	window.setTimeout(function(){blendeHomeHinweisAus();},zeitBisHinweisAusgeblendetWird)

	$('.print').click(function(){
		var content = '<div id="print-header"><h1>Eberle Bau Landau - http://www.eberlebau-landau.de/</h1>';
		var date	= new Date();
		date		= date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear();
		content	   += '<p>Gedruckte Fassung der Website (Quelle: '+window.location+', Stand: '+date+')';
		content	   += '<hr /></div>';
		$('#header').after(content);
		window.print();
	});
	
});

function switchToNextAward(zeit) {
	$('#awards .current').fadeOut(500,function(){
		var nextAward	= $(this).next('img');
		if (nextAward.length==0) nextAward = $('#awards > img:first');
		$(this).removeClass('current');
		nextAward.addClass('current').fadeIn(500,function(){
			window.setTimeout(function(){switchToNextAward(zeit)},zeit);
		});
		
	});
}

function blendeHomeHinweisEin() {
	$('#go-home-hint').fadeIn(500);
}
function blendeHomeHinweisAus() {
	$('#go-home-hint').fadeOut(500);
}
