//
//  Javascript for Inn at Babson Court menu frame
//  Donald Roby
//

//
// Global Variables
//

var currentPage = -1;
var count = 0;
var menuLoaded = 0;

var menuLow = new Array();
var menuHigh = new Array();
var menuCurrent = new Array();
var menuName = new Array();
var menuAlt = new Array();

menuName[0] = "welcome";
menuName[1] = "history";
menuName[2] = "rooms";
menuName[3] = "rates";
menuName[4] = "amenities";
menuName[5] = "location";
menuName[6] = "cape";
//menuName[7] = "staff";

menuAlt[0] = "Welcome";
menuAlt[1] = "History";
menuAlt[2] = "Rooms";
menuAlt[3] = "Rates";
menuAlt[4] = "Amenities";
menuAlt[5] = "Location";
menuAlt[6] = "About Cape Ann";
//menuAlt[7] = "Staff";

//
//  Determine browser & adjust for
//  javascript & css implementation differences.
//

function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.oldns = (this.ns && (this.major < 5));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
}

var is = new Is();

if(is.ns4) {
    doc = "document";
    sty = "";
    htm = ".document"
    xpos = "e.pageX";
    ypos = "e.pageY";
} else if(is.ie4) {
    doc = "document.all";
    sty = ".style";
    htm = ""
    xpos = "event.x";
    ypos = "event.y";
}

if (is.oldns) {
	location.replace("old/welcome.html");
}

//
//  Load images
//

function loadMenu() {

	for ( i=0; i<menuName.length; i++) {

		menuLow[i] = new Image();
		menuLow[i].src = "images/"+menuName[i]+"-blue.jpg";

		menuHigh[i] = new Image();
		menuHigh[i].src = "images/"+menuName[i]+"-green.jpg";

		menuCurrent[i] = new Image();
		menuCurrent[i].src = "images/"+menuName[i]+"-pink.jpg";

		buttonImg = document.getElementById('button_' + menuName[i]);
		buttonImg.alt = menuAlt[i];
	}

	menuLoaded = 1;
}

function highlightButton(index) {

	if (!menuLoaded) { loadMenu(); }
	if (index != currentPage) {
		buttonImg = document.getElementById('button_' + menuName[index]);
		buttonImg.src = menuHigh[index].src;
	}
	return;
}

function normalButton(index) {

	if (!menuLoaded) { loadMenu(); }
	if (index != currentPage) {
		buttonImg = document.getElementById('button_' + menuName[index]);
		buttonImg.src = menuLow[index].src;
	}
	return;
}

function homeButton(index) {

	if (!menuLoaded) { loadMenu(); }
	buttonImg = document.getElementById('button_' + menuName[index]);
	buttonImg.src = menuCurrent[index].src;
	currentPage = index;
	return;
} 



