/**
 * avoid IE bg flicker
 */
	try {
		document.execCommand("BackgroundImageCache",false,true);
	}catch(e){}
	
/**
 * browserDetect
 */
var browserDetect = {
	safari : (navigator.userAgent.indexOf("Safari") != -1)? true : false,
	safari2 : (navigator.userAgent.indexOf("AppleWebKit/41") != -1)? true : false,
	FF : (navigator.userAgent.indexOf("Firefox") != -1)? true : false,
	IE : (navigator.userAgent.indexOf("MSIE") != -1)? true : false,
	IE4 : (navigator.userAgent.indexOf("MSIE 4") != -1)? true : false,
	IE5 : (navigator.userAgent.indexOf("MSIE 5") != -1)? true : false,
	IE6 : (navigator.userAgent.indexOf("MSIE 6") != -1)? true : false,
	IE7 : (navigator.userAgent.indexOf("MSIE 7") != -1)? true : false,
	IE8 : (navigator.userAgent.indexOf("MSIE 8") != -1)? true : false,
	MacIE : (document.all && !window.clipboardData)? true : false,
	NN4 : (document.layers)? true : false,
	NN6 : (navigator.userAgent.indexOf("Netscape/6") != -1)? true : false,
	NN7 : (navigator.userAgent.indexOf("Netscape/7") != -1)? true : false
};

/**
 * OSDetect
 */
var OSDetect = {
	win : (navigator.userAgent.match(/Win/))? true : false,
	mac : (navigator.userAgent.match(/Mac/))? true : false
};

/**
 * css/js loader
 */
(function(){
	var GLOBALS={
		jsBaseURL : null,
		cssBaseURL : null
	};
	GLOBALS.jsBaseURL = (function(){
		var scripts = document.getElementsByTagName("script");
		return scripts[scripts.length-1].src.replace(/^(.+\/)[^/]*$/,"$1");
	})();
	GLOBALS.cssBaseURL = (function(){
		var links = document.getElementsByTagName("link");
		for(var i=0,link; link=links[i]; i++){
			if(!link.href) continue;
			if(link.href.search("css/common.css")>-1) return link.href.replace(/common\.css/,"");
		}
	})();
	function jsLoader(file)
	{
		if(!file) return;
		file = GLOBALS.jsBaseURL + file;
		document.open();
		document.write('<script type="text/javascript" src="'+ file + '"><\/script>');
		document.close();
	}
	function cssLoader(file)
	{
		if(!file) return;
		file = GLOBALS.cssBaseURL + file;
		document.open();
		document.write('<link href="' + file + '" rel="stylesheet" type="text/css" media="all">');
		document.close();
	}
	
	var legacy;
	if(browserDetect.safari2 || browserDetect.IE5 || browserDetect.MacIE){
		legacy = true;
	}else{
		legacy = false;
	}
	
	if(OSDetect.mac){
		cssLoader("os_mac.css");
	}
	if(!legacy){
		jsLoader("jquery.js");
		jsLoader("jqPopWin.js");
		jsLoader("misc.js");
	}
})();
