var Mc = Class.create({
	initialize: function()
	{
		this.code = readCookie('mc');

		document.observe('dom:loaded', this.start.bind(this));
	},
	
	start: function()
	{
		this.input = $('mediaCodeInput');
		
		if (this.input)
		{
			this.input.setValue(this.code);
		}
		
		this.setAnaliticsValue();
	},
	
	setAnaliticsValue: function()
	{
		var input = $('gaInput');
		var cookie = readCookie('__utmz');
		
		if (input && cookie)
		{
			input.setValue(cookie);
		}
	},
	
	setCode: function(code)
	{
		this.code = code;
		createCookie('mc', this.code, 31);
	}
});


var mc = new Mc();
