﻿var currentDescription = null;

//class representing a full job description
function JobPresentation(jobID, onload) {
  var presentation = this;
  this.jobID = jobID;
  this.document = null;
  this.setPage = function(n) {
      var i = 0;
      var page = $('Page' + i);

      if (page != null) {
          while (page != null) {
              page.style.display = 'none';
              page = $('Page' + i++);
          }

          $('Page' + n).style.display = 'block';
      }
  }


  //loading from dependent page, use AJAX
  if (jobID != null) {
    //AJAX constructor
    request("/Jobs/Describe/" + jobID, null, function() {
      presentation.document = document.createElement("div");
      presentation.document.innerHTML = arguments[0];
      if (onload != null) {
        onload(presentation);
      }
    });
  //independent page, just need to set the page
  } else {
    this.setPage(0);
  }
}

//When the presentation is fully loaded do this
function PresentationLoaded() {
  //make the slider slide
  $j('#imageSlider').codaSlider({
    dynamicArrows: false,
    dynamicTabs: false,  
    autoSlide: true,
    autoSlideInterval: 200,
    firstPanelToLoad: 1
  });

  //loading on independent page...
  if (currentDescription == null) {
    currentDescription = new JobPresentation();
  }
};