// JavaScript Document

var tb_nums = 12;
var tb_normals = new Array();
var tb_overs = new Array();
var tb_clicks = new Array();
var tb_downs = new Array();
var tb_select = -1;

// Content selection flag. 0: 3D model, 1: 2D image, 2: Flash movie, 3: Media file
var content_select = -1;

var tb_ids = new Array(
	0,
	1,
	2,
	3,
	4,
	5,
	6,
	7,
	8,
	9,
	10,
	11
);

function startBusyCursor()
{
		document.body.style.cursor = 'wait';
}

function stopBusyCursor()
{
		document.body.style.cursor = 'default';
}

function showElement(id)
{
	var v = document.getElementById(id);
	v.style.display = 'block';
}

function hideElement(id)
{
	var v = document.getElementById(id);
	v.style.display = 'none';
//	v.hide();
}

function newImage(arg) 
{
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function initThumbImages()
{
	var tbimgs = document.getElementsByTagName("a");
	var index = 0;
	for (var i = 0; i < tbimgs.length; i++)
	{
		if (tbimgs[i].className == "thumbImageRef") 
		{
			var image = document.createElement("img");
			image.src=tb_normals[index].src;
			image.alt=tb_tooltips[index];
			image.title=tb_tooltips[index];
			image.width="120";
			image.height="93";
			image.border="0";
			image.id=tb_ids[index];
			image.name="thumbImage";
			
			tbimgs[i].appendChild(image);
			
			index++;
		}
	}
}

var preloadFlag = false;
function preloadImages() 
{
	startBusyCursor();
	
	if (document.images) 
	{
		// Create thumbnail images
		for (var i = 0; i < tb_nums; i++)
		{
			tb_normals[i] = newImage(tb_thumbimage_urls[i * 4 + 0]);
			tb_overs[i]   = newImage(tb_thumbimage_urls[i * 4 + 1]);
			tb_downs[i]   = newImage(tb_thumbimage_urls[i * 4 + 2]);
			tb_clicks[i]  = newImage(tb_thumbimage_urls[i * 4 + 3]);
		}

		preloadFlag = true;

		// Initialize thumbnail images
		initThumbImages();
	}
	// Cache object
	flash_object = document.getElementById("FlashPlayer");
	
	stopBusyCursor();
}

function tb_mouseOver(id) 
{
	if (document.images && (preloadFlag == true) && (tb_select != id)) 
	{
		document.images[tb_ids[id]].src = tb_overs[id].src;
	}
		
}

function tb_mouseOut(id) 
{
	if (document.images && (preloadFlag == true) && (tb_select != id)) 
	{
		document.images[tb_ids[id]].src = tb_normals[id].src;
	}
}

function tb_mouseDown(id) 
{
	if (document.images && (preloadFlag == true) && (tb_select != id)) 
	{
		document.images[tb_ids[id]].src = tb_downs[id].src;
	}
}

function tb_mouseClick(id) 
{
	//alert("id= " + id + " ; tb_flash_urls[id] = " + tb_flash_urls[id]);
	//alert("flash_object = " + flash_object.id);
	if (document.images && (preloadFlag == true)) 
	{		
		document.images[tb_ids[id]].src = tb_clicks[id].src
		tb_temp = tb_select;
		if (tb_temp != -1) 
		{
			tb_mouseOut(tb_temp);
		}
		var v = document.getElementById("pageTitle");
		v.innerText = page_titles[id];

		var v = document.getElementById("pageDesc");
		v.innerText = page_description[id];
		
		flash_object.loadMovie(0, tb_flash_urls[id]);
		flash_object.play();

	}
	
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

