$(document).ready(function(){

    $('.toValidate').validate();
    $('a.thickbox').fancybox({
        'zoomSpeedIn': 300,
        'zoomSpeedOut': 300,
        'overlayShow': true,
        'zoomOpacity': true,
        'overlayOpacity': 0.8
    });
    $('a.fancylink').fancybox({
        'autoDimensions': false,
        'width': 520,
        'height': 420
    });
    $('.SITE .loader').show();
    $('.SITE #line-banner').hide();
    //	$('span#clock').epiclock();
    $(function(){
        $('#clock').epiclock({
            'format': 'j/m/Y G:i:s'
        }) // We define the clock...
.clocks(EC_RUN); // Then start the manager. 
    });
    
	
	function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    
	$('.branch-prev').removeClass('nasconditi');
	$('.branch-next').removeClass('nasconditi');
	
	if (index == 0) {
		$('.branch-prev').removeClass('nasconditi');
		$('.branch-next').removeClass('nasconditi');
		$('.branch-prev').addClass('nasconditi');
	}
	
	if (index == opts.slideCount - 1) {
		$('.branch-prev').removeClass('nasconditi');
		$('.branch-next').removeClass('nasconditi');
		$('.branch-next').addClass('nasconditi');
	}
	
	}
	
    $('.branchs-center-padding').cycle({
        next:'.branch-next',
        prev:'.branch-prev',
		nowrap: 1,
		timeout:0,
		after:onAfter
    });
	
	$('.ViewNewsSection #line-banner .xt-multimediacontents-wrapper').cycle();
	$('.home-news-icon .xt-multimediacontents-wrapper').cycle();

});



$(window).load(function(){

    setTimeout(function(){
        $('.SITE .loader').hide();
    }, 2200);
    setTimeout(function(){
        $('.SITE #line-banner').show();
    }, 2200);
    
    /*
     setTimeout(function() { $('.news-padding').cycle({
     fx: 'fade',
     timeout: 1500,
     speed: 3000
     }); },2100);
     */
    //text-sizer
    
    $(function(){
        $('#font-sizer li').click(function(){
            var ourText = $('div');
            var currFontSize = ourText.css('fontSize');
            var finalNum = parseFloat(currFontSize, 10);
            var stringEnding = currFontSize.slice(-2);
            if (this.id == 'large') {
                finalNum *= 1.2;
            }
            else 
                if (this.id == 'small') {
                    finalNum /= 1.2;
                }
            ourText.css('fontSize', finalNum + stringEnding);
        });
    });
    
    
    var smh = $('.sub-menu').height();
    if (smh >= 252) {
        $('.sub-menu').height(smh);
    }
    $('div.cycle div.xt-content-wrapper div').cycle({
        fx: 'fade',
        timeout: 1500,
        speed: 1500
    });
    $('#OneColumn .left-section').accordion({
        header: 'div.xt-title-wrapper',
        active: false,
        alwaysOpen: false,
        animated: false,
        autoheight: false
    });
    $('#Accordion .left-section').accordion({
        header: 'div.xt-title-wrapper',
        active: false,
        alwaysOpen: false,
        animated: false,
        autoheight: false
    });
    
});

