var facebook = {
	loadReady:function(){
		facebook.getData();
        $('#refresh_button').click(function(){
             facebook.refreshData();
        });        
	},
	
	getData:function(){
		$(".view_comments").click(function(){
			var offset = $('#offset').val();
			var total = $('#total').val();
			var opertation = 10;
			offset = parseInt(offset);
			if(offset<total){
				offset = offset + opertation;
			}else{
                //console.log('else');
                offset = offset;
            }
            var   imgloading = '<table width="100%" height="90%" ';
            imgloading += 'cellpadding="0" cellspacing="0" border="0">';
            imgloading += '<tr>';
            imgloading += '<td align="center" valign="middle">';
            imgloading += '<img src="../images/utils/ajax-loader.gif" />';
            imgloading += '</td>';
            imgloading += '</tr>';
            imgloading += '</table>';
            //$("#content").append(imgloading);           
			$.ajax({
				type: "POST",
				url: "viewajax.php",
				data: {'offset':offset, 'total':total},   
				cache: false,
				success: function(data){
                      /*offset = parseInt(offset);
             f((offset-1) >= total){                
                 $("#MoreUpdate").text('Non See More');
             }else{*/
                    /*$("#content").append(data).slideDown('slow',function() {
                        $.scrollTo($(".comment_text:last"), {duration:3000});
                    });*/
                    $("#content").append(data);
                    $('#offset').val(offset);
                    //console.log($('.hidden-ref').length);
                    var totalRef = $('.hidden-ref').length;
                    //$(".comment_text:last").after(data);				    
				    //$('input').focus();
             //}
              for(var i=0;i<totalRef;i++){
                    var refdata =  $('.hidden-ref:eq('+i+')').val();
                    refdata = refdata.split(':');                   
                 }
                    var totalDisplay = $('.comment_text').length;
                    if(totalDisplay == total){
                        $("#MoreUpdate").empty().text('No More Update');
                    }
                    
				}
			});
			
		});
	},
    
    refreshData:function(){
    var   imgloading = '<table width="100%" height="90%" ';
            imgloading += 'cellpadding="0" cellspacing="0" border="0">';
            imgloading += '<tr>';
            imgloading += '<td align="center" valign="middle">';
            imgloading += '<img src="../images/utils/ajax-loader.gif" />';
            imgloading += '</td>';
            imgloading += '</tr>';
            imgloading += '</table>';
            //console.log(style);
        //if($('#'+flg).val()=='N'){
            $("#content").empty().append(imgloading);
            $.ajax({
                type: "POST",
                url: "viewajax.php",
                data: {'offset':0, 'total':$('#total').val()},   
                cache: false,
                success: function(data){             
                    $("#content").empty().append(data);
                   jQuery(".jcarousel-skin-tango-picupdate").jcarousel({
                        scroll: 3,
                        //initCallback: mycarouselupdate_initCallback,
                        // This tells jCarousel NOT to autobuild prev/next buttons
                        //buttonNextHTML: null,
                        //buttonPrevHTML: null

                        buttonNextHTML: '<div></div>',
                        buttonPrevHTML: '<div></div>'
                    });
                    jQuery(".jcarousel-skin-tango-vdoupdate").jcarousel({
                        scroll: 3,
                        //initCallback: mycarouselupdate_initCallback,
                        // This tells jCarousel NOT to autobuild prev/next buttons
                        //buttonNextHTML: null,
                        //buttonPrevHTML: null

                        buttonNextHTML: '<div></div>',
                        buttonPrevHTML: '<div></div>'
                    });
                    $('#offset').val(0);
                    $("#MoreUpdate").empty().html('<span  class="view_comments" style="cursor: pointer;">View More Updates</span>');
                    facebook.getData();
                   /* $('.div-image:even, .div-content-update:even').addClass('div-even');
                    $('.div-image:odd, .div-content-update:odd').addClass('div-odd');*/
                }
            });
    }
}