/*
	IE bg flicker problem fix
*****************************************************/

	try {
	document.execCommand("BackgroundImageCache",false,true);
	}catch(e){}
	
	
/*
	browserDetect
*****************************************************/

	var browserDetect = {
		isSafari : (navigator.userAgent.indexOf("Safari") != -1)? true : false,
		isSafari2 : (navigator.userAgent.indexOf("AppleWebKit/41") != -1)? true : false,
		isFF : (navigator.userAgent.indexOf("Firefox") != -1)? true : false,
		isIE : (navigator.userAgent.indexOf("MSIE") != -1)? true : false,
		isIE4 : (navigator.userAgent.indexOf("MSIE 4") != -1)? true : false,
		isIE5 : (navigator.userAgent.indexOf("MSIE 5") != -1)? true : false,
		isIE6 : (navigator.userAgent.indexOf("MSIE 6") != -1)? true : false,
		isIE7 : (navigator.userAgent.indexOf("MSIE 7") != -1)? true : false,
		isMacIE : (document.all && !window.clipboardData)? true : false,
		isNN4 : (document.layers)? true : false,
		isNN6 : (navigator.userAgent.indexOf("Netscape/6") != -1)? true : false,
		isNN7 : (navigator.userAgent.indexOf("Netscape/7") != -1)? true : false
	}


/*
	load javascript
	- load() should be loaded in head
*****************************************************/

	var javascriptLoader = {
		files : [
			"/twcu/common/js/jq.js",
			"/twcu/common/js/jquery.tooltip.js",
			"/twcu/common/js/jq_functions.js",
			"/twcu/common/js/scroll.js",
			"/twcu/common/js/styleswitcher.js"
		],
		load : function(){
			if(javascriptLoader.files.length<1) return;
			for(var i=0, file; file=javascriptLoader.files[i] ;i++){
				document.open();
				document.write('<script type="text/javascript" src="'+ file + '"><\/script>');
				document.close();
			}
		}
	}
	javascriptLoader.load();

/*
	browser fix css
*****************************************************/

	var browserCssLoader =
	{
		load: function()
		{
			if(browserDetect.isFF)
			{
				document.open();
				document.write('<link rel="stylesheet" type="text/css" media="print" href="/twcu/common/css/browsercss/ffprint.css" />');
				document.close();
			}
			if(browserDetect.isSafari2)
			{
				document.open();
				document.write('<link rel="stylesheet" type="text/css" media="screen,tv,projection,print" href="/twcu/common/css/browsercss/safari2.css" />');
				document.close();
			}
			if(browserDetect.isSafari)
			{
				document.open();
				document.write('<link rel="stylesheet" type="text/css" media="screen,tv,projection,print" href="/twcu/common/css/browsercss/safariall.css" />');
				document.close();
			}
		}
	}
	browserCssLoader.load();
	

/*
	onload event control
*****************************************************/

	function addLoadEvent(func) {
		if(document.addEventListener && navigator.userAgent.indexOf('Gecko/') != -1){
			document.addEventListener("DOMContentLoaded", function(){func()}, false);
		}
		else{
			var oldonload = window.onload;
			window.onload = function() {
				func();
				if(typeof oldonload == 'function') oldonload();
			}
		}
	}
	function addUnLoadEvent(func) {
		var oldonunload = window.onunload;
		window.onunload = function() {
			if(typeof window.onunload != 'function') oldonunload();
			func();
		}
	}


/*
	onload event control
*****************************************************/

	var windowClose=
	{
		write: function(){
			document.write("<ul class='popup-close'><li><a href='javascript:void(0)' onclick='windowClose.close(); return false;'><img src='/twcu/common/imgs/content_imgs/popup_close/1.gif' alt='閉じる' /></a></li></ul>");
		},
		close: function(){
			window.opener = window;
			var win = window.open(location.href,"_self");
			win.close();
		}
	}