function NewsFilterScroll(options,contentOption) {

	var vstart = 1;
	var hstart = 1;           
	var newsdom = options.dom;                                                        
	var lengthList = 0;
	var vScrollStep = 0;
	var hScrollStep = 0;
	var thisDate = newsdom.find(".date").html();
	contentOption.offset = 0;      
	contentOption.current_date_diff = 0;
	
	var resetSize = function () {                  
		lengthList = newsdom.find(".wrapperVScrollFloat li").length;
		vScrollStep = 0;
        if (newsdom.find(".wrapperVScrollFloat li").length != 0)
			hScrollStep = newsdom.find(".wrapperVScrollFloat li").get(0).offsetWidth; 
		newsdom.find(".wrapperVScrollFloat li").each(function () {
			vScrollStep += $(this).get(0).offsetHeight;
		})
		newsdom.find(".wrapperVScrollFloat").css("height",(vScrollStep*2)+"px");
		newsdom.find(".wrapperHScrollFloat").css("width",(hScrollStep*2)+"px");
		
		newsdom.find(".wrapperVScroll").css("height",(vScrollStep)+"px");
		newsdom.find(".wrapperVScroll").css("width",(hScrollStep)+"px");
		newsdom.find(".wrapperVScrollFloat").css("width",(hScrollStep)+"px");
		
		newsdom.find(".wrapperHScroll").css("height",(vScrollStep)+"px");
		newsdom.find(".wrapperHScroll").css("width",(hScrollStep)+"px");
		newsdom.find(".wrapperHScrollFloat").css("height",(vScrollStep)+"px");
		
		newsdom.find(".wrapperHScroll").css("overflow","hidden");
		newsdom.find(".wrapperVScroll").css("overflow","hidden");
		newsdom.find(".wrapperVScroll").css("float","left");
		newsdom.find(".wrapperHScrollFloat").css("clear","left");
		
	}

	
	var bindButton = function () {
		if (options.ubutton)
			options.ubutton.click (goUp);
		if (options.dbutton)
			options.dbutton.click (goDown); 
		
		if (options.lbutton)
			options.lbutton.click (goLeft); 
		
		if (options.rbutton)
			options.rbutton.click (goRight);
	}
	
	var unBindButton = function () {
		if (options.ubutton)
			options.ubutton.unbind("click");
		if (options.dbutton)
			options.dbutton.unbind("click");
		if (options.lbutton)
			options.lbutton.unbind("click");
		if (options.rbutton)
			options.rbutton.unbind("click");
	}
	
	var goUp = function () {   
			unBindButton();

			var cateId = $.trim($("input[name=cate_filter]:checked").serialize().replace(/cate_filter=/g," ").replace(/\&\ /g,","));
			var column_list = "content_id,category_id,image_thumbnail,title,intro,pubdate";
			if(contentOption.bulloon_content == "true"){ 
				column_list+=",body";
			}
			contentOption.offset -= parseInt(contentOption.amount);
			if (contentOption.offset >= 0)
			{
			var option = {method:"getContent",categoryID:cateId,limit:contentOption.amount,offset:contentOption.offset,dateCurrentDiff:contentOption.current_date_diff,columnlist:column_list,fixdate:contentOption.fixdate,joinCategory:"true"};
			$.ajax({
			  type: "GET",
			  url: "/cfcustom/handlerfunction.cfc",
			  data: option,
			  dataType:"json",
			  success: function(response){
				
				var tempHTML = "";
				for(var i = 0; i < response.DATA.length; i++)
				{
					var title = response.DATA[i][$.inArray("TITLE",response.COLUMNS)];
					var content_id = response.DATA[i][$.inArray("CONTENT_ID",response.COLUMNS)];
					var tmSplit = response.DATA[i][$.inArray("PUBDATE",response.COLUMNS)].split(" ");
					if(contentOption.bulloon_content == "true"){
						var content_body = response.DATA[i][$.inArray("BODY",response.COLUMNS)];
					}

					var pubdate = tmSplit[0]+" "+tmSplit[1]+" "+tmSplit[2];
					var pubtime = response.DATA[i][$.inArray("THAITIME",response.COLUMNS)];
					if(contentOption.bulloon_content == "true"){
						
					tempHTML += '<li class="list-slideHotnews">'+
							' <div class="th_horoscope_title" title="'+$("<span>").text(content_body).get(0).innerHTML+'">'+
							' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'" rel="popupBullon_'+content_id+'" class="popupBullon_'+content_id+'">'+
							' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
							' <span class="time-hotnews">'+pubtime+'</span> '+
							' <span class="hidden_id">'+content_id+'</span> '+
							' <span>'+title+'</span> '+
							' </a>'+
							' </div>'+
							'</li>';
					
				}else{
					tempHTML += '<li class="list-slideHotnews">'+
							' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'">'+
							' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
							' <span class="time-hotnews">'+pubtime+'</span> '+
							' <span class="hidden_id">'+content_id+'</span> '+
							' <span>'+title+'</span> '+
							' </a>'
						'</li>';
					}	
				}         
				if (tempHTML != "")
				{
					newsdom.find(".wrapperVScrollFloat").prepend(tempHTML);
					newsdom.find(".wrapperVScroll").scrollTop(vScrollStep);
					newsdom.find(".wrapperVScroll").filter(':not(:animated)').animate({scrollTop : '+=' + (-vScrollStep)}, 500,function() {
						newsdom.find(".wrapperVScrollFloat li:gt("+(response.DATA.length-1)+")").remove();
						bindButton(); 
						resetSize();
						if($(document).find("div[class^=th_horoscope_title]").length)
						$(document).find("div[class^=th_horoscope_title]").bt(
							{
							  fill: '#F7F7F7', 
							  
							  spikeLength: 10, 
							  spikeGirth: 10, 
							  padding: 8, 
							  cornerRadius: 5, 
							  shadow: true,
						      shadowOffsetX: 3,
						      shadowOffsetY: 3,
						      shadowBlur: 8,
						      shadowColor: 'rgba(0,0,100,.9)',
						      shadowOverlap: false,
						      noShadowOpts: {strokeStyle: '#999', strokeWidth: 2},
							  
							  cssStyles: {
							    fontFamily: '"lucida grande",tahoma,verdana,arial,sans-serif', 
							    fontSize: '11px'
							  	}
							  	
							}  
						);
					});
				} else {
					contentOption.offset += parseInt(contentOption.amount);
					bindButton(); 
				}
			  }
	        });
		}else {
			contentOption.offset = 0;
			bindButton(); 
			resetSize();
		}
		 	
			
	}

    var goDown = function () {

        unBindButton();
        contentOption.offset += parseInt(contentOption.amount);
	
		var cateId = $.trim($("input[name=cate_filter]:checked").serialize().replace(/cate_filter=/g," ").replace(/\&\ /g,","));
	        var column_list = "content_id,category_id,image_thumbnail,title,intro,pubdate";
	       if(contentOption.bulloon_content == "true"){ 
			column_list+=",body";
		}
		var option = {method:"getContent",categoryID:cateId,limit:contentOption.amount,offset:contentOption.offset,dateCurrentDiff:contentOption.current_date_diff,columnlist:column_list,fixdate:contentOption.fixdate,joinCategory:"true"};
		$.ajax({
		  type: "GET",
		  url: "/cfcustom/handlerfunction.cfc",
		  data: option,
		  dataType:"json",
		  success: function(response){
			var tempHTML = "";
			for(var i = 0; i < response.DATA.length; i++)
			{
				var title = response.DATA[i][$.inArray("TITLE",response.COLUMNS)];
				var content_id = response.DATA[i][$.inArray("CONTENT_ID",response.COLUMNS)];
				var tmSplit = response.DATA[i][$.inArray("PUBDATE",response.COLUMNS)].split(" ");
				if(contentOption.bulloon_content == "true"){
					var content_body = response.DATA[i][$.inArray("BODY",response.COLUMNS)];
				}

				var pubdate = tmSplit[0]+" "+tmSplit[1]+" "+tmSplit[2];
				var pubtime = response.DATA[i][$.inArray("THAITIME",response.COLUMNS)];
				if(contentOption.bulloon_content == "true"){
						
					tempHTML += '<li class="list-slideHotnews">'+
							' <div class="th_horoscope_title" title="'+$("<span>").text(content_body).get(0).innerHTML+'">'+
							' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'" rel="popupBullon_'+content_id+'" class="popupBullon_'+content_id+'">'+
							' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
							' <span class="time-hotnews">'+pubtime+'</span> '+
							' <span class="hidden_id">'+content_id+'</span> '+
							' <span>'+title+'</span> '+
							' </a>'+
							' </div>'+
							'</li>';
					
				}else{
				tempHTML += '<li class="list-slideHotnews"> '+
						' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'">'+
						' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
						' <span class="time-hotnews">'+pubtime+'</span> '+
						' <span class="hidden_id">'+content_id+'</span> '+
						' <span>'+title+'</span> '+
						' </a>'+
					'</li>';
				}	
			}          
			if ( tempHTML != "") 
			{
				newsdom.find(".wrapperVScrollFloat").append(tempHTML);
				newsdom.find(".wrapperVScroll").scrollTop(-vScrollStep)
				newsdom.find(".wrapperVScroll").filter(':not(:animated)').animate({scrollTop : '+=' + vScrollStep}, 500,function() {
					newsdom.find(".wrapperVScrollFloat li:lt("+lengthList+")").remove();                                            
					newsdom.find(".wrapperVScroll").scrollTop(-vScrollStep)
					bindButton(); 
					resetSize();
					if($(document).find("div[class^=th_horoscope_title]").length)
						$(document).find("div[class^=th_horoscope_title]").bt(
							{
							  fill: '#F7F7F7', 
							  
							  spikeLength: 10, 
							  spikeGirth: 10, 
							  padding: 8, 
							  cornerRadius: 5, 
							  shadow: true,
						      shadowOffsetX: 3,
						      shadowOffsetY: 3,
						      shadowBlur: 8,
						      shadowColor: 'rgba(0,0,100,.9)',
						      shadowOverlap: false,
						      noShadowOpts: {strokeStyle: '#999', strokeWidth: 2},
							  
							  cssStyles: {
							    fontFamily: '"lucida grande",tahoma,verdana,arial,sans-serif', 
							    fontSize: '11px'
							  	}
							  	
							}  
						);
					
				});
			} else {
				contentOption.offset -= parseInt(contentOption.amount);
				bindButton(); 
			}
		  }
        });


	}

	var goLeft = function () {
		unBindButton();

	if ($.trim(thisDate) != $.trim(newsdom.find(".date").html())) {
		contentOption.current_date_diff++;  
		contentOption.offset = 0;

		var cateId = $.trim($("input[name=cate_filter]:checked").serialize().replace(/cate_filter=/g," ").replace(/\&\ /g,","));
		var column_list = "content_id,category_id,image_thumbnail,title,intro,pubdate";
		if(contentOption.bulloon_content == "true"){ 
			column_list+=",body";
		}
		var option = {method:"getContent",categoryID:cateId,limit:contentOption.amount,offset:contentOption.offset,dateCurrentDiff:contentOption.current_date_diff,columnlist:column_list,fixdate:contentOption.fixdate,joinCategory:"true"};
		$.ajax({
		  type: "GET",
		  url: "/cfcustom/handlerfunction.cfc",
		  data: option,
		  dataType:"json",
		  success: function(response){
			var dSplit = newsdom.find(".date").html().split("/");
			var d = new Date((Date.parse( dSplit[1]+"/"+dSplit[0]+"/"+dSplit[2]) ) + (24*60*60*1000));
			var dd = ( ("0"+d.getDate()).length > 2)?d.getDate():("0"+d.getDate());
			var mm = ( ("0"+(d.getMonth()+1)).length > 2)?(d.getMonth()+1):("0"+(d.getMonth()+1));
			newsdom.find(".date").html(dd+"/"+(mm)+"/"+(d.getYear()+1900));
			var tempHTML = "";
			tempHTML+='<li class="wrapperVScroll" style="overflow: hidden; height: 580px; width: 290px;float:left">';
			tempHTML+='	<ul class="wrapperVScrollFloat">';
			for(var i = 0; i < response.DATA.length; i++)
			{
				var title = response.DATA[i][$.inArray("TITLE",response.COLUMNS)];
				var content_id = response.DATA[i][$.inArray("CONTENT_ID",response.COLUMNS)];
				if(contentOption.bulloon_content == "true"){
					var content_body = response.DATA[i][$.inArray("BODY",response.COLUMNS)];
				}
				var tmSplit = response.DATA[i][$.inArray("PUBDATE",response.COLUMNS)].split(" ");
				var pubtime = response.DATA[i][$.inArray("THAITIME",response.COLUMNS)];
				var pubdate = tmSplit[0]+" "+tmSplit[1]+" "+tmSplit[2];
				if(contentOption.bulloon_content == "true"){
						
					tempHTML += '<li class="list-slideHotnews">'+
							' <div class="th_horoscope_title" title="'+$("<span>").text(content_body).get(0).innerHTML+'">'+
							' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'" rel="popupBullon_'+content_id+'" class="popupBullon_'+content_id+'">'+
							' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
							' <span class="time-hotnews">'+pubtime+'</span> '+
							' <span class="hidden_id">'+content_id+'</span> '+
							' <span>'+title+'</span> '+
							' </a>'+
							' </div>'+
							'</li>';
					
				}else{
				tempHTML += '<li class="list-slideHotnews"> '+
						' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'">'+
						' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
						' <span class="time-hotnews">'+pubtime+'</span> '+
						' <span class="hidden_id">'+content_id+'</span> '+
						' <span>'+title+'</span>'+
						'</a>'+
					'</li>';
				}	

			}
			tempHTML+='	</ul>';
			tempHTML+='</li>';

			newsdom.find(".wrapperHScrollFloat").append(tempHTML);
				newsdom.find(".wrapperHScroll").filter(':not(:animated)').animate({scrollLeft : '+=' + (hScrollStep)}, 500,function() {
					newsdom.find(".wrapperVScroll:eq(0)").remove();
					newsdom.find(".wrapperHScroll").scrollLeft(-hScrollStep);
					bindButton();
					resetSize();
					if($(document).find("div[class^=th_horoscope_title]").length)
						$(document).find("div[class^=th_horoscope_title]").bt(
							{
							  fill: '#F7F7F7', 
							  
							  spikeLength: 10, 
							  spikeGirth: 10, 
							  padding: 8, 
							  cornerRadius: 5, 
							  shadow: true,
						      shadowOffsetX: 3,
						      shadowOffsetY: 3,
						      shadowBlur: 8,
						      shadowColor: 'rgba(0,0,100,.9)',
						      shadowOverlap: false,
						      noShadowOpts: {strokeStyle: '#999', strokeWidth: 2},
							  
							  cssStyles: {
							    fontFamily: '"lucida grande",tahoma,verdana,arial,sans-serif', 
							    fontSize: '11px'
							  	}
							  	
							}  
						);
				});
		  }
        });      
	}else {
		bindButton();
	}                               
	}
	
	var goRight = function () { 
	    unBindButton();
		contentOption.offset = 0;
		contentOption.current_date_diff--;
		var cateId = $.trim($("input[name=cate_filter]:checked").serialize().replace(/cate_filter=/g," ").replace(/\&\ /g,","));
		var column_list = "content_id,category_id,image_thumbnail,title,intro,pubdate";
		if(contentOption.bulloon_content == "true"){ 
			column_list+=",body";
		}

		var option = {method:"getContent",categoryID:cateId,limit:contentOption.amount,offset:contentOption.offset,dateCurrentDiff:contentOption.current_date_diff,columnlist:column_list,fixdate:contentOption.fixdate,joinCategory:"true"};
		$.ajax({
		  type: "GET",
		  url: "/cfcustom/handlerfunction.cfc",
		  data: option,
		  dataType:"json",
		  success: function(response){                    
			var dSplit = newsdom.find(".date").html().split("/");
			var d = new Date((Date.parse( dSplit[1]+"/"+dSplit[0]+"/"+dSplit[2]) ) - (24*60*60*1000));
			var dd = ( ("0"+d.getDate()).length > 2)?d.getDate():("0"+d.getDate());
			var mm = ( ("0"+(d.getMonth()+1)).length > 2)?(d.getMonth()+1):("0"+(d.getMonth()+1));
			newsdom.find(".date").html(dd+"/"+(mm)+"/"+(d.getYear()+1900));
			var tempHTML = "";
			tempHTML+='<li class="wrapperVScroll" style="overflow: hidden; height: 580px; width: 290px;float:left">';
			tempHTML+='	<ul class="wrapperVScrollFloat">';
			for(var i = 0; i < response.DATA.length; i++)
			{
				var title = response.DATA[i][$.inArray("TITLE",response.COLUMNS)];
				var content_id = response.DATA[i][$.inArray("CONTENT_ID",response.COLUMNS)];
				if(contentOption.bulloon_content == "true"){
					var content_body = response.DATA[i][$.inArray("BODY",response.COLUMNS)];
				}
				var tmSplit = response.DATA[i][$.inArray("PUBDATE",response.COLUMNS)].split(" ");
				var pubdate = tmSplit[0]+" "+tmSplit[1]+" "+tmSplit[2];
				var pubtime = response.DATA[i][$.inArray("THAITIME",response.COLUMNS)];
				
				if(contentOption.bulloon_content == "true"){
						
					tempHTML += '<li class="list-slideHotnews">'+
							' <div class="th_horoscope_title" title="'+$("<span>").text(content_body).get(0).innerHTML+'">'+
							' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'" rel="popupBullon_'+content_id+'" class="popupBullon_'+content_id+'">'+
							' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
							' <span class="time-hotnews">'+pubtime+'</span> '+
							' <span class="hidden_id">'+content_id+'</span> '+
							' <span>'+title+'</span> '+
							' </a>'+
							' </div>'+
							'</li>';
					
				}else{
				
					tempHTML += '<li class="list-slideHotnews"> '+
							' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'">'+
							' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
							' <span class="time-hotnews">'+pubtime+'</span> '+
							' <span class="hidden_id">'+content_id+'</span> '+
							' <span>'+title+'</span> '+
							' </a> '+
						'</li>';
				}	

			}
			tempHTML+='	</ul>';
			tempHTML+='</li>';
			newsdom.find(".wrapperHScrollFloat").prepend(tempHTML);
			newsdom.find(".wrapperHScroll").scrollLeft(hScrollStep);
			newsdom.find(".wrapperHScroll").filter(':not(:animated)').animate({scrollLeft : '+=' + (-hScrollStep)}, 500,function() {
				newsdom.find(".wrapperVScroll:eq(1)").remove();
				bindButton();
				resetSize();
					if($(document).find("div[class^=th_horoscope_title]").length)
						$(document).find("div[class^=th_horoscope_title]").bt(
							{
							  fill: '#F7F7F7', 
							  
							  spikeLength: 10, 
							  spikeGirth: 10, 
							  padding: 8, 
							  cornerRadius: 5, 
							  shadow: true,
						      shadowOffsetX: 3,
						      shadowOffsetY: 3,
						      shadowBlur: 8,
						      shadowColor: 'rgba(0,0,100,.9)',
						      shadowOverlap: false,
						      noShadowOpts: {strokeStyle: '#999', strokeWidth: 2},
							  
							  cssStyles: {
							    fontFamily: '"lucida grande",tahoma,verdana,arial,sans-serif', 
							    fontSize: '11px'
							  	}
							  	
							}  
						);

			});
		  }
        });		
	}


	// Binding Category Filter checkbox clicked
	$("input[name=cate_filter]").click(function () {
		var cateId = $.trim($("input[name=cate_filter]:checked").serialize().replace(/cate_filter=/g," ").replace(/\&\ /g,","));
		var column_list = "content_id,category_id,image_thumbnail,title,intro,pubdate";
		var option = {method:"getContent",categoryID:cateId,limit:contentOption.amount,offset:contentOption.offset,dateCurrentDiff:contentOption.current_date_diff,columnlist:column_list,fixdate:contentOption.fixdate,joinCategory:"true"};
		$.ajax({
		  type: "GET",
		  url: "/cfcustom/handlerfunction.cfc",
		  data: option,
		  dataType:"json",
		  success: function(response){
			var tempHTML = "";
			for(var i = 0; i < response.DATA.length; i++)
			{
				var title = response.DATA[i][$.inArray("TITLE",response.COLUMNS)];
				var content_id = response.DATA[i][$.inArray("CONTENT_ID",response.COLUMNS)];
				var tmSplit = response.DATA[i][$.inArray("PUBDATE",response.COLUMNS)].split(" ");
				var pubdate = tmSplit[0]+" "+tmSplit[1]+" "+tmSplit[2];
				var pubtime = response.DATA[i][$.inArray("THAITIME",response.COLUMNS)];
				tempHTML += '<li class="list-slideHotnews"> '+
						' <a href="'+contentOption.contentBaseURL+'content/'+content_id+'">'+
						' <img class="pngImg" src="/mcot/images/hotnews/icon-hotnews.png" /> '+
						' <span class="time-hotnews">'+pubtime+'</span> '+
						' <span class="hidden_id">'+content_id+'</span> '+
						' <span>'+title+'</span> '+
						'</a>'+
					'</li>';

			}
			newsdom.find(".wrapperVScrollFloat").html(tempHTML);
		}});
	});
 bindButton();   
 resetSize();
}
