cdm.api.Home = cdm.api.Home ? cdm.api.Home : {};
cdm.api.Home.getImageCarouselError = $("#cdm_language_error_herewasaproblemretrievingtheimages").val();

//url:  "ajax/cdm_api.php",
cdm.api.Home.getImageCarousel = function(collection){
  $.ajax({
    type: "GET",
    url:  "/utils/getimagecarousel/collection/"+collection,
    dataType: "html",

    success: function (msg) {
      if(msg != "failure") {
        $("#imageCarousel_"+collection).html(msg);
        $(".cdm-carousel-home-"+collection).jcarousel({
          scroll: 1,
          visible: 3
        });
      } else {
        $("#imageCarousel_"+collection).html("");
        cdm.util.ajaxErrorAlerts(cdm.api.Home.getImageCarouselError,"","","");
      }
    },
    error: function (a, b, c) {
      $("#imageCarousel_"+collection).html();
      cdm.util.ajaxErrorAlerts(cdm.api.Home.getImageCarouselError,a, b, c);
    }
  });
  //$("#imageCarousel_"+collection).show();
}

cdm.api.Home.init = function(){
  for(c=0;c<carouselCount;c++){
    cdm.api.Home.getImageCarousel(collectionCarousels[c]);
  }
}
$(document).ready(function() {
  if($("#cdm_language_error_failedtoretrieveimages").exists()){
    cdm.api.Home.getImageCarouselError = $("#cdm_language_error_failedtoretrieveimages").val();
  }
  cdm.api.Home.init();
});
