jQuery.noConflict();

jQuery(document).ready(function() {
  
  // ----- MENU
  
  jQuery('#menu li').hover(
    function() { 
      jQuery('ul', this).css('display', 'block');
    },
    function() { 
      jQuery('ul', this).css('display', 'none');
    }
  );

  /* append a separator after each first or middle item */
  var liMiddle = jQuery("<li></li>").addClass('middle');
  var imgMiddle = jQuery("<img>").attr('src', '/images/layout/sub-middle.png');
  jQuery('.submenu li:not(.last)').after(liMiddle.append(imgMiddle));
  
  /* prepend frame top at the very top */
  var liTop = jQuery("<li></li>").addClass('top');
  jQuery('.submenu li.first').before(liTop);
  
  /* append frame bottom at the very bottom */
  var liBottom = jQuery("<li></li>").addClass('bottom');
  jQuery('.submenu li.last').after(liBottom);
  

  // ----- REVOLVING CAROUSEL TEXTS

  if (typeof advanceText == 'function') {
    // load the collection after jQuery is ready
    textsCollection = jQuery('#dynamicText .text');
    
    // show the first text
    advanceText(); //changed from carouselClick to advanceText MGR - not working changed back.
  
  
  // ----- HOME PAGE BUTTONS
  
    var buttonFadeOutRunning = {};
    var buttonFadeInRunning = {};
    
    jQuery("a.button").hover(
      // mouse over = fade out
      function () {
        var currentId = jQuery(this).attr('id');
        if ((buttonFadeOutRunning[currentId]) && (buttonFadeOutRunning[currentId] == true)) {
          return;
        }
        buttonFadeOutRunning[currentId] = true;
        jQuery(this).prev("div.button").css("color", "black");
        jQuery(this).prev().find("img.stamp").fadeOut(100, function () {
          //jQuery(this).parents().eq(0).css("color", "black");
          buttonFadeOutRunning[currentId] = false;
        });
      }, 
      // mouse out = fade in
      function () {
        var currentId = jQuery(this).attr('id');
        if ((buttonFadeInRunning[currentId]) && (buttonFadeInRunning[currentId] == true)) {
          return;
        }
        buttonFadeInRunning[currentId] = true;
        jQuery(this).prev("div.button").css("color", "#ccc07e");
        jQuery(this).prev().find("img.stamp").fadeIn(450, function () {
          buttonFadeInRunning[currentId] = false;
        });
      }
    );
  }
  
});

// ----- FEATURES - CHANGING PICTURE

function featuresPicture(picPath) {
  jQuery("#featuresPic").attr('src', picPath);
}

function featuresLinkPicture(picPath, linkPath) {
  jQuery("#featuresPic").attr('src', picPath);
  if (linkPath === undefined)
   linkPath = picPath;
  jQuery("#featuresAnchor").attr('href', linkPath);
}