jQuery.noConflict();

jQuery(document).ready(function() {
  // jQuery("#Saba").ezBgResize();

  // Set the Round Corners of the Main Menu
  jQuery("#MainMenu li").corner("bottom");

  // Set the menu selected item
  jQuery("h1").each(function() {
    // Add the selected class
    jQuery("#" + this.id + "Link").addClass("selected");
  });

  var sabaImage = jQuery("#Saba");

  function setImagePosition() {
    var windowHeight = getWindowHeight();
    var scrollHeight = jQuery(this).scrollTop();
    var containerHeight = jQuery("#Container").height();
    if (containerHeight > 800) {
      var topPosition;
      if (windowHeight > 800) {
        topPosition = windowHeight - sabaImage.height() + scrollHeight;
      }
      else {
        topPosition = 110 + scrollHeight;
      }

      if (topPosition + sabaImage.height() > containerHeight) {
        topPosition = containerHeight - sabaImage.height();
      }

      sabaImage.css('top', topPosition + "px");
    }
    else {
      sabaImage.css('top', "110px");
    }

  }

  jQuery(window).bind("scroll resize", function() {
    setImagePosition();
  });

  setImagePosition();
  
  // Dependable function to get Window Height
  function getWindowHeight() {
    var windowHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
      windowHeight = window.innerHeight;
    }
    else {
      if (document.documentElement && document.documentElement.clientHeight) {
        windowHeight = document.documentElement.clientHeight;
      }
      else {
        if (document.body && document.body.clientHeight) {
          windowHeight = document.body.clientHeight;
        }
      }
    }
    return windowHeight;
  };

  // Dependable function to get Window Width
  function getWindowWidth() {
    var windowWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
      windowWidth = window.innerWidth;
    }
    else {
      if (document.documentElement && document.documentElement.clientWidth) {
        windowWidth = document.documentElement.clientWidth;
      }
      else {
        if (document.body && document.body.clientWidth) {
          windowWidth = document.body.clientWidth;
        }
      }
    }
    return windowWidth;
  };
});

 

