/*-------------------- /projects/84/templates/js/main.js --------------------*/
/*
    Document   : main.js
    Created on : 12.05.2011, 11:17:33
    Description:
        Basis javascript Datei  
*/

var scrollpane_options = {
	enableKeyboardNavigation: false,
	scrollbarMargin: 5,
	scrollbarWidth:13
}



$(document).ready(function () {

	Cufon.replace('h1, h2, h3', {fontFamily: 'Delicious'});

	initPrettyFoto();
	$('.logo').css({'opacity':0.9});
	//$('.home #Content').hide();

	initArticleGallery();

	//initAjax();
	

	$('.scrollable, .scrollable2, .scrollable3').jScrollPane(scrollpane_options);

	$('.ArtikelListeThumbs .title').css({'opacity':0.9});
	$('.ArtikelListeThumbs .listitem').hover(function(){
		$(this).find('.title').stop().animate({opacity:0.1},400);
    },function(){
		$(this).find('.title').stop().animate({opacity:0.8},600);
	});

});

function initArticleGallery(){
	var $infos			= $('.article-detail .imagepager .infos');
	var $articel_images = $('.article-detail .image img');
	var length			= $articel_images.length;
	$infos.html('Bild 1 von '+length);
	$('.article-detail .imagepager .back').css('cursor','pointer').click(function(){
		var $active = $('.article-detail .image a:not(:hidden)') ;
		var $prev =  $active.prev().length ? $active.prev() : $('.article-detail .image a:last');
		$infos.html('Bild '+($prev.index()+1)+' von '+length);
		$prev.fadeIn();
		$active.fadeOut();
	});
	$('.article-detail .imagepager .next').css('cursor','pointer').click(function(){
		var $active = $('.article-detail .image a:not(:hidden)') ;
		var $next =  $active.next().length ? $active.next() : $('.article-detail .image a:first');
		$infos.html('Bild '+($next.index()+1)+' von '+length);
		$next.fadeIn();
		$active.fadeOut();
	});
}

function initAjax(){
	initLinkClickHandler();
	$('#MainNav a').click(function(){
		var s = $(this).parent('li').siblings().removeClass('active') ;
		$(this).parent('li').addClass('active');
		var href = $(this).attr('href');
		var rel = $(this).attr('rel');
		loadContent(href, rel);
		return false;
	});

}

function initLinkClickHandler(){
	$('a.ajax').click(function(){
		var href = $(this).attr('href');
		loadContent(href);
		return false;
	});


}

function loadContent(href, rel){
	var $content = $('#Content') ;
	
	$content.fadeOut(400, function(){
		$content.removeClass().addClass(rel);
		$content.load(href, {'nobody':1}, function(){
			logo_clickhandler();
			initPrettyFoto();
			initArticleGallery();
			initLinkClickHandler();
			Cufon.replace('h1, h2, h3', {fontFamily: 'Delicious'});
			$content.fadeIn(400, function(){
				$('.scrollable, .scrollable2, .scrollable3').jScrollPane(scrollpane_options);
			});
		});
	});
}

function logo_clickhandler(){
	$('a.logo').click(function(){
		$('#Content').fadeOut(400);
	});
}

function ajax_trackimage(image_id){ }

function slideshow(){ }

function initPrettyFoto(){
	/*-------------------------------------------------------------------------
	   prettyPhoto
	---------------------------------------------------------------------------*/
	$("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal',
			opacity: 0.55,
			showTitle: true,
			allowresize: true,
			counter_separator_label: '/' ,
			theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
		});
}


function bgSlider2(bgid, bgPause, bgFadeTime) {
    var $active = $('#'+bgid+' img.active');
    //if ( $active.length == 0 ) $active = $('#'+bgid+' img:first');
    var $next =  $active.next().length ? $active.next() : $('#'+bgid+' img:first');
	$next.delay(bgPause).css({opacity: 0}).addClass('active')
	.animate({opacity: 1.0}, bgFadeTime, function() {
		$active.removeClass('active');
 		bgSlider(bgid, bgPause, bgFadeTime);
    });
}

function bgSlider(bgid, bgPause, bgFadeTime) {
    var $active = $('#'+bgid+' img.active');
    //if ( $active.length == 0 ) $active = $('#'+bgid+' img:first');
    var $next =  $active.next().length ? $active.next() : $('#'+bgid+' img:first');
	$next.delay(bgPause).css({opacity: 0}).addClass('active').animate({opacity: 1.0}, bgFadeTime, function() {

 		bgSlider(bgid, bgPause, bgFadeTime);
    });
}
/*--------------------------------------------------------------------------------
sum bytes: 4112 (4 KB)
--------------------------------------------------------------------------------*/

