// Issue dropdown
function onIssueDropdownChange(ddl)
{
	var val = ddl.options[ddl.selectedIndex].value;
	if(val === "") return;
	
	var index = val.indexOf("_");
	if(index == -1) return;
	
	var idType = val.substring(0, index);
	var id = val.substring(index+1);
	
	if(idType == "issue" && id != "orphans")
		location.href = "/healthier_lives/you/"+id+"/";
	else
		location.href = "/healthier_lives/you/article.php?article_id="+id;
}


// You Issue page functions

function prevTip()
{
	// Clear the rotation interval (if playing)
	if(!isPaused)
		clearInterval(timerID);
	
	oldTip = iTip;
	iTip--;
	
	if(iTip <= 0)
		iTip = nTips;
	
	// Hide the old tip; show the new
	DHTMLHelper.elementAddClass(document.getElementById("tip_"+oldTip), "hidden");
	DHTMLHelper.elementRemoveClass(document.getElementById("tip_"+iTip), "hidden");
	
	// Update the "Tip # of #" display
	document.getElementById("current_tip_number").innerHTML = ""+iTip;
	
	// Reinstate the timer (if playing)
	if(!isPaused)
		timerID = setInterval(tipRotateCallback, timerInterval);
}

function nextTip()
{
	// Clear the rotation interval (if playing)
	if(!isPaused)
		clearInterval(timerID);
	
	oldTip = iTip;
	iTip++;
	
	if(iTip > nTips)
		iTip = 1;
	
	// Hide the old tip; show the new
	DHTMLHelper.elementAddClass(document.getElementById("tip_"+oldTip), "hidden");
	DHTMLHelper.elementRemoveClass(document.getElementById("tip_"+iTip), "hidden");
	
	// Update the "Tip # of #" display
	document.getElementById("current_tip_number").innerHTML = ""+iTip;
	
	// Reinstate the timer (if playing)
	if(!isPaused)
		timerID = setInterval(tipRotateCallback, timerInterval);
}

function playPause()
{
	var buttonImgCtrl = document.getElementById("tip_pause_play");
	
	if(isPaused)
	{
		// Time to play
		nextTip();
		timerID = setInterval(tipRotateCallback, timerInterval);
		buttonImgCtrl.src = "/img/healthier_lives/you/tips/buttons/pause_btn.gif";
	}
	else
	{
		// Time to pause
		clearInterval(timerID);
		buttonImgCtrl.src = "/img/healthier_lives/you/tips/buttons/play_btn.gif";
	}
	
	isPaused = !isPaused;
}
					
function tipRotateCallback()
{
	if(isPaused)
		return;
		
	nextTip();
}