(function($) {
	$.fn.extend({

		landingSlider: function(options) {

			var defaults = {
				slideButtons		: '',
				slideInfo			: '',
				slideDiv			: '',
				easing				: '',
				delay				: 800,
				itemHeight			: 102,
				itemWidth			: 178,
				viewItem			: 3,
				direction			: 'vertical',
				cufonReplace		: true,
				CufonFontList		: CufonFontList
			};

			var options = $.extend(defaults, options);
			
			return this.each(function() {
				var o 			= options;
				var obj			= $(this);
				var objButtons 	= obj.find(o.slideButtons);
				var slideInfo	= obj.find(o.slideInfo);
				var slideDiv	= obj.find(o.slideDiv);
				newsPage 		= 1;
				newsTotalPage 	= Math.round(slideDiv.children('.slide').length / o.viewItem)/2;		
				newsTotalPage 	-= 2;		
		
				switch (o.direction) {
				case 'vertical':
					slideDiv.css({
						'height' : slideDiv.children('.slide').length * o.itemHeight
					});
					break;
				case 'horizantal':
					slideDiv.css({
						'width' : slideDiv.children('.slide').length * o.itemWidth
					});	
					
					var itemWidth	= o.viewItem * o.itemWidth;
										
					break;
				default:
					break;
				}
				
				slideInfo.html(newsPage+'/'+newsTotalPage);
								
				objButtons.children('a').click(function(){
																		
					newsPage 	= ($(this).attr('id') == 'prev' ? newsPage-1 : newsPage+1);

										
					switch (o.direction) {
					case 'vertical':
						slideWidth	= o.itemHeight*(newsPage);
							break;
					case 'horizantal':
						slideWidth	= itemWidth * (newsPage);
						break;
					default:
						break;
					}		
								
					if(newsPage <= newsTotalPage && newsPage > 0){
						switch (o.direction) {
						case 'vertical':
							slideDiv.stop().animate({'top':'-'+slideWidth+'px' },o.delay,o.easing);
								break;
						case 'horizantal':
							slideDiv.stop().animate({'left':'-'+slideWidth+'px' },o.delay,o.easing);
							break;
						default:
							break;
						}
						
						objButtons.children('li.activebutton').removeClass('activebutton');
		
						$(this).addClass('activebutton');
						
						slideInfo.html(newsPage+'/'+newsTotalPage);
						
						if(o.cufonReplace){
							for(i=0;i<o.CufonFontList.length;i++){
								fontClass = '.'+slideInfo.attr('class');
								if(fontClass.search(o.CufonFontList[i][0]) > -1){
									cufonReReplace(slideInfo,{fontFamily:o.CufonFontList[i][1],hover:true});
									break;
								}
							}
						}
					}else{
						if(newsPage < 1){ newsPage = 1; }else{ newsPage -=1; }	
					}
					
					return false;
				});
				
			});

		}
	});
})(jQuery);

