var lastOpenNavMenu
var lastOpenTipAnswer
var customGoHome
var customLookupCountryDomain
var customNoRegionCookie
var customPageIsUnloading
var customSetFormAction
var customUpdateSessionOnNewRegion
var customGetDomain
var customFormSubmit
var customSwapDomains
var customGo


LETTERS = NUMBERS = SPACES = RETURNS = SECURE = true
INSECURE = false
SESSION_DELIMITER = ";"
LIST_DELIMITER = "|"

var pageIsSubmitted = false
var popupWindow = null
var display = null
var currentFocus = null
var display = ""
var menuLoadValues = ""

var fields = new Array()
var fieldNames = new Array()
var groups = new Array()
var groupNames = new Array()
var radioSets = new Array()
var customErrorMsgs = new Array()
var limitedContents = new Array()

function fieldObj(name, type, label, required, length, validation, group, targets) {
	fieldNames[fieldNames.length] = name
	this.name = name
	this.type = type
	this.label = label
	this.required = required
	this.length = length
	this.validation = validation
	this.group = group
	this.targets = targets
	this.initialValue = null
	this.getField = getField
	this.getValue = getValue
	this.setValue = setValue
	this.setFocus = setFocus
	this.setInitialValue = setInitialValue
	if (group != "") {
		if (groups[group] == null) {
			groupNames[groupNames.length] = group
			groups[group] = new Array()
		}
		groups[group][groups[group].length] = this
	}
}

function getField() {
	return eval("getForm()." + this.name)
}

function getValue() {
	var fieldRef = this.getField()
	if (fieldRef == null) return ""
	type = (fieldRef.type == null) ? fieldRef[0].type : fieldRef.type
	if (type == "checkbox") {
		if (fieldRef.checked) {
			return "on"
		} else {
			return "off"
		}
	} else if (type == "radio") {
		if (fieldRef.length == null || fieldRef[0] == null){
			if (fieldRef.checked) {
				return fieldRef.value
			} else {
				return ""
			}
		} else {
			for (var i = 0; i < fieldRef.length; i++) {
				if (fieldRef[i] != null && fieldRef[i].checked) {
					return fieldRef[i].value
				}
			}
			return ""
		}
	} else if (type.indexOf("select") != -1) {
		if (fieldRef.selectedIndex == -1) {
			value = ""
		} else {
			value = fieldRef.options[fieldRef.selectedIndex].value
			if (value == "*") {
				value = fieldRef.options[fieldRef.selectedIndex].text
			}
		}
		return trim(value)
	} else {
		return trim(fieldRef.value)
	}
}

function setInitialValue() {
	if (this.initialValue != null) {
		this.setValue(this.initialValue)
	}
}

function setValue(value) {
	fieldRef = this.getField()
	if (fieldRef == null) return ""
	type = (fieldRef.type == null) ? fieldRef[0].type : fieldRef.type
	if (type == "checkbox") {
		fieldRef.checked = (value == "true") || (value == "on") || (fieldRef.value == value)
	} else if (type == "radio") {
		if (fieldRef.length == null){
			radioClick(fieldRef, null, fieldRef.value == value ? "on" : "off")
		} else {
			var radioClickDone = false
			for (var i = 0; i < fieldRef.length; i++) {
				if (fieldRef[i].value == value) {
					radioClick(fieldRef[i], null, "on")
					radioClickDone = true
				} else if (value == "" || value == null) {
					radioClick(fieldRef[i], null, "off")
				} else {
					fieldRef[i].checked = false
				}
			}
			if ((value != "" || value != null) && !radioClickDone) {
				radioClick(fieldRef[0], null, "off")
			}
		}
	} else if (type == "select-one") {
		menuLoadValues += this.name +"="+ value +";"
		if (value == "") {
			if (fieldRef.size > 0) {
				return
			}
			fieldRef.selectedIndex = 0
		} else {
			for (var i = 0; i < fieldRef.options.length; i++) {
				menuItem = fieldRef.options[i].value != "" ? fieldRef.options[i].value : fieldRef.options[i].text
				if (menuItem == value) {
					fieldRef.selectedIndex = i
					break
				}
			}
		}
	} else {
		fieldRef.value = value
	}
}

function setFocus() {
	this.getField().focus()
}

//----- cookies -----

function isHttpOnly(cookieName) {
    if (cookieName.indexOf("6CGGUK") != -1) return false;
    if (cookieName.indexOf("AGENTLOCATORSURVEY") != -1) return false;
    if (cookieName.indexOf("CNY") != -1) return false;
    if (cookieName.indexOf("CONTROL") != -1) return false;
    if (cookieName.indexOf("D2B_Destination") != -1) return false;
    if (cookieName.indexOf("DHECT3") != -1) return false;
    if (cookieName.indexOf("DORMANT_FLOW_START") != -1) return false;
    if (cookieName.indexOf("HOME_PAGE") != -1) return false;
    if (cookieName.indexOf("HXBV8D") != -1) return false;
    if (cookieName.indexOf("image") != -1) return false;
    if (cookieName.indexOf("JGYCYV") != -1) return false;
    if (cookieName.indexOf("KXMJ2H") != -1) return false;
    if (cookieName.indexOf("MM_FlashUserDemurred") != -1) return false;
    if (cookieName.indexOf("MM_FlashDetectedSelf") != -1) return false;
    if (cookieName.indexOf("languagePref") != -1) return false;
    if (cookieName.indexOf("languagePrefs") != -1) return false;
    if (cookieName.indexOf("LAST_SERVLET_CALL") != -1) return false;
    if (cookieName.indexOf("limitedContent_") != -1) return false;
    if (cookieName.indexOf("LinkShareDateStamp") != -1) return false;
    if (cookieName.indexOf("LinkShareID") != -1) return false;
    if (cookieName.indexOf("LinkShareMerchantID") != -1) return false;
    if (cookieName.indexOf("LOGIN_STATE") != -1) return false;
    if (cookieName.indexOf("mtReceipt") != -1) return false;
    if (cookieName.indexOf("PERMISSIONS") != -1) return false;
    if (cookieName.indexOf("region") != -1) return false;
    if (cookieName.indexOf("SECURE_KEY") != -1) return false;
    if (cookieName.indexOf("SERVER_VALUE") != -1) return false;
    if (cookieName.indexOf("SESSION_CREATED") != -1) return false;
    if (cookieName.indexOf("SESSION_ID") != -1) return false;
    if (cookieName.indexOf("SuccessfulTransaction") != -1) return false;
    if (cookieName.indexOf("time") != -1) return false;
    if (cookieName.indexOf("TNS_SURVEY") != -1) return false;
    if (cookieName.indexOf("UNIQUE_ID") != -1) return false;
    return true
}

function getCookie(name) {
	name = doEscape(name)
	var cookie = document.cookie
	var offset, value
	if ((offset = cookie.indexOf(name +"=")) != -1) {
		if ((endOffset = cookie.indexOf(";", offset)) == -1) {
			value = cookie.substring(offset + name.length + 1)
		} else {
			value = cookie.substring(offset + name.length + 1, endOffset)
		}
	}
	return doUnescape(value)
}

function setCookie(name, value, expDate) {
	var cookie = doEscape(name) +"="+ doEscape(removeIllegalChars(value)) + ";domain=" + getDomain() + ";path=/"
	if (expDate == "") {
		var exp = new Date()
		exp.setTime(exp.getTime() + (365 * 24 * 60 * 60 * 1000 * 10))
		cookie += ";expires=" + exp
	} else if (expDate != null) {
		cookie += ";expires=" + expDate
	}
	if ((name.indexOf("region") == -1) && (name.indexOf("language") == -1)) {
	    cookie += ";secure "
	}
	//if (isHttpOnly(name)) {
	//   cookie += "; httponly" 
	//}

	document.cookie = cookie
}

