var PreLoader = 
{
	loadImages: function (images)
	{
		var array = images.images;
		
		for (var i = 0; i < array.length; ++i)
		{
			var path = array[i];
			var image = new Image();
			image.src = path;
		}
	}
}

var PlayList = 
{
	rollover: function (domId)
	{
		var row = $(domId);
		
		row.style.backgroundColor = '#fbf7c2';	
	},
	
	rollout: function (domId)
	{
		var row = $(domId);
		
		row.style.backgroundColor = '#ffffff';	
	}
};

/**
 */
var Button =
{
	/**
 	 */
	rollover: function (buttonId, buttonType)
	{
		var imageURL = '';
		
		var leftedge = $(buttonId + "_button_left");
		imageURL = CONFIG.BUTTONS_URL + buttonType + '/left_over.gif';				
		leftedge.style.backgroundImage = "url('" + imageURL + "')";
		
		var middle = $(buttonId + "_button_middle");
		imageURL = CONFIG.BUTTONS_URL + buttonType + '/bg_over.gif';	
		middle.style.backgroundImage = "url('" + imageURL + "')";
		
		var rightedge = $(buttonId + "_button_right");
		imageURL = CONFIG.BUTTONS_URL + buttonType + '/right_over.gif';	
		rightedge.style.backgroundImage = "url('" + imageURL + "')";
	},

	/**
	 */
	rollout: function (buttonId, buttonType)
	{
		var imageURL = '';
		
		var leftedge = $(buttonId + "_button_left");
		imageURL = CONFIG.BUTTONS_URL + buttonType + '/left.gif';	
		leftedge.style.backgroundImage = "url('" + imageURL + "')";
		
		var middle = $(buttonId + "_button_middle");
		imageURL = CONFIG.BUTTONS_URL + buttonType + '/bg.gif';	
		middle.style.backgroundImage = "url('" + imageURL + "')";
		
		var rightedge = $(buttonId + "_button_right");
		imageURL = CONFIG.BUTTONS_URL + buttonType + '/right.gif';	
		rightedge.style.backgroundImage = "url('" + imageURL + "')";
	},
	
	/**
	 */
	toggleButton: function (buttonIndex, groupId)
	{
		var numButtons = $(groupId + 'NumButtons').value;	
		var orientation = $(groupId + 'Orientation').value;	
		
		if (orientation == 'horizontal')
		{
			var displayType = 'inline'
		}
		else
		{
			var displayType = 'block'
		}
		
		for (i = 0; i < numButtons; ++i)
		{
			var buttonId = groupId + i;
	
			$(buttonId + 'ActiveOuter').hide();
			$(buttonId + 'Outer').style.display = displayType;
		}
		   
		if (buttonIndex != null)
		{
			/*
			 * Eval reads in the JSON object from the button action.
			 * The JSON object is named 'button'.
			 */
			var buttonAction = $(groupId + buttonIndex + 'Action').value;
			//alert(buttonAction);
			eval(buttonAction);
	
			$(groupId + buttonIndex + 'Outer').hide();
			$(groupId + buttonIndex + 'ActiveOuter').style.display = displayType;
			
			functionCall = button['functionCall'];
			eval(functionCall);
		}
		//workspace.selectContent(button);           
	}
};