/*
	speedup ie
*****************************************************/
/*@cc_on _d=document;eval('var document=_d')@*/

/*
	get js/css base URL
*****************************************************/
var GLOBALS={
	jsBaseURL : null,
	cssBaseURL : null
};
GLOBALS.jsBaseURL = (function(e){
	if(e.nodeName.toLowerCase()=='script') return e;
	return arguments.callee(e.lastChild)
})(document).src.replace(/^(.+\/)[^/]*$/,"$1");

GLOBALS.cssBaseURL = (function(){
	var links = document.getElementsByTagName("link");
	for(var i=0,link; link=links[i]; i++){
		if(link.rel=="stylesheet") return link;
	}
})().href.replace(/^(.+\/)[^/]*$/,"$1");

/*
	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,
	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 js/css
*****************************************************/

/*** common js/css ***/
jsLoader("jq.js");
jsLoader("jq_functions.js");
jsLoader("det_flash.js");
jsLoader("scroll.js");
jsLoader("styleswitcher.js");
cssLoader("prehideforjs.css","all");

/*** load browser css ***/
if(browserDetect.isSafari2) cssLoader("browsercss/safari2.css","all");
if(browserDetect.isSafari) cssLoader("browsercss/safariall.css","all");
if(browserDetect.isFF) cssLoader("browsercss/ffprint.css","print");

/*
	IE bg flicker problem fix
*****************************************************/
try {
document.execCommand("BackgroundImageCache",false,true);
}catch(e){}

	
/*
	jsLoader
*****************************************************/
function jsLoader(file)
{
	if(!file) return;
	file = GLOBALS.jsBaseURL + file;
	document.open();
	document.write('<script type="text/javascript" src="'+ file + '"><\/script>');
	document.close();
}

/*
	cssLoader
*****************************************************/
function cssLoader(file,media)
{
	if(!file) return;
	file = GLOBALS.cssBaseURL + file;
	document.open();
	document.write('<link rel="stylesheet" type="text/css" media="'+media+'" href="'+ file + '" />');
	document.close();
}


/*
	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='windowManage-close'><li><a href='javascript:void(0)' onclick='windowClose.close(); return false;'><img src='/swc/common/imgs/content_imgs/winmanage_close/1.gif' alt='ウィンドウを閉じる' width='112' height='27' /></a></li></ul>");
	},
	close: function(){
		window.opener = window;
		var win = window.open(location.href,"_self");
		win.close();
	}
}
