var totalInsight;
var currentInsight = 1;
var  disableButtons = false;


function insightNext()
{
	if(!disableButtons)
	{
	nextInsight();
	}
	}


function insightPrevious()
{
		if(!disableButtons)
		{
		previousInsight();
		}
}
	
	
function getTotalInsight()
{
    totalInsight = $("[id^='insight']").length;
}

//function doPlay()
//{
       
        
   // setTimeout("nextQuote();doPlay();",5000);    
              
//}

function nextInsight()
{
    disableButtons = true;
	slideInsightOut(currentInsight);
    moveCurrentInsight();
    setTimeout("slideInsightIn()", 200);
       
}

function previousInsight()
{
    disableButtons = true;
	slideInsightOut(currentInsight);
    moveCurrentBack();
    setTimeout("slideInsightIn()", 200);
       
}


function slideInsightOut(id)
{
	$("#insight"+currentInsight).animate({opacity:"0"},200);
	
	$("#insight"+currentInsight).addClass("low");
	$("#insight"+currentInsight).removeClass("high");
	
	setTimeout("disableButtons = false;", 300);
}

function slideInsightIn()
{
	$("#insight"+currentInsight).animate({opacity:"1"},200);
	
	$("#insight"+currentInsight).addClass("high");
	$("#insight"+currentInsight).removeClass("low");
	
	setTimeout("disableButtons = false;", 300);
}



function moveCurrentBack()
{
    if(currentInsight  == 1)
    {
        currentInsight = totalInsight;
    }
    else{
    currentInsight--;
    }

}



function moveCurrentInsight()
{
    if(currentInsight  == totalInsight)
    {
        currentInsight =1;
    }
    else{
    currentInsight++;
    }

}


$(document).ready(function(){



getTotalInsight();

$(".insightArticle >[id^='insight']").animate({opacity:"0"},1);

$("#insight1").animate({opacity:"1"},1);
$("#insight1").addClass("high");



if(totalInsight > 1)
{
	totalInsight= totalInsight-1;
}


 });


