/*global $, document */
/**
 * Recreate the interactive Flash movie in JavaScript.
 */
function HomePageHighlights() {
	var args = arguments;
	this.profile = args[0];
  this.target_container  = $(this.profile + "-target");
  this.root_folder       = args[1];
	this.target_link       = this.profile + "-" + args[2];
  this.current_list      = [];
  var  current_list_item = 0;
	
  var myThis = this;

  $(this.target_link).onclick = function() {
		if (myThis.current_list[myThis.current_image][2] != "<nolink>") {
			document.location.href = myThis.current_list[myThis.current_image][2];
		}
		return false;
	};

  var get_on_click_function = function(target, i) {
		return function() {
			target.current_image = i;
			target.changeImage(target.current_image);
			return false;
		};
	};

	for (var i = 3; i < args.length; i += 3) { 
    this.current_list[current_list_item++] = [ args[i], args[i + 1], args[i + 2] ];
		$(this.profile + "-" + args[i]).onclick = get_on_click_function(myThis, current_list_item - 1);
		$(this.profile + "-" + args[i]).noHref = true;
	}
	
	this.current_image = 0;
	
	this.image = document.createElement("img");
	this.image.isMap = true;
	this.image.useMap = "#" + this.profile + "-map";
	this.image.border = 0;
	
	this.target_container.appendChild(this.image);
  this.changeImage(this.current_image);
}

HomePageHighlights.prototype.changeImage = function(which) {
	this.image.src     = this.root_folder + this.current_list[which][1];
	this.current_image = which;
};

