var undefined;
function updateOptions(regionName) {
	var regionObj = getRegionDataObject(regionName);
	var countryArray = getRegionCountries(regionObj);
	var pricookie = getCookie(COUNTRY_COOKIE_NAME);
	var countryVal = parseCookieValue(pricookie);
	document.theForm.country.length = 1;
	for (var i=0;i<countryArray.length;i++) {
		var cobj = getCountryObject(countryArray[i]);
		if(cobj.id!=-1){
			addOption(document.theForm.country, cobj.name, cobj.countryISOCode);
		}
		//if there is a valid country code in countryVal var, and if it matches the current country iso code
		//if((countryVal!=undefined)&&(countryVal!="")&&(countryVal!=null)&&(countryVal==cobj.countryISOCode)){
			// then set the selected property of the country pulldown for that specific item in the list.
			// this enables the page to select the same country that you have cookied currently.
			//document.theForm.country.options[i].selected=true;
		//}
	}
	if(isMacintosh()&&isMSIE())document.theForm.country.blur();
}

function addOption(cbox, name, value) {
	var len = cbox.length;
	var option = new Option();
	option.text = name;
	option.value = value;
	cbox.options[len] = option;
	if(isMacintosh()&&isMSIE()){
		cbox.focus();
	}
}

// Check the browser...we're looking for ie/win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

function userDecision(b,countryName){
	var oldperm = parseCookieValue(getCookie(COUNTRY_COOKIE_NAME));
	var oldtemp = parseCookieValue(getCookie(COUNTRY_COOKIE_NAME_TMP));
	if(b){
		setPrimaryCookie(countryName);
		setTmpCookie(countryName);
		if (oldtemp==''){
			var trackingURL = getTrackerURL(oldperm, oldperm, countryName, countryName);
        	if (debug){ alert(trackingURL);}
			var trackerimg = new Image();
			trackerimg.src =  trackingURL;			
		}else{
			var trackingURL = getTrackerURL(oldperm, oldtemp, countryName, countryName);
        	if (debug){ alert(trackingURL);}
			var trackerimg = new Image();
			trackerimg.src =  trackingURL;
		}
	}
	else {
		setTmpCookie(countryName);
		if (oldtemp=='')  {
			var trackingURL = getTrackerURL(oldperm, oldperm, oldperm, countryName);
        	if (debug){ alert(trackingURL);}
			var trackerimg = new Image();
			trackerimg.src =  trackingURL;
		}
		else {
			var trackingURL = getTrackerURL(oldperm, oldtemp, oldperm, countryName);
        	if (debug){ alert(trackingURL);}
			var trackerimg = new Image();
			trackerimg.src =  trackingURL;
		}
	}

	var args = getArgs();
	var retURL = URLEncode(args.retURL);
	var retcountry = URLEncode(args.retcountry);
	if (isEmpty(retcountry)){
			retcountry = 1;
		}else{
			retcountry = parseInt(retcountry);
			if(parseInt(retcountry)!=1){retcountry = 0;}
	}	
	sendToDestination(retURL, retcountry, window,countryName); 
}