function removeIllegalChars(data) {
	var regExp = /[<>"'%;)(&+]/g // "
	return (data + "").replace(regExp, "")
}

function getExpDate(days){
	var date = new Date()
	tenYearsFromNow = date.getTime() + (days * 24 * 60 * 60 * 1000)
	date.setTime(tenYearsFromNow)
	return date.toGMTString()
}

function doEscape(text) {
	if (text == null || text == "") {
		return text;
	} else {
		return convertChar(convertChar(escape(text), "%", "%25"), "_", "%5F")
	}
}

function doUnescape(text) {
	if (text == null || text == "") {
		return text;
	} else {
		return unescape(convertChar(text, "%25", "%"));
	}
}

// -----

function appendCountryParameter(region, domain, filePath, params) {
	return useCountry == "true" &&
		(
			getDomain().indexOf(getDomain(null, domain)) == -1 ||
			region != getRegion() ||
			(
				region != "US" &&
				domain.indexOf("westernunion.com") != -1 &&
				domain.indexOf("westernunion.com.au") == -1
			)
		) &&
		filePath.indexOf("selectCountry") == -1 &&
		filePath.indexOf("country=") == -1 &&
		(params == null || params.indexOf("country=") == -1)
}

function checkDirectory(filePath) {
	if (
		filePath.indexOf("homePage") == -1 &&
		filePath.indexOf("index_") == -1 &&
		filePath.indexOf("/") == -1
	) {
		filePath = "asp/" + filePath
	}
	return filePath
}

function buildLocalFilePath(filePath, region, makeSecure, domain) {
	filePath = checkDirectory(filePath)
	if (filePath.charAt(0) == "/") {
		filePath = filePath.substring(1)
	}
	url = domain != null ? domain : lookupCountryDomain(region, filePath, makeSecure)
	if (("/" + filePath).indexOf(path) != 0) {
		url += path
	} else {
		url += "/"
	}
	url += filePath
	return url
}

function changeImages(imageName, onImage) {
	document[imageName].src = onImage
}

function changeStyle(object, style) {
	object.className = style
}

function comma(number) {
	var numberArray = number.split(".")
	var integerValue = numberArray[0]
	var decimalValue = numberArray[1]
	var integerValueLength = integerValue.length
	var result = ""
	for (var i = integerValueLength - 1 ; i >= 0; i--) {
		if ((integerValueLength - i) % 3 == 1 && i != integerValueLength - 1) {
			result = "," + result
		}
		result = integerValue.charAt(i) + result
	}
	return result + (decimalValue != null ? "." + decimalValue : "")
}

function completeSubmission(which) {
	var form = getForm()
	var newDisplay
	var currentPage = lookupNameValuePair(form.SESSION.value, "CURRENT_PAGE")
	if (currentPage.indexOf("agentLink") != -1) {
		newDisplay = lookupNameValuePair(form.SESSION.value, "NEW_DISPLAY")
	}
	var regExp = new RegExp("&(#?[^ \n\r\t;]*);","g")
	form.SESSION.value = form.SESSION.value.replace(regExp, "&$1\t")
	var regExp = new RegExp("&([^#;& \n\r\t]?[^;& \n\r\t]*([ \n\r&])|[^#;& \n\r\t]?[^;& \n\r\t]*$)","g")
	form.SESSION.value = form.SESSION.value.replace(regExp, "&amp\t$1")
	if (form.RESULT.value == "ERROR") {
		destination = form.action
		var errorField = lookupNameInNameValuePairs(form.SESSION.value, "_ERROR")
		if (errorField != null) {
			errorField = errorField.substring(0, errorField.indexOf("_ERROR"))
		}
		setFormAction(lookupNameValuePair(form.SESSION.value, "CURRENT_PAGE"), null,"err=" + errorField)
		if (display != null && display != "") {
			removeFromSession("DISPLAY", false)
			if (display == "MODIFY") {
				display = "MODIFY_ERROR"
			}
			form.SESSION.value += "DISPLAY=" + display + SESSION_DELIMITER + "DESTINATION=" + destination + SESSION_DELIMITER
		}
	} else {
		if (currentPage.indexOf("agentLink") != -1) {
			display = newDisplay
		}
		updateDisplay()
		form.RESULT.value = "SUBMIT"
		action = form.action
		if ((actionOffset = form.action.lastIndexOf("/")) != -1) {
			action = action.substring(actionOffset + 1)
		}
		if (action.indexOf("sessionTerminated.asp") != -1) {
			if (which == "newUser") {
				setFormAction(newUserPage)
			} else if (which == "signIn") {
				setFormAction(signInPage)
			} else {
				submitPage = lookupNameValuePair(form.SESSION.value, "SUBMIT_PAGE")
				if (
					currentPage == null ||
					submitPage == null ||
					currentPage == "" ||
					submitPage == ""
				) {
					return true
				} else {
					setFormAction(submitPage, null, customParams())
				}
			}
		}
		pruneSession()
	}
	enterCheckboxesInSession()
	return true
}

function convertChar(text, oldString, newString) {
	if (text == null) return null
	if (text == "") return ""
	text += ""
	prevOffset = offset = count = 0
	newLength = newString.length

	while (prevOffset < text.length && (offset = text.substring(prevOffset).indexOf(oldString)) != -1 && count++ < 1000) {
		offset += prevOffset;
		text = text.substring(0,offset) + newString + text.substring(offset + oldString.length)
		prevOffset = offset + newLength
	}
	return text
}

function customParams() {}

function customValidation() {}

function doKeyDown(evt) {
	if (evt.which == 13) {
		if (doSubmit()) formSubmit(getForm())
		return false
	}
	return true
}

function doRefresh(closePopup, params) {
	var windowDisplay = display
	var form = getForm()
	if (closePopup != null && opener != null && opener.popupWindow != null) {
		form = opener.getForm()
		windowDisplay = opener.display
	}
	if (windowDisplay != null && windowDisplay != "") {
		removeFromSession("DISPLAY", false, form)
		form.SESSION.value = form.SESSION.value + "DISPLAY=" + windowDisplay + SESSION_DELIMITER
	}
	form.RESULT.value = "REFRESH"
	currentPage = lookupNameValuePair(form.SESSION.value, "CURRENT_PAGE")
	if (currentPage != null && currentPage.indexOf("SubmitHeader") != -1) {
		var hold_form = form
		var hold_currentPage = currentPage
			
		var form = parent.completeTransactionContent.document.forms[0];	   
		if (form != null) {
			currentPage = lookupNameValuePair(form.SESSION.value, "CURRENT_PAGE")
			if (currentPage.indexOf("Receipt") != -1) {
				form.RESULT.value = "REFRESH"
				setFormAction(currentPage, null, params, null, form)			 
				updateDisplayForm(form)
				formSubmit(form)
		    	}
		}
		form = hold_form
		currentPage = hold_currentPage
	}
	if (currentPage == null) {
		currentPage = lookupNameValuePair(form.SESSION.value, "SUBMIT_PAGE")
	        if (currentPage.indexOf("Receipt") != -1) {
			form.RESULT.value = "REFRESH"
			setFormAction(currentPage, null, params, null, form)			 
			updateDisplayForm(form)
			formSubmit(form)
		}
	}
		
	setFormAction(currentPage, null, params, null, form)
	updateDisplay()
	formSubmit(form)
	if (closePopup == true && opener != null && opener.popupWindow != null) {
		close()
	}
}

function doSubmit() {
	if (pageIsSubmitted || fields == null) return false
	pageIsSubmitted = true
	validate()
	if (customValidation() == false) return false
	var result = completeSubmission()
	return result
}

function enterCheckboxesInSession() {
	var form = getForm()
	for (var i = 0; i < fieldNames.length; i++) {
		theField = fields[fieldNames[i]]
		if (theField.type == "checkbox" && theField.getValue() == "off") {
			checkboxName = theField.name
			removeFromSession(checkboxName, false)
			form.SESSION.value = form.SESSION.value + checkboxName + "=off" + SESSION_DELIMITER
		}
	}
}

function error(msg, field, validation, substitutions) {
	var form = getForm()
	if (validation != null) {
		customErrorMsg = customErrorMsgs[field.name + "_" + validation]
		if (customErrorMsg != null && customErrorMsg != "") {
			msg = customErrorMsg
		}
		if (substitutions != null) {
			for (var i = 0; i < substitutions.length; i++) {
				msg = convertChar(msg, substitutions[i][0], substitutions[i][1])
			}
		}
	}
	if ((errorCode = errorCodes[validation]) != null) {
		msg = errorCode +" "+ msg
	}
	if (field != "ERROR") {
		form.SESSION.value += field.name + "_ERROR=" + msg + SESSION_DELIMITER
		if ((group = field.group) != '') {
			form.SESSION.value += group + "_ERROR=*" + SESSION_DELIMITER
		}
		if ((SESSION_DELIMITER + form.SESSION.value).indexOf(SESSION_DELIMITER + "ERROR=") == -1) {
			form.SESSION.value += "ERROR=*" + SESSION_DELIMITER
		}
	} else {
		removeFromSession("ERROR", false)
		form.SESSION.value += "ERROR=" + msg + SESSION_DELIMITER
	}
	form.RESULT.value = "ERROR"
}

function formSubmit(form) {
	if (customFormSubmit) {
		customFormSubmit(form)
	} else {
    if (form.PAGE_NAME.value.indexOf("CorporateContactUs") != -1) {
			  form.PAGE_NAME.value = "helpContactUs" 
		}			
		form.submit()
	}
}

function getBrowserVersion() {
	var appVersion = navigator.appVersion
	if ((offset = appVersion.indexOf(" ")) != -1) {
		appVersion = appVersion.substring(0, offset)
	}
	if (isNaN(appVersion = parseInt(appVersion))) {
		return "0"
	}
	return appVersion
}

function getDefaultHomePage(country) {
	if (("US,RU").indexOf(country) != -1) {
		return "index_consumer"
	} else if (("U1,R1").indexOf(country) != -1) {
		return "info/bsIndex"
	} else {
		return "info/homePage"
	}
}

function getDefaultLanguage(country) {
	if (countryLanguages[country] != null) {
		return countryLanguages[country].split(",")[0]
	}
	return "en"
}

var customGetDocumentLocation
function getDocumentLocation() {
    if (customGetDocumentLocation )return customGetDocumentLocation()
    return document.location.href + ""
}

function getDomain(segments, url) {
	if (url == null) {
		url = document.location + ""
	}
	var urlSegments = url.split("/")
	if (segments == "full") {
		return urlSegments[0] +"//"+ urlSegments[2]
	}
	var domain = urlSegments[2].split(":")[0]
	var domainSegments = domain.split(".")
	var segmentCount = domainSegments.length
	if (segments == null) {
		segments = segmentCount - 1
	} else if (segments == "first") {
		return domainSegments[0]
	}
	var result = ""
	for (var i = segmentCount - 1; i >= segmentCount - segments; i--) {
		result = domainSegments[i] + (result != "" ? "." : "") + result
	}
	return result
}

function getForm() {
	if (document.forms.length > 1) {
		return document.mainForm
	} else {
		return document.forms[0]
	}
}

function getHomePage(form, country) {
	var homePage = getCookie("HOME_PAGE")
	if ((homePage == null || homePage == "") && form != null) {
		homePage = lookupNameValuePair(form.SESSION.value, "HOME_PAGE")
	}
	if (homePage != null && homePage != "") {
		var homePageArray = homePage.split(LIST_DELIMITER)
		var found = false
		for (var i = 0; i < homePageArray.length; i++) {
			var countryHomePage = homePageArray[i].split(":")
			if (countryHomePage[0] == country) {
				homePage = countryHomePage[1]
				found = true
				break
			}
		}
		if (!found) {
			homePage = getDefaultHomePage(country)
		}
	} else {
		homePage = getDefaultHomePage(country)
	}
	return homePage
}

function getLanguage(country) {
	var form = getForm()
	if (country == null) {
		country = getRegion()
	}
	var customCountry
	if (customGetCountry && (customCountry = customGetCountry(country)) != null) {
		country = customCountry
	}
	var language
	if (useLanguage == "true") {
		if ((languagePrefs = getCookie("languagePref")) == null) {
			if (form && form.SESSION) {
				languagePrefs = lookupNameValuePair(form.SESSION.value, "language")
				if (languagePrefs == null || languagePrefs == "") {
					if (fields["language"] != null && fields["language"].getValue().length == 2 && fields["language"].getValue() != getDefaultLanguage(country)) {
						languagePrefs = country + ":" + fields["language"].getValue() + LIST_DELIMITER
					}
				}
			}
		}
		if (languagePrefs != null && languagePrefs != "") {
			var languageArray = languagePrefs.split(LIST_DELIMITER)
			var found = false
			for (var i = 0; i < languageArray.length; i++) {
				var countryLanguage = languageArray[i].split(":")
				if (countryLanguage[0] == country) {
					language = countryLanguage[1]
					found = true
					break
				}
			}
		}
		if (!found) {
   	        language = getDefaultLanguage(country)
		}
	} else {
        language = getDefaultLanguage(country)
	}
	return language
}

function getQueryParameter(key) {
	var url = document.location.toString()
	key = key.toLowerCase() + "="
	var offset = url.toLowerCase().indexOf("?" + key)
	if (offset == -1) {
		offset = url.toLowerCase().indexOf("&" + key)
	}
	if (offset == -1) {
		return null
	}
	url = url.substring(offset + key.length + 1)
	if ((offset = url.indexOf("&")) != -1) {
		url = url.substring(0, offset)
	}
	if ((offset = url.indexOf("#")) != -1) {
		url = url.substring(0, offset)
	}
	return url
}

function getRegion(url) {
	var form = getForm()
	var region
	if ((region = getQueryParameter("country")) != null) {
		return region
	} else if ((region = getCookie("region")) != null) {
		return region
	} else if (form != null && (region = lookupNameValuePair(form.SESSION.value, "region")) != null) {
		return region
	} else {
		region = lookupCountryByDomain(url)
		if (form != null || region != "US") {
			return region
		}
	}
}

function analyzeURL(url)
{
	var Url = location.href
	Url = Url.replace(/.*\?(.*?)/,"$1")
	Variables = Url.split ("&")
	//Variables = ""
	var result = ""
	
	for (i = 0; i < Variables.length; i++) 
	{       
		Separ = Variables[i].split("=")
		if(Separ[0] == "src" || Separ[0] == "pid")
		{
			result+=Separ[0]+'='+Separ[1]
		}
		//alert (Separ[0]+'="'+Separ[1]+'"')
	}
	return result
}

function get_new_framework_url(region,where) {
	var newfm_url = ""
	var newfm_domain = "www.westernunion.__"
	var pageName = "HomePage"
	var sprotocol = "http://"

	var toadd = ""
	
	toadd = analyzeURL(location.href)
	
	if ( (where != null) && (where.indexOf("osMoneyTransferOptions") != -1) ) {
		   pageName = "osMoneyTransferOptions"
	     sprotocol = "https://"
	}

	
	var env = environment.toLowerCase();


  if (is_new_framework_NT_country(region))  {
 			if (env.indexOf("dev") != -1 || env.indexOf("local") != -1) 
				newfm_domain = "devnt.westernunion.com"
			else if (env.indexOf("qa") != -1)
				newfm_domain = "qant.westernunion.com"
			else if (env.indexOf("uat") != -1)
			{ 
				if(region != "UA")
				{
					if (region == "NG")
					{
						newfm_domain = "uatntnigeria.westernunion.__"
					}
					else if(region == "CM")
					{
						newfm_domain = "uatntcameroon.westernunion.__"
					}
					else if(region == "AI" || region == "AG" || region == "AW" || region == "BS" || region == "BB" || region == "BZ" || region == "BM" || region == "VI" || region == "KY" || region == "DM" || region == "DO" || region == "GD" || region == "GY" || region == "HT" || region == "JM" || region == "MS" || region == "KN" || region == "LC" || region == "S1" || region == "MF" || region == "VC" || region == "SR" || region == "TT" || region == "TC" || region == "VG")
					{
						newfm_domain = "uatntcaribbean.westernunion.__"
					}
					else if(region == "FJ" || region == "WS" || region == "TO" || region == "GU" || region == "PG")
					{
						newfm_domain = "uatntpacific.westernunion.__"
					}
					else if(region == "SN")
					{
						newfm_domain = "uatntsenegal.westernunion.__"
					}
					else if(region == "CU")
					{
						newfm_domain = "uatntcuba.westernunion.__"
					}
					else if(region == "IN")
					{
						newfm_domain = "uatntindia.westernunion.__"
					}
					else if(region == "MA")
					{
						newfm_domain = "uatntmorocco.westernunion.__"
					}
					else if(region == "DZ")
					{
						newfm_domain = "uatntalgeria.westernunion.__"
					}
					else if(region == "ID")
					{
						newfm_domain = "uatntindonesia.westernunion.__"
					}
					else if(region == "TN")
					{
						newfm_domain = "uatnttunisia.westernunion.__"
					}
					else if(region == "AE")
					{
						newfm_domain = "uatntuae.westernunion.__"
					}
					else if(region == "KW")
					{
						newfm_domain = "uatntkuwait.westernunion.__"
					}
					else if(region == "GA")
					{
						newfm_domain = "uatntgabon.westernunion.__"
					}
					else if(region == "CO")
					{
						newfm_domain = "uatntcolombia.westernunion.__"
					}
					else
						newfm_domain = "uatnt.westernunion.__"
				}
				else
		     			newfm_domain = "uatnt.westernunion.com"  
			}


	}    
  else { 				
		if (env.indexOf("dev") != -1 || env.indexOf("local") != -1) 
			newfm_domain = "devstg.westernunion.com"
		else if (env.indexOf("qa") != -1)
			newfm_domain = "qastg.westernunion.com"
		else if (env.indexOf("uat") != -1) 		
	     newfm_domain = "uatstg.westernunion.com"
	}
	
	// temporary code to redirect to Venus Environments for Spain
	if (region == "ES") {
			if (env.indexOf("qa") != -1)
				newfm_domain = "qavenus.westernunion.com"
			else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatvenus.westernunion.com"  
  }	
	else if(region == "AT")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qa.westernunion.at"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uat.westernunion.at"  
	}
	else if(region == "AU")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qa.westernunion.com.au"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uat.westernunion.com.au"  
	}
	else if(region == "SE")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qa.westernunion.se"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uat.westernunion.se"  
	}	
	else if(region == "IE")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qawucr.westernunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatmercury.westernunion.com"  
	}
	else if(region == "GB")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qawucr.westernunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatmercury.westernunion.com"  
	}
	else if(region == "NO")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qavenus.westernunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatvenus.westernunion.com"  
	}
	else if(region == "IT")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qavenus.westernunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatvenus.westernunion.com"  
	}
	else if(region == "NZ")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "qavenus.westernunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatvenus.westernunion.com"  
	}
	else if(region == "US")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "jupiter.qawesternunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatjupiter.westernunion.com"  
	}
	else if(region == "BE")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "venus.qawesternunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatvenus.westernunion.com"  
	}
	else if(region == "CA")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "venus.qawesternunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatvenus.westernunion.com"  
	}
	else if(region == "PT")
	{
		if (env.indexOf("qa") != -1)
			newfm_domain = "venus.qawesternunion.com"
		else if (env.indexOf("uat") != -1) 
		     newfm_domain = "uatvenus.westernunion.com"  
	}

	var lang = getLanguage(region) + ""
  if (lang.length != 2) {
     lang = "en"
  }
	  
	var regEx = new RegExp ('__', 'i') ;
	
  if (region == "US")      newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "GB") newfm_domain = newfm_domain.replace(regEx, 'co.uk')
	else if (region == "CA") newfm_domain = newfm_domain.replace(regEx, 'ca')
	else if (region == "IT") newfm_domain = newfm_domain.replace(regEx, 'it')
  else if (region == "NZ") newfm_domain = newfm_domain.replace(regEx, 'co.nz')
	else if (region == "DE") newfm_domain = newfm_domain.replace(regEx, 'de')
	else if (region == "ES") newfm_domain = newfm_domain.replace(regEx, 'es')		
	else if (region == "FR") newfm_domain = newfm_domain.replace(regEx, 'fr')
	else if (region == "NL") newfm_domain = newfm_domain.replace(regEx, 'nl')
	else if (region == "UA") newfm_domain = newfm_domain.replace(regEx, 'ua')
	else if (region == "PL") newfm_domain = newfm_domain.replace(regEx, 'pl')
	else if (region == "DK") newfm_domain = newfm_domain.replace(regEx, 'dk')
	else if (region == "GR") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "KE") newfm_domain = newfm_domain.replace(regEx, 'co.ke')
	else if (region == "NG") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "AR") newfm_domain = newfm_domain.replace(regEx, 'com.ar')
	else if (region == "PA") newfm_domain = newfm_domain.replace(regEx, 'com.pa')
	else if (region == "ZA") newfm_domain = newfm_domain.replace(regEx, 'co.za')
	else if (region == "CM") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "AT") newfm_domain = newfm_domain.replace(regEx, 'at')
	else if (region == "AU") newfm_domain = newfm_domain.replace(regEx, 'com.au')
	else if (region == "SE") newfm_domain = newfm_domain.replace(regEx, 'se')
	else if (region == "BE") newfm_domain = newfm_domain.replace(regEx, 'be')
	else if (region == "AI") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "AG") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "AW") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "BS") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "BB") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "BZ") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "BM") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "VI") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "KY") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "DM") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "DO") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "GD") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "GY") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "HT") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "JM") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "MS") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "KN") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "LC") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "S1") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "MF") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "VC") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "SR") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "TT") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "TC") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "VG") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "FJ") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "WS") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "TO") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "GU") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "IE") newfm_domain = newfm_domain.replace(regEx, 'ie')
	else if (region == "PE") newfm_domain = newfm_domain.replace(regEx, 'com.pe')
	else if (region == "TR") newfm_domain = newfm_domain.replace(regEx, 'com.tr')
	else if (region == "UG") newfm_domain = newfm_domain.replace(regEx, 'co.ug')
	else if (region == "CI") newfm_domain = newfm_domain.replace(regEx, 'ci')
	else if (region == "SN") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "NO") newfm_domain = newfm_domain.replace(regEx, 'no')
	else if (region == "PG") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "PT") newfm_domain = newfm_domain.replace(regEx, 'pt')
	else if (region == "CU") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "BR") newfm_domain = newfm_domain.replace(regEx, 'com.br')
	else if (region == "MX") newfm_domain = newfm_domain.replace(regEx, 'com.mx')
	else if (region == "IN") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "RO") newfm_domain = newfm_domain.replace(regEx, 'ro')
	else if (region == "MA") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "DZ") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "RU") newfm_domain = newfm_domain.replace(regEx, 'ru')
	else if (region == "TN") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "ID") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "MY") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "AE") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "KW") newfm_domain = newfm_domain.replace(regEx, 'com')
	else if (region == "CH") newfm_domain = newfm_domain.replace(regEx, 'ch')
	else if (region == "GA") newfm_domain = newfm_domain.replace(regEx, 'com')
  	else if (region == "CO") newfm_domain = newfm_domain.replace(regEx, 'com')
  	else if (region == "VE") newfm_domain = newfm_domain.replace(regEx, 'co.ve')

  if (region == "US") {
  	if ( (where != null) && (where.indexOf("osMoneyTransferOptions") != -1) ) {
  	  regEx = new RegExp ('www', 'i') ;
      newfm_domain = newfm_domain.replace(regEx, 'wumt')
	  }
  }
  else
  if (region == "UA") {
  	lang = "uk"
 	  //regEx = new RegExp ('www', 'i') ;
    //newfm_domain = newfm_domain.replace(regEx, 'wunt')
  }
  else
  if (region == "ES") {
  	lang = "es"
  }
  else
  if (region == "GR") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'wunt');
	  lang = "el"
  }
  else
  if (region == "NG") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'nigeria');
  }
   else
  if (region == "DK") {
	lang = "da"
  }
   else
  if (region == "PL") {
	lang = "pl"
  }
  else
  if (region == "AR") {
  	lang = "sp"
  }
  else
  if (region == "PA") {
	lang = "sp"
  }
  else
  if (region == "CM") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'cameroon');
  	lang = "fr"
  }
  else
  if (region == "AT") {
	lang = "de"
  }
  else
  if (region == "SE") {
	lang = "sv"
  }
  else
  if (region == "BE") {
	lang = "fr"
  }
  else
  if (region == "AI" || region == "AG" || region == "AW" || region == "BS" || region == "BB" || region == "BZ" || region == "BM" || region == "VI" || region == "KY" || region == "DM" || region == "DO" || region == "GD" || region == "GY" || region == "HT" || region == "JM" || region == "MS" || region == "KN" || region == "LC" || region == "S1" || region == "MF" || region == "VC" || region == "SR" || region == "TT" || region == "TC" || region == "VG") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'caribbean');
  }
  else
  if (region == "FJ" || region == "WS" || region == "TO" || region == "GU" || region == "PG") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'pacific');
  }
  else
  if (region == "PE") {
	lang = "sp"
  }
  else
  if (region == "TR") {
	lang = "tr"
  }
  else
  if (region == "CI") {
	lang = "fr"
  }
  else
  if (region == "SN") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'senegal');
	lang = "fr"
  }
  else
  if (region == "NO") {
	lang = "no"
  }
  else
  if (region == "IT") {
	lang = "it"
  }
  else
  if (region == "PT") {
	lang = "pt"
  }
  else
  if (region == "CU") {
	lang = "sp"
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'cuba');
  }
  else
  if (region == "MX") {
	lang = "sp"
  }
  else
  if (region == "BR") {
	lang = "pt"
  }
  else
  if (region == "RO") {
	lang = "ro"
  }
  else
  if (region == "IN") {
	regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'india');
  }
  else
  if (region == "MA") {
	lang = "ar"
	regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'morocco');
  }
  else
  if (region == "DZ") {
	lang = "ar"
	regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'algeria');
  }
  else
  if (region == "TN") {
	lang = "ar"
	regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'tunisia');
  }
  else
  if (region == "ID") {
	regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'indonesia');
  }
  else
  if (region == "MY") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'wunt');
	lang = "en"
  }
  else
  if (region == "RU") {
	lang = "ru"
  }
  else
  if (region == "AE") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'uae');
	lang = "ar"
  }
  else
  if (region == "KW") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'kuwait');
	lang = "ar"
  }
  else
  if (region == "CH") {
	lang = "en"
  }
  else
  if (region == "GA") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'gabon');
	lang = "fr"
  }
  else
  if (region == "CO") {
 	  regEx = new RegExp ('www', 'i') ;
          newfm_domain = newfm_domain.replace(regEx, 'colombia');
	lang = "sp"
  }
  else
  if (region == "VE") {
	lang = "sp"
  }
  if(region == "PG")
  {
	lang = "en"
  }


  	newfm_url = sprotocol + newfm_domain + "/WUCOMWEB/staticMid.do?method=load&countryCode="+ region +"&languageCode=" + lang + "&pagename=" + pageName

	if (region == "DE" || region == "FR" || region == "NL" || region == "ES" || region == "AT" || region == "AU" || region == "SE" || region == "IE" || region == "GB" || region == "NO" || region == "BE" || region == "PT") {
		if (pageName == "osMoneyTransferOptions")
		    newfm_url += "&nextSecurePage=Y"
	}

  if(toadd != "")
  {
  	newfm_url = newfm_url + "&" + toadd
  }
  
  //alert(newfm_url)
	return newfm_url
}


