function replaceCufon(){
  /*Replace font START*/
  Cufon.replace('.c-font', {hover: true }); // add class c-font to apply the function
  Cufon.replace('ul#menu-top-menu li a', {hover: true});
  Cufon.replace('ul.menu li a', {hover: true });    
  Cufon.replace('.article-date-event', {hover: true });
  Cufon.replace('.posttitle', {hover: true });
  Cufon.replace('#content-twocolumn #sidebar h6', {hover: true }); 
  Cufon.replace('h4', {hover: true });
  Cufon.replace('.fbcomments h3', {hover: true });              
  /*Replace font END*/
}

//replaceCufon();
  
//$.noConflict(); UPDATED 06-01-2011
$ = jQuery.noConflict();// heheh
var currentVideoId;
var currentPlaylist;
var isAuthenticated;
var mediaHelperUrl = 'http://www.f5dc.com/f5dc-ajax.php';
var loading = 'Loading';
var loading_img = '<p class="t-aligncenter"><img src="' +rooturltemp+ '/images/ajax-loader.gif" /></p>';
var updateURI;

(function($) {
    // $() will work as an alias for jQuery() inside of this function

	$(document).ready(function(){	
	// load modal
	$('#media-btn-msg').jqm(); //Modal dialog box  		  
	
	// START Change Menu Style
    $('.changemenu').click(function(){
      var menu_type = $(this).attr('id');      
      // save to session
      $.get(rooturl+"/f5dc-ajax.php", { action: "changemenu", menustyle: menu_type });
      // hide and show menu
      var hidemenu = 'menu-icons';
  	  var new_css = 'text';
  	  var cur_css = 'icon';
	  
	  if (menu_type == 'menu-icons') {
        hidemenu = 'menu-text';
		new_css = 'icon';
		cur_css = 'text';
      }  

	$('.bottom-'+hidemenu).hide('slide', {direction: 'right'}, 1000, function(){
		 var str = $('.header-menu-lines').attr('id');	  
		$('.header-menu-lines').attr('id', str.replace(cur_css, new_css));	  
		$('.bottom-'+menu_type).show('slide', {direction: 'right'}, 1000);
	});	
    });
	$('.changemenuv2').click(function(){
		var showmenu = $(this).attr('id');
		var hidemenu = $('.currentmenu').attr('id');
  	    var new_css = 'text'; var cur_css = 'icon';	  
	  
	  if (showmenu == 'menu-icons') {
		new_css = 'icon';
		cur_css = 'text';
      }  
	  // save to session
	    $.get(rooturl+"/f5dc-ajax.php", { action: "changemenu", menustyle: showmenu });	  
		$('.bottom-'+hidemenu).hide('slide', {direction: 'right'}, 1000, function(){
			$(this).removeClass('currentmenu'); 
			var str = $('.header-menu-lines').attr('id');	  
			$('.header-menu-lines').attr('id', str.replace(cur_css, new_css));	  
			$('.bottom-'+showmenu).show('slide', {direction: 'right'}, 1000, function(){ $(this).addClass('currentmenu')});
			$('.changemenuv2').attr('id', hidemenu);
		});	
	
	});	
	// END Change Menu Style
	//paging AJAX
	$('ul.pagemenus li a').hover(function(){
		alert(currentpage + ' -- '+ $this.attr('rel'));
	});
    // hover item list
    $('.listpost-article').hover(function(){
        $('#article-details-'+$(this).attr('id')).show();
        $('#top-'+$(this).attr('id')).hide();    
    },function () {
        $('#article-details-'+$(this).attr('id')).hide();
        $('#top-'+$(this).attr('id')).show();
      }
    );
	
	     
	
	$('#outerWrapper').click(function(){
		if($('#page-live-feeds').css('display') == 'block'){
			$('#page-live-feeds').hide();
		}
	});
	
	$('.pagemenus li').click(function(){
		if($('#page-live-feeds').css('display') == 'block'){
			$('#page-live-feeds').hide();
		}
	});
	
	$('#logo-select').click(function(){
		if($('#page-live-feeds').css('display') == 'block'){
			$('#page-live-feeds').hide();
		}
	});
    	
    /*END LOGO*/    
    /*LOGO MENU*/
	$('#header-desc').click(function(e) {
		e.preventDefault();
		
		$('#logo-menu p').hide();
    $('#logo-menu').removeClass('Overlay_DC Overlay_DE Overlay_DO').addClass('Overlay_DG');
    		
		$('#logo-menu').slideToggle("slow");  
          
    $('html').click(function(event){                                      
        var t_click = $(event.target).attr('id');
        var t_click_p =$(event.target).parent().attr('id');
        var t_click_pp =$(event.target).parent().parent().attr('id'); 
        var no_click = new Array('logo-menu','overlay-details');
        if ( (t_click == 'header-desc') || ($.inArray(t_click_p, no_click) >= 0) || ($.inArray(t_click_pp, no_click) >= 0)  ) {
             
        } else {
          $('#logo-menu').slideUp("slow");
        }    
        e.preventDefault();                                               
    });
     	
	});	        
      /*END LOGO MENU*/        
      //$('a.logo-menu-link').click(function(){return false;});
      $('a.logo-menu-link').hover(function(){
        var ids = $(this).attr('id');
    		var g_link = $(this).attr('href');
    		var g_title = $(this).attr('title');  
        $('#logo-menu p').show();      
    		$('#logo-menu').removeClass('Overlay_DG Overlay_DC Overlay_DE Overlay_DO').addClass(ids);
        $('#group-desc').html(g_title);
    		$('#group-desc').attr('href', glink);
      });
      /*END LOGO*/
	  /*SEARCH*/
	  $('#dsearchform').click(function(){
		if ($(this).hasClass('iconsearchclicked')) {
			$('#popupsearch').fadeOut(); 
			$(this).removeClass("iconsearchclicked");
		} else {
			$('#popupsearch').fadeIn();
			$(this).addClass("iconsearchclicked");					
		}									   
		});
	  //video
	  $('#videomore').click(function(){
	     $('.btnshow').toggle();
      $('#video-moredetails').toggle('slow');
    });
    // video playlist
  
  //load subpage menu
  $('.opensubmenu').click(function(){
  	var submenu = '#list'+$(this).attr('id'); // show
	var submenu2 = '#'+$('.currentlist').attr('id');
	$('.opensubmenu').removeClass('fcream'); $(this).addClass('fcream');
	$(submenu2).hide('slide', {direction: 'left'}, 1000, function(){
		$(submenu2).removeClass('currentlist');
		$(submenu).show('slide', {direction: 'left'}, 1000, function(){ $(this).addClass('currentlist'); });
	});	
	return false;
  });
  // load subpage
  $('.menu-channel a').click(function(){
      // add ajax
  	 $('.menu-channel a').removeClass('bgGray');
  	 $(this).addClass('bgGray');
	 var playlist = $(this).attr('id');
	 loadplaylistvideos(playlist);
        return false;
    });  
  // reset session
 $('.icon-f5digital-media a').click(function(){ $.get(rooturl+"/f5dc-ajax.php", { action: "resetmediasection" }); });
  $('.menu-item-f5digital-media a').click(function(){ $.get(rooturl+"/f5dc-ajax.php", { action: "resetmediasection" }); });
  
    $('#media-commentsubmit').click(function(){
   			 // form validation       			 
   			var def = 'Respond to this video...';                                                 
        var tcomment = $("#media-commentfield").val(); 
        if ((tcomment == '')||(tcomment == def)) {
            $("#media-commentfield").val('');
            $("#media-commentfield").focus();        
			//$('#media-commentfield').focus(function(){$('#warn-comment').html('');});
            $('#warn-comment').html('<span class="errors">Please Enter your comment.</span>');                                
	    	} else {
		  $('#warn-comment').html('<img src="'+rooturltemp+'/images/ajax-loader.gif" />');		
          $.ajax({ url: mediaHelperUrl, data: ({videoId: currentVideoId, action: "addComment", comment: tcomment }), success: function(response) {
  				 //updateComments();
  				 if(response == 'false') {
					$('#warn-comment').html('<span class="errors">Failed.</span>');
				 } else {
					$("#media-commentfield").val(def); 
				 	$('#warn-comment').html('<span class="sent-ok">Comment successfully saved.</span>');
					  // reload comment
					  loadcomments(currentVideoId);					
				 }
  				 
  	    	}});        
        }
    });    
    
	// temporary need more time
	$('.videolikeaction').click(function(){
		if(isAuthenticated == true) {
			//ready
		  var actions = $(this).val();		  
		  $('#sent-ok').html('<img src="'+rooturltemp+'/images/ajax-loader.gif" />');
		  var cc = this;          
          $.ajax({ url: mediaHelperUrl, data: ({videoId: currentVideoId, action: actions }), success: function(response) {
  				 //updateComments();
  			 if(response == 'false') {
					$('#warn-likes').html('<span class="errors">Failed.</span>');
				 } else {
				 	$('#warn-likes').html('<span class="sent-ok">You '+$(cc).attr('rel')+' this video.</span>');
					  // reload dislikes					    
					getvideodetails();
				 }
  				 
  	    	}});  
		  
		} else {			
			$('#media-btn-msg').jqmShow();
		}								 								 
	});  
  
    	
  $('#action-addto').click(function(){
		if(isAuthenticated == true) {
			//ready      
      $('#userplaylist').toggle();
      
		} else {			
			$('#media-btn-msg').jqmShow();
		}								 								 
	});  
  	
    //Document scroll function
    $(document).scroll(function() {
        $("#dsearchform").removeClass("iconsearchclicked");
        $("#popupsearch").css("display", "none");        
        $('#page-live-feeds').slideUp("slow");
        $('#logo-menu').slideUp("slow");
    });
    
	}); // end ready function



})(jQuery);	
		// sec with min
