$(document).ready( function() {
    
    //header logo
    $('#headerLogo').click(function () 
	{
        //hide clicked minislide, display associated slide
        document.location = langRoot;
    });
    
    //init main menu
    initMainMenu(); 
    
    $('#mainMenu').mouseleave(function () 
	{
        hideMainMenuItems();
    });
    
        
    //header slideshow
    initSlideShow(null);
    $('.o_minislide').mouseenter(function () 
	{
        //animate selected minislide
        animateMiniSlide( $(this) );
    });
    $('.o_minislide').click(function () 
	{
        //hide clicked minislide, display associated slide
        switchMiniSlide( $(this), true );
    });
    $('#minislides').mouseleave(function () 
	{
        resetAllMiniSlides();
    });
    
    //init top menu
    initTopMenu(); 
    
    $('#topMenu').mouseleave(function () 
	{
        hideTopMenuItems();
    });
        
    
    //forms: set focus to highlighted error input
    if( formErrorsExist ) 
    {
        $('form .inputError').focus();
    }    
    
    //forms: reset styles for highlighted error inputs
    $( 'form .inputError' ).click( function() {
        $('form .inputError').removeClass( 'inputError' );
    });
    $( 'form .inputError' ).change( function() {
        $('form .inputError').removeClass( 'inputError' );
    });
    
    //forms: submit form when enter key is pressed in text inputs
    $('input').keydown( function(e) {
        if( e.keyCode == 13 ) {
            $(this).parents('form').submit();
            return false;    
        }
    });
    
    //set home highlights background
    
    if( $('#highlightArticle').length != 0 )
    {
        var theHeight = $( '#highlightArticle div.articleBody' ).height();
        
        if( theHeight < 100 ){
            $( '#homeHighlights' ).css( { 'background-image': 'url(' + tpath + 'images/bg_highlights_small.png)' } );
        }else {
            $( '#homeHighlights' ).css( { 'background-image': 'url(' + tpath + 'images/bg_highlights_medium.png)' } );
        }
    }
    
    // apply custom controls ( select ) styling
    if( $('select.customized').length > 0 )
        $('select.customized').customSelect();
    
    // overlay window close action    
    $( '.oClose' ).click( function() {
        //$( '#overlayWindow .updatedContent' ).html('');
        $( '#overlayWindow, #overlay, #oIframe' ).hide();
    });

	$('img#legacyImg').mouseenter(function() {
      $(this).animate({
        opacity: 0.85,
      }, 100, function() {}
      );
    });

    $('img#legacyImg').mouseleave(function() {
      $(this).animate({
        opacity: 1,
      }, 100, function() {}
      );
    });
    
});	
