$(document).ready(function() {
	
	$('.toggle').click(function(e){
		e.preventDefault();
		$(this).next().toggle();
		
		if($(this).hasClass('min')){
			$(this).removeClass('min').addClass('plu');
		} else if($(this).hasClass('plu')){
			$(this).removeClass('plu').addClass('min');
		}
	});

	$('.scrollbar').jScrollPane({dragMinHeight:70});
	
	// iScroll
	if($('body').hasClass('iscroll'))
	{
		resizeItems();
		var myScroll;
		myScroll = new iScroll('iscroll', {
			snap: true,
			momentum: true,
			vScrollbar: false,
			scrollbarClass: 'myScrollbar'
		 });
	}
	
	$("body.iscroll .browse .prev").click(function(e){
		e.preventDefault();
		myScroll.scrollToPage('prev', 0);
	});
	$("body.iscroll .browse .next").click(function(e){
		e.preventDefault();
		myScroll.scrollToPage('next', 0);
	});
});



function resizeItems()
{
	var items =  $(".slider .items"),
		 item =  items.find('li'),
		 itemWidth = item.width(),
		 marginItems,
		 total;

	marginItems = parseInt(item.css("margin-right"), 10); //Total Margin Width
	total = item.size() * (itemWidth + marginItems);
	$("#scroller").width(total);

	return total;
}