function redirect_to_new_framework(region,where) {
	var sUrl = get_new_framework_url(region,where) 
	setCookie('region',region,"")
	document.location = (sUrl)
  parent.document.location = (sUrl)
}

function is_new_framework_country(region) {
 
  	switch (region) { 
  		case "US":
  		case "NZ":
  		case "GB":
  		case "CA":
  		case "IT":
  		case "DE":
		case "DK":
  		case "ES":  		
  		case "FR":
		case "GR":
		case "KE":
		case "NG":
  		case "NL":
		case "PL":
  		case "UA": 
		case "ZA": 
		case "PA":
		case "CM":
		case "AR":
		case "AT":
		case "AU":
		case "SE":
		case "BE":
		case "AI":
		case "AG":
		case "AW":
		case "BS":
		case "BB":
		case "BZ":
		case "BM":
		case "VI":
		case "KY":
		case "DM":
		case "DO":
		case "GD":
		case "GY":
		case "HT":
		case "JM":
		case "MS":
		case "KN":
		case "LC":
		case "S1":
		case "MF":
		case "VC":
		case "SR":
		case "TT":
		case "TC":
		case "VG":
		case "FJ":
		case "WS":
		case "TO":
		case "GU":
		case "IE":
		case "PE":
		case "TR":
		case "UG":
		case "CI":
		case "SN":
		case "NO":
		case "PG":
		case "PT":
		case "CU":
		case "MX":
		case "BR":
		case "RO":
		case "IN":
		case "MA":
		case "DZ":
		case "RU":
		case "TN":
		case "ID":
		case "MY":
		case "AE":
		case "KW":
		case "CH":
		case "GA":
		case "CO":
		case "VE":
  		   return true;
  		   break;
  		   
  		default: 
  		  return false; 
    }		   
}
function is_new_framework_NT_country(region) {
 
  	switch (region) {  
		case "DK":
		case "GR":
		case "KE":
		case "NG":
		case "PL": 
  		case "UA": 
		case "ZA":  
		case "PA":
		case "CM":
		case "AR":
		case "AI":
		case "AG":
		case "AW":
		case "BS":
		case "BB":
		case "BZ":
		case "BM":
		case "VI":
		case "KY":
		case "DM":
		case "DO":
		case "GD":
		case "GY":
		case "HT":
		case "JM":
		case "MS":
		case "KN":
		case "LC":
		case "S1":
		case "MF":
		case "VC":
		case "SR":
		case "TT":
		case "TC":
		case "VG":
		case "FJ":
		case "WS":
		case "TO":
		case "GU":
		case "PE":
		case "TR":
		case "UG":
		case "CI":
		case "SN":
		case "PG":
		case "CU":
		case "MX":
		case "BR":
		case "RO":
		case "IN":
		case "MA":
		case "DZ":
		case "RU":
		case "TN":
		case "ID":
		case "MY":
		case "AE":
		case "KW":
		case "CH":
		case "GA":
		case "CO":
		case "VE":
  		   return true;
  		   break;
  		   
  		default: 
  		  return false; 
    }		   
}
function go(where, closePopup, region, params, anchorField, target) {

  var cmsPreviewing = false
  var sLoc = document.location + ""
   
  if (sLoc.indexOf("wucms01") >= 0) {
      cmsPreviewing = true
  }    
  
  //alert("document.location:"+sLoc+", where="+where); 
	if ((!cmsPreviewing) && (is_new_framework_country(region))) {
  	  redirect_to_new_framework(region,where)
  	  return
  }

	var isPopupCloser = false
	try {
		if (closePopup == true && opener != null && opener.popupWindow != null) {
			isPopupCloser = true
		}
	} catch (err) {}
	if (customGo && customGo(where, closePopup, region, params, anchorField, target, isPopupCloser) == true) return


	var showingTestPage = false

	for(var i in limitedContents ){
		if (limitedContents[i].testPage == where) {
			if (limitedContents[i].thisSessionOnly) {
				setCookie("limitedContent_" + limitedContents[i].pageName, "true", null)
			} else {
				setCookie("limitedContent_" + limitedContents[i].pageName, "true", limitedContents[i].endDate)
			}
			showingTestPage = true
		}
	}

	if (!showingTestPage && limitedContents[where] != null) {
		var limitedContent = limitedContents[where]

		if (showLimitedContent(limitedContent.pageName, limitedContent.percentage, limitedContent.thisSessionOnly, limitedContent.endDate, limitedContent.availableCountriesAndLanguages)) {
			where = limitedContent.testPage
		}
	}

	if (target == null) {
		target = '_top'
	}
	var form = getForm()
	var origRegion = region
	try {
		if (closePopup == true && opener != null && opener.popupWindow != null) {
			form = opener.getForm()
		}
	} catch (err) {}
	if ((offset = where.indexOf("?")) != -1) {
		params = where.substring(offset + 1) + (params != null ? params : "")
		where = where.substring(0, offset)
	}
	if ((offset = where.indexOf("#")) != -1) {
		anchorField = where.substring(offset + 1)
		where = where.substring(0, offset)
	}
	var currentRegion = getRegion()
	if (region == null || region == "") {
		region = currentRegion
	}
	if (form != null) {
		form.RESULT.value = "go"
		removeFromSession("CONTENT_ONLY")
	}
	if ((where.indexOf("http://") != -1 || where.indexOf("https://") != -1) && where.toUpperCase().indexOf("WESTERNUNION") == -1) {
		//document.location = lookupCountryDomain(currentRegion)+"/redirect.asp?goTo=" + convertChar(convertChar(convertChar(where+'?'+params, "?", "%3F"), "&", "%26"), "#", "%23") + "&cameFrom=" + getForm().PAGE_NAME.value
		document.location = where+'?'+params
		if (closePopup == true && opener != null) { close() }
	} else {
		if (
			where == "PREVIOUS_PAGE" ||
			where == "REVIEW_PAGE" ||
			where == "CANCEL_PAGE"
		) {
			setFormAction(lookupNameValuePair(form.SESSION.value, where), null, params, anchorField, form)
		} else if (where == "home") {
			if (region == null || region == "" || region == "global") {
				where = "info/selectCountry.asp"
			} else {
				var newDomain
				var countryByDomain = lookupCountryByDomain()
				if (form == null && countryByDomain != "US") {
					region = countryByDomain
				}
				if (region != countryByDomain && getDomain("full") != (newDomain = lookupCountryDomain(region))) {
					where = newDomain + "/globalPortal.asp"
				} else {
					where = getHomePage(form, region)
				}
			}
			if (customGoHome != null) {
				var result = customGoHome()
				if (result != null) {
					where = result[0]
					region = result[1]
				}
			}
			if (where.indexOf("/") == -1 && where.indexOf("homePage") == -1 && where.indexOf("index_") == -1) {
				where = "asp/" + where
			}
			if (form != null) {
				setFormAction(where, null, params, anchorField, form, region, target)
			} else {
				var externalUrl = where.indexOf("http://") != -1 || where.indexOf("https://") != -1
				var appendCountry =
					region != null &&
					region != "" &&
					(region != "US" || getQueryParameter("country") != -1) &&
					where.indexOf("country=") == -1 &&
					(params == null || params.indexOf("country=") == -1)
				var language = getLanguage()
				var appendLanguage = language != null &&
					language != "" &&
					language != "en" &&
					where.indexOf("language=") == -1
				var homePage =
					(!externalUrl && region != null && region != "" ? lookupCountryDomain(region) + "/" : "") +
					where +
					(where.indexOf(".asp") == -1 ? ".asp" : "") +
					(appendCountry ? "?country=" + region : "") +
					(params != null ? (appendCountry ? "&" : "?") + params : "") +
					(appendLanguage ? (appendCountry || params != null ? "&" : "?") + "language=" + language : "")
					if ((!cmsPreviewing) && (is_new_framework_country(region))) {
  	  			redirect_to_new_framework(region,where)
  	  			return
  				}	
				document.location = homePage
				return
			}
		} else if (where.indexOf(".") != -1) {
			setFormAction(where, null, params, anchorField, form, region)
		} else {
			return
		}
		servletMap("GO", form)
		pruneSession()
		pageIsSubmitted = true
		form.target = target
		formSubmit(form)
		if (isPopupCloser) {
			close()
		}
	}
}

