var Kiss = function(){};

// Static Variables
Kiss.URL_STAGE = "";
Kiss.URL_PREPROD = "";
Kiss.URL_PROD = "";

// Environments
Kiss.Env = 
{
	ENV_LOCAL	: 'env_local',
	ENV_STAGE	: 'env_stage',
	ENV_PREPROD	: 'env_preprod',
	ENV_PROD	: 'env_prod'
};

// Static Methods
Kiss.writeKissInsights = function()
{
	var kissURL = Kiss.getJSURL(Kiss.getEnvironment());
	document.write('<scr' + 'ipt type="text/javascript">var _kiq = _kiq || [];</scr' + 'ipt>');
	document.write('<scr' + 'ipt type="text/javascript" src="' + kissURL + '" async="true"></scr' + 'ipt>')
};

Kiss.getEnvironment = function()
{
	var url = document.URL;
	
	if(url.indexOf('local') != -1 || url.indexOf('localdev') != -1)
	{
		return Kiss.Env.ENV_LOCAL;
	}
	else if(url.indexOf('stage') != -1)
	{
		return Kiss.Env.ENV_STAGE;
	}
	else if(url.indexOf('contentmanager') != -1)
	{
		return Kiss.Env.ENV_PREPROD;
	}
	else
	{
		return Kiss.Env.ENV_PROD;
	}
};

Kiss.getJSURL = function(env)
{
	switch(env)
	{
		case Kiss.Env.ENV_LOCAL:
		case Kiss.Env.ENV_STAGE:
			return Kiss.URL_STAGE;
			break;
		
		case Kiss.Env.ENV_PREPROD:
			return Kiss.URL_PREPROD;
			break;
		
		default:
			return Kiss.URL_PROD;
	}
}
