// This method is used to show the sub nav.
function ShowSubNav(elementID){
	if(document.getElementById(elementID)){
		document.getElementById(elementID).style.display = "block";
		document.getElementById("Item"+elementID).style.height = '150px';
}
}

function HideSubNav(elementID){
	if(document.getElementById(elementID)){
		document.getElementById(elementID).style.display = "none";
		document.getElementById("Item"+elementID).style.height = '25px';
	}
}

// ********************************************************************
//     HOME PAGE ROTATOR
// ********************************************************************
// ARRAY THAT HOLDS THE HOME ROTATOR DATA
var homeHighsIndex = -1;
var homeHighs = new Array();

function StartHomeHighlightRotator(){
	// setup the data
        AddHomeHighObject('images/pictures/homepic_womensmin.png', 'Fall 2010 Women\'s Ministry', 'Empowering women to <br/> think differently about grace <br/> and their roles in ministry!', '../womensmin.pdf', 'Read More &gt;');
	AddHomeHighObject('images/pictures/homepic_corinthclass.png', 'Summer Short Course 2010', 'Exploring closely the <br /> 1 and 2 Corinthian texts in their <br /> historical, social and religious contexts!', '../corinthsyllabus.pdf', 'Read More &gt;');
	AddHomeHighObject('images/pictures/homepic_glen.png', 'Student Working in Montreal', 'Glen is in Montreal, QC! <br/> He is currently full-time with <br /> <a href="http://www.vecoc.org/">Ville-Emard Church of Christ</a>', '../glen.pdf', 'Read More &gt;');

	// start the rotator
	setTimeout("HomeHighlightRotator();", 1);
}

function HomeHighlightRotator(){
	homeHighsIndex ++;
	if(homeHighsIndex >= homeHighs.length)
		homeHighsIndex = 0;

	// replace the content
	if(document.getElementById("HomeHighs")){
		document.getElementById("HomeHighs").style.backgroundImage = homeHighs[homeHighsIndex].GetImage();
		document.getElementById("HomeHighsMsg").innerHTML = homeHighs[homeHighsIndex].GetMessageHTML();
		// start timer to rotate
		setTimeout("HomeHighlightRotator();", 5000);
	}
}


// This method will add a HOMEHIGHOBJECT to the array
function AddHomeHighObject(image, headText, message, linkURL, linkText){
	var homeHigh = new HomeHighObject();
	homeHigh.Load(image, headText, message, linkURL, linkText);
	homeHighs.push(homeHigh);
}

// Object used to represent a HomeHighlight (picture & text)
function HomeHighObject(){
	var image;
	var headText;
	var message;
	var linkURL;
	var linkText;

	// exposed methods
	this.Load = Load;
	this.GetImage = GetImage;
	this.GetMessageHTML = GetMessageHTML;

	function Load(imageIn, headTextIn, messageIn, linkURLIn, linkTextIn) {
		image = imageIn;
		headText = headTextIn;
		message = messageIn;
		linkURL = linkURLIn;
		linkText = linkTextIn;
	}

	function GetImage(){
		return "url('"+image+"')";
	}

	function GetMessageHTML(){
		var uiText = '';
		uiText += '<span class="Head">'+headText+'</span>';
		uiText += '<span class="Text">'+message+'</span>';
		uiText += '<a href="'+linkURL+'">'+linkText+'</a>';
		return uiText;
	}
}
