/*
	Script: portfolio.js

	Copyright: Fishnet NewMedia (c) 2004

	Create: 02.25.04

	Version: 1.0

	Compatibility:

	Functions: none

	Changes: none

	Description:

*/


// object literal/associative array for 
// storing image action/name object pairs
portfolio_preloads = {};


// array for storing category subnavigation ids
portfolio_categories = new Array();


function portfolio_Preview(id,display) {
	// toggles display of record preview
	var elm = document.getElementById(id);
	elm.style.display = display;
}


function portfolio_LoadIMG(file) {
	// creates a new image object and returns object to caller
	var img = new Image();
	img.src = file;
	return img;
}


function portfolio_SwapIMG(name,action){
	// swaps an image based on name and action arguments
	document.images[name].src = portfolio_preloads[name][action].src;
}


function portfolio_Supported(){
	// Parse the navigator object for browser 
	// type and platform for compatibility.
	// Supported browsers include MSIE version 
	// 5+ and Netscape with Gecko version 1+.
	// Return the supported browser's initial.
	
	var useragent = navigator.userAgent;	// user agent string for the current browser.
	var browser = navigator.appName;		// official name of the current browser
	var platform = navigator.platform;		// platform on which the current browser is running
	var product = navigator.product;		// product name of the current browser
	var productsub = navigator.productSub;	// build number of the current browser
	
	if (product == "Gecko" && Number(productsub) > 20020605){
		// supported browser - Netscape
		return "N";
	}
	else if (browser == "Microsoft Internet Explorer" && document.getElementById) {
		if (platform.substring(0,3) == "MacPPC"){
			if(/MSIE ([0-9\.]+)/.test(useragent) && Number(RegExp.$1) >= 5.1){
				 // supported browser - MSIE
				 return "M";
			}
			else{
				 // unsupported browser
				 return "";
			}
		}
		else{
			// supported browser - MSIE
			return "M";
		}
	}
	else {
		// unsupported browser
		return "";
	}
}


function portfolio_ShowNav(evnt) {
	// the argument "evnt" is the event object for the event
	// the event object contains properties that describe a 
	// javascript event, and is passed as an argument to an 
	// event handler when the event occurs
	if (portfolio_Supported() == "M") {
		// create reference to the event actuator object
		actuator = window.event.srcElement;
	}
	else if (portfolio_Supported() == "N") { 
		// create reference to the event actuator object
		actuator = evnt.target;
	}
	// bubble up through each DOM element starting from 
	// actuator element through each ancestors elements
	loop:
	while (actuator){
		// ignore all events from non-category DOM elements
		for (value in portfolio_categories){
			// ignore all none category elements
			if (actuator.className && actuator.className.indexOf(portfolio_categories[value]) != -1){
				if (document.getElementById(portfolio_categories[value])){
					document.getElementById(portfolio_categories[value]).style.display = "block";
				}
				break loop; // exit the "bubble" loop
			}
		}
		actuator = actuator.parentNode;
	}
}


function portfolio_HideNav() {
	for (value in portfolio_categories){
		if (document.getElementById(portfolio_categories[value])){
			document.getElementById(portfolio_categories[value]).style.display = "none";
		}
	}
}


function portfolio_InitEvents() {
	if (portfolio_Supported() == "N"){
		// capture all of the following events
		if (document.captureEvents){
			document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		}
	}
	// initialize event handlers
	document.onmouseover = portfolio_ShowNav;		// show the navigation
	document.onmouseout = portfolio_HideNav;		// hide the navigation
}