var Server = {};

var scripts = document.getElementsByTagName("script");
for(var i=0;i<scripts.length;i++){
	if(/.*js\/main\.js$/g.test(scripts[i].getAttribute("src"))){
		var jsPath = scripts[i].getAttribute("src").replace(/js\/main\.js$/g,'');
		if(jsPath.indexOf("/")==0){
			Server.ContextPath = jsPath;
			break;
		}
		var arr1 = jsPath.split("/");
		var path = window.location.href;
		if(path.indexOf("?")!=-1){
			path = path.substring(0,path.indexOf("?"));
		}
		var arr2 = path.split("/");
		arr2.splice(arr2.length-1,1);
		for(var i=0;i<arr1.length;i++){
			if(arr1[i]==".."){
				arr2.splice(arr2.length-1,1);
			}
		}			
		Server.ContextPath = arr2.join('/')+'/';
		break;
	}
}

Server.loadScript = function(url){
	document.write('<script type="text/javascript" src="' + Server.ContextPath+url + '"><\/script>') ;
};

Server.loadCSS = function(url){
	if(isGecko){
		var e = document.createElement('LINK') ;
		e.rel	= 'stylesheet' ;
		e.type	= 'text/css' ;
		e.href	= url ;
		document.getElementsByTagName("HEAD")[0].appendChild(e) ;
	}else{
		document.createStyleSheet(url);
	}
};


window.onerror = function(message,file,line){
	return true;
};

/*START_LOADSCRIPT*/
Server.loadScript("theme/default/js/jquery.js");
Server.loadScript("theme/default/js/swfobject.js");
Server.loadScript("theme/default/js/jcarousellite_1.0.1.js");
Server.loadScript("theme/default/js/jquery.ifixpng.js");
Server.loadScript("theme/default/js/jquery.pngFix.js");
/*END_LOADSCRIPT*/
