function loadPagination(recordCount,pageSize,divid,callback) {
	$("#"+divid).pagination(parseInt(recordCount,10), {
		items_per_page:pageSize,
		prev_text:"Previous",
		next_text:"Next",
		link_to:"###",
		num_edge_entries: 1,
		num_display_entries: 6,
        callback: callback,
        goto_btn_src:ctx+"/images/common/pagination/go.png"
    });
}

function loadCurrentPagination(currentPage, recordCount,pageSize,divid,callback) {
	$("#"+divid).pagination(parseInt(recordCount,10), {
		items_per_page:pageSize,
		current_page:currentPage,
		prev_text:"Previous",
		next_text:"Next",
		link_to:"###",
		num_edge_entries: 1,
		num_display_entries: 6,
        callback: callback,
        goto_btn_src:ctx+"/images/common/pagination/go.png"
    });
}

function loadPageData(page_id, url, divid,callback){	
	$.ajax(
	{
		type: "POST",
		url: url,
		data: "page="+(page_id+1),
		success: function(msg){					
			$("#"+divid).html(msg);
			if ($.isFunction(callback)) {
				callback();
			}
			$(".timeago").timeago();
			return;
		},
		error: function(XMLHttpRequest, textStatus, thrownError){
			//alertMessageWarning("Error, please try again later.responseText:["+XMLHttpRequest.responseText+"]",'');
			$(".timeago").timeago();
			return;
		}                    
	});
} 

function loadPageDataSortBy(sort_field, order_type, page_id, url, divid){	
	$.ajax(
	{
		type: "POST",
		url: url,
		data: "page="+(page_id+1)+"&sortField="+sort_field+"&orderType="+order_type,
		success: function(msg){	
			$("#"+divid).html(msg);
			$(".timeago").timeago();
			return;
		},
		error: function(XMLHttpRequest, textStatus, thrownError){
//			alertMessageWarning("Error, please try again later.responseText:["+XMLHttpRequest.responseText+"]",'');
			$(".timeago").timeago();
			return;
		}                    
	});
}

function loadGroupAdminData(page_id,url,divid,condition,method,order_field,order_type){

	$.ajax(
			{
				type: "POST",
				url: url,
				data: "page="+(page_id+1)+"&method="+method+"&nameOrId="+condition+"&field="+order_field+"&type="+order_type,
				success: function(msg){					
					$("#"+divid).html(msg);
					$(".timeago").timeago();
					return;
				},
				error: function(XMLHttpRequest, textStatus, thrownError){
//					alertMessageWarning("Error, please try again later.responseText:["+XMLHttpRequest.responseText+"]",'');
					$(".timeago").timeago();
					return;
				}                    
			});
}

function gotoViewUserPage(userId){
	window.location.href = ctx + "/user/view.u?u=" + userId;
}
function breakWords(strContent, strlength) {
    var strTemp = '';

    while (strContent.length >= strlength) {

      var result = strContent.substr(strlength-1,strContent.length-1);

      index = result.indexOf(" ");
      if(index > 5 ){
        index = 3;
        strTemp += strContent.substr(0,strlength + index)+'-<br>';
      }else{
        strTemp += strContent.substr(0,strlength + index);
        strTemp += '<br>';
      }
      strContent = strContent.substr(strlength + index , strContent.length-1);
    }
    strTemp += strContent;
    return strTemp;
}