/*
	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_tooltip.js");
jsLoader("jq_leafbox.js");
jsLoader("jq_animatedNarrowDown.js");
jsLoader("jq_specifiedRollover.js");
jsLoader("jq_misc.js");
jsLoader("jq_setup.js");
jsLoader("scroll.js");
cssLoader("prehideforjs.css","all");

/*** load browser css ***/
if(browserDetect.isSafari2) cssLoader("browser_safari2.css","all");
if(browserDetect.isSafari) cssLoader("browser_safariall.css","all");

/*** avoid IE6 print css ***/
(function(){
	if(!browserDetect.isIE6) return false;
	var links = document.getElementsByTagName("link");
	var cssLink;
	for(var i=0,link; link=links[i]; i++){
		if(link.rel=="stylesheet")
		{
			cssLink = link;
			break;
		}
	}
	cssLink.media="screen";
})();



/*
	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();
	}
}
