/*****************************************************************************
 * 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.                      *
 *           Also handles the fading and rotation of the Testimonials.       *
 ****************************************************************************/

//Global Variables
var hex=255, hex2=255; //initial color variable
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;
var List2 = new Array(99), onceThrough=0, popList=0, lCount=0;
var ran2=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 + "')", 1200); //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 + "')", 600);//change Text, # miliseconds before changing text
	}
}


function changeText(divName)
{
	var newContent;
	var TopLevel = 4;

ran ++;

	switch(ran) //Select text based on random number (0-4)
	{
	   case 1:
	      newContent = "Domestic Violence Inventory (DVI)";
	      break;
	   case 2:
	      newContent = "DVI Short Form";
	      break;
	   case 3:
	      newContent = "DVI Juvenile";
	      break;
	   case 4:
	      newContent = "DVI Pre-Post";
	      ran=0;
	      break;	   
	   default: //to catch 5 and anything above (should only be 0-4)
	      newContent = "Domestic Violence Inventory (DVI)"
	      ran=0;
	      break;
	}
	
	document.getElementById(divName).innerHTML=newContent; //Set new content
	fadeIn(divName); //begin fade
}


function fadeIn2(divName2)
{ 
	if(hex>0) 
	{ //If color is not black yet
		hex-=10; // increase color darkness
		document.getElementById(divName2).style.color="rgb("+hex+","+hex+","+hex+")";
		setTimeout("fadeIn2('" + divName2 + "')", 100); // continue fading in, # miliseconds between each shade
	}
	else
		setTimeout("fadeOut2('" + divName2 + "')", 1600); //fade out, # miliseconds before fading out
}

function fadeOut2(divName2) //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(divName2).style.color="rgb("+hex+","+hex+","+hex+")";
		setTimeout("fadeOut2('" + divName2 + "')", 12); 
	}
	else
	{
		setTimeout("changeText2('" + divName2 + "')", 100);//change Text, # miliseconds before changing text
	}
}

function changeText2(divName2)
{
	var newContent2;
	var TopLevel2 = 7;

ran2 ++;

	switch(ran2) //Select text based on random number (0-4)
	{
	   case 1:
	      newContent2 = "Domestic Violence Screening";
	      break;
	   case 2:
	      newContent2 = "Domestic Violence Treatment Effectiveness";
	      break;
	   case 3:
	      newContent2 = "People Accused or Convicted of Domestic Violence";
	      break;
	   case 4:
	      newContent2 = "Adult and/or Juvenile Probation";
	      break;
	   case 5:
	      newContent2 = "Misdemeanor or Felony";
	      break;
	   case 6:
	      newContent2 = "Adult and/or Juvenile Courts";
	      break;
	   case 7:
	      newContent2 = "Domestic Violence Treatment Effectiveness";
	      break;
	   
	   
	   default: //to catch 15 and anything above (should only be 0-14)
	      newContent2 = "People Accused or Convicted of Domestic Violence"
	      ran2=0;
	      break;
	}
	
	document.getElementById(divName2).innerHTML=newContent2; //Set new content
	fadeIn2(divName2); //begin fade
}
