$(window).load(function() {
  	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:700, //Slide transition speed
		pauseTime:6500,
		startSlide:'rand', //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:false, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
});

$(document).ready(function() {    
    $('#alert').bgscroll({scrollSpeed:80 , direction:'h' });
    
    $('marquee').marquee();
    
    $('#news-container').vTicker({
        speed: 500,
        pause: 3000,
        showItems: 2,
        animation: 'fade',
        mousePause: false,
        height: 0,
        direction: 'up'
    });
    
/*
    jwplayer("jpId").setup({
        flashplayer: "/js/player.swf",
        file: "/media/transfer/aud/sound_and_fury_of_the_skies_2.mp3",
        height: 24,
        width: 857,
        controlbar: "bottom",
        autostart: true
    });
*/
});

(function() {
    $.fn.bgscroll = $.fn.bgScroll = function( options ) {
         
        if( !this.length ) return this;
        if( !options ) options = {};
        if( !window.scrollElements ) window.scrollElements = {};
         
        for( var i = 0; i < this.length; i++ ) {
             
            var allowedChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            var randomId = '';
            for( var l = 0; l < 5; l++ ) randomId += allowedChars.charAt( Math.floor( Math.random() * allowedChars.length ) );
             
                this[ i ].current = 0;
                this[ i ].scrollSpeed = options.scrollSpeed ? options.scrollSpeed : 70;
                this[ i ].direction = options.direction ? options.direction : 'h';
                window.scrollElements[ randomId ] = this[ i ];
                 
                eval( 'window[randomId]=function(){var axis=0;var e=window.scrollElements.' + randomId + ';e.current -= 1;if (e.direction == "h") axis = e.current + "px 0";else if (e.direction == "v") axis = "0 " + e.current + "px";else if (e.direction == "d") axis = e.current + "px " + e.current + "px";$( e ).css("background-position", axis);}' );
                                                          
                setInterval( 'window.' + randomId + '()', options.scrollSpeed ? options.scrollSpeed : 70 );
            }
             
            return this;
        }
})(jQuery);