function goMenu(menuName) {
	menuSelection = fields[menuName].getValue()
	eval(menuSelection)
}

function initPage() {}

function insertFieldNameIntoMessage(message, field) {
	return message = convertChar(message, "[N]", field.label)
}

function languageDropDown_disableCheck() {
  var myPage = lookupNameValuePair(getForm().SESSION.value, "CURRENT_PAGE")
  //alert("languageDropDown_disableCheck - this Page:"+myPage)
  if (myPage.indexOf("SubmitHeader") != -1) {
		  try {  	
			   getObjStyle("language").display = "none";   	
				 var myform = document.parentWindow.parent.frames[2].document.forms[0];	   
				 if (myform != null) {
					  myPage = lookupNameValuePair(myform.SESSION.value, "CURRENT_PAGE")
		        //alert("languageDropDown_disableCheck - center frame Page:"+myPage)
		        if (myPage.indexOf("Receipt") != -1) {
						   getObjStyle("language").display = "inline"; 
						}
				 }
			}
			catch (err) {}		
	}		
}	

function languageDropDown_enableCheck() {
  var myPage = lookupNameValuePair(getForm().SESSION.value, "CURRENT_PAGE")
  //alert("languageDropDown_enableCheck - this Page:"+myPage)
   if (myPage.indexOf("Receipt") != -1) {
	  try {  	
				 var myform = document.parentWindow.parent.frames[1].document.forms[0];	   
				 if (myform != null) {
					  myPage = lookupNameValuePair(myform.SESSION.value, "CURRENT_PAGE")
		        //alert("languageDropDown_enableCheck - top frame page:"+myPage)
		        if (myPage.indexOf("SubmitHeader") != -1) {
						   getObjStyle("language","document.parentWindow.parent.frames[1].").display = "inline";  	
						}
				 }
			}
			catch (err) {}		
	}		
}

