/*****************************************************************************
 * Filename: main.js                                                         *
 * Language: Javascript                                                      *
 * Purpose:  Provide functions for fading text in and out as well as changing*
 *           the text inside the box between each fade.                      *
 *                                                                           *
 ****************************************************************************/

//Global Variables
//var hex=255, hex2=255; //initial color variable
var hex=255, hex2=204;
var oldR1=99, oldR2=98, oldR3=97, oldR4=96, oldR5=95; //oldRandom values
var oldT=99;
var List = new Array(99), onceThrough=0, popList=0, lCount=0;
var ran=0;

function uniqueID()
{
    var newDate = new Date;
    return newDate.getTime();    
}

function roll_over(img_name, img_src)
{
    document[img_name].src = img_src;
}


function fadeIn(divName)
{ 
	if(hex>0) 
	{ //If color is not black yet
		hex-=10; // increase color darkness
		document.getElementById(divName).style.color="rgb("+hex+","+hex+","+hex+")";
		setTimeout("fadeIn('" + divName + "')", 100); // continue fading in, # miliseconds between each shade
	}
	else
		setTimeout("fadeOut('" + divName + "')", 400); //fade out, # miliseconds before fading out
}

function fadeOut(divName) //Function to fade text from black to white (fade out)
{ 
	if(hex<255) 
	{ //If color is not white yet
		hex+=10; // increase color brightness
		document.getElementById(divName).style.color="rgb("+hex+","+hex+","+hex+")";
		setTimeout("fadeOut('" + divName + "')", 12); 
	}
	else
	{
		setTimeout("changeText('" + divName + "')", 100);//change Text, # miliseconds before changing text
	}
}


function changeText(divName)
{
	var newContent;
	var TopLevel = 6;
	
ran ++;

	switch(ran) //Select text based on random number (0-14)
	{
	   case 1:
	      newContent = "Truthfulness Scale";
	      break;
	   case 2:
	      newContent = "Suicide Scale";
	      break;
	   case 3:
	      newContent = "Depression Scale";
	      break;
	   case 4:
	      newContent = "Alcohol Scale";
	      break;
	   case 5:
	      newContent = "Drugs Scale";
	      break;
	   case 6:
	      newContent = "Stress Coping Scale";
		   ran=0;
	      break;
	   default: //to catch 15 and anything above (should only be 0-14)
	      newContent = "OTHERS"
	      ran=0;
	      break;
	}
	
	document.getElementById(divName).innerHTML=newContent; //Set new content
	fadeIn(divName); //begin fade
}



	









