jQuery.noConflict();
jQuery( document ).ready( function () {

  // if working locally...
  if (jQuery( 'base' ).exists() && jQuery( 'base' ).attr( 'href' ).match( '127.0.0.1' )) {

    var sPath = jQuery( 'base' ).attr( 'href' ).replace( /\/application\/.+\//, '' );

    // prepend absolute links with (abbreviated) local path
    jQuery( 'a[href^=/]' ).each( function () { jQuery( this ).attr( 'href', sPath + jQuery( this ).attr( 'href' ) ); } );

    // prepend form actions with (abbreviated) local path
    jQuery( 'form' ).each( function () {
      if (jQuery( this ).attr( 'action' ).match( /^\// )) { jQuery( this ).attr( 'action', sPath + jQuery( this ).attr( 'action' ) ); }
    } );

  } else {

    // prepend absolute links with (abbreviated) local path
    jQuery( 'a[href^=/]' ).each( function () { jQuery( this ).attr( 'href', jQuery( this ).attr( 'href' ) ); } );
  }

  // if focus... blur
  jQuery( 'a' ).focus( function () { this.blur() } );

  // initialize external links
  jQuery( 'a.external' ).click( function() {
    window.open( jQuery( this ).attr( 'href' ) );
    return false;
  } );

  // initialize image hover
  jQuery( 'dl.header_region a[class!=unlink] img' ).hover(
    function () { jQuery( this ).css( 'opacity', 0.8 ); },
    function () { jQuery( this ).css( 'opacity', 1.0 ); }
  );

  // if carousel...
  if (jQuery( 'div#divCarousel' ).exists) {

    // initialize carousel
    jQuery( 'div.carousel' ).jCarouselLite( {
      auto : 5000,
      auto : 0,
      speed: jQuery( 'div.carousel ul li' ).length > 1 ? 4000 : 0,
      speed: 0,
      easing: 'easeInOutQuint',
      visible : 1
    } );
  }

  // activate lightbox
  jQuery( 'div.asset a' ).lightBox();

} );

/*
 * Custom jQuery methods
 */
jQuery.fn.exists  = function() { return jQuery( this ).length > 0; }

