/*##########################################################################*/
/*	JAVASCRIPT: HOMEPAGE FUNCTIONS
	By: Andrew Gaddis (2009) */
/*##########################################################################*/


/*--------------------------------------------------------------------------*/
function setupHome()
{
	//Hide Pane DIVs
	hide('panetravel');
	hide('panehealth');
	hide('panestudent');
	hide('panelife');
	hide('paneresources');
	//Hide Long/Full Pane Text
	hide('textclickhome');
	hide('textclicktravel');
	hide('textclickhealth');
	hide('textclickstudent');
	hide('textclicklife');
	hide('textclickresources');
	//Set Global Variables
	home_lastpane = 'home';
	home_lastpaneButton = '';
	return false;
}
/*--------------------------------------------------------------------------*/
function viewerHover(type,name,title)
{
	var animTime = 300;
	var nameID = 'pane'+name;
	var homeID = 'panehome';
	var lastID = 'pane'+home_lastpane;
	var lastpbID = 'pane'+home_lastpaneButton;
	//Flip Pane Background
	toggleBackground(name,type);
	//Hide Previous Pane Button
		if (home_lastpaneButton!='') { hide(lastpbID); }
		//$("#"+lastpbID).hide("fast");
	//View Brief Pane Text
		if (type=='over')
		{
			//Notes: hide'lastID', show'nameID'
			$(".pane").stop();
			JQtoggleSlide(lastID,nameID,animTime);
			home_lastpaneButton = name;
		}
		else if (type=='out')
		{
			//Notes: hide'nameID', show'lastID'
			$(".pane").stop();
			JQtoggleSlide(nameID,lastID,animTime);
		}
t("<b>viewerHover</b> type("+type+") name("+nameID+") home("+homeID+") last("+lastID+") lastpane("+home_lastpane+") lastPB("+home_lastpaneButton+")");
t("##########################################################################");
	return false;
}
/*--------------------------------------------------------------------------*/
function viewerClick(name,title)
{
	//Parameters
	var animTime = 300;
	var nameID = 'pane'+name;
	var lastID = 'pane'+home_lastpane;
	var hoverID = 'texthover'+name;
	var lasthoverID = 'texthover'+home_lastpane;
	var clickID = 'textclick'+name;
	var lastclickID = 'textclick'+home_lastpane;
	var linkID = 'link'+name;
	var lastlinkID = 'link'+home_lastpane;
	var instypeID = 'insurancetype';
	//Flip Background
	toggleBackground(name)
	//Switch Link Background
	var linkOBJ = document.getElementById(linkID);
	linkOBJ.style.backgroundImage = "url('/images/design/bgs/home-sidelink-active.jpg')";
	linkOBJ.style.color = '#FFFFFF';
	linkOBJ.style.textAlign = 'right';
	if ((home_lastpane!='home') && (home_lastpane!=name))
	{
		//Remove styling from previous link:
		var lastlinkOBJ = document.getElementById(lastlinkID);
		lastlinkOBJ.style.color = '';
		lastlinkOBJ.style.backgroundImage = '';
		lastlinkOBJ.style.textAlign = '';
	}
	home_lastlink = name;
	//Show & Hide DIVs
		//$("#"+lastID).hide("slow");
		//$("#"+nameID).show("slow");
		hide(lastID);
		show(nameID);
	//Hide Short Text, Reveal Long Text
		//JQtoggleSlide(hoverID,clickID,animTime);
		//???$("#"+hoverID).hide("slow");
		//???$("#"+clickID).show("slow");
		hide(hoverID);
		//show(clickID);
		$("#"+clickID).slideDown(animTime);
	//Switch Insurance Type in Border
	var linktextVAR = 'home_linktitle_'+name;
	var linktext = window[linktextVAR];
	var instypeOBJ = document.getElementById(instypeID);
	instypeOBJ.innerHTML = linktext;
	//Reset Short/Long Text for Last Click
	if (home_lastpane!=name)
	{
		//$("#"+lastclickID).hide("slow");
		//$("#"+lasthoverID).show("slow");
		hide(lastclickID);
		show(lasthoverID);
	}
	//Reset Parameters
	home_lastpane = name;
	return false;
}
/*##########################################################################*/
function toggleBackground(name,type)
{
	var imgID = 'bgIMG';
	var imgOBJ = document.getElementById(imgID);
	if (type=='over')
	{
		var newimg = 'home_img_'+name;
		var imgurl = window[newimg];
		imgOBJ.src = imgurl;
	}
	else if (type=='out')
	{
		var lastimg = 'home_img_'+home_lastpane;
		var lasturl = window[lastimg];
		imgOBJ.src = lasturl;
	}
}
/*##########################################################################*/
function home_highlights_reset()
{
	//PURPOSE: Forces hide of all items.
	home_highlights_stop();
	window.highlights_current = null;
	clearInterval(window.highlights_cron);
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_stop()
{
	//PURPOSE: Stops animation on all objects.
	$('#highlights_preview1').stop.hide();
	$('#highlights_preview2').stop.hide();
	$('#highlights_preview3').stop.hide();
	$('#highlights_preview4').stop.hide();
	$('#highlights_preview5').stop.hide();
	$('#highlights_title1').stop.hide();
	$('#highlights_title2').stop.hide();
	$('#highlights_title3').stop.hide();
	$('#highlights_title4').stop.hide();
	$('#highlights_title5').stop.hide();
	$('#highlights_banner1').stop.hide();
	$('#highlights_banner2').stop.hide();
	$('#highlights_banner3').stop.hide();
	$('#highlights_banner4').stop.hide();
	$('#highlights_banner5').stop.hide();
	$('#highlights_icon1').removeClass("selected");
	$('#highlights_icon2').removeClass("selected");
	$('#highlights_icon3').removeClass("selected");
	$('#highlights_icon4').removeClass("selected");
	$('#highlights_icon5').removeClass("selected");
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_setup()
{
	//PURPOSE: Initializes startup of highlights.
	window.highlights_timer = ((10)*1000);
	window.highlights_max = (5);
	window.highlights_current = null;
	window.highlights_timeout = null;
	window.highlights_clicked = false;
	if (window.highlights_current==null) { window.highlights_current = 1; }
	home_highlights_select(window.highlights_current);
	window.highlights_cron = setInterval("home_highlights_rotate();",window.highlights_timer);
	//Bind Hovers
	$('#highlights').hover(function () { home_highlights_pause(); },function () { home_highlights_resume(); });
	$('#highlights_icon1 a').hover(function () { home_highlights_preview(1); },function () { home_highlights_unpreview(1); });
	$('#highlights_icon2 a').hover(function () { home_highlights_preview(2); },function () { home_highlights_unpreview(2); });
	$('#highlights_icon3 a').hover(function () { home_highlights_preview(3); },function () { home_highlights_unpreview(3); });
	$('#highlights_icon4 a').hover(function () { home_highlights_preview(4); },function () { home_highlights_unpreview(4); });
	$('#highlights_icon5 a').hover(function () { home_highlights_preview(5); },function () { home_highlights_unpreview(5); });
	//Bind Clicks
	$('#highlights_icon1 a').click(function (event) { home_highlights_clicked(1); event.preventDefault(); });
	$('#highlights_icon2 a').click(function (event) { home_highlights_clicked(2); event.preventDefault(); });
	$('#highlights_icon3 a').click(function (event) { home_highlights_clicked(3); event.preventDefault(); });
	$('#highlights_icon4 a').click(function (event) { home_highlights_clicked(4); event.preventDefault(); });
	$('#highlights_icon5 a').click(function (event) { home_highlights_clicked(5); event.preventDefault(); });
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_select(item)
{
	//PURPOSE: Will manually select a given item.
	$('#highlights_title'+item).stop(true,true).fadeIn(1000);
	$('#highlights_banner'+item).stop(true,true).fadeIn(1000);
	$('#highlights_preview'+item).stop(true,true).show(500);
	$('#highlights_icon'+item+' a').addClass('selected');
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_deselect(item)
{
	//PURPOSE: Will manually deselect a given item.
	$('#highlights_title'+item).stop(true,true).hide();
	$('#highlights_banner'+item).stop(true,true).hide();
	$('#highlights_preview'+item).stop(true,true).hide();
	$('#highlights_icon'+item+' a').removeClass('selected');
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_switch(previous,current)
{
	//PURPOSE: Deselects previous and transitions to showing current.
	home_highlights_deselect(previous);
	home_highlights_select(current);
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_rotate()
{
	//PURPOSE: This is called periodically to rotate to next item.
	var current = window.highlights_current;
	var max = window.highlights_max;
	var use = (current+1);
	if (use>max) { use = (1); }
	home_highlights_switch(current,use);
	window.highlights_current = use;
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_pause()
{
	//PURPOSE: Pauses animation/rotation of highlights.
	clearInterval(window.highlights_cron);
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_resume()
{
	//PURPOSE: Resumes animation/rotation of highlights.
	var clicked = window.highlights_clicked;
	if (clicked==false)
	{
		window.highlights_cron = setInterval("home_highlights_rotate();",window.highlights_timer);
	}
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_preview(item)
{
	//PURPOSE: Called when visitor hovers over icon.
	var current = window.highlights_current;
	if (current==item) { /*do-nothing*/ }
	else
	{
		home_highlights_deselect(current);
		home_highlights_select(item);
	}
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_unpreview(item)
{
	//PURPOSE: Called when visitor hovers off of icon.
	var current = window.highlights_current;
	var clicked = window.highlights_clicked;
	if ((clicked==true) && (item==current)) { /*do-nothing*/ }
	else
	{
		home_highlights_deselect(item);
		home_highlights_select(current);
	}
	return false;
}
/*--------------------------------------------------------------------------*/
function home_highlights_clicked(item)
{
	//PURPOSE: Called when item is clicked.
	window.highlights_clicked = true;
	window.highlights_current = item;
	//Set Redirect
	var link = window.highlights_links[item];
	$('#home_highlights_clickedmemo').show('slow');
	setTimeout("window.location = '"+link+"';",4000);
	return false;
}
/*##########################################################################*/
