function Rescue() { return true; }
window.onerror = Rescue;

var TARGETID = "intro";
var INTERVAL = 8000;
var LOADWAIT = 500;

var IEXPLORE = (document.all && navigator.userAgent.search('MSIE [5-9]') > -1) ? true : false;
var IEFILTER = "blendTrans() revealTrans(duration=1.00, transition=6);";

var Index = 0;
var Canvas = null;
var Pictures = new Array();

function Picture()
{
	this.src = "";
	this.uri = "";
	this.alt = "";
	this.img = new Image();
	this.div = null;
}

function LayerWriter()
{
	var art = "";
	for (var i=0; i<Pictures.length; i++)
	{
		with (Pictures[i])
		{
			if (uri && uri.length > 0) {
				art += "<div id=\"i_layer" + i + "\" style=\"display : none;\"><a href=\"" + uri + "\"><img src=\"" + src + "\" alt=\"" + alt + "\" /></a></div>\n";
			} else {
				art += "<div id=\"i_layer" + i + "\" style=\"display : none;\"><img src=\"" + src + "\" alt=\"" + alt + "\" /></div>\n";
			}
		}
	}
	Canvas.innerHTML = art;
	for (var i=0; i<Pictures.length; i++)
	{
		with (Pictures[i])
		{
			div = document.getElementById("i_layer" + i);
			if (i == 0) {
				div.style.display = "block";
			}
		}
	}
}

function LayerChanger()
{
	if (IEXPLORE) {
		Canvas.filters(0).apply();
		Canvas.filters(1).apply();
	}
	Pictures[Index].div.style.display = "none";
	Index = (Index + 1) % Pictures.length;
	Pictures[Index].div.style.display = "block";
	if (IEXPLORE) {
		Canvas.filters(0).play();
		Canvas.filters(1).play();
	}
	setTimeout("Postpone(Pictures[Index].img)", INTERVAL);
}

function Postpone(img)
{
	if (true && img && img.complete) {
	// if (img && img.complete)
		LayerChanger();
	} else {
		setTimeout("Postpone()", LOADWAIT);
	}
}

function Showing()
{
	if (Canvas = document.getElementById(TARGETID)) {
		LayerWriter();
		if (IEXPLORE) {
			with (Canvas.style)
			{
				width = "100%";
				filter = IEFILTER;
			}
		}
		setTimeout("LayerChanger()", INTERVAL);
	}
}

if (document.getElementById) {

	var index = 0;

/*
	with (Pictures[index++] = new Picture())
	{
		src = "intro/panacea.png";
		uri = "products/panacea/index.html";
		alt = "調剤薬局医療事務システム PANACEA";
	}
*/

	with (Pictures[index++] = new Picture())
	{
		src = "intro/panacea2.png";
		uri = "products/panacea/index.html";
		alt = "レセコン＆電子薬歴一体型システム PANACEA2";
	}

	with (Pictures[index++] = new Picture())
	{
		src = "intro/cure.png";
		uri = "products/cure/index.html";
		alt = "電子薬歴システム CURE";
	}

/*
	with (Pictures[index++] = new Picture())
	{
		src = "intro/eripple.png";
		uri = "products/eripple/index.html";
		alt = "歯科保険請求システム e-Ripple";
	}
*/

	if (IEXPLORE) {
		for (var i=0; i<Pictures.length; i++)
		{
			with (Pictures[i])
			{
				img.src = src;
			}
		}
	}

	window.onload = Showing;

}