function loadMenus() {
	var menuValues = menuLoadValues.split(";")
	for (var i = 0; i < menuValues.length - 1; i++) {
		var keyData = menuValues[i].split("=")
		fields[keyData[0]].setValue(keyData[1])
	}
}

function logBlur(fieldName) {
	if (fieldName == currentFocus)
		currentFocus = null
}

function logFocus(fieldName) {
	currentFocus = fieldName
	updateCustomSelect(fieldName)
}

function lookupCountryByDomain(url) {
	if (url == null) {
		url = document.location + ""
	}
	url = url.split("/")[2]
	for (var i = 0; i < countryDomains.length - 1; i++) {
		if (typeof(countryDomains[i][1]) != "string") {
			for (var j = 0; j < countryDomains[i][1].length; j ++) {
				if (url.indexOf(countryDomains[i][1][j]) != -1) {
					return countryDomains[i][0].split(",")[0]
				}
			}
		} else {
			var domain = countryDomains[i][1]
			var temp
			if ((temp = url.indexOf(domain)) != -1 && temp + domain.length == url.length) {
				return countryDomains[i][0].split(",")[0]
			}
		}
	}
	return "US"
}

function lookupCountryDomain(country, filePath, makeSecure) {
	var url = (document.location + "").toLowerCase()
	var fileIsSecure = url.indexOf("https") != -1
	var fileNeedsToBeSecure = filePath != null && (
		("/" + filePath).indexOf("/asp/") != -1 ||
			filePath.indexOf(".s.") != -1 ||
		filePath.indexOf(".s/") != -1 ||
		makeSecure == true
	)
	if (filePath != null && filePath.indexOf("ins/") != -1) makeSecure = false
	for (var i = 0; i < countryDomains.length - 1; i++) {
		if (countryDomains[i][0].indexOf(country) != -1 || i == countryDomains.length - 2) {
			var domainIndex
			if (typeof(countryDomains[i][1]) != "string") {
				for (var j = 0; j < countryDomains[i][1].length; j ++) {
					if (url.indexOf(countryDomains[i][(fileIsSecure && countryDomains[i][2] != null ? 2 : 1)][j]) != -1) {
						domainIndex = j
						break
					}
				}
				if (domainIndex == null) {
					domainIndex = countryDomains[i][1].length - 1
				}
			}
			if (
				(
					(
						fileIsSecure &&
						(country == getQueryParameter("country") || countryDomains[i][0].indexOf(lookupCountryByDomain()) != -1)  &&
						makeSecure != false
					) || fileNeedsToBeSecure
				) && countryDomains[i][2] != null && countryDomains[i][2] != "" && useSSL == "true"
			) {
				var useHttps = countryDomains[i][3] != null ? countryDomains[i][3] : true
				var domainSegments = (domainIndex == null ? countryDomains[i][2] : countryDomains[i][2][domainIndex])
				url = (useHttps ? "https://" : "http://") + (domainSegments.charAt(0) == "." ? getDomain("first") : "") + domainSegments
			} else {
				var domainSegments = (domainIndex == null ? countryDomains[i][1] : countryDomains[i][1][domainIndex])
				url = "http://" + (domainSegments.charAt(0) == "." ? getDomain("first") : "") + domainSegments
			}
			break
		}
	}
	var customUrl
	if (customLookupCountryDomain && ((customUrl = customLookupCountryDomain(url)) != null)) {
		url = customUrl
	}
	if (customSwapDomains != null && (customUrl = customSwapDomains(url.toLowerCase(), country)) != null) {
		url = customUrl
	}
	if (url.indexOf("http://cms") != -1 || url.indexOf("https://cms") != -1) {
		url += ":8500"
	}
 	return url
}

