//
// MM_HotSpot.js
//
// Copyright (C) 2001-2007 Mixtur Interactive, Inc. All rights reserved.
// http://www.mixtur.com, 1-866-268-3994. Unlicensed use is prohibited.
//
// Mark Eissler, mark@mixtur.com
//
// $Id: MM_HotSpot.js,v 1.2 2007/01/03 23:47:19 mark Exp $
//

/*
 IMPORTANT:  This Mixtur software is supplied to you by Mixtur Interactive, Inc. ("Mixtur")
 in consideration of your agreement to the following terms, and your use, installation, 
 or modification of this Mixtur software constitutes acceptance of these terms.  If you do
 not agree with these terms, please do not use, install, or modify this Mixtur software.
 
 In consideration of your agreement to abide by the following terms, and subject to these 
 terms, Mixtur grants you a personal, non-exclusive license, under MixturÕs copyrights in 
 this original Mixtur software (the "Mixtur Software"), to use, reproduce and modify the
 Mixtur Software.
 
 IMPORTANT:  THIS AGREEMENT DOES NOT PROVIDE FOR NOR DOES IT ALLOW REDISTRIBUTION OF THIS
 MIXTUR SOFTWARE. YOU MAY NOT REDISTRIBUTE THIS SOFTWARE WITH OR WITHOUT MODIFICATIONS.

 Neither the name, trademarks, service marks or logos of Mixtur Interactive, Inc. may be 
 used to endorse or promote products derived from the Mixtur Software without specific 
 prior written permission from Mixtur. Except as expressly stated in this notice, no other
 rights or licenses, express or implied, are granted by Mixtur herein, including but not
 limited to any patent rights that may be infringed by your derivative works or by other
 works in which the Mixtur Software may be incorporated.
 
 The Mixtur Software is provided by Mixtur on an "AS IS" basis.  MIXTUR MAKES NO WARRANTIES, 
 EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, 
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE MIXTUR SOFTWARE OR ITS 
 USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
 
 IN NO EVENT SHALL MIXTUR BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL 
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, 
 REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE MIXTUR SOFTWARE, HOWEVER CAUSED AND 
 WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR 
 OTHERWISE, EVEN IF MIXTUR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// global vars
var hs_array = new Array(10);	// a global array of hotSpot_items

// location of the root folder relative to the page that invokes this
// script.
//
// Note: this var is set with navInit().
var path_root;

// location of images relative to the page that invokes this script
// Note: this var is set with hotSpotInit().
var path_img;



// hotSpot_Item
//
// Create an an object with the on and off graphics, url (link) and other
// stuff needed to support a hot spot item for onMouseOver and onMouseOut
// src graphic manipulations.
//
// Note: This is similar to nav_item but we don't care about state because
// we will never turn these items off (to disable them). 
//
function hotSpot_item(name, link, w, h) {
	this.iName = name;
	this.iLink = link;
	this.iH = h;	// height in pixels
	this.iW = w;	// width in pixels
	this.iOn = new Image(w, h);
	this.iOff = new Image(w, h);
	
	this.iOn.src = eval('"' + path_img + 'hs_' + name + '_on.png"');
	this.iOff.src = eval('"' + path_img + 'hs_' + name + '_off.png"');
	
}

// hotSpotInit()
//
// Initialize the path_img variable so that it points at the url for images
// relative to the page that the function was called from.
//
// Note: This function must be called before any other function in here.
//
function hotSpotInit(root_path, image_path) {

	// set the root folder
	path_root = root_path;
	
	// set the path
	path_img = image_path;
	
	return;
}



// hs_swapOn()
//
// Swap the "on" image into the name image's src.
//
function hs_swapOn(name) {

	// find the correct image in the hs_array
	for (var i in hs_array) {
		if(hs_array[i].iName == name) {
		
			document[name].src = hs_array[i].iOn.src;

		}	
	}


}


// hs_swapOff()
//
// Swap the "off" image into the name image's src.
//
function hs_swapOff(name) {


	// find the correct image in the hs_array
	for (var i in hs_array) {
		if(hs_array[i].iName == name) {
		
			document[name].src = hs_array[i].iOff.src;

		}	
	}

}


// hotSpotAdd()
//
// Create a hotSpot item for the parameters specified. Then add the item
// to the hs_array.
//
// You would call this function after hotSpotInit() in the HEAD section of
// a web page. Then you would place the item later on in the page using the
// hotSpotPlace() function and specifying whatever you passed for the "name"
// parameter.
//
function hotSpotAdd(name, link, h, w) {

	// make a new hotSpot_item
	var theHSItem = new hotSpot_item(name, link, h, w);

    // add it to the hs_array
    hs_array.push(theHSItem);
    
    return;
}


// hotSpotPlace()
//
// This function places a hotSpot graphic that has been preloaded into 
// the hs_array (hotSpot array) defined in the global variables.
//
// Note: the hotSpotMake() function is more flexible as we don't have to
// predefine an array in here.
//
function hotSpotPlace(name) {

	for (var i in hs_array) {
		if(hs_array[i].iName == name) {
		
			// 
			// write out the anchor tag
			//
			
			// write the onMouseOver part
			document.write('<a href="' + hs_array[i].iLink + '" onMouseOver="hs_swapOn(\'' + hs_array[i].iName + '\'); return true;" ');
			
			// write the onMouseOut part
			document.write('" onMouseOut="hs_swapOff(\'' + hs_array[i].iName + '\'); return true;" >');
		
			// write the image tag
			document.write('<img src="' + hs_array[i].iOff.src + '" border="0" name="' + hs_array[i].iName + '"></a>');

		}	
	}

	return;
}


// hotSpotMake
//
// Create a new hotspot item and insert all of the code into the sheet.
// This just saves us the hassle of having to write out all of those
// onMouseOver/onMouseOut statements along with name tags.
//
// Whenever a call is made to this function, the on and off images will
// be preloaded.
//
function hotSpotMake(name, link, h, w) {

	// make a new hotSpot_item
	var theHSItem = new hotSpot_item(name, link, h, w);
	
	
	// 
	// write out the anchor tag
	//
	
	// write the onMouseOver part
	document.write('<a href="' + theHSItem.iLink + '" onMouseOver="document.' + name + '.src=\'' + theHSItem.iOn.src + '\';" ');
	
	// write the onMouseOut part
	document.write('" onMouseOut="document.' + name + '.src=\'' + theHSItem.iOff.src + '\';" >');

	// write the image tag
	document.write('<img src="' + theHSItem.iOff.src + '" border="0" name="' + name + '"></a>');
	
	return;
}

