/*
*	JoshuaStanton.com
*	globals.js
*	Functions used throughout the site.
*
*/

/*********************************************
global variables
**********************************************/
var bName = navigator.appName;				// browser name
var bPlatform = navigator.platform;			// platform
var bVer = parseInt(navigator.appVersion);	// version
var browser = "";							// browser name shorthand
if (document.all) {
	browser="IE";
	if (bPlatform=="MacPPC") {
		bVerStart = navigator.appVersion.indexOf("MSIE")+5;
		bVer = parseInt(navigator.appVersion.substr(bVerStart,5));
	} 
} else if (document.layers) {
	browser="NN";
} else if (document.getElementById) {
	browser="NS6";
	bVerStart = navigator.userAgent.lastIndexOf("/")+1;		
	bVer = parseInt(navigator.userAgent.substr(bVerStart,navigator.userAgent.length));
}

/*********************************************
Functions: general
**********************************************/
/*
 *	General initialization of webpage
 */
function init() {
	return true;
}

/*********************************************
Functions: rollovers
**********************************************/
/*
 *	Apply a rollover effect to the given image
 *	Mouseover will show the onSrc
 *	Mouseout will show the current src
 *	Apply this script onload -- i.e. 
 *	(c) 2006 BoogieScripts.com - MIT style license
 */
var _rolloverPreloads = new Array();
function setRollover(img,onSrc) {
	// 1. get name/id for image element
	var name = img.src.replace(/[\W]/gi,"");
	
	// 2. preload the rollover state, and store a reference to the original state
	_rolloverPreloads[name] = new Image();
	_rolloverPreloads[name].src = onSrc;
	_rolloverPreloads[name].oldSrc = img.src;
	
	// 3. add the mousehanders
	img.onmouseover = function() {
		img.src = _rolloverPreloads[name].src;
	};
	
	img.onmouseout = function() {
		img.src = _rolloverPreloads[name].oldSrc;
	};
	
	// 4. turnoff onload, so we don't get called again
	img.onload = function() { return true; };
}

/************************************************************
commerce functions
*************************************************************/
function setCart(f) {
	// set cookie telling us to show the view cart button
	setCookie("view_cart","true",0,"/","joshuastanton.com");
	show("cartButton");
	return true;
}