/**
* This function is instantiated on page load and captures marketing variables passed
* on the URL and stores them in a cookie for the purpose of passing the values on to
* tickets1.livenation.com when a buy ticket link is clicked.
**/
LIVENATION.global.marketing_vars = function(query){
	var objQueryString = query.parseQueryString();
	var cookie_value = '';
	if (objQueryString.c != undefined && objQueryString.p != undefined) {
		//alert('writing m_vars cookie');
		cookie_value += 'c=' + objQueryString.c + '&p=' + objQueryString.p;
	}
	else if (objQueryString.c != undefined && objQueryString.p == undefined) {
		cookie_value += 'c=' + objQueryString.c;
	}
	else if (objQueryString.c == undefined && objQueryString.p != undefined) {
		cookie_value += 'p=' + objQueryString.p;
	}
	
	if (cookie_value != '') {
		Cookie.write('m_vars', cookie_value, {domain: '.livenation.com', path: '/'});
	}
}

// add onload handling here which checks for anything in the querystring and if so, passes to marketing_vars
window.addEvent('load', function() {
	var query = window.location.search.substring(1);
	if (query) {
		//alert('calling marketing_vars');
		LIVENATION.global.marketing_vars(query);
	}
});