function listGalleries(site_id) {

  $("galleries").style.display = "block";

  var url = '?';
  var pars = "CoMeT_function=run_module&module=ModProjects&function=list_projects&my_site_id=" + site_id;

  var myAjax = new Ajax.Request(
    url,
    {
      method: 'post',
      postBody: pars,
      encoding: 'ISO-8859-1',
      onComplete: listGalleriesResponse
    });
}

function listGalleriesResponse(resp) {
  $('galleries_list').innerHTML = resp.responseText;
}


function hideGalleries() {
  $("galleries").style.display = 'none';
}




function renderProject(project_id) {

  $("galleries").style.display = "block";

  var url = '?';
  var pars = "CoMeT_function=run_module&module=ModProjects&function=render_project&project_id=" + project_id;

  var myAjax = new Ajax.Request(
    url,
    {
      method: 'post',
      postBody: pars,
      encoding: 'ISO-8859-1',
      onComplete: renderProjectResponse
    });
}

function renderProjectResponse(resp) {
  $('projects_inner').innerHTML = resp.responseText;
}




var img_top;

function renderProjectImage(project_id, image_id, this_div) {

  img_top = this_div.offsetTop;
  var url = '?';
  var pars = "CoMeT_function=run_module&module=ModProjects&function=render_project_image&project_id=" + project_id + "&image_id=" + image_id;

  var myAjax = new Ajax.Request(
    url,
    {
      method: 'post',
      postBody: pars,
      encoding: 'ISO-8859-1',
      onComplete: renderProjectImageResponse
    });
}

function renderProjectImageResponse(resp) {

  $('project_image_container').innerHTML = resp.responseText;
  $("project_image_container").style.visibility = "hidden";
  $("project_image_container").style.display = "block";
  var imgw = $('project_image_container').clientWidth;
  //var parentw = $('project').clientWidth;
  var parentw = 860;
  $('project_image_container').style.marginTop = img_top + "px";
  $('project_image_container').style.left = parseInt(parentw/2 - imgw/2) + "px";
  $("project_image_container").style.visibility = "visible";
}


function hideProjectImage() {
  $("project_image").style.display = 'none';
}
