var move_obj;
var citeShowSpeed = 700;

var showCites = function()
{
		var current = $('div.quote_holder div').index($('div.quote_holder div.current')[0]);
		var next = (current+1) % $('div.quote_holder div').size();
		$('div.quote_holder div.current').removeClass('current').animate({opacity:0},citeShowSpeed, 
			function(){
				$($('div.quote_holder div')[next]).addClass('current').animate({opacity:1},citeShowSpeed);
			});
}

$(document).ready(function(){
	if($('a.hide_show').get(0))
	{
		$('a.hide_show').toggle(
			function(){
				if( !$(this).is('.unit_one') )
				{
				    $(this).addClass('active');
    				$(this).html('hide');
    			}
				$(this).parent().next().slideDown(500);
				return false;
			},
			function(){
				if( !$(this).is('.unit_one') )
				{
    				$(this).removeClass('active');
    			}
				var scrollto = $(this).parent().next().height()+20;
				move_obj = $(this).parent().next();
				if(($(document).height() - $(this).parent().next().height()) < $(document).scrollTop()+$(window).height())
				{
					$(document).scrollTo('-='+scrollto,300);
					setTimeout("move_obj.slideUp(500);",300);
				}
				else
				{
					$(this).parent().next().slideUp(500);
				}
				if( !$(this).is('.unit_one') )
    				$(this).html('show');
				return false;
			}
		)	
	}
	if($('a.toggler').get(0))
	{
		$('a.toggler').toggle(
			function(){
				$(this).parent().addClass('active');
				$(this).next('div').slideDown(500);
			},
			function(){
				$(this).parent().removeClass('active');
				var scrollto = $(this).next('div').height()+20;
				move_obj = $(this).next('div');
				if(($(document).height() - $(this).next('div').height()) < $(document).scrollTop()+$(window).height())
				{
					$(document).scrollTo('-='+scrollto,300);
					setTimeout("move_obj.slideUp(500);",300);
				}
				else
				{
					$(this).next('div').slideUp(500);
				}
			}
		)	
	}
	/*
	if($('div.green-box').attr('tagName')){
		$('div.callout a.btn-survey').click(function(){
			$(this).parent().addClass('hidden');
			$(this).parent().next().removeClass('hidden');
		})
	}
	*/
	
	$('div.quote_holder div').css({'opacity':0,'display':'block'});
	$('div.quote_holder div.current').css('opacity',1);
	
	setInterval("showCites()",6000);	
})