var URLParts		= document.location.href.split('/');
var URLHost			= URLParts[2];
var IS_PRD			= (URLHost.toLowerCase() == "www.happymeal.co.nz" || URLHost.toLowerCase() == "happymeal.co.nz")?true:false;
var IS_STG			= (URLHost.toLowerCase() == "www.staging.happymeal.co.nz")?true:false;
var IS_DEV			= (URLHost.toLowerCase() == "www.development.happymeal.co.nz")?true:false;

var ENV				= (IS_PRD)?'PRD':(IS_STG)?'STG':'DEV';


/*
* Configure gateway depending on current host
*/
var AFFGateway;
if(IS_STG){
	AFFGateway		= "http://mcworld.staging.happymeal.com/virtualworld/RemoteService";
}else if(IS_PRD){
	AFFGateway		= "http://mcworld.happymeal.com/virtualworld/RemoteService";
}else if(IS_DEV){
	AFFGateway		= "http://mcworld.development.happymeal.com/virtualworld/RemoteService";
}
else {
	AFFGateway		= "http://dev.creatainteractive.com/virtualworld/RemoteService";
}

/*
* Weekly Rollouts
*/
var today = new Date();
//process address bar overrides:
var dateY = getQueryStringParameter("y");
if(dateY != null){
	today.setYear(Number(dateY));
}
var dateM = getQueryStringParameter("m");
if(dateM != null){
	today.setMonth(Number(dateM)-1);
}
var dateD = getQueryStringParameter("d");
if(dateD != null){
	today.setDate(Number(dateD));
}
//alert(today);

//setup dates for 4 week rollout (1-4)
//Start by setting the week to the highest possible value:
var week = 4;
//only apply week logic to production:
if(IS_PRD){
	//reduce the week # according to the current date:
	if((today.getMonth()+1)==7){
		//out.println("It's July!");
		if(today.getDate()<27){
			week = 4;
		}
		if(today.getDate()<20){
			week = 3;
		}
		if(today.getDate()<13){
			week = 2;
		}
		if(today.getDate()<6){
			week = 1;
		}
	}else if((today.getMonth()+1)==8){
		//August
	}
}

/*
* Finally, Build Config
*/
var HappyMealLocale = 'en_NZ';
var HappyMealConfig = {
	env:			ENV,
	serverURL:		URLParts[0]+"//"+URLHost+"/",
	baseURL:		URLParts[0]+"//"+URLHost+"/"+URLParts[3]+"/",
	swfURL:			"/"+HappyMealLocale+"/swf/",
	swf3URL:		"/"+HappyMealLocale+"/swf3/",
	flvURL:			"/"+HappyMealLocale+"/flv/",
	gatewayURL:		"/hm2_3nz/RemoteService",
	aGateway: {
		URL: AFFGateway,
		languageName: "English (New Zealand)",
		languageAbbreviation: "en-NZ",
		languageId: 18,
		countryName: "New Zealand",
		countryAbbreviation: "NZ",
		countryId: 70
	},

	debugMode:		getQueryStringParameter("debug")	|| 0,
	date: {
		year:	today.getFullYear(),
		month:	(today.getMonth()+1),
		day:	today.getDate(),
		week:	getQueryStringParameter("w")	|| week
	},
	
	GoogleAnalytics: {
		enabled:	false,
		account:	"UA-527676-20"
	},
	
	WebTrends: {
		enabled:	true,
		domain:		"webtrends02.mcdonalds.com",
		ID:		"dcs0mznplawm1ir843y85kd3j_4p8g"
	},
	
	files: {
		main: {
			url:	getQueryStringParameter("swf")	|| "swf3/main.swf",
			id:		getQueryStringParameter("id")	|| "swf_mainContainer",
			width:	getQueryStringParameter("swfW")	|| "100%",
			height:	getQueryStringParameter("swfH")	|| "100%",
			color:	getQueryStringParameter("bgc")	|| "#FFFFFF",
			version: "10"
		},
		footer: {
			url:	"/"+HappyMealLocale+"/swf3/components/footer.swf",
			id:		"swf_Footer",
			width:	760,
			height:	130,
			version: "10"
		},
		expressInstall: {
			url:	"/"+HappyMealLocale+"/swf3/expressinstall.swf"	
		},
		core: {
			url:	"/"+HappyMealLocale+"/swf/core.swf"	
		},
		core3: {
			url:	"/"+HappyMealLocale+"/swf3/core.swf"	
		},
		config: {
			url:	"/"+HappyMealLocale+"/config/flash.xml"
		}
	},
	
	firstSection:	getQueryStringParameter("s") || URLParts[5]	|| "Home",
	lastSection:	getQueryStringParameter("bs")	|| "Home"
};


