//basePath
var basePath = "http://etmaps.evtel.com";

//Anonymous function (load all js and css) ******************************************************
(
function() {
	ETLoadJS();
	ETLoadCSS();
}
)();
//End Anonymous function (load all js and css) **************************************************

function ETLoadCSS()
{
	if ((typeof(pw) == "undefined")) {
		if (typeof(useIE) == "undefined") {
			ETincludeCSS("http://extjs.cachefly.net/ext-2.3.0/resources/css/ext-all.css","css"); //cachefly
			//ETincludeCSS("http://extjs/resources/css/ext-all.css","css"); //Eventi
		}
		ETincludeCSS("/css/style_etgm.css","css");
	} else if ((typeof(pw) != "undefined") && (pw == 1)) {
		ETincludeCSS("/css/style_etgm.css","css","screen");
		ETincludeCSS("/css/style_etgmprint.css","css","print");
	}
}

function ETLoadJS()
{
	if ((typeof(pw) == "undefined")) {
		ETinclude("/et-locale.js","js");
		//ETinclude("/extjs/ext-build.js","js");
		//ETinclude("/min/ext-basex-min.js","js");
	ETinclude("http://extjs.cachefly.net/builds/ext-cdn-2366.js","js"); //cachefly
	//ETinclude("http://extjs/ext-core.js","js"); //Eventi
	//ETinclude("http://extjs/ext-all.js","js"); //Eventi
		//ETinclude("http://extjs.cachefly.net/builds/ext-cdn-2235.js","js");
		//ETinclude("http://extjs.cachefly.net/builds/ext-cdn-2367.js","js");
		//ETinclude("http://extjs.cachefly.net/builds/ext-cdn-2060.js","js");
		ETinclude("/etutil.js","js");
		ETinclude("/mapInterface.js","js");
		ETinclude("/StreetViewPanoramaWindow.js","js");
		//serve solo per il titolo editabile
		if ((typeof(preview) != "undefined") && (preview)) {
			//ETinclude("/min/Ext.ux.PanelWEditableTitle-min.js","js");
			ETinclude("/extjs/extension/Ext.ux.PanelWEditableTitle.js","js");
		}
	} else if ((typeof(pw) != "undefined") && (pw == 1)) {
		//se necessario carico qualcosa (pw ==> printing)
		ETinclude("/et-locale.js","js");
	}
	ETinclude("/etgmfull.js","js");
}

function ETincludeCSS(to_add,what,media_type)
{
	//complete path...
	if (to_add.indexOf("http")==-1)
		to_add = basePath + to_add;

	if (what == "css") {
		var headID = document.getElementsByTagName("head")[0];
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = to_add;
		if ((typeof(media_type)!="undefined")) {
			cssNode.media = media_type;
		} else {
			cssNode.media = 'screen';
		}
		headID.appendChild(cssNode);
	}
}

function ETinclude(to_add,what)
{
	//complete path...
	if (to_add.indexOf("http")==-1)
		to_add = basePath + to_add;

	if (what == "js") {
		//var bodyID = document.getElementsByTagName("body")[0];
		//var newScript = document.createElement('script');
		//newScript.type = 'text/javascript';
		//newScript.defer = 'defer';
		//newScript.src = to_add;
    //bodyID.appendChild(newScript);
		
		document.write('<'+'script type="text/javascript" src="'+to_add+'">'+'<'+'\/script'+'>');
	}
}