function lookupNameInNameValuePairs(data, key, delimiter) {
	if (delimiter == null) delimiter = SESSION_DELIMITER
	data = SESSION_DELIMITER + data
	var dataOffset = data.indexOf(key + "=")
	if (dataOffset == -1) {
		return ""
	}
	var dataSegment = data.substring(0, dataOffset + key.length)
	return dataSegment.substring(dataSegment.lastIndexOf(delimiter) + 1)
}

function lookupNameValuePair(data, key, delimiter) {
	if (delimiter == null) delimiter = SESSION_DELIMITER
	var dataOffset = (data + SESSION_DELIMITER).indexOf(key + "=")
	if (dataOffset == -1) return null
	var dataSegment = data.substring(dataOffset + key.length + 1)
	return dataSegment.substring(0, dataSegment.indexOf(delimiter))
}

function navHeaderClick(menu) {
	var isDown = getObjStyle(menu).background.indexOf("turndown") != -1
	getObjStyle(menu).background = "url(/images/bullets/arrow_turn" + (isDown ? "up.gif) no-repeat 10px 15px" : "down.gif) no-repeat 8px 17px")
	getObjStyle(menu + "_submenu").display = isDown ? "none" : ""
	if (lastOpenNavMenu != null && lastOpenNavMenu != menu) {
		navHeaderClick(lastOpenNavMenu)
	}
	lastOpenNavMenu = isDown ? null : menu
}

function pageIsLoaded() {
	var form = getForm()
	pageName = form.PAGE_NAME.value
	var browserVersion = getBrowserVersion()
	var browserIsNav = navigator.appName.toLowerCase().indexOf("netscape") != -1
	if (
		browserIsNav &&
		browserVersion > 4 &&
		browserVersion < 7
	) {
		loadMenus()
	}
	if (browserIsNav && browserVersion == 4) {
		document.captureEvents(Event.KEYDOWN)
		document.onKeyDown = doKeyDown
	}
	form.action = "sessionTerminated.asp?DISPLAY=JAVASCRIPT_ERROR"
	form.RESULT.value = form.ORIG_RESULT.value
	var session = form.SESSION.value = form.ORIG_SESSION.value
	var country = lookupNameValuePair(session, "region")
	setCookie("region", country, "")
	removeFromSession("_ERROR")
	setInitialValues()
	initPage()
	resultValue = getForm().RESULT.value
	display = lookupNameValuePair(resultValue, "DISPLAY")
	focusField = lookupNameValuePair(resultValue, "FOCUS")
	docLoc = document.location + ""
	if (docLoc.indexOf("setHomePage=true") != -1) {
		setHomePage()
	}
	if ((offset = docLoc.indexOf("#")) != -1) {
		focusField = docLoc.substring(offset + 1)
		if ((offset = focusField.indexOf("?")) != -1) {
			focusField = focusField.substring(0, offset)
		}
		focusField = fields[focusField]
		if (focusField != null) {
			focusField.getField().focus()
		}
	} else if (getQueryParameter("survey") == null) {
		if (focusField != null && focusField != "") {
			document.location = "#" + focusField + "_ERROR"
			obj = eval("getForm()." + focusField)
			if (obj != null) {
				try {
					obj.focus()
				} catch (err) {}
			}
		} else if (defaultFocus != "") {
			defaultFocus = fields[defaultFocus]
			if (defaultFocus != null) {
				try {
					defaultFocus.getField().focus()
				} catch (err) {}
			}
		}
	}
}

function pageIsUnloading() {
	if (customPageIsUnloading != null) customPageIsUnloading()
}

