$(document).ready(function(){
	$("#breadcrumbs").hover(
		function() {
  			$(this).animate({ opacity: 1}, "fast");
		}, function() {
  			$(this).animate({ opacity: 0.7 }, "fast");
  		}
	).fadeTo(0.7,'fast');

	$('.article a[href]').addClass('link');
	
	$('#carousel ul').cycle({
		before : function(currSlideElement, nextSlideElement, options, forwardFlag)  {
				$(currSlideElement).find('div.container').animate({top:'-290px'},'normal')
			},
		after: function(currSlideElement, nextSlideElement, options, forwardFlag)  {
				$(nextSlideElement).find('div.container').animate({top:'0px'},'normal')				
				
			},
		cleartypeNoBg : true,
		fx : 'scrollHorz',
		next : '#carouselRight',
		prev : '#carouselLeft',
		pause : true,
		timeout : 6000,
		easing : 'swing',
		speed : 500
	});	
		
	$('#newsBox li').hover(
	  function() {
	  	 if ($(this).hasClass('current')) return;
	    $('#newsBox li').removeClass('current');
	    $('#newsBox .content').css({display:'none', opacity : 0});
	    $(this).addClass('current').find('.content').css('display','block').stop().fadeTo('fast',1);
	  }
	).each(function(i) {
		$(this).addClass('title_'+i);
	}).eq(0).mouseover();
	
	$('#menu li').hover(function() {
		$(this).children('.submenu').show();	
		},
		function() {
		$(this).children('.submenu').hide();		
		}
	);	
	
	$('.buttons a').hover(function() {
			var i = $(this).find('img');
			i.animate({left : '-='+(i.width()-160)+'px'},100);
		},
		function() {
			$(this).find('img').animate({left : 0},100);
		}
	);
						

	$('.galleryThumb a').colorbox({
		
		speed: 300,
		title: false,
		slideshow: true,
		slideshowSpeed: 3000,
		slideshowStart: _('slideshow_start'),
		slideshowStop: _('slideshow_stop'),
		current: '{current}/{total}',
		previous: _('slideshow_previous'),
		next: _('slideshow_next'),
		close: _('slideshow_close'),
		onComplete : function() {
			var $p = $('#progressBar').eq(0);
			
			if (!$p.length) {
				$p = $('<div id="progressBar"></div>');
				$('#cboxLoadedContent').append($p);
			}
			console.log($p);
			$p.css({width: '1px', left : '5px', bottom: '5px'}).stop().animate({width: $('#cboxLoadedContent').width()},3000, function() {$(this).css({width : 0});});
		}
	});
	
	$('a[rel=colorbox]').colorbox({
		
		title: false,
		slideshowStart: _('slideshow_start'),
		slideshowStop: _('slideshow_stop'),
		current: '{current}/{total}',
		previous: _('slideshow_previous'),
		next: _('slideshow_next'),
		close: _('slideshow_close'),
	});
	
	$('.mceContentBody img').removeAttr('width').removeAttr('height');
	$('.foldingMenu li.level_1').hover(function() {
			$(this).find('.submenu').fadeIn('fast');
		},
		function() {
			$(this).find('.submenu').fadeOut('fast');
		}
	);
	
	$('.required > label').each(function() {$(this).html($(this).html()+'*')});
});


$(window).load(function() {
	$('.partners li,.partnerLogo').each(function() {
		$(this).height($(this).find('img').height()/2);
		$(this).find('img').fadeIn('fast');
	});
	$('.partners li,.partnerLogo').hover(
		function() {
			var logo = $(this).find('img');
			var h = $(logo).height()/2*-1;
			$(logo).animate({'top' : (h) + 'px'},'fast')
	  },
	  function() {
			var logo = $(this).find('img');
			var h = $(logo).height()/2;
			$(logo).animate({'top' : 0 },'fast')
	  }
	);

});
