/* ===============================================
	check Layer Id
=============================================== */
	function checkLayerId(id){
		if(document.all || document.getElementById){
			if(document.all){
				if( document.all(id) != null ){
					return true;
				}
			} else if(document.getElementById){
				if( document.getElementById(id) != null ){
					return true;
				}
			}
		}
		return null;
	}

/* ===============================================
	change Layer Display
=============================================== */
	function changeLayerDisplay(id,dis){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).style.display = dis;
			} else if(document.getElementById){
				document.getElementById(id).style.display = dis;
			}
		}
	}

/* ===============================================
	write ID Inner
=============================================== */
	function writeIdArea(id,writeData){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).innerHTML = writeData;
			} else if(document.getElementById){
				document.getElementById(id).innerHTML = writeData;
			}
		}
	}

/* ===============================================
	window open
=============================================== */
	function opWin(opUrl,winWidth,winHeight){
		var win_set = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+winWidth+',height='+winHeight;
		openWindow = window.open(opUrl,"popup",win_set);
		openWindow.focus();
	}

//=============================================
// Img RollOver
//=============================================
var initRollovers = {
	temp : {
		cName    : "ov",
		sTempSrc : null,
		src      : null,
		hsrc     : null,
		ftype    : null
	},

	main : function (){
		var aPreLoad = new Array();
		var sTempSrc;
		var aImages = document.getElementsByTagName('img');

		for (var i = 0; i < aImages.length; i++) {
			if ( aImages[i].className.indexOf(initRollovers.temp.cName)  != -1 ) {
				var src = aImages[i].getAttribute('src');
					initRollovers.temp.src = src;
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
					initRollovers.temp.ftype = ftype;
				var hsrc = src.replace(ftype, '_on'+ftype);
					initRollovers.temp.hsrc = hsrc;

				aImages[i].setAttribute('hsrc', hsrc);

				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;

				try {
					aImages[i].addEventListener('mouseover', initRollovers.imgOver, false);
					aImages[i].addEventListener('mouseout', initRollovers.imgOut, false);
				} catch (e) {
					aImages[i].attachEvent('onmouseover', (function(el){return function(){initRollovers.imgOver.call(el);};})(aImages[i])); 
					aImages[i].attachEvent('onmouseout', (function(el){return function(){initRollovers.imgOut.call(el);};})(aImages[i])); 
				}
			}
		}
	},

	imgOver : function(){
		var src  = initRollovers.temp.src;
		var hsrc = initRollovers.temp.hsrc;
		initRollovers.temp.sTempSrc = this.getAttribute('src');
		this.setAttribute('src', this.getAttribute('hsrc'));
	},

	imgOut : function(){
		var src   = initRollovers.temp.src;
		var hsrc  = initRollovers.temp.hsrc;
		var ftype = initRollovers.temp.ftype;
		if (!initRollovers.temp.sTempSrc) initRollovers.temp.sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
		this.setAttribute('src', initRollovers.temp.sTempSrc);
	},

	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
}
initRollovers.addEvent();


//=============================================
// form elements onfocus bgColor
//=============================================
var initFormelEments = {
	temp : {
		focusColor : "#FFFBBF",
		blurColor  : "#FFFFFF",
		cName      : "ontxt",
		formTag    : new Array("input","select","textarea")
	},

	setProcess : function (){
		if (!document.getElementById) return
		for( si=0 ; si < initFormelEments.temp.formTag.length ; si++ ){
			initFormelEments.main(initFormelEments.temp.formTag[si]);
		}
	},

	main : function (tagName){
		var tagName = document.getElementsByTagName(tagName);
		if( tagName.length != 0 ){
			for( i=0 ; i < tagName.length ; i++ ){
				try {
					tagName[i].addEventListener('focus', initFormelEments.changeBGFocus, false);
					tagName[i].addEventListener('blur', initFormelEments.changeBGBlur, false);
				} catch (e) {
					tagName[i].attachEvent('onfocus', (function(el){return function(){initFormelEments.changeBGFocus.call(el);};})(tagName[i])); 
					tagName[i].attachEvent('onblur', (function(el){return function(){initFormelEments.changeBGBlur.call(el);};})(tagName[i])); 
				}
			}
		}
	},

	changeBGFocus : function(){
		if ( this.className.indexOf(initFormelEments.temp.cName)  != -1 ) {
			this.style.backgroundColor = initFormelEments.temp.focusColor;
		}
	},
	changeBGBlur : function(){
		var bColor = "#ffffff";
		if ( this.className.indexOf(initFormelEments.temp.cName)  != -1 ) {
			this.style.backgroundColor =  initFormelEments.temp.blurColor;
		}
	},

	addEvent : function(){
		try {
			window.addEventListener('load', this.setProcess, false);
		} catch (e) {
			window.attachEvent('onload', this.setProcess);
		}
	}
}
initFormelEments.addEvent();


