function showContent(orderBy, imd5, idd, page )
{
	cname=$("#c_name__").attr("value");
  $("#" + idd).empty();
  $("#" + idd).append("<DIV class='cfolderview' style='padding-left: 220px;'><img src='/img/line_2.gif'></DIV><div style='float:left; text-align:right; width:550px; padding-top:176px;'></div><div style='width:550px;'><div style='float:left;'><img src='/img/file_lb.gif' height='11' width='10' border='0' /></div><div style='float:left;font-size:1px;'></div><div style='float:right;'><img src='/img/file_rb.gif' height='11' width='10' border='0' /></div></div>");

  $.post('/community/' +cname,
			{action:'showContent', sort: orderBy, page: page, imd5:imd5 },
  function(data)
  {
    if(idd != '')
    {
      $("#" + idd).empty();
      $("#" + idd).append(data);

      changeTabContent("latest", "#6ca6c1", "");
      changeTabContent("popular", "#6ca6c1", "");
      changeTabContent("favorite", "#6ca6c1", "");

      if(orderBy=='latest')
      {
        changeTabContent("latest", "#fff000", "act");
        $("#text_latest").html('&nbsp;&nbsp;Latest&nbsp;&nbsp;');
        $("#text_popular").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'popular\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Popular</a>&nbsp;&nbsp;');
        $("#text_favorite").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'favorite\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Favorite</a>&nbsp;&nbsp;');
      }
      else if(orderBy=='popular')
      {
        changeTabContent("popular", "#fff000", "act");
        $("#text_latest").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'latest\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Latest</a>&nbsp;&nbsp;');
        $("#text_popular").html('&nbsp;&nbsp;Popular&nbsp;&nbsp;');
        $("#text_favorite").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'favorite\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Favorite</a>&nbsp;&nbsp;');
      }
      else if(orderBy=='favorite')
      {
        changeTabContent("favorite", "#fff000", "act");
        $("#text_latest").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'latest\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Latest</a>&nbsp;&nbsp;');
        $("#text_popular").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'popular\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Popular</a>&nbsp;&nbsp;');
        $("#text_favorite").html('&nbsp;&nbsp;Favorite&nbsp;&nbsp;');
      }
    }

  }
  );
}

function changeTabContent(type, color, act)
{
  //$("#contentDiv" + type).css("background-color", color);
	if (act == "act")
	{
		$("#contentDiv" + type).attr("class", "tabfilesact");
		$("#contentImgl" + type).attr("src", "/img/file_tab_l.gif");
		$("#contentImgr" + type).attr("src", "/img/file_tab_r.gif");
	}
	else
	{
		$("#contentDiv" + type).attr("class", "tabfiles");
		$("#contentImgl" + type).attr("src", "/img/nav_tab_left.gif");
		$("#contentImgr" + type).attr("src", "/img/nav_tab_right.gif");
	}
}


function showFolders(orderBy, imd5, idd, page)
{
  //el.innerHTML="<DIV class='don' style='padding-left: 120px; '>loading... please wait...</DIV>";
	cname=$("#c_name__").attr("value");

  $("#" + idd).empty();
  //$("#" + idd).append("<DIV class='cfolderview' style='padding-left: 220px;'><img src='/img/line.gif'></DIV><div style='float:left; text-align:right; width:550px; padding-top:136px;'></div><div style='width:550px;'><div style='float:left;'><img src='/img/folder_lb.gif' height='11' width='10' border='0' /></div><div style='float:left;font-size:1px;'></div><div style='float:right;'><img src='/img/folder_rb.gif' height='11' width='10' border='0' /></div></div>");
  $("#" + idd).append("<br><br><br><br><div style='text-align:center; color: #4f5680; font-weight: bold; padding-top:79px;'><img src='/img/line_2.gif'></div><br><br><br><br><br></div>");
  $.post('/community/' +cname,
			{action:'showFolders', sort: orderBy, page: page, imd5:imd5 },
  function(data)
  {
    if(idd != '')
    {
      $("#" + idd).empty();
      $("#" + idd).append(data);

      changeTabFolder("latest", "#6ca6c1", "");
      changeTabFolder("popular", "#6ca6c1", "");
      changeTabFolder("favorite", "#6ca6c1", "");

      if(orderBy=='latest')
      {
        changeTabFolder("latest", "#c5dfee", "_act");
        $("#folder_latest").html('&nbsp;&nbsp;Latest&nbsp;&nbsp;');
        $("#folder_popular").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showFolders( \'popular\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Popular</a>&nbsp;&nbsp;');
        $("#folder_favorite").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showFolders( \'favorite\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Favorite</a>&nbsp;&nbsp;');
      }
      else if(orderBy=='popular')
      {
        changeTabFolder("popular", "#c5dfee", "_act");
        $("#folder_latest").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showFolders( \'latest\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Latest</a>&nbsp;&nbsp;');
        $("#folder_popular").html('&nbsp;&nbsp;Popular&nbsp;&nbsp;');
        $("#folder_favorite").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showFolders( \'favorite\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Favorite</a>&nbsp;&nbsp;');
      }
      else if(orderBy=='favorite')
      {
        changeTabFolder("favorite", "#c5dfee", "_act");
        $("#folder_latest").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showFolders( \'latest\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Latest</a>&nbsp;&nbsp;');
        $("#folder_popular").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showFolders( \'popular\', \''+imd5+'\', \''+idd+'\', \''+page+'\');">Popular</a>&nbsp;&nbsp;');
        $("#folder_favorite").html('&nbsp;&nbsp;Favorite&nbsp;&nbsp;');
      }
    }

  }
  );
}


function changeTabFolder(type, color, act)
{
  $("#folderDiv" + type).css("background-color", color);
  $("#folderImgl" + type).attr("src", "/img/folder_tab_l" + act + ".gif");
  $("#folderImgr" + type).attr("src", "/img/folder_tab_r" + act + ".gif");
}

