/* ArnaldoCohen.com JS file */

//image arrays
var offImages = new Array();

	offImages["bio"] 			= "" + getImagePath(locale, "off", "bio.gif");
	offImages["tour"] 			= "" + getImagePath(locale, "off", "tour.gif");
	offImages["liveperf"] 		= "" + getImagePath(locale, "off", "liveperf.gif");
	offImages["recordings"] 	= "" + getImagePath(locale, "off", "recordings.gif");
	offImages["repertoire"] 	= "" + getImagePath(locale, "off", "repertoire.gif");
	offImages["reviews"] 		= "" + getImagePath(locale, "off", "reviews.gif");
	offImages["articles"] 		= "" + getImagePath(locale, "off", "articles.gif");
	offImages["interviews"] 	= "" + getImagePath(locale, "off", "interviews.gif");
	offImages["press"] 			= "" + getImagePath(locale, "off", "press.gif");
	offImages["photos"] 		= "" + getImagePath(locale, "off", "photos.gif");
	offImages["forum"] 			= "" + getImagePath(locale, "off", "forum.gif");
	offImages["language"] 		= "" + getImagePath(locale, "off", "language.gif");
	offImages["contact"] 		= "" + getImagePath(locale, "off", "contact.gif");
	offImages["search"] 		= "" + getImagePath(locale, "off", "search.gif");

var onImages = new Array();

	onImages["bio"] 			= "" + getImagePath(locale, "on", "bio.gif");
	onImages["tour"] 			= "" + getImagePath(locale, "on", "tour.gif");
	onImages["liveperf"] 		= "" + getImagePath(locale, "on", "liveperf.gif");
	onImages["recordings"] 		= "" + getImagePath(locale, "on", "recordings.gif");
	onImages["repertoire"] 		= "" + getImagePath(locale, "on", "repertoire.gif");
	onImages["reviews"] 		= "" + getImagePath(locale, "on", "reviews.gif");
	onImages["articles"] 		= "" + getImagePath(locale, "on", "articles.gif");
	onImages["interviews"] 		= "" + getImagePath(locale, "on", "interviews.gif");
	onImages["press"] 			= "" + getImagePath(locale, "on", "press.gif");
	onImages["photos"] 			= "" + getImagePath(locale, "on", "photos.gif");
	onImages["forum"] 			= "" + getImagePath(locale, "on", "forum.gif");
	onImages["language"] 		= "" + getImagePath(locale, "on", "language.gif");
	onImages["contact"] 		= "" + getImagePath(locale, "on", "contact.gif");
	onImages["search"] 			= "" + getImagePath(locale, "on", "search.gif");
		
function getImagePath(locale, state, name)
{
	if (state == "off")
	{
		return "/images/" + locale + "/buttons/off/" + name;
	}
	else
	{
		return "/images/" + locale + "/buttons/on/" + name;
	}
}

function preloadImages()
{
	//load off images
	for (offImageName in offImages)
	{
		var eachImage = new Image();
		eachImage.src = offImages[offImageName];
	}
	
	//load on images
	for (onImageName in onImages)
	{
		var eachImage = new Image();
		eachImage.src = onImages[onImageName];
	}
	
	
	if (stayOn != "home")
	{
		var docImage = eval("document." + stayOn);
		docImage.src = onImages[stayOn];
	}
	
}

function swap(image)
{
	if (image == stayOn)
	{
		return;
	}
	
	docImage = eval("document." + image);
	imageSrc = docImage.src;
	
	if (imageSrc.indexOf("/off/") != -1)
	{
		docImage.src = onImages[image];
	}
	else if (imageSrc.indexOf("/on/") != -1)
	{
		docImage.src = offImages[image];
	}
}

function ltrim ( s )
{
	return s.replace( /^\s*/, "" );
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}

function trim ( s )
{
	return rtrim(ltrim(s));
}

