// JavaScript Document
$(document).ready(function() {
	/*easing efekti*/
	$.easing.custom = function (x, t, b, c, d) { 
	if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}
	/*css*/
	$(".tuotteet_popup").css("display", "none");
	$("#flowpanes div").css("float", "left");
	$(".tuotetiedot").css("height", "350px");
	$("#flowpanes").css("height", "450px");
	
	/*Tuotekaruselli*/
	$("#flowpanes").scrollable({	
		easing: 'custom',
		speed: 600,
		size: 1,
		clickable: false,
		indexed:true,
		steps: 1,

		onBeforeSeek: function() {
			var conf = $("#flowpanes").scrollable().getConf(); 
				if (this.getIndex()==11) {conf.speed = 1;} else {conf.speed = 600;}	
			},
		onSeek: function() { 
			/*alert(this.getIndex());*/
			if (this.getPageIndex()!=0) { 
				$("img#alkuun").css("display", "block");
				/*$(".prev").css("display", "block");
				$(".next").css("display", "block");*/
			} else {
				$("img#alkuun").css("display", "none");
			/*	$(".prev").css("display", "none");
				$(".next").css("display", "block");*/
			}
			if (this.getIndex()==11) {alkuun();}
    	}
	}).circular().navigator ({	
		navi: ".tuotenavi",
		naviItem: 'img',
		activeClass: 'current'
	});
		
	/*Popup*/
	$("a[rel]").overlay({top:170, effect: 'apple' }); 
	
	/*Tooltip*/
	$(".tuotenavi img[title]").tooltip({ 
        tip: '#tooltip',  
        offset: [280, 0],  
        effect: 'slide'
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    }); 	
	/*$.address.change(function(event) {
         /*alert('address');
   });*/
});

function alkuun(pullo) {
	var s = $("#flowpanes").scrollable({api: true});
	s.setPage(0);
}

