var URLParts		= document.location.href.split('/');
var URLHost			= URLParts[2];
var IS_PRD			= (URLHost.toLowerCase() == "fun.mcdonalds.com")?true:false;
var IS_STG			= (URLHost.toLowerCase() == "fun.staging.mcdonalds.com")?true:false;
var IS_DEV			= (URLHost.toLowerCase() == "fun.development.mcdonalds.com")?true:false;
var IS_CREATA		= (!IS_PRD && !IS_STG && !IS_DEV)?true:false;

var ENV				= (IS_PRD)?'PRD':(IS_STG)?'STG':(IS_DEV)?'DEV':'CREATA';

var url = document.location.href;
var Locale = '';
if ((url.indexOf('http') < 0) || (url.indexOf('http://local.mcdonalds') >= 0)){ 
  Locale = '';
}
var LocalePath = '';
var LocaleFull = '';
var Application = "mva";
var Top = '' + Locale + '';
var uProtocol = 'http';
var uDomain =  '';
var uPath = '';

firstCutPos = url.indexOf('//');
uProtocol = url.substring(0,firstCutPos-1);
uPath = url.substring(firstCutPos+2);
nextCutPos = uPath.indexOf('/');
uDomain = uPath.substring(0,nextCutPos);
uPath = uPath.substring(nextCutPos+1);
lastCutPos = uPath.lastIndexOf('/');
uPath = uPath.substring(0,lastCutPos);
if (uPath.indexOf('#') > 0) {
  uPath = uPath.substring(0,uPath.indexOf('#')-1);
}
if (uPath == '#') {
  uPath = '';
}

uTop = uProtocol + "://" + uDomain + "/" + uPath + '/';
if (Locale !=  "" && uPath == "") {
  uTop = uTop + Locale + '/';
}

  
if (Locale != '')
{
  
  lastCutPos = url.lastIndexOf('/', url.length-2);
  LocalePath = url.substring(firstCutPos+2, lastCutPos);
	if (LocalePath.indexOf('/') >= 0) {
    LocalePath = LocalePath.substring(LocalePath.indexOf('/') + 1);
	  Top = '/' + LocalePath + '/' + Locale + '/';
    LocaleFull = LocalePath + '/' + Locale;
  }
  else {
    LocalePath = ''; 
	  Top = '/' + Locale + '/';
    LocaleFull = Locale;
  }
}

var MyConfig = {
  env:			ENV,
	serverURL:	uProtocol + "://" + uDomain,
	baseURL:		uProtocol + "://" + uDomain + "/" + uPath + "/",
	swf3DIR:		"swf3/languages/",
	localeDIR:      LocaleFull + "/",
	application:		Application,
	serviceGatewayURL: uProtocol + "://" + uDomain + "/" + Application + "/RemoteService",
		
	GoogleAnalytics: {
		enabled:	true,
		account:	"UA-527676-34",
		account2:	"UA-310045-19"
	},
		
	files: {
		main: {
			url:	getQueryStringParameter("swf")	|| uTop + "swf3/Main.swf",
			id:		getQueryStringParameter("id")	|| "defaultContent",
			width:	getQueryStringParameter("swfW")	|| "100%",
			height:	getQueryStringParameter("swfH")	|| "100%",
			color:	getQueryStringParameter("bgc")	|| "#000000",
			version: "9.0.0.0"
		},	

		expressInstall: {
			url:	uTop + "swf3/expressinstall.swf"	
		},

		config: {
			url:	uTop + "config/config.xml"
		}
	}
};

