//::display questions in javascript:: written by Raj Hungund for Depthstyles (c) 2005


//create selection placedholder
	var currSelection = 0;	
	

//function declaration to shuffle/randomize questions
	shuffle = function(o){
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
//shuffle/randomize questions
	aQuestions = shuffle(aQuestions);	

	
//function to display question
	displayQuestion = function(dir) {
	
		if (dir == 0)
			currSelection--;
		else
			currSelection++;
						
		//displayPrev();
		displayNext();
		
		document.getElementById('divQuestionArea').innerHTML = aQuestions[currSelection];

	}
	
//function declaration to display previous question
	displayPrev = function() {
		if (currSelection > 0)
			document.getElementById('divPrevArea').innerHTML = "<a href='javascript:displayQuestion(0);'> << prev </a>";
		else
			document.getElementById('divPrevArea').innerHTML = '';
	}
		
//function declaration to display next question
	displayNext = function() {		
		if (currSelection < (aQuestions.length -1)) {
			//document.getElementById('divNextArea').innerHTML = "<a href='javascript:displayQuestion(1);'> next >> </a>";
			
			document.getElementById('divNextArea').innerHTML = "<table border='0' width='100%'><tr><td width='13'><img src='/images/arrow.gif' width='13' height='10'></td><td height=50><a href='javascript:displayQuestion(1);'>next</a></td></tr></table>";
		} else { 
			//document.getElementById('divNextArea').innerHTML = '';	
			currSelection = 0;
			displayQuestion(1);
		}
		
	}
	
//initialize function
	init = function() {
		//displayPrev();
		displayNext();
		
		document.getElementById('divQuestionArea').innerHTML = aQuestions[currSelection];
		
		//load up News Story
		//document.getElementById('divNewsStory').innerHTML = document.getElementById('newsItem' + currStory).innerHTML;
		showStory(currStory);
	}

	
	
//CODE SECTION FOR NEWS STORIES
	var numStories = 2;
	var currStory =Math.floor(Math.random()*(numStories +1));
	
	
function showStory(num) {
	currStory = num;
	document.getElementById('divNewsStory').innerHTML = document.getElementById('newsItem' + currStory).innerHTML;
	revertButtons((currStory + 1));
	
	var e = window.event;
	e.cancelBubble = true;
	e.stopPropagation();
	
	
}

function revertButtons(nExcept) {
	for (n=1; n <= (numStories + 1); n++) {
		if (n != nExcept)
			document.getElementById('newsbutton' + n).src = 'images/news_' + n + '.gif';
	}	
	document.getElementById('newsbutton' + nExcept).src = 'images/news_' + nExcept + '_2.gif';
	
	
}

function nextStory() {
	if ((currStory +1)> numStories)
		showStory(0);
	else
		showStory(currStory + 1);
}

function previousStory() {
	if ((currStory -1) < 0)
		showStory(numStories);
	else
		showStory(currStory - 1);
}
	
function pausecomp(millis)
{
date = new Date();
var curDate = null;

do { var curDate = new Date(); }
while(curDate-date < millis);
}

function checkToHighlight(num) {
	if (num = currStory)
		document.getElementById('newsbutton' + (num + 1)).src = 'images/news_' + (num + 1) + '_2.gif';

}

function getMoreInfo() {
	location.href = 'newst' + (currStory + 1) + '.asp';
}
