try {
	Cufon.replace('menu a, a.big, .cat h2 a, .cat .shower', { hover : true });
	Cufon.replace('h1, .news h2, .partners h3, .info h2, .prod h2', { });
} catch (err) {
	throw new Error(err);
}

$(document).ready(function() {
	try {
		if (element('.effect')) {
			new (function() {
				var prodWidth = parseInt($('.prod').attr('offsetWidth'));
				var plusWidth = 70; // musi byt cislo delitelne dvema
				var smallWidth = (prodWidth-(plusWidth/2));
				
				var offsetTimeOn = 200;
				var offsetTimeOff = 200;
				
				function closeIt() {
					$('.prod').animate({
					width : (prodWidth)+'px',
						marginLeft : '0px'
					}, offsetTimeOff);
				}
				
				$('body').hover(function() {
					closeIt();
				});
				
				$('#big-item-1').hover(function() {
					$('.prod').stop();
					
					$(this).animate({
						width : (prodWidth+plusWidth)+'px'
					}, offsetTimeOn);
					
					// if ($('#big-item-2').width() > smallWidth) {
					$('#big-item-2').animate({
						width : smallWidth+'px',
						marginLeft : (plusWidth)+'px'
					}, offsetTimeOn);
					// }
					
					// if ($('#big-item-3').width() > smallWidth) {
					$('#big-item-3').animate({
						width : smallWidth+'px',
						marginLeft : (plusWidth/2)+'px'
					}, offsetTimeOn);
					// }
				}, function() {
					closeIt();
				});
				
				$('#big-item-2').hover(function() {
					$('.prod').stop();
					
					$(this).animate({
						width : (prodWidth+plusWidth)+'px',
						marginLeft : '-'+(plusWidth/2)+'px'
					}, offsetTimeOn);
					
					// if ($('#big-item-1').width() > smallWidth) {
						$('#big-item-1').animate({
						width : smallWidth+'px'
					}, offsetTimeOn);
					// }
					
					// if ($('#big-item-3').width() > smallWidth) {
					$('#big-item-3').animate({
						width : smallWidth+'px',
						marginLeft : (plusWidth/2)+'px'
					}, offsetTimeOn);
					// }
				}, function() {
					closeIt();
				});
				
				$('#big-item-3').hover(function() {
					$('.prod').stop();
					
					$(this).animate({
						width : (prodWidth+plusWidth)+'px',
						marginLeft : '-'+(plusWidth)+'px'
					}, offsetTimeOn);
					
					// if ($('#big-item-2').width() > smallWidth) {
					$('#big-item-2').animate({
						width : smallWidth+'px',
						marginLeft : '-'+(plusWidth/2)+'px'
					}, offsetTimeOn);
					// }
					
					if ($('#big-item-1').width() > smallWidth) {
						$('#big-item-1').animate({
							width : smallWidth+'px'
						}, offsetTimeOn);
					}
				}, function() {
				closeIt();
				});
			});
		}
		
		if (element('.partners section')) {
			new (function() {
				var partners = $('.partners section');
				var slideLogos = function() {
					var left = parseInt(partners.css('marginLeft') == 'auto' ? 0 : partners.css('marginLeft'))*(-1);
					var wid = partners.children('span').width();
					var offset = wid*partners.children('span').size();
					var newLeft = left+wid*2;
					var _time;
					
					if (newLeft > offset) {
						newLeft = 0;
						_time = 1000;
					} else {
						newLeft = newLeft*(-1);
						_time = 2000;
					}
				
					partners.animate({
						'margin-left' : newLeft+'px'
					}, _time, null, setTimeout(slideLogos, 4000));
				};
				
				setTimeout(slideLogos, 2000);
			});
		}
		
		/**
		 * spesl hover efekt
		 * vypis podkategorii u produktu a referenci
		 **/
		if (element('.categories .cat')) {
			new (function() {
				var originalLeft = $('.shower').css('left');
				var offsetTime = 375;
				
				$('.categories .cat').hover(function() {
					$(this).children('.shower').stop().animate({ left : 0 }, offsetTime);
				}, function() {
					$(this).children('.shower').stop().animate({ left : originalLeft }, offsetTime);
				});
			});
		}
		
		/**
		 * pridani classy kazdemu sudemu td
		 * lze samozrejme prebit v TINY nastavenim background-color natvrdo
		 **/
		if (element('.detail table')) {
			$('.detail table tr:nth-child(odd)').addClass('odd');
			$('.detail table tr:first-child').addClass('first');
			$('.detail table tr:first-child td').css({textAlign : 'left'});
		}
	} catch (err) {
		if (typeof console != 'undefined') {
			console.log(getException(err));
		} else {
			throw new Error(getException(err));
		}
	}
});