function popup(filePath, windowName, width, height, features, anchorText, makeSecure, newWindow, useRegion) {
	
	var spage = filePath.toLowerCase()
	if (spage.indexOf('agentlocatorlookup.asp') != -1 || spage.indexOf('agentinquiryintl.asp') != -1) {
			try {
			  if (window.parent.frames.length > 0) 
	         window.parent.location = '/info/agentLocator.asp?country=' + getRegion()  
	      else       	   
	         window.location = '/info/agentLocator.asp?country=' + getRegion()
      }
      catch (err) {
         window.parent.location = '/info/agentLocator.asp?country=' + getRegion()
      }	    
	    return;
	}

	
	var externalSite = (filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1)
	if (!externalSite) {
		if (useRegion == null) {
			useRegion = getRegion()
		}
		filePath = buildLocalFilePath(filePath, useRegion, makeSecure, (customGetDomain ? customGetDomain(filePath) : null))
	}

  if (filePath != 'http://firstdatacorp.inquisiteasp.com/cgi-bin/qwebcorporate.dll?5R3JNE') {
	   filePath += (filePath.indexOf("?") == -1 ? "?" : "&") + "POPUP=true&PAGE_NAME=" + getForm().PAGE_NAME.value
  }
  
	var language = getLanguage()
	if (
		language != null &&
		language != "" &&
		language != "en" &&
		filePath.indexOf("globalPortal") == -1 &&
		filePath.indexOf("selectCountry") == -1 &&
		filePath.indexOf("language") == -1
	) {
		filePath = filePath + "&language=" + language
	}
	var region
	if (filePath.indexOf("globalPortal") != -1 || filePath.indexOf("selectCountry") != -1) {
		region = "US"
	} else {
		region = getRegion()
	}
	var domain = lookupCountryDomain(region, filePath)
	if (appendCountryParameter(region, domain, filePath)) {
		filePath += (filePath.indexOf("?") == -1 ? "?" : "&") + "country=" + (region == null || region == "" ? "global" : region)
	}

	filePath += (anchorText != null && anchorText != "" ? "#" + anchorText : "")
	if (externalSite) {
		//filePath = lookupCountryDomain(region, filePath)+"/redirect.asp?goTo=" + convertChar(convertChar(convertChar(filePath, "?", "%3F"), "&", "%26"), "#", "%23") + "&cameFrom=" + getForm().PAGE_NAME.value
		filePath = filePath
	}
	if (opener != null && newWindow != true) {
		window.location = filePath
	} else {
		windowProperties =
			(width != null ? "width=" + width +"," : "") +
			(height != null ? "height=" + height +"," : "") +
			(!externalSite ? "dependant" : "") +
			((features != null && features != "") ? "," + features : "")
		popupWindow = windowOpen(filePath, windowName, windowProperties)
		if (popupWindow != null) {
			popupWindow.opener = this
		}
	}
}

function pruneSession() {
	removeFromSession("CURRENT_PAGE")
	removeFromSession("SUBMIT_PAGE")
	removeFromSession("PREVIOUS_PAGE")
	removeFromSession("REVIEW_PAGE")
	removeFromSession("CANCEL_PAGE")
}

function removeFromCountryArray(countryList, country) {
	if (countryList == null) return ""
	var countryArray = countryList.split(LIST_DELIMITER)
	for (var i = 0; i < countryArray.length; i++) {
		var countryValue = countryArray[i].split(":")
		if (countryValue[0] == country || countryValue[1] == null) {
			countryArray[i] = null
		}
	}
	var result = ""
	for (var i = 0; i < countryArray.length; i++) {
		if (countryArray[i] != null) {
			result += countryArray[i] + LIST_DELIMITER
		}
	}
	return result.substring(0)
}

function removeFromSession(what, partial, form) {
	if (form == null) form = getForm()
	if (partial == null) partial = true
	var sessionArray = form.SESSION.value.split(SESSION_DELIMITER)
	var sessionData = ""
	for (var i = 0; i < sessionArray.length; i++) {
		if (sessionArray[i] == null || sessionArray[i] == "") continue
		var key = sessionArray[i].split("=")[0]
		if (
			(partial && key.indexOf(what) == -1) ||
			(!partial && key != what)
		) {
			sessionData += sessionArray[i] + SESSION_DELIMITER
		}
	}
	form.SESSION.value = sessionData
}

function servletMap(what, form) {
	if (form == null) form = getForm()
	removeFromSession("SERVLET_MAP", null, form)
	form.SESSION.value = form.SESSION.value + "SERVLET_MAP=" + what + SESSION_DELIMITER
}

var customSetDocumentLocation
function setDocumentLocation(url) {
    if (customSetDocumentLocation )customSetDocumentLocation(url)
    document.location.href = url
}

function setFormAction(filePath, ext, params, anchorField, form, region, target) {
	if (form == null) form = getForm()
	if (filePath == null) return
	filePath = checkDirectory(filePath)
	if (target == null) {
		target = lookupNameValuePair(form.SESSION.value, "TARGET")
	}
	if ((offset = filePath.indexOf("?")) != -1) {
		params = filePath.substring(offset + 1) + (params != null ? params : "")
		filePath = filePath.substring(0, offset)
	}
	var externalUrl = filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1
	var newRegion
	var oldRegion = getRegion()
	var pageName = form.PAGE_NAME.value
	if (filePath.indexOf("selectCountry") != -1) {
		region = "US"
		newRegion = true
	} else if (region == null || region == "") {
		region = oldRegion
		newRegion = false
	} else {
		newRegion = (region != oldRegion)
	}
	var domain = lookupCountryDomain(region, filePath)
	if (newRegion) {
		if ((document.location + "").indexOf(domain) == -1) {
			if (customUpdateSessionOnNewRegion != null) customUpdateSessionOnNewRegion()
		}
		removeFromSession("region")
		form.SESSION.value = "region=" + region + SESSION_DELIMITER + form.SESSION.value
		if (customNoRegionCookie != null && !customNoRegionCookie()) {
			setCookie("region", region, "")
		}
	}
	if (customGetDomain) domain = customGetDomain(filePath)
	if (!externalUrl) {
		filePath = buildLocalFilePath(filePath, region, null, domain)
	}
	if (useCountry == "true") {
		if (appendCountryParameter(region, domain, filePath, params)) {
			params = (params != null && params != "" ? params + "&" : "") + "country=" + (region == null || region == "" ? "global" : region)
		}
		if (newRegion) {
			params = (params != null && params != "" ? params + "&" : "") + "origination=" + (pageName.indexOf("selectCountry") != -1 ? "global" : oldRegion)
		}
	}
	var language = getLanguage(region)
	if (
		useLanguage == "true" &&
		language != null &&
		language != "" &&
		language != "en" &&
		(params == null || params.indexOf("language") == -1) &&
		lookupCountryDomain(region) == lookupCountryDomain(getRegion())
	) {
		params = (params != null && params != "" ? params + "&" : "") + "language=" + language
	}

	if (
		!externalUrl &&
		filePath.indexOf(".asp") == -1 &&
		filePath.indexOf(".htm") == -1 &&
		filePath.indexOf(".html") == -1
	) {
		filePath += ((ext != null) ? "." + ext : ".asp")
	}
	filePath +=(params != null ? "?" + params : "") + ((anchorField != null) ? "#" + anchorField : "")
	if (customSetFormAction != null) {
		filePath = customSetFormAction(form, filePath, language, region)
	}
	form.action = filePath
	if (target != null && target != "") {
		form.target = target
	}
}

function setHomePage(country) {
	var form = getForm()
	if (country == null) {
		country = getRegion()
	}
	var homePage = getCookie("HOME_PAGE")
	if ((homePage == null || homePage == "") && form != null) {
		homePage = lookupNameValuePair(form.SESSION.value, "HOME_PAGE")
	}
	homePage = removeFromCountryArray(homePage, country)
	var pageName = form.PAGE_NAME.value
	if (pageName.indexOf("selectCountry") != -1) {
		pageName = ""
	}
	if (homePage.indexOf(LIST_DELIMITER) == -1) {
		homePage = ""
	}
	if (pageName != getDefaultHomePage(country) && pageName != "") {
		homePage += country +":"+ pageName + LIST_DELIMITER
	}
	setCookie("HOME_PAGE", homePage, "")
	removeFromSession("HOME_PAGE")
	form.SESSION.value += "HOME_PAGE=" + homePage + SESSION_DELIMITER
}

function setInitialValues() {
	for (var k = 0; k < fieldNames.length; k++) {
		fields[fieldNames[k]].setInitialValue()
	}
}

