function reSetUserContext(destAirportCode,iFrameId){
	
	var cookiename = "usercontext";
	var userContextCookie = readCookie(cookiename);
	var cookieResult;
	
	if(userContextCookie){
		// we have a cookie
		cookieResult = userContextCookie;
		
		// Find if we have a full cookie or just a dep#SYD
		if(cookieResult.indexOf("arr#")==-1 && cookieResult.indexOf("|tvldate#")==-1){
			// half cookie
			var dummyDate = getdummydate(7);
			cookieResult += unescape("|arr#XXX|tvldate#"+dummyDate);
		}
	}
	else{
		// we dont have a cookie
		var dummyDate = getdummydate(7);
		cookieResult = unescape("dep#SYD|arr#XXX|tvldate#"+dummyDate);
	}
	
	var startIndex = cookieResult.indexOf("arr#");
	var endIndex = cookieResult.indexOf("|tvldate#");		
	var expDate = getexpirydate(365);		
	
	var startCookieResult = cookieResult.substring(0,startIndex+4);
	var endCookieResult = cookieResult.substring(endIndex,cookieResult.length);
	var finalString = startCookieResult + destAirportCode + endCookieResult;
	
	//alert("usercontext="+ finalString +";path=/;EXPIRES="+expDate);
	
	document.cookie="usercontext="+ finalString +";path=/;EXPIRES="+expDate;

	refreshPromos(iFrameId);
	
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function getexpirydate(nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function getdummydate(nodays){
	// returns a date in the following format: 20070511
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	var fullYear = Today.getFullYear();
	var fullMonth = (Today.getMonth()+1);
	var fullMonthStr = fullMonth.toString();
	if(fullMonthStr.length<2){
		fullMonthStr = "0"+fullMonthStr;
	}
	var fullDate = Today.getDate();
	var convertedDate = fullYear+''+fullMonthStr+''+fullDate;
	return convertedDate;
}

function refreshPromos(frameId){
	var myFrame = document.getElementById(frameId);
	myFrame.contentWindow.location.reload(true);
	// hides the map if there is one showing
	// this is not a good place to have it but when it s in
	// Flash along reSetUserContext it only calls one of them
	// and skips the other one.
	showHideMap(false);
}







