//
// COPYRIGHT NOTICE
// Copyright 2009 Michael L. Benson. All rights reserved.
//
// This script may be used and modified free of charge provided that this
// copyright notice remains intact. By using this code you are agreeing to
// indemnify the author, Michael L. Benson, from any liability which might arise
// from its use.
//
// You may give copies of this script to any third party, but you may not sell
// this script for any reason whatsoever without the prior written consent of
// Michael L. Benson. 
//
// You must obtain prior written consent from Michael L. Benson if you intend to
// redistribute this script over the Internet or via any other medium.
//
// In all cases where this script is given to a third party, this copyright
// notice must remain intact and at the beginning of the script. At all times
// this script remains the property of Michael L. Benson.
//


NUM_MAIN_MENUS = 6;
NUM_SUB_MENUS = 6;

menu_img_on = new Array();
menu_img_off = new Array();
menu_img_here = new Array();

function InitMenus(path)
{
	for (i = 0;  i < NUM_SUB_MENUS;  i++) {
		menu_img_on[i] = new Image();
		menu_img_on[i].src = path + "images/menus/menu" + i + "_on.png";
		menu_img_off[i] = new Image();
		menu_img_off[i].src = path + "images/menus/menu" + i + "_off.png";
		menu_img_here[i] = new Image();
		menu_img_here[i].src = path + "images/menus/menu" + i + "_on.png";
	}
	go_img_on = new Image();
	go_img_on.src = path + "images/go_button_on.gif";
	go_img_off = new Image();
	go_img_off.src = path + "images/go_button_off.gif";
}

function ClearMenus()
{
	for (i = 0;  i < NUM_SUB_MENUS;  i++) {
		divname = "submenu_" + i;
		HideDiv(divname);
	}
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//
// These functions are for the rotating highlights on the home page.
//

var windowTimerFunc;
var highlight_num;
var num_highlights;
var titlestr;
var picturestr;
var urlstr;
var new_windowstr;
var attachmentpath;
var dirpath;

function InitRotation()
{
	windowTimerFunc = window.setInterval("RotateHighlights()", 4000);
}

function PreloadHighlights(h_num_highlights, h_titlestr, h_picturestr, h_urlstr, h_new_windowstr, h_attachmentpath, h_dirpath)
{
	num_highlights = h_num_highlights;
	titlestr = h_titlestr;
	picturestr = h_picturestr;
	urlstr = h_urlstr;
	new_windowstr = h_new_windowstr;
	attachmentpath = h_attachmentpath;
	dirpath = h_dirpath;
	highlight_num = 1;

	var pictures = picturestr.split(",");
	for (i = 0;  i < num_highlights;  i++) {
		img = new Image();
		img.src = "http://" + attachmentpath + pictures[i];
	}
}

function RotateHighlights()
{
	var titles = titlestr.split(",");
	var pictures = picturestr.split(",");
	var urls = urlstr.split(",");
	var new_windows = new_windowstr.split(",");

	if (highlight_num >= num_highlights) { highlight_num = 0; }

	divcontent = "";
	if (num_highlights == 0) {
		divcontent = "<a href=''><img src='" + dirpath + "images/shim.gif' alt='No highlights found!' width='300' height='245' border='0' \/><\/a>";
	} else {
		url = urls[highlight_num];
		new_window = new_windows[highlight_num];
		picture = pictures[highlight_num];
		title = titles[highlight_num];
		divcontent = "<a href='" + url + "' " + new_window + "><img src='http://" + attachmentpath + picture + "' alt='" + title + "' width='300' height='245' border='0' \/><\/a>";
	}
	
	SetDivContent("homepage_col_right", divcontent);
	highlight_num++;
}

