var $timer;
$(document).ready(function(){

Cufon.replace('#presentation h1', { fontFamily: 'font_ortodent_italic', hover: true, textShadow: '#999 1px 1px' });
Cufon.replace('#presentation .parent_title', { fontFamily: 'font_ortodent_italic', hover: true, textShadow: '#999 1px 1px' });
Cufon.replace('#promos div.promo h2 a', { fontFamily: 'font_ortodent_italic', hover: true, textShadow: '#999 1px 1px' });
Cufon.replace('div.box h2.title', { fontFamily: 'font_ortodent', hover: true});
Cufon.replace('div.contact_box h2.title', { fontFamily: 'font_ortodent'});
Cufon.replace('div.entry h1', { fontFamily: 'font_ortodent'});
Cufon.replace('#elements div.element p.title', { fontFamily: 'font_ortodent'});


	if ($('body').hasClass('home'))
	{
		homepage_banners(1);

		$('#boxes div.box').each(function(){
			$(this).addClass('pos_'+$('div.box').index(this));
		});

		$('div.navi').hover(
			function(){
				$(this).addClass('navi_hover');
			},
			function(){
				$(this).removeClass('navi_hover');
			});

		$('div.navi_right').click(function(){
			clearTimeout($timer);
			$('#promos div.promo').each(function(){
				if ($(this).hasClass('selected'))
				{
					$curent_item = $('#promos div.promo').index(this);

				}
			});
			$curent_item++
			homepage_banners($curent_item+1);
			return false;
		});

		$('div.navi_left').click(function(){
			clearTimeout($timer);
			$('#promos div.promo').each(function(){
				if ($(this).hasClass('selected'))
				{
					$curent_item = $('#promos div.promo').index(this);
				}
			});
			$curent_item++
			if ($curent_item != 1)
			{
				homepage_banners($curent_item-1);
			}
			if ($curent_item == 1)
			{
				homepage_banners($('#promos div.promo').length);
			}
			return false;
		});
	}

	$('div.ngg-galleryoverview a').lightBox();
	$('li.pic a').lightBox();


	$('#menu li').hover(
		function(){$(this).addClass('selected');},
		function(){$(this).removeClass('selected');}
	);


//	$('div.entry h2').each(function(){
//	    var $current_html =$(this).html();
//		$(this).html('<span class="subtitle_cnt">'+$current_html+'</span>');
//	});

});


function homepage_banners(x){
	n = $('#promos div.promo').length;
	current_banner = '#promos div.pos'+x;
	if (x<=n)
	{
		$('#promos div.promo').fadeOut().removeClass('selected');
		$(current_banner).fadeIn().addClass('selected');
		x++;
		$timer = setTimeout( function() { homepage_banners(x);}, 5000);
	} else {
		homepage_banners(1);
	}
}
