$(function() {
	
	$('body').addClass('js-on');
	
	$('.carousel').cycle({ 
    fx:    'fade', 
    speed:  1500,
				timeout:  6500
 });

});


(function ($){
	
	if (icl_lang == 'en') {
 	tuotetiedottext = "Product info";
 	jalleenmyyjatext = "Retailers";
 }
 else 
 	if (icl_lang == "ru") {
 		tuotetiedottext = "Информация об изделии";
 		jalleenmyyjatext = "Дилеры";
 	}
 	else {
 		tuotetiedottext = "Tuotetiedot";
 		jalleenmyyjatext = "Jälleenmyyjät";
 	}
		
	var defaults = {buttons: [
		['.product', '<div class="toggler"><a href="#">X</a></div>'],
		['.utility-nav', '<li><a href="#">' + tuotetiedottext + '</a></li>']
	], duration: 500};
	
	$.fn.buttonSlideToggle = function (options) {
		
		options = $.extend(defaults, options);
		
		return this.each(function () {
			var $this = $(this),
							$buttonHolder,
							$button;		
			$.each(options.buttons, function (index, key) {
				$buttonHolder = $(key[0]);
				$button = $(key[1]);
				$buttonHolder.prepend($button);
				$button.click(function (event) {
					
					$this.slideToggle(options.duration);
					event.preventDefault();
				})				
			});
		});
	}
})(jQuery);

(function ($) {
	$(document).ready(function () {
		$('.product').hide();
		$('.retailers').hide();
		$('.product').buttonSlideToggle();
		$('.aside.shadow').prepend($('<div class="toggler"><a href="#">X</a></div>').click(function(e){$(this).closest('.aside').fadeToggle(500);e.preventDefault();}));
		$('.footer-nav.left li:first').after($('<li class="eraser"><a href="#">' + jalleenmyyjatext + '</a></li>').click(function(e){$('.retailers').fadeToggle(500);$('.main').toggleClass('retailviewer');e.preventDefault();}));
		$('.retailers').prepend($('<div class="toggler"><a href="#" style="color#fff;">X</a></div>').click(function(e){$(this).closest('.retailers').fadeToggle(500);$('.main').toggleClass('retailviewer');e.preventDefault();}));
	});
})(jQuery);


$('.fbshare').click(function(e){
		var self = $(this);
		var u = self.attr('href');
		var t = self.attr('title');
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
		e.preventDefault();
});