function setLanguage(country) {
	var form = getForm()
	if (country == null) {
		country = getRegion()
	}
	var customCountry
	if (customGetCountry && (customCountry = customGetCountry(country)) != null) {
		country = customCountry
	}
	var languagePrefs = getCookie("languagePref")
	if ((languagePrefs == null || languagePrefs == "") && form != null) {
		languagePrefs = lookupNameValuePair(form.SESSION.value, "language")
	}
	languagePrefs = removeFromCountryArray(languagePrefs, country)
	var language
	if (fields["language"] != null) {
		language = fields["language"].getValue()
	}
	if (languagePrefs.indexOf(LIST_DELIMITER) == -1) {
		languagePrefs = ""
	}
	//if (language != getDefaultLanguage(country)) {
		languagePrefs += country +":"+ language + LIST_DELIMITER
	//}
	setCookie("languagePref", languagePrefs, "")
	removeFromSession("LANGUAGE_PREFS")
	form.SESSION.value += "LANGUAGE_PREFS=" + languagePrefs + SESSION_DELIMITER
}

function trim(fieldValue) {
	if (fieldValue == "") return ""
	fieldValue = convertChar(fieldValue, "  ", " ")
	while (fieldValue.charAt(0) == " ") {
		fieldValue = fieldValue.substring(1)
	}
	while (fieldValue.charAt(fieldValue.length - 1) == " ") {
		if (fieldValue.length == 1) {
			fieldValue = ""
		} else {
			fieldValue = fieldValue.substring(0, fieldValue.length-1)
		}
	}
	return fieldValue
}

function updateDisplay() {
	var form = getForm()
	removeFromSession("DISPLAY")
	if ((offset = display.indexOf("_ERROR")) != -1) {
		display = display.substring(0, offset)
	}
	if (display != null && display != "" && display != "ERROR") {
		servletMap(display)
		form.SESSION.value = "DISPLAY=" + display + SESSION_DELIMITER + form.SESSION.value
	}
}

function updateDisplayForm(form) {
	removeFromSession("DISPLAY")
	if ((offset = display.indexOf("_ERROR")) != -1) {
		display = display.substring(0, offset)
	}
	if (display != null && display != "" && display != "ERROR") {
		servletMap(display)
		form.SESSION.value = "DISPLAY=" + display + SESSION_DELIMITER + form.SESSION.value
	}
}



var customWindowOpen
function windowOpen(url, windowName, windowProperties) {
	if (customWindowOpen) return customWindowOpen( url, windowName, windowProperties )
    return window.open(url, windowName, windowProperties)
}

countryDomainLookup = null ;
function checkForSecureURL(url, filePath, region, makeSecure) { return url ; }


function limitedContent(pageName, testPage, percentage, thisSessionOnly, endDate, availableCountriesAndLanguages) {
	this.pageName = pageName
	this.testPage = testPage
	this.percentage = percentage
	this.thisSessionOnly = thisSessionOnly
	this.endDate = endDate
	this.availableCountriesAndLanguages = availableCountriesAndLanguages
}


function applyLimitedContent(limitedContentName, id, percentage, thisSessionOnly, endDate, availableCountriesAndLanguages) {
	if (!showLimitedContent(limitedContentName, percentage, thisSessionOnly, endDate, availableCountriesAndLanguages)) {
		hideLimitedContent(id)
	}
}

function showLimitedContent(limitedContentName, percentage, thisSessionOnly, endDate, availableCountriesAndLanguages) {
	var returnValue = false;

	if (thisSessionOnly == null) {
		thisSessionOnly = false;
	}

	if (endDate == "" ||  (new Date(endDate) > new Date())) {

		var acceptedCountryAndLanguage = false

		if (availableCountriesAndLanguages == "") {
			acceptedCountryAndLanguage = true
		} else {
			var arr = availableCountriesAndLanguages.split(",")

			for (var i = 0; i < arr.length; i++) {
				var country = arr[i].split("-")[0]
				var language = arr[i].split("-")[1]

				if ((country == "" || country == getRegion()) &&
					(language == "" || language == getLanguage()) ) {

					acceptedCountryAndLanguage = true
				}
			}
		}

		if (acceptedCountryAndLanguage) {

			if (getCookie("limitedContent_" + limitedContentName) != null) {
				return getCookie("limitedContent_" + limitedContentName) == "true"
			} else {
				if (Math.random() < percentage) {
					returnValue = true
				}

				if (thisSessionOnly) {
					setCookie("limitedContent_" + limitedContentName, new String(returnValue), null)
				} else {
					setCookie("limitedContent_" + limitedContentName, new String(returnValue), endDate)
				}
			}
		}
	}

	return returnValue
}

function hideLimitedContent(id) {
	var isNav, obj
	var version = parseInt(navigator.appVersion)
	var coll = ""
	var styleObj = ""

	if (version >= 4) {
		if (navigator.appName == "Netscape") {
			isNav = true
			if (version >= 5) {
				styleObj = ".style"
			}
		} else {
			coll = "all."
			styleObj = ".style"
		}
	}

	if (isNav && version >= 5) {
		obj = eval("document.getElementById('" + id + "')" + styleObj)
	} else {
		obj = eval("document." + coll + id + styleObj)
	}
	obj.visibility = "hidden"
	obj.display = "none"
}

// custom select object

var customSelectCounter = 0
var customSelectOpen
var onchangeFunc = new Array()
var maxMenuDisplay = 20

function selectReplacement(obj, count, menuCount) {
	if (obj.onchange != null) onchangeFunc[obj.name] = /{([^}]*)}/.exec(obj.onchange + "")[1]
 	obj.className += ' replaced'
	var opts = obj.options;
	if (menuCount == null) menuCount = opts.length
	var ul = document.createElement('ul')
	ul.className = 'selectReplacement'
	ul.id = obj.id + "_replaced"
	ul.style.height = Math.min(maxMenuDisplay, menuCount) * 18 + 2
	var selectedOpt = (!obj.selectedIndex) ? 0 : obj.selectedIndex;

	for (var i = 0; i < opts.length; i++) {
		var li = document.createElement('li')
		var txt = document.createTextNode(opts[i].text)
		li.appendChild(txt)
		li.selIndex = i
		li.selectID = obj.id
		
		li.onclick = function() {
			selectMe(this)
		}
		if (i == selectedOpt) {
			li.className = 'selected'
			li.onclick = function() {
				logFocus(obj.id)
				customSelectOpen = obj.id
				this.parentNode.className += ' selectOpen'
				this.onclick = function() {
					selectMe(this)
				}
			}
		}
		if (window.attachEvent) {
			li.onmouseover = function() {
				this.className += ' hover'
			}
			li.onmouseout = function() {
				this.className = this.className.replace(new RegExp(" hover\\b"), '')
			}
		}
		ul.appendChild(li)
	}
	
	obj.onfocus = function() {
		ul.className += ' selectFocused'
	}
	obj.onblur = function() {
		ul.className = 'selectReplacement'
	}
	obj.onchange = function() {
		var idx = this.selectedIndex
		selectMe(ul.childNodes[idx])
		if (onchangeFunc[this.name] != null) eval(onchangeFunc[this.name])
	}
	obj.onkeypress = obj.onchange

	obj.parentNode.insertBefore(ul,obj)
}

function selectMe(obj) {
	logFocus(obj.selectID)
	var lis = obj.parentNode.getElementsByTagName("li")
	for (var i = 0; i < lis.length; i++) {
		if (lis[i] != obj) {
			lis[i].className = ""
			lis[i].onclick = function() {
				selectMe(this)
			}
		} else {
			setVal(obj.selectID, obj.selIndex)
			obj.className = "selected"
			obj.parentNode.className = obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), "")
			obj.onclick = function() {
				logFocus(this.selectID)
				customSelectOpen = this.selectID
				obj.parentNode.className += " selectOpen"
				this.onclick = function() {
					selectMe(this)
				}
			}
		}
	}
}

function updateCustomSelect(id) {
	if (customSelectOpen != null && id != customSelectOpen) {
		closeCustomSelect()
	}	
	customSelectOpen = null
}

function closeCustomSelect() {
	var obj = getObj(customSelectOpen + "_replaced")
	var lis = obj.getElementsByTagName("li")
	for (var i = 0; i < lis.length; i++) {
		if (lis[i].className != "selected") {
			lis[i].className = ""
			lis[i].onclick = function() {
				selectMe(this)
			}
		} else {
			obj.className = obj.className.replace(new RegExp(" selectOpen\\b"), "")
			lis[i].onclick = function() {
				logFocus(this.selectID)
				customSelectOpen = this.selectID
				obj.className += " selectOpen"
				this.onclick = function() {
					selectMe(this)
				}
			}
		}
	}
}

function setVal(objID, val) {
	var obj = document.getElementById(objID)
	obj.selectedIndex = val
	eval(onchangeFunc[obj.name])
}

function showTip(which) {
	if (lastOpenTipAnswer != null) {
		hideTip(lastOpenTipAnswer)
	}
	lastOpenTipAnswer = which
	getObjStyle(which + "_a_link").display = "none"
	getObjStyle(which + "_answer").display = "block"
	getObj(which).className = "box_inside_box"	
}

function hideTip(which) {
	getObjStyle(which + "_a_link").display = "block"
	getObjStyle(which + "_answer").display = "none"
	getObj(which).className = "tip"
}