function shownavbar(url, currpage, totpages, is_additional)
{

  var linkfirstprev = '';
  if (currpage > 10)
    linkfirstprev += '<a href="javascript:nav(\'i--\',\''+ url +'\','+ currpage +','+ totpages +')">First</a>&nbsp;';
  linkfirstprev += '<a href="javascript:nav(\'i-\',\''+ url +'\','+ currpage +','+ totpages +')"><< Prev</a>&nbsp;&nbsp;&nbsp;';

  linknextlast = '<a href="javascript:nav(\'i+\',\''+ url +'\','+ currpage +','+ totpages +')">&nbsp;Next >> </a>';
  if (currpage < (Math.ceil(totpages/10)*10-10)+1)
    linknextlast += '&nbsp;&nbsp;&nbsp;<a href="javascript:nav(\'i++\',\''+ url +'\','+ currpage +','+ totpages +')">Last</a>';

/*
  if (currpage > 1)
    $('#firstprev').html(linkfirstprev);
  else
    $('#firstprev').html('');

  if (currpage == totpages || totpages == 0)
    $('#nextlast').html('');
  else
    $('#nextlast').html(linknextlast); */

  if (currpage <= 1)
    linkfirstprev = "";
  if (currpage == totpages || totpages == 0)
	linknextlast = "";

  var minpage = 1;
  if (totpages > 10 && (Math.ceil(totpages/10)*10 != Math.floor(totpages/10)*10)) {
    if (currpage > Math.floor(totpages/10)*10) {
      if ((totpages - currpage) < 9)
        minpage = totpages - 9;
    }
	else
       minpage = (Math.ceil(currpage/10)*10-10)+1;
  }
  else {
    minpage = (Math.ceil(currpage/10)*10-10)+1;
  }

  var pagehtml = ''; var count = 0;
  for (i=minpage; i<=totpages; i++)
  {
    count+=1;
    if (count > 10) break;
    if (i == currpage)
      pagehtml += '<b>['+i+']</b>&nbsp;&nbsp;';
    else
      pagehtml += '<a href="javascript:nav('+i+',\''+ url +'\','+ currpage +','+ totpages +')">'+i+'</a>&nbsp;&nbsp;';
  }
//  $('#pageno').html(pagehtml);

  $('#pagination').html(linkfirstprev+pagehtml+linknextlast);
  if (is_additional == 1)
	  $('#pagination1').html(linkfirstprev+pagehtml+linknextlast);

}

function nav(i,url,currpage,totpages)
{

  if (i > 0)
    currpage = i;
  if (i == 'i--')
    currpage = 1;
  else if (i == 'i++')
    currpage = totpages;
  else if (i == 'i-')
    currpage = currpage - 1;
  else if (i == 'i+')
    currpage = currpage + 1;
  
    window.location = url+currpage;
}


function displayfolder() {
	$.get('/data/json.php?f=print_folder&p1=true', function(data) {
		$('#filefolderbox').html(data);
	});
}

function displayfiles(folder_id) {
	$.get('/data/json.php?f=print_files&p1='+folder_id, function(data) {
		$('#filefolderbox').html(data);
	});
}

function addphoto(path) {
	var obj = tinyMCE.getInstanceById('txtdesc');
	var desc = obj.getHTML();
	desc = desc + "&nbsp<img src='"+path+"'>";
	obj.setHTML(desc);
}

function addfile(path, title) {
	var obj = tinyMCE.getInstanceById('txtdesc');
	var desc = obj.getHTML();
	desc = desc + "&nbsp<a href='"+path+"'>" + title + "</a>";
	obj.setHTML(desc);
}

