set_scroll_gallery_select = {
	builder: function() {
		checkButtons(false, "#gallery_select_arrows .rev a", "#gallery_select_arrows .fwd a", iGallerySelectBottom, iGallerySelectTotal, 4);
		
		//绑定箭头的点击事件
		$("#gallery_select_arrows .rev a").click(function() {
			iGallerySelectBottom = moveFrames("#gallery_select_wrapper", 216, 'left', iGallerySelectTotal, 4, iGallerySelectBottom);
			checkButtons(false, "#gallery_select_arrows .rev a", "#gallery_select_arrows .fwd a", iGallerySelectBottom, iGallerySelectTotal, 4);
			return false;
		});
		$("#gallery_select_arrows .fwd a").click(function() {
			iGallerySelectBottom = moveFrames("#gallery_select_wrapper", 216, 'right', iGallerySelectTotal, 4, iGallerySelectBottom);
			checkButtons(false, "#gallery_select_arrows .rev a", "#gallery_select_arrows .fwd a", iGallerySelectBottom, iGallerySelectTotal, 4);
			return false;
		});
		
	},
	
	init: function() {
		iGallerySelectTotal = $("#gallery_select_wrapper li").length;
		iGallerySelectBottom = 4;
		
		set_scroll_gallery_select.builder();
	}
}

set_scroll_gallery_list = {
	builder: function() {
		checkButtons(false, "#gallery_list_arrows .rev a", "#gallery_list_arrows .fwd a", iGalleryListBottom, iGalleryListTotal, 6);
		
		//绑定箭头的点击事件
		$("#gallery_list_arrows .rev a").click(function() {
			iGalleryListBottom = moveFrames("#gallery_list_wrapper", 147, 'left', iGalleryListTotal, 6, iGalleryListBottom);
			checkButtons(false, "#gallery_list_arrows .rev a", "#gallery_list_arrows .fwd a", iGalleryListBottom, iGalleryListTotal, 6);
			return false;
		});
		$("#gallery_list_arrows .fwd a").click(function() {
			iGalleryListBottom = moveFrames("#gallery_list_wrapper", 147, 'right', iGalleryListTotal, 6, iGalleryListBottom);
			checkButtons(false, "#gallery_list_arrows .rev a", "#gallery_list_arrows .fwd a", iGalleryListBottom, iGalleryListTotal, 6);
			return false;
		});
		
	},
	
	init: function() {
		iGalleryListTotal = $("#gallery_list_wrapper li").length;
		iGalleryListBottom = 6;
		
		set_scroll_gallery_list.builder();
	}
}

set_gallery_list = {
	builder: function() {
		$('#gallery_list a').click(function(){
			if (this.parentNode.className.indexOf('selected') >= 0 ) {
				this.blur();
				return false;
			}
			var sPicUrl = this.href;
			$('#i_gallery_pic').fadeTo(500,0,function(){
				$('#i_gallery_pic').attr('src',sPicUrl)
			});
			$('#a_dl_pic').fadeOut(500).attr('href',sPicUrl);  //同步下载按钮的链接
			$('#gallery_list li.selected').removeClass('selected');
			$(this.parentNode).addClass('selected');
			this.blur();
			return false;
		});
		$('#i_gallery_pic').load(function(){
			setTimeout(function(){
				$('#i_gallery_pic').fadeTo(500,1);
				$('#a_dl_pic').fadeIn(500);
			},100);
		});
	},
	init: function() {
		$('#a_dl_pic').attr('href',$('#i_gallery_pic').attr('src'));  //启动时同步下载按钮的链接
		set_gallery_list.builder();
	}
}


$(document).ready(function() {
	set_scroll_gallery_select.init();
	set_scroll_gallery_list.init();
	set_gallery_list.init();
});
