
N = {} // Based on sML JavaScript Library

// ========================================================================================================================

UA = {
	WK : ((navigator.userAgent.indexOf("AppleWebKit") > -1) ? 1 : 0),
	Ge : ((navigator.userAgent.indexOf("Gecko/") > -1)      ? 1 : 0),
	Op : ( window.opera                                     ? 1 : 0),
	IE : ((document.all && !this.Op)                        ? 1 : 0)
}

if(UA.WK) {
	UA.WK = navigator.userAgent.replace(/.+AppleWebKit\/([\d]+).+/, "$1");
}

if(UA.IE) {
	     if(document.documentMode)                      UA.IE = parseInt(document.documentMode);
	else if(navigator.userAgent.indexOf("MSIE 7") > -1) UA.IE = 7;
}

// ------------------------------------------------------------------------------------------------------------------------


if(!Array.prototype.push) {
	Array.prototype.push = function() {
		for(var i = 0; i < arguments.length; i ++) this[this.length] = arguments[i];
		return this.length;
	}
}

if(!Array.prototype.forEach) {
	Array.prototype.forEach = function(F, pThis) {
		if(typeof F != "function") throw new TypeError();
		for(var i = 0; i < this.length; i++) if(i in this) F.call(pThis, this[i], i, this);
	}
}

foreach = function(O, F, pThis) {
	if(O.length) for(var i = 0; i < O.length; i ++) F(O[i], i, pThis);
	else         for(var i in O) F(O[i], i, pThis);
}

toArray = function() {
	var A = new Array;
	foreach(arguments, function(i) { foreach(i, function(j) { A.push(j); }); });
	return A;
}

// ------------------------------------------------------------------------------------------------------------------------

N.onRead = {
	compatible : (((UA.WK > 525) || UA.Ge || UA.Op) ? 1 : 0),
	eventListeners : new Array,
	executeAll : function() { for(var i = 0; i < this.eventListeners.length; i ++) this.eventListeners[i](); },
	addEventListener : function(F) {
		if(this.compatible) document.addEventListener('DOMContentLoaded', F, false);
		else                this.eventListeners.push(F);
	}
}

if(!N.onRead.compatible) {
	if(UA.IE) N.onRead.IE = document.documentElement.addBehavior('/n-08a/sp/js/N-08A.onRead.IE.htc');
	else      window.onload = function() { N.onRead.executeAll(); }
}

//========================================================================================================================

if(UA.IE) {
	N.eOb = function(e) { this.target = e.srcElement; }
	N.ELM = function(a) {
		if(a) return function(Ev, F) { this.attachEvent("on" + Ev, function() { return F(new N.eOb(event)); }); }
		else  return function(Ev, F) { this.detachEvent("on" + Ev, F); }
	}
	window.addEventListener    = document.addEventListener    = N.ELM(1);
	window.removeEventListener = document.removeEventListener = N.ELM(0);
	try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
}

//========================================================================================================================

class_fp = function() {
	this.version = 0;
	if(navigator.plugins && navigator.mimeTypes.length) {
		var fPI = navigator.plugins["Shockwave Flash"];
		if(fPI && fPI.description) this.version = fPI.description.replace(/^[^\d]+(\d+\.\d+)\s*(r(\d+))*\.*$/, "$1.$3").split(".")[0];
	} else {
		var fAX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
		if(fAX) this.version = fAX.GetVariable("$version").split(" ")[1].split(",")[0];
	}
	this.checkVersion = function(V) {
		if(this.version < V) return 0;
		else                 return 1;
	}
	this.getHTML = function(Ps) {
		return [
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"',
			' width="' + Ps['width'] + '"',
			' height="' + Ps['height'] + '"',
			'>',
			'<param name="movie" value ="' + Ps['movie']   + '" />',
			'<param name="bgcolor" value ="' + Ps['bgcolor'] + ' />',
			'<param name="quality" value ="high" />',
			'<param name="allowScriptAccess" value="sameDomain" />',
			'<param name="allowFullScreen" value="false" />',
			'<embed type="application/x-shockwave-flash"',
			' src="' + Ps['movie'] + '"',
			' width="' + Ps['width'] + '"',
			' height="' + Ps['height'] + '"',
			' bgcolor="' + Ps['bgcolor'] + '"',
			' align="middle"',
			' quality="high"',
			' allowScriptAccess="sameDomain"',
			' allowFullScreen="false"',
			' />',
			'</object>'
		].join("");
	}
	this.setFlash = function(ID, V, F, W, H, B, aHTML) {
		if(this.checkVersion(V)) {
			HTML = N.fp.getHTML({
				"movie"   : F,
				"width"   : W,
				"height"  : H,
				"bgcolor" : B
			});
		} else if(arguments.length > 6) {
			HTML = aHTML;
		} else {
			return;
		}
		var fA = document.getElementById(ID);
		fA.innerHTML = "";
		setTimeout(function() { fA.innerHTML = HTML; }, (UA.WK ? 100 : 10));
	}
}

N.fp = new class_fp();

//========================================================================================================================

N.onRead.addEventListener(function() {

	var aHTML = "";

	N.fp.setFlash("content", 9, "index.swf", "100%", "100%", "#FFFFFF", aHTML);

	window.onresize = window.maintain = function () {
		var fArea = document.getElementById("content");
		var W = window.innerWidth  || document.documentElement.clientWidth  || document.body.clientWidth;
		var H = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
		fArea.style.width  = (W < 1000) ? "1000px" : "100%";
		fArea.style.height = (H < 670) ? "670px" : "100%";
//		status = "W:" + W + " " + "H:" + H;
	}
	window.maintain();

});

//========================================================================================================================

