//**************************************************************************************
//
// Global Rollover Script - v1.0
//
// Copyright 2001, Pedro Ribeiro <m42@clix.pt>. Licensed under GPL - GNU General Public
// License, version 2.0 or above. You can get a copy of GPL at www.gnu.org
//
//**************************************************************************************
//
// This code was inspired by the book: "Voodoo's introducion to JavaScript" by Stefan
// Koch (skoch@rumms.uni-mannheim.de).
//
//**************************************************************************************
//
// This code serves two types of rollovers: the "button" type and the "map" type.
// The "button" type uses two images for each button on the page. It gives the 
// traditional rollover efect.
// The "map" type uses several images for each map. 
//
//**************************************************************************************
//
// The preload functions has two parameters. If we're implementing a button type
// rollover, the first parameter is the name of the button and the second is zero.
// If we're setting up a map type rollover, the first parameter is the name of the
// map and the second one is not zero.
//
// First we define some global vars...
//
// Counters for the button type and map type images.
//
numImg = 0 ;
numMap = 0 ;
//
// Image Arrays, for the buttons and for the map.
//
butPict = new Array() ; 
mapPict = new Array() ;
//
// Image prefixes and sufixes, for the buttons and the map:
//
// ps[0] -> On button Prefix 
// ps[1] -> On button Suffix 
// ps[2] -> Off button Prefix 
// ps[3] -> Off button Suffix 
// ps[4] -> Map Prefix 
// ps[5] -> Map Suffix 
ps = new Array(6) ;
//
// Config function. The first parameter is the index and the second is the value.
//
function config(idx, val) {
	ps[idx] = val ;
}
//
// Pre-loading function. It requires two parameters: the name of the image and
// the type. Type should be zero for buttons and non-zero for maps.
//
function preload(nome,ismap) {
	if (ismap==0) {
		butPict[numImg] = new Array(3) ;
		butPict[numImg][0] = new Image() ;
		butPict[numImg][0].src = ps[0] + nome + ps[1] ;
		butPict[numImg][1] = new Image() ;
		butPict[numImg][1].src = ps[2] + nome + ps[3] ;
		butPict[numImg][2] = nome ;
		numImg++ ;
	} else {
		mapPict[numMap] = new Image() ;
		mapPict[numMap].src = ps[4] + nome + ps[5] ;
		numMap++ ;
	}
}
//
// Turns the button on.
//
function on(nome) {
	for(i=0;i<numImg;i++){
		if (nome == butPict[i][2]) {
			document.images[butPict[i][2]].src = butPict[i][0].src ;
		}
	}
}
//
// Turns the button off.
//
function off(nome) {
	for(i=0;i<numImg;i++){
		if (nome == butPict[i][2]) {
			document.images[butPict[i][2]].src = butPict[i][1].src ;
		}
	}
}
//
// Turns the map image. As there are several images, we only need one function.
//
function changeMap(num) {
	document.images["mapa"].src = mapPict[num].src ;
}