/** START VIDEO ************************************************************/
  function loadplaylistvideos(playlist) {
	  $('#channellist-all').html(loading_img);
	  	resetloading();  	                                                                                                                                 
        
	  	
	  	$.getJSON('http://gdata.youtube.com/feeds/api/playlists/'+playlist+'?callback=?&v=2&alt=json&orderby=position', function(data){
          showlistall(data);  
		  currentPlaylist = playlist;
        });	      
  }	// END loadplaylistvideos()
  function userplaylist(){
      // get user playlist
    //$.ajax({ url: mediaHelperUrl, data: ({action: "getUserPlaylists", username: currentUsername}) });//, success: function(response) { var userplaylists = $.parseJSON(response);
    $.getJSON('http://gdata.youtube.com/feeds/api/users/'+currentUsername+'/playlists/?callback=?&v=2&alt=json&orderby=position', function(response){           
		var feed = response.feed;
		var playlists = feed.entry || [];		
		var playlistcount = 0;
		var playlistHtml = '<li id="media-add-favorites">Favorites</li>';
        $.each(playlists, function(key, value) {
		  // count video list getPlaylist
		    /*$.ajax({ url: mediaHelperUrl, data: ({action: "getPlaylist", playlistId: value.yt$playlistId.$t}), success: function(response){
        	var data = $.parseJSON(response);
			var feed = data.feed;
        	var entries = feed.entry || [];
			var playlistcount = entries.length;		
			alert(dump(data));																													 
			} });*/
			$.getJSON('http://gdata.youtube.com/feeds/api/playlists/'+value.yt$playlistId.$t+'?callback=?&v=2&alt=json&orderby=position', function(pdata){		  																														  
        	//var data = $.parseJSON(data);
			var feed = pdata.feed;
        	var entries = feed.entry || [];
			var playlistcount = entries.length;						
			//alert(playlistcount);
			});	 
			playlistHtml += '<li id="media-add-' + value.yt$playlistId.$t + '">' + value.title.$t + ' ('+playlistcount+')</li>';
        });
		playlistHtml += '<li id="media-add-newplaylist">New Playlist</li>';
        $('#userplaylist').html(playlistHtml);
    });
  }

	function initialvideo(vid){
    var playerUrl = $(vid).attr('id');	
  	var videolist = $(vid).attr('rel');    												
	  resetloading();  	
		var vid_details = new Array;
		var vid_details = playerUrl.split("::")
		var playerUrl = vid_details[0];
		var currentDvideo = playerUrl;		 	
	  updateURL('loadvideo', currentDvideo);
	  
  	loadvideo(playerUrl, 1);   
  } 
  // loading function
  function resetloading(){
	//loading
	$('#commentform').slideUp();	
  	$('#customplayer-content').html(loading_img);   		        		    		
  	$('#media-description').html(loading);
    $('#video-moredetails').html(loading);
    // reset more details
    $('#video-moredetails').removeAttr('style');
    $('.btnshow').removeAttr('style');        	
  	$('#viewscount').html('0');
  	$('#viewslikes').html(loading);						
  	$('#commentlist').html(loading_img);
	$('.seeAllcomment').fadeOut('fast', function(){$('#comment-bottom').fadeOut();});
  }               
  function updateURL(updateURI, currentDvideo) {             
		// update url, get current category, get video id		  
      $mediaload = true;
			var urlsplit = this.location.href.split('#');
      var newURL = urlsplit[0] + '#/f5digital-media/';
      var category = $('#media-nav-tab .media-category-active').attr('id');
      // update URL      
      if (updateURI == 'category') {
        newURL = newURL+ category + '/';                
      } else if (updateURI == 'loadvideo') {                
        newURL = newURL+ category + '/?video='+ currentDvideo;
      }
      $pageChange = 'media'; 
      this.location.href =  newURL;                                                    				      				      				                      				            
  } //updateURL()    
	// load video
	function loadvideo(playerUrl, play){
	    
		$('#comment-bottom').fadeOut();
		$ = jQuery.noConflict();
		var vid_details = new Array;
		var vid_details = playerUrl.split("::")
		var playerUrl = vid_details[0];
		var currentDvideo = $('.detailvideos').attr('id');
		$('.detailvideos').removeAttr('id');
		var videoid = currentDvideo ? currentDvideo : playerUrl;
		currentVideoId = videoid; 								
		
		//var likes = addCommas(vid_details[1])+' likes, '+ addCommas(vid_details[2])+ ' dislikes';				
		var playCount = 0;

		// get more details		    	
		$.getJSON('http://gdata.youtube.com/feeds/api/videos/'+videoid+'?callback=?&alt=json&v=2', function(data) {																										 
			var video = data.entry;
			//var entries = feed.entry || [];	
      var pagelink = new Array();
			var urlsplit = location.href.split('#');
      var newURL = urlsplit[0] + '#/f5digital-media/';
      var category = $('#media-nav-tab .media-category-active').attr('id');
                   
      pagelink['url'] = newURL + category + '?video='+ videoid;
      pagelink['title'] = video.media$group.media$title.$t == null ? 'F5 Digital Media.' : video.media$group.media$title.$t;
      pagelink['image'] = video.media$group.media$thumbnail[0].url == null ? 'F5Digital Media - '+pagelink['title'] : video.media$group.media$thumbnail[0].url;
      pagelink['excerpt'] = video.media$group.media$description.$t == null ? 'F5Digital Media' : video.media$group.media$description.$t; 
      updateShareThis(pagelink);	
            			
			var desc = video.media$group.media$description.$t;
			if (video.yt$statistics) {
				playCount = addCommas(video.yt$statistics.viewCount);
			}
			
		  //var desc = $('#desc-'+videoid).val();
		  if (desc==''){ desc = '<p class="t-aligncenter"><i>no description available</i></p>';}
			desc = desc.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
			  return '<a target="_blank" href="'+url+'">'+url+'</a>';
			});
			var categ = '<p><label>Category: </label>'+video.media$group.media$category[0].label+'</p>';
			var tags = '<p><label>Tags: </label>'+video.media$group.media$keywords.$t+'</p>';
			//var licence = '<p><label>Licence: </label>'+video.media$group.media$category[0].label+'</p>';
			// regenerate url
			//playerUrl = 'http://www.youtube.com/v/'+playerUrl+'?app=youtube_gdata';  // added by fritz 11-25-2010   	
			$("#customplayer-content").html('<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/' + currentVideoId + '?version=3&feature=player_embedded" width="620" height="380"><param name="movie" value="http://www.youtube.com/v/' + currentVideoId + '?version=3&feature=player_embedded"/><param name="wmode" value="transparent"></object>');
			//$('#customplayer-content').html('<object width="620" height="380"><param name="movie" value="'+playerUrl+'&hl=en&fx=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+playerUrl+'&autoplay='+play+'"&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="620" height="380"></embed></object>');   		        		    		
	
			$('#viewscount').html(playCount+ ' views');
			//$('#viewslikes').html(likes);
			
			getvideodetails();
			
			//$('#media-description').html(desc);   			 
			$('#media-description').html(desc);
			$('#video-moredetails').html(categ +''+ tags);
      $('#videomore').show();    
		
			//$('#vid-ids').val(videoid);
			/* reload cufon replace gg
			Cufon.replace('#viewscount', {hover: true });
			Cufon.replace('#viewslikes', {hover: true });		  
			Cufon.replace('#video-moredetails p label', {hover: true });
      */   
			$.get(rooturl+"f5dc-ajax.php", { action: "mediasection", playlist: currentPlaylist, videoId:currentVideoId });
    });	
		
  	  // load comment
	  loadcomments(currentVideoId);
	  
	  	$('#media-commentsubmit').click(function(){
			 // form validation       			 
			var def = 'Respond to this video...';                                                 
		var tcomment = $("#media-commentfield").val(); 
		if ((tcomment == '')||(tcomment == def)) {
			$("#media-commentfield").val('');
			$("#media-commentfield").focus();        
			//$('#media-commentfield').focus(function(){$('#warn-comment').html('');});
			$('#warn-comment').html('<span class="errors">Please Enter your comment.</span>');                                
			} else {
		  $('#warn-comment').html('<img src="'+rooturltemp+'/images/ajax-loader.gif" />');		
		  $.ajax({ url: mediaHelperUrl, data: ({videoId: currentVideoId, action: "addComment", comment: tcomment }), success: function(response) {
				 //updateComments();
				 if(response == 'false') {
					$('#warn-comment').html('<span class="errors">Failed.</span>');
				 } else {
					$("#media-commentfield").val(def); 
					$('#warn-comment').html('<span class="sent-ok">Comment successfully saved.</span>');
					  // reload comment
					  loadcomments(currentVideoId);					
				 }
				 
			}});        
		}
		});    
		
		// temporary need more time
		$('.videolikeaction').click(function(){
		if(isAuthenticated == true) {
			//ready
		  var actions = $(this).val();		  
		  $('#sent-ok').html('<img src="'+rooturltemp+'/images/ajax-loader.gif" />');
		  var cc = this;          
		  $.ajax({ url: mediaHelperUrl, data: ({videoId: currentVideoId, action: actions }), success: function(response) {
				 //updateComments();
			 if(response == 'false') {
					$('#warn-likes').html('<span class="errors">Failed.</span>');
				 } else {
					$('#warn-likes').html('<span class="sent-ok">You '+$(cc).attr('rel')+' this video.</span>');
					  // reload dislikes					    
					getvideodetails();
				 }
				 
			}});  
		  
		} else {			
			$('#media-btn-msg').jqmShow();
		}								 								 
		});  
		
		
		$('#action-addto').click(function(){
		if(isAuthenticated == true) {
			//ready      
		$('#userplaylist').toggle();
		
		} else {			
			$('#media-btn-msg').jqmShow();
		}								 								 
		}); 
	  			
	} // END loadvideo()
  // reload like/unlikes to be recode the video details function
  function getvideodetails() {
		$.ajax({ url: mediaHelperUrl, data: ({action: "getVideo", videoId: currentVideoId }), success: function(response) {
			var videoInfo = $.parseJSON(response);
			var numLikes = isNaN(videoInfo.numLikes[0]) ? "0" : parseInt(videoInfo.numLikes[0]);
			var numDislikes = isNaN(videoInfo.numLikes[0]) ? "0" : parseInt(videoInfo.numDislikes[0]);
			
			$('#viewslikes').html((addCommas(numLikes)) + " likes, " + addCommas(numDislikes) + " dislikes");
			
			var likesWidth = Math.round(numLikes / (numLikes + numDislikes) * 100);
			
			$("#likesbar").css("width",  likesWidth + "%");
			$("#dislikesbar").css("width", (100 - likesWidth) + "%");
			
			//Cufon.replace('#viewslikes', {hover: true });
		}});  
  } // END getvideodetails()
   	
	function loadcomments(currentVideoId) {
	    var commentHtml = "";
	    
		$.ajax({ url: mediaHelperUrl, data: ({action: "getComments", videoId: currentVideoId }), success: function(response) {
		    var data = $.parseJSON(response);
		    
            if (response.indexOf("content") != -1) {
                var commentInfo = $.parseJSON(response);

                if (commentInfo.entry.content != null) {
                    //Single comment
                    var friendlyDate = "";
                    var postDate = new Date();
                    
                    postDate.setUTCFullYear(commentInfo.entry.published.substring(0, 4));
                    postDate.setUTCMonth(parseInt(commentInfo.entry.published.substring(5, 7)) - 1);
                    postDate.setUTCDate(commentInfo.entry.published.substring(8, 10));
                    postDate.setUTCHours(commentInfo.entry.published.substring(11, 13));
                    postDate.setUTCMinutes(commentInfo.entry.published.substring(14, 16));
                    postDate.setUTCSeconds(commentInfo.entry.published.substring(17, 19));
                    
                    var dateDiff = Math.round(((new Date()).getTime() - postDate.getTime()) / 1000);
                    
                    if (dateDiff < 3600) {
                        dateDiff = Math.floor(dateDiff / 60);
                        friendlyDate = dateDiff + ' minute' + (dateDiff > 1 ? 's' : '') + ' ago';
                    }
                    else if (dateDiff < 86400) {
                        dateDiff = Math.floor(dateDiff / 3600);
                        friendlyDate = dateDiff + ' hour' + (dateDiff > 1 ? 's' : '') + ' ago';
                    }
                    else if (dateDiff < 604800) {
                        dateDiff = Math.floor(dateDiff / 86400);
                        friendlyDate = dateDiff + ' day' + (dateDiff > 1 ? 's' : '') + ' ago';
                    }
                    else {
                        dateDiff = Math.floor(dateDiff / 604800);
                        friendlyDate = dateDiff + ' week' + (dateDiff > 1 ? 's' : '') + ' ago';
                    }
                    
                    commentHtml += '<div class="commentpage"><div class="entrycomment"><p>' + commentInfo.entry.content + '</p><p><a href=http://youtube.com/user/' + commentInfo.entry.author.name + '>' + commentInfo.entry.author.name + '</a><span class="media-time"> ' + friendlyDate + '</span></p></div></div>'
                }
                else {
                    //Multiple comments
                    var x = 1;
                    
                    commentHtml += '<div class="commentpage">';
                    
                    $.each(commentInfo.entry, function(key, value) {
                        var friendlyDate = '';
                        var postDate = new Date();
                        
                        postDate.setUTCFullYear(value.published.substring(0, 4));
                        postDate.setUTCMonth(parseInt(value.published.substring(5, 7)) - 1);
                        postDate.setUTCDate(value.published.substring(8, 10));
                        postDate.setUTCHours(value.published.substring(11, 13));
                        postDate.setUTCMinutes(value.published.substring(14, 16));
                        postDate.setUTCSeconds(value.published.substring(17, 19));
                        
                        var dateDiff = Math.round(((new Date()).getTime() - postDate.getTime()) / 1000);
                        
                        if (dateDiff < 3600) {
                            dateDiff = Math.floor(dateDiff / 60);
                            friendlyDate = dateDiff + ' minute' + (dateDiff > 1 ? 's' : '') + ' ago';
                        }
                        else if (dateDiff < 86400) {
                            dateDiff = Math.floor(dateDiff / 3600);
                            friendlyDate = dateDiff + ' hour' + (dateDiff > 1 ? 's' : '') + ' ago';
                        }
                        else if (dateDiff < 604800) {
                            dateDiff = Math.floor(dateDiff / 86400);
                            friendlyDate = dateDiff + ' day' + (dateDiff > 1 ? 's' : '') + ' ago';
                        }
                        else {
                            dateDiff = Math.floor(dateDiff / 604800);
                            friendlyDate = dateDiff + ' week' + (dateDiff > 1 ? 's' : '') + ' ago';
                        }
                        
                        commentHtml += '<div class="entrycomment"><p>' + value.content + '</p><p><a href="http://youtube.com/user/' + value.author.name + '">' + value.author.name + '</a><span class="media-time"> ' + friendlyDate + '</span></p></div>'
                        
                        if (x % 5 == 0) {
                            commentHtml += '</div><div class="commentpage">';
                        }
                        else if (x + 1 == commentInfo.entry.length) {
                            commentHtml += '</div>';
                        }
                        
                        x++;
                    });
                }
                
                $("#commentlist").html(commentHtml);  
                $("#commentlist").cycle("destroy");
                $('#commentform').slideDown();
                
                if (commentInfo.entry.length > 5) {             
                    //pagination
                    $("#commentlist").cycle({
                        fx: "scrollHorz",
                        pause:1,
                        before: function(curr, next, opts) { opts.animOut.opacity = 0; },
                        randomizeEffects:0,
                        fastOnEvent:0,
                        fit:1,
                        speed: 1000,
                        timeout: 0,
                        next: "#com-next", prev: "#com-prev", pager: "#commentpagination"
                    });   
                          
                    $('.seeAllcomment').fadeIn('fast', function() { $('#comment-bottom').fadeIn(); });
                }
		    }
            else {
                $("#commentlist").html("");
            }
		    
            /*
			var feed = data.feed;
			var entries = feed.entry || [];	
			$('#commenttoptitle').html('Comment['+entries.length+']');
			//Cufon.replace('#commenttoptitle', {hover: true });
			if (entries.length <= 0) {
				html.push('<p class="t-aligncenter"><i>No Comments</i></p>');
				// hide pagination
				$('.seeAllcomment').fadeOut('fast', function(){$('#comment-bottom').fadeOut(); $('#toppistcomment').hide();});				
			}
			else {
				var perpage = 5;
				html.push('<div class="commentpage">');
				
				for (var i = 0; i < entries.length; i++) {
					var entry = entries[i];
					var c_entry = entry.content.$t;
					c_entry = c_entry.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
					  return '<a target="_blank" href="'+url+'">'+url+'</a>';
					});				
					var comment = '<p>' +c_entry+ '</p>';
					var author = '<span class="media-author fgray2">' +entry.author[0].name.$t+ '</span>';
					var ctime = '<span class="media-time fgray">' +relative_time(entry.published.$t)+ '</span>';
					
					var c_action = '<div id="e-'+i+'-action" class="fright comment-action-hover hide"><input type="button" value="like" id="likecomment" /><input type="button" value="unlike" id="unlikecomment" /><input type="button" value="reply" id="commentreply" /></div>';			
					html.push('<div id="e-'+i+'" class="entrycomment"><div class="fleft commentdetails"><p>' +comment+ '</p><p class="comment-action">' +author+ '' +ctime+ '<span class="media-likecount fcream">0</span></p></div>'+c_action+'<div class="clearer"></div></div>');
					x++;
					
    				if ((i+1) == entries.length) {
    					html.push('</div>');
    					x = 1;
    				}
    				else if (x == perpage) {
    					html.push('</div><div class="commentpage">');
    					x = 1;
    				}
    				else {
    					brk = '';  
    				} 	
				}			
			}
			*/
		}});	
			// for hover menu			
      $('.entrycomment').hover(function(){
        $('#'+$this.attr('id')+'-action').fadeIn();
      },function () {
        $('.comment-action-hover').fadeOut();
      });			
	} // END loadcomment()
	
		
