/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito@gmail.com )
* http://www.jugbit.com/jquery-vticker-vertical-news-ticker/
*/
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/
var $a = jQuery.noConflict();
function slideSwitch() {
    var $active = $a('#slideshow div.active');

    if ( $active.length == 0 ) $active = $a('#slideshow div:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $a('#slideshow div:first');
	//console.log($next);
    
	// uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$a(function() {
    setInterval( "slideSwitch()", 5000 );
});

var $j = jQuery.noConflict();
$j(function(){
	$j('#tweetwrap').vTicker({ 
		speed: 2000,
		pause: 6000,
		animation: 'fade',
		mousePause: false,
		showItems: 1,
		height:60
	});
	
	$j('#slideshow-intro').vTicker({ 
		speed: 1000,
		pause: 5000,
		animation: 'fade',
		mousePause: false,
		showItems: 1,
		height:100
	});
	$j('#slideshow-intro').css("position", "absolute");
	
	$j('#advertblockwrap').vTicker({ 
		speed: 1000,
		pause: 5000,
		animation: 'fade',
		mousePause: false,
		showItems: 1,
		height:0
	});
	
	

});


(function($j){
$j.fn.vTicker = function(options) {
var defaults = {
speed: 700,
pause: 4000,
showItems: 3,
animation: '',
mousePause: true,
isPaused: false,
direction: 'up',
height: 0
};
var options = $j.extend(defaults, options);
moveUp = function(obj2, height, options){
if(options.isPaused)
return;
var obj = obj2.children('ul');
var clone = obj.children('li:first').clone(true);
if(options.height > 0)
{
height = obj.children('li:first').height();
}
obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
$j(this).children('li:first').remove();
$j(this).css('top', '0px');
});
if(options.animation == 'fade')
{
obj.children('li:first').fadeOut(options.speed);
if(options.height == 0)
{
obj.children('li:eq(' + options.showItems + ')').hide().fadeIn(options.speed).show();
}
}
clone.appendTo(obj);
};
moveDown = function(obj2, height, options){
if(options.isPaused)
return;
var obj = obj2.children('ul');
var clone = obj.children('li:last').clone(true);
if(options.height > 0)
{
height = obj.children('li:first').height();
}
obj.css('top', '-' + height + 'px')
.prepend(clone);
obj.animate({top: 0}, options.speed, function() {
$j(this).children('li:last').remove();
});
if(options.animation == 'fade')
{
if(options.height == 0)
{
obj.children('li:eq(' + options.showItems + ')').fadeOut(options.speed);
}
obj.children('li:first').hide().fadeIn(options.speed).show();
}
};
return this.each(function() {
var obj = $j(this);
var maxHeight = 0;
obj.css({overflow: 'hidden', position: 'relative'})
.children('ul').css({position: 'absolute', margin: 0, padding: 0})
.children('li').css({margin: 0, padding: 0});
if(options.height == 0)
{
obj.children('ul').children('li').each(function(){
if($j(this).height() > maxHeight)
{
maxHeight = $j(this).height();
}
});
obj.children('ul').children('li').each(function(){
$j(this).height(maxHeight);
});
obj.height(maxHeight * options.showItems);
}
else
{
obj.height(options.height);
}
var interval = setInterval(function(){
if(options.direction == 'up')
{
moveUp(obj, maxHeight, options);
}
else
{
moveDown(obj, maxHeight, options);
}
}, options.pause);
if(options.mousePause)
{
obj.bind("mouseenter",function(){
options.isPaused = true;
}).bind("mouseleave",function(){
options.isPaused = false;
});
}
});
};
})($j);




