﻿function Double1(container,nextItem, prevItem, per)
{
	var nx = $('#' + nextItem) || null;
	var pr = $('#' + prevItem) || null;
	var d = per || 200;
	var b = $('#'+container) || null;
	var i = $('#'+container + ' > div');
	nx.title = i.length > 1 ? 1 : 0;
	pr.title = 0;//i.length > 1 ? i.length - 1 : 0;

	function go(el)
	{
		var t = el.title;
		var delta = 0;
		nx.title = t < i.length - 1 ? t+1 : i.length - 1;
		pr.title = t >= 1 ? t-1 : 0;
		delta = t*d;
		b.animate({top: -delta}, { duration: 500, queue: false } );
	}
	nx.click(function(event){go(nx);});
	pr.click(function(event){go(pr);});
}

window.onload = function(){
	if($('#box1'))
		var list1 = new Double1('box1', 'next1','prev1', 200);
	if($('#box2'))
		var list1 = new Double1('box2', 'next2','prev2', 200);
}