
jQuery(function($) {

  
  /* Added some stuff - Jed */
  /* Sidebar clickable sign up. */
  if($('.btn-signup').length) {
    $('.btn-signup').click(function() {
      if($.browser.mozilla) {
       $.fancybox({width: 580, height: 514, href: 'http://tools.euroland.com/Clienttools/InvestorTools/RNSSubscription/EmailAlertService.aspx?cid=51437', type: 'iframe'});  
      } else {
        $.fancybox({width: 580, height: 508, href: 'http://tools.euroland.com/Clienttools/InvestorTools/RNSSubscription/EmailAlertService.aspx?cid=51437', type: 'iframe'}); 
      }
     
     //$(this).parent().fadeOut('fast');
     return false;
    }); 
  }
  /* Board loop out fix. */
  if($('li.board-entry').length > 0) {
   $('li.board-entry:nth-child(4)').addClass('last'); 
  }
  $('.field, textarea').focus(function() {
        if(this.title==this.value) {
            this.value = '';
        }
    }).blur(function(){
        if(this.value=='') {
            this.value = this.title;
        }
    });

    $('#navigation li').hover(
      function() {
        $(this)
          .find('a:eq(0)').addClass('hover')
          .end()
          .find('.dd:eq(0)').stop(true,true).fadeIn();
      },
      function() {
        $(this)
          .find('a:eq(0)').removeClass('hover')
          .end()
          .find('.dd:eq(0)').stop(true,true).fadeOut();
      }
    );

    $('.notification-bar .btn-close').click(function() {
        $(this).parent().fadeOut();
    });

    $(window).load(function(){
        if(($.browser.msie && $.browser.version > 8) || !$.browser.msie) {
            imgGrayScale('.widget-img');
        }
    });

    $('.tabs-head li a').click(function() {
        var href = $(this).attr('href');
        $(this).parents('.tabs-head:eq(0)').find('a.active').removeClass('active');
        $(this).addClass('active');
        $(this).parents('.tabs-head:eq(0)').next('.tabs-body').find('.tab').hide();
        $(href).fadeIn();

        return false;
    });


    if ($('#press-releases .scrollable-content').length) {
        $("#press-releases .scrollable-content ul").jcarousel({
            vertical: true,
            scroll: 1,
            initCallback: mycarousel2_initCallback,
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    };
    if ($('#latest-videos .videos-scroller').length) {
        $("#latest-videos .videos-scroller ul").jcarousel({
            vertical: true,
            scroll: 1,
            initCallback: mycarousel3_initCallback,
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    };
    if ($('.projects-scroller').length) {
        $(".projects-scroller ul").jcarousel({
            vertical: true,
            scroll: 1,
            initCallback: mycarousel4_initCallback,
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    };
    $('a.fancybox').fancybox({
        transitionIn: 'elastic',
        transitionOut: 'elastic',
        speedIn: 200,
        speedOut: 20
    });
    $('.video-link').fancybox({
        transitionIn: 'elastic',
        transitionOut: 'elastic',
        speedIn: 200,
        speedOut: 200,
        width: 560,
        height: 345,
        padding: 0,
        type: 'swf',
        swf: {'allowfullscreen':'true', 'wmode':'transparent'}
    });

    $('.cnt-tabs-head li a').click(function() {
        var $this = $(this),
            href = $(this).attr('href'),
            url = $(this).attr('rel');

            $this.parents('.cnt-tabs-head').find('a.active').removeClass('active');
            $this.addClass('active');
            $this.parents('.cnt-tabs-head').next('.cnt-tabs-body').find('.tab:visible').hide();
            $(href).fadeIn();

        return false;
    });

    $('.history-tabs-head li a').click(function() {
        var $this = $(this),
            href = $(this).attr('href');
        //    url = $(this).attr('rel');
        var t = $(this);
        $($('.history-tabs-head a.active').attr('href')).fadeOut('slow', function() {
            $('.history-tabs-head').find('a.active').removeClass('active');
            $(t).addClass('active');
            $(href).fadeIn();
        });

        return false;
    });


   $( "input.datepicker" ).datepicker({
        showOn: "button",
         dateFormat: "dd/mm/yy",
        buttonImage: "/images/icon-calendar.png",
        buttonImageOnly: true
    });

    $('.video-entry a.video-overlay').click(function() {
        $(this).fadeOut().next().show();
        return false;
    });


});

function mycarousel0_initCallback(carousel) {
    $('#home-rns-news .scrollable-controls a.arrow-up').click(function() {
        carousel.prev();
        return false;
    });
    
    $('#home-rns-news .scrollable-controls a.arrow-down').click(function() {
        carousel.next();
        return false;
    });
    
};

function mycarousel1_initCallback(carousel) {
    $('#rns-news .scrollable-controls a.arrow-up').click(function() {
        carousel.prev();
        return false;
    });
    
    $('#rns-news  .scrollable-controls a.arrow-down').click(function() {
        carousel.next();
        return false;
    });
    
};

function mycarousel2_initCallback(carousel) {
    $('#press-releases .scrollable-controls a.arrow-up').click(function() {
        carousel.prev();
        return false;
    });
    
    $('#press-releases .scrollable-controls a.arrow-down').click(function() {
        carousel.next();
        return false;
    });
    
};

function mycarousel3_initCallback(carousel) {
    $('#latest-videos .videos-scroller-controls a.arrow-up').click(function() {
        carousel.prev();
        return false;
    });
    
    $('#latest-videos .videos-scroller-controls a.arrow-down').click(function() {
        carousel.next();
        return false;
    });
    
};


function mycarousel4_initCallback(carousel) {
    $('.projects-scroller .scroller-controls a.arrow-up').click(function() {
        carousel.prev();
        return false;
    });
    
    $('.projects-scroller .scroller-controls a.arrow-down').click(function() {
        carousel.next();
        return false;
    });
    
};


