var $isOn = 1;

$(document).ready(function() {
	$("a[href^='http://']").attr('target','_blank');

    setInterval(startSwap, 4000);
	setInterval(otherSwap, 6000);
	$(".textContainer .newsTitle").click(function() {
		var $next = $(this).next();
		
		if ( !$next.hasClass('current') ) {
			$(".textContainer .newsArticle").removeClass('current').slideUp('slow');
			$next.slideDown('slow').addClass('current');
		}
	});
});

function startSwap() {
    var $active = $('span.headActive');
    var $next = $active.next().length ? $active.next() : $('span.headInactive:first');
    
    $active.animate({opacity: 0.1},1000,function() { 
        $active.addClass('headInactive').removeClass('headActive'); 
        
        $next.css({opacity: 0.1})
            .addClass('headActive')
            .animate({opacity: 0.99}, 1000, function() { });
    });
}

function otherSwap() {
	if ($isOn) {
		$("img.miniLogo").animate({opacity:0.0},1000,function() { });	
		$isOn = 0;
	} else {
		$("img.miniLogo").animate({opacity:0.99},1000,function() { });		
		$isOn = 1;		
	}
}

var quoteList = new Array(
												'&ldquo;For those who were not on the webinar, you missed a good event. The real-time analysis was great, and I am sure glad that Mike didn&rsquo;t use our website as an example of what NOT to do! We are in the process of a total web reconstruction to match our updated business model and the information was good confirmation of what we need to do.&rdquo;<br /><br />- Brad, AMT member',
												'&ldquo;What an awesome job at Open Mike Night! I tell everyone that will listen how much you broadened my social networking horizons. Thanks again!&rdquo;<br /><br />- Manager, Power Utility',
												'&ldquo;I learn something new everytime I hear these guys speak. It&rsquo;s amazing how they stay on top of new trends, but then show you exactly how to use them.&rdquo;<br /><br />- Chamber Director',
												'&ldquo;I also rank this webinar as a winner. In fact, I&rsquo;m hoping to juggle schedules around and attend the next session too. There&rsquo;s so much to learn from these web warriors.&rdquo;<br /><br />- Diane, manufacturing company'
												);
var activeQ1 = -1;
var activeQ2 = -1;
												
$(document).ready( function(){
	if ( $('#quote1').length ) {
		var random = -1;
	
		setInterval(firstQuote, 7500);
		//setInterval(secondQuote, 9300);
		random = Math.floor(Math.random()*4);
		$('#quote1').html( quoteList[random] );
		/*
		random = random + 1 > 3 ? 0 : random + 1;
		$('#quote2').html( quoteList[random] );
		*/
	}
});

function firstQuote(){
	$('#quote1').animate({opacity:0.01},2000, function(){
		$(this).html('');
		
		var random = -1;
	
		while ( random == activeQ1 || random == activeQ2 || quoteList[random] == $(this).html() ) {
			random = Math.floor(Math.random()*4);
		}
	
		activeQ1 = random;
		$('#quote1').html( quoteList[random] ).animate({opacity:1},1500);
	});
}

function secondQuote(){
	$('#quote2').animate({opacity:0.01},2000, function(){
		$(this).html('');
		
		var random = -1;
	
		while ( random == activeQ1 || random == activeQ2 || quoteList[random] == $(this).html() ) {
			random = Math.floor(Math.random()*4);
		}
	
		activeQ1 = random;
		$('#quote2').html( quoteList[random] ).animate({opacity:1},1500);
	});
}
