var Spotlight={

    interval: 2500,
    fadeSpeed: 750,

    init: function(){

        /**$('#spotlight')
        .mouseenter(function(){
            window.clearInterval(Spotlight.timer);
        })
        .mouseleave(function(){
            window.clearInterval(Spotlight.timer);
            Spotlight.timer = window.setInterval('Spotlight.change()', Spotlight.interval);
        });
        **/
        Spotlight.timer = window.setInterval('Spotlight.change()', Spotlight.interval);

    },
    change: function(){

        var currentSpotlight = $('#spotlight div.active');

        if(currentSpotlight.next().length){
            nextSpotlight = currentSpotlight.next();
        }else{
            nextSpotlight = $('#spotlight .spotlight-item').first();
        }

        $(currentSpotlight).fadeOut(Spotlight.fadeTime);

        nextSpotlight.fadeIn(Spotlight.fadeTime, function(){
            currentSpotlight.removeClass('active');
            nextSpotlight.addClass('active');
        });

    }

};

$(document).ready(function() {

    // OPEN LINK IN NEW WINDOW
    $('a.new-window').click(function(){
        window.open(this.href);
        return false;
    });

	// FANCYBOX
	$("a[rel=fancybox], a.fancybox").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'over',
		'overlayOpacity'	: '0.6',
		'overlayColor'		: '#000',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});

    Spotlight.init();

    // RESIZE BOXES ON HOMEPAGE
    var spotlightHeight = $('#page-home .double-col').height();
    if(spotlightHeight != 0){
        //$('#page-home #news-list').css('height',spotlightHeight-30);
    }

    $('#contact-form form').validate();


});
