﻿// JavaScript Document
var zCarousel = {
	obj:[],
	index:0,
	count:4,
	step:0,
	speed:600,
	sl:0,
	init:function()
	{
		$('.scroll dl').each(function(){
			zCarousel.obj.push($(this));
		});
		$('.listView .leftArr').css('cursor','pointer').attr('title','Next');
		$('.listView .rightArr').css('cursor','pointer').attr('title','Previous');
		zCarousel.step = typeof zCarousel.obj[0]=="object"?zCarousel.obj[0].width()||0:0;
	},
	start:function()
	{
		this.init();
		zCarousel.bindEvent();
	},
	bindEvent:function()
	{
		$('.listView .leftArr').bind('click',function(){
			zCarousel.leftMove();
		});
		$('.listView .rightArr').bind('click',function(){
			zCarousel.rightMove();
		});
	},
	fireEvent:function()
	{
		$('.listView .leftArr').unbind('click');
		$('.listView .rightArr').unbind('click');
	},
	leftMove:function()
	{
		if(zCarousel.obj.length-zCarousel.index<=zCarousel.count)
		return;
		zCarousel.fireEvent();
		zCarousel.sl+=zCarousel.step;
		zCarousel.index++;
		zCarousel.move();
	},
	rightMove:function()
	{
		if(zCarousel.index<=0)
		return;
		zCarousel.fireEvent();
		zCarousel.sl-=zCarousel.step;
		zCarousel.index--;
		zCarousel.move();
	},
	move:function()
	{
		$('.listView .scroll').animate({
			scrollLeft:zCarousel.sl
		},zCarousel.speed,zCarousel.bindEvent);
	}
}