﻿/* CMCL 2010 - main.js */
 
$(function() {  // ACÇÕES QUE VÃO DECORRER DEPOIS DA PÁGINA ESTAR CARREGADA
  //CORRECT MENU HEIGHT
  var maxHeight = 0;
  $("#Menu ul li").each(function() {
    if ($(this).parent().attr("class") != "M1") {
      if (parseInt($(this).height()) > maxHeight)
        maxHeight = parseInt($(this).height());
    }
  });
  $("#Menu ul li").each(function() {
    if ($(this).parent().attr("class") != "M1") {
      $(this).css("height", maxHeight+"px")
    }
  });
  
  // CORRECT RIGHT COLUMN
  $("#RightColumn").css("margin-top","-"+(maxHeight-25)+"px")
  $("#LeftColumn, #CenterColumn").css("float", "left");
});
 
 
 
function CreateGallery(path, SmallHeight, BigWidth, BigHeight) {
  path = path.substring(0,path.lastIndexOf("/"));
  $.ajax({
      url: location.protocol + "//" + location.hostname + "/Files/GetFolderContents.aspx?Path=" + path,
      success: function(data){
        var xml;
        if ($.browser.msie && typeof data == "string") {
          xml = new ActiveXObject("Microsoft.XMLDOM");
          xml.async = false;
          xml.loadXML(data);                
        } else {
           xml = data;
        }
        
        $(xml).find("File").each(function() {
          PathImg=($(this).attr('href'));
          
          $("#NewsImageGallery").append('<div class="ItemGallery"><a href="/admin/public/getimage.aspx?&Image='+PathImg+'&Height='+BigHeight+'&Width='+BigWidth+'&Crop=0"><img src="/admin/public/getimage.aspx?&Image='+PathImg+'&Height='+SmallHeight+'&Crop=0" alt="" border=""/></a></div>');
          $('#NewsImageGallery a').lightBox({fixedNavigation:false});
        });
        $("#ListGallery").append("<div style='clear: both;'></div>")
      }
  });
}