//=============================================
// main navigation
//=============================================
var mainnavigation = {
	temp : {
		timmer    : null,
		time      : 500,
		closeFlag : "on",
		tree      : new Array("navi02")
	},

	popup : function(flag){
		mainnavigation.temp.closeFlag = "off";
		flag = ( flag == "" ) ? "tree" : flag;
		var lng = mainnavigation.temp.tree.length;
		for( i=0 ; i < lng ; i++ ){
			var id = mainnavigation.temp.tree[i];
			if( id != flag ){ changeLayerDisplay(id,'none'); }
			if( id == flag ){ changeLayerDisplay(id,'block'); }
		}
		this.changeImgOver(flag);
	},

	popupClose : function(flag){
		flag = ( flag == "" ) ? "tree" : flag;
		var lng = mainnavigation.temp.tree.length;
		for( i=0 ; i < lng ; i++ ){
			var id = mainnavigation.temp.tree[i];
			if( id != flag ){ changeLayerDisplay(id,'none'); }
			else { mainnavigation.popupCloseSet(flag); }
		}
		this.changeImgOut(flag);
	},

	popupCloseFlag : function(flag,imgId){
		mainnavigation.temp.closeFlag = flag;
		this.changeImgOver(imgId);
	},
	popupCloseSet : function(id){
		this.changeImgOut(id);
		mainnavigation.temp.closeFlag = "on";
		mainnavigation.temp.timmer = setTimeout(function(){mainnavigation.popupCloseThis(id);},mainnavigation.temp.time);
	},
	popupCloseThis : function(id){
		if( mainnavigation.temp.closeFlag == "on" ){
			changeLayerDisplay(id,'none');
		}
	},

	changeImgOver : function(imgId){
		var imgId  = imgId + 'm';
		if( checkLayerId(imgId) != null ){
			if(document.all || document.getElementById){
				if(document.all){
					imgId = document.all(imgId);
				} else if(document.getElementById){
					imgId = document.getElementById(imgId);
				}
			}
			var imgSrc = imgId.getAttribute('src');
			if( imgSrc.indexOf('_on.gif') == -1 ){ imgSrc = imgSrc.replace('.gif','_on.gif'); }
			imgId.src = imgSrc;
		}
	},
	changeImgOut : function(imgId){
		var imgId  = imgId + 'm';
		if( checkLayerId(imgId) != null ){
			if(document.all || document.getElementById){
				if(document.all){
					imgId = document.all(imgId);
				} else if(document.getElementById){
					imgId = document.getElementById(imgId);
				}
			}
			var imgSrc = imgId.getAttribute('src');
			if( imgSrc.indexOf('_on.gif') != -1 ){ imgSrc = imgSrc.replace('_on.gif','.gif'); }
			imgId.src = imgSrc;
		}
	}
}


//=============================================
// set Top Flash Area
//=============================================
var setTopFlashArea = {
	temp : {
		id : "topFlashArea"
	},

	main : function(){
		var writeData = '' +
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="752" height="233" id="kurosuflash" align="middle">' +
				'<param name="allowScriptAccess" value="sameDomain" />' +
				'<param name="allowFullScreen" value="false" />' +
				'<param name="movie" value="/common/swf/top.swf" />' +
				'<param name="quality" value="high" />' +
				'<param name="bgcolor" value="#ffffff" />' +
				'<param name="wmode" value="transparent" />' +
				'<embed src="/common/swf/top.swf" quality="high" bgcolor="#ffffff" width="752" height="233" name="kurosuflash1226" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
			'</object>';

		if( checkLayerId(setTopFlashArea.temp.id) != null ){
			writeIdArea(setTopFlashArea.temp.id,writeData);
		}
	},

	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
}
setTopFlashArea.addEvent();


//=============================================
// init set BLINK
//=============================================
var initSetBlink = {
	temp : {
		flugFirst: true,
		flug     : false,
		timmerID : null,
		timmer   : 1000,
		cName    : "blink",
		blinkTag : new Array("span","img")
	},

	setProcess : function (){
		if (!document.getElementById) return

		for( si=0 ; si < initSetBlink.temp.blinkTag.length ; si++ ){
			initSetBlink.main(initSetBlink.temp.blinkTag[si]);
		}

		if( initSetBlink.temp.flugFirst ){
			initSetBlink.temp.timmerID = setTimeout(function(){initSetBlink.setProcess();}, initSetBlink.temp.timmer);
		} else if( initSetBlink.temp.flug ){
			initSetBlink.temp.timmerID = setTimeout(function(){initSetBlink.setProcess();}, initSetBlink.temp.timmer);
		}
		initSetBlink.temp.flugFirst = false;
	},

	main : function (tagName){
		var tagName = document.getElementsByTagName(tagName);
		if( tagName.length != 0 ){
			for( i=0 ; i < tagName.length ; i++ ){
				if ( tagName[i].className.indexOf(initSetBlink.temp.cName)  != -1 ) {
					if( tagName[i].style.visibility == "hidden" ){
						tagName[i].style.visibility = "visible";
					} else {
						tagName[i].style.visibility = "hidden";
					}
				}
			}
		}
		initSetBlink.temp.flugFirst = true;
	},

	addEvent : function(){
		try {
			window.addEventListener('load', this.setProcess, false);
		} catch (e) {
			window.attachEvent('onload', this.setProcess);
		}
	}
}
initSetBlink.addEvent();


//=============================================
// check flash plugin
//=============================================
var checkSwfObjectTemp = {
	contentVersion : 9,
	flashCanPlay   : false,
	pluginWords    : null
}
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if (plugin) {
	checkSwfObjectTemp.pluginWords = navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i = 0; i < checkSwfObjectTemp.pluginWords.length; ++i) {
		if (isNaN(parseInt(checkSwfObjectTemp.pluginWords[i])))
		continue;
		checkSwfObjectTemp.flashCanPlay = checkSwfObjectTemp.pluginWords[i]; 
	}
	checkSwfObjectTemp.flashCanPlay = checkSwfObjectTemp.flashCanPlay >= checkSwfObjectTemp.contentVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0
	&& (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('checkSwfObjectTemp.flashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & checkSwfObjectTemp.contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
