try {
	if (wsstag_enabled) {}
} catch (err) {
	var wsstag_enabled = false;
}

var wsstag_searchString = "";
var locatorCountry = "";
function LocatorFormState() {
	return {
		address : new Address(),
		radius : "",
		distanceUnit : "",
		categories : new Array(),
		maxLocations : locatorLocationsPerPage,
		merchantName : "",
	
		reset : function() {
			var saveCountry = this.address.country;
			this.address.reset();
			this.address.country = saveCountry;
			this.radius = "";
			this.distanceUnit = "";
			this.maxLocations = locatorLocationsPerPage;
			this.categories = new Array();
			this.merchantName = "";
			return true;
		},
		
		saveFromForm : function(locatorForm) {
			this.reset();
			if (locatorForm) {
				var wsstag_airportCode= "";
				var wsstag_countryCode= "";
				var wsstag_firm= "";
				var wsstag_city= "";
				var wsstag_postalCode= "";
				var wsstag_radius= "";
				var wsstag_streetAddress= "";
				
				if (locatorForm.streetAddress && locatorForm.streetAddress.value) {
					this.address.streetAddress = locatorForm.streetAddress.value;
					wsstag_streetAddress = locatorForm.streetAddress.value;
				} else {
					this.address.streetAddress = "";
				}
				if (locatorForm.streetAddress2 && locatorForm.streetAddress2.value) {
					this.address.streetAddress2 = locatorForm.streetAddress2.value;
				} else {
					this.address.streetAddress2 = "";
				}
				if (locatorForm.city && locatorForm.city.value) {
					this.address.city = locatorForm.city.value;
					wsstag_city =locatorForm.city.value;
				} else {
					this.address.city = "";
				}
				if (locatorForm.countryCode && locatorForm.countryCode.value) { 
					this.address.country.countryCode = locatorForm.countryCode.value;
					wsstag_countryCode = locatorForm.countryCode.value;
				}
				
				if (locatorForm.countrySubDivision && locatorForm.countrySubDivision.value) {
					this.address.countrySubDivision = locatorForm.countrySubDivision.value;
				} else {
					this.address.countrySubDivision = "";
				}
				if (locatorForm.postalCode && locatorForm.postalCode.value) {
					this.address.postalCode = locatorForm.postalCode.value;
					wsstag_postalCode = locatorForm.postalCode.value;
				} else {
					this.address.postalCode = ""
				}
				if (locatorForm.airportCode && locatorForm.airportCode.value) {
					this.address.airportCode = locatorForm.airportCode.value;
					wsstag_airportCode=locatorForm.airportCode.value;
				} else {
					this.address.airportCode = ""
				}
				if (locatorForm.firm && locatorForm.firm.value) {
					this.address.firm = locatorForm.firm.value;
					wsstag_firm = locatorForm.firm.value;
				} else {
					this.address.firm = ""
				}
				if (document.getElementById("merchantName")) {
					this.merchantName = document.getElementById("merchantName").value;
				} else {
					this.merchantName = "";
				}
				if (locatorForm.radius && locatorForm.radius.value) {
					this.radius = locatorForm.radius.value;
					wsstag_radius = locatorForm.radius.value;
				} else {
					this.radius = "25";
				}
				
				if (locatorForm.distanceUnitMiles && locatorForm.distanceUnitKilometers) {
					if (locatorForm.distanceUnitMiles.checked) {
						this.distanceUnit = locatorDistanceUnitMiles;
					} else if (locatorForm.distanceUnitKilometers.checked) {
						this.distanceUnit = locatorDistanceUnitKilometers;
					} else {
						// Default
						this.distanceUnit = locatorDistanceUnitMiles;
					}
				} else if (locatorForm.distanceUnit) {
					this.distanceUnit = locatorForm.distanceUnit.value;
				}
				
				for (var i=0; i < locatorForm.elements.length; i++) {
 				  var element = locatorForm.elements[i];
 				  
 				  if (element.name.indexOf("filter.in.MERCH_CAT") == 0) {
 					  this.categories[element.name] = element.checked;
				  }
 				 if (element.name.indexOf("filter.in.lserv_LOC_TYPE_ID") == 0) {
 					 this.categories[element.name] = element.checked;
 				  }
 				 if (element.name.indexOf("filter.in.AVAIL") == 0) {
 					 this.categories[element.name] = element.checked;
 				  }
 				 if (element.name.indexOf("filter.in.HANDICAP_ACCESSABLE") == 0) {
 					 this.categories[element.name] = element.checked;
 				  }
 				 if (element.name.indexOf("filter.in.SRCHRG_FREE_ALNC") == 0) {
 					 this.categories[element.name] = element.checked;
 				  }
 				 if (element.name.indexOf("filter.in.SHR_DEPST") == 0) {
 					 this.categories[element.name] = element.checked;
 				  }
				}
				if(locatorLocationType == "atm"){
					if(searchATMType == "Airport"){
						wsstag_searchString ="__AC--" + wsstag_airportCode+ "__CO--" +  wsstag_countryCode;
					} else if(searchATMType == "Attraction"){
						wsstag_searchString ="__AT--" + wsstag_firm + "__CI--" + wsstag_city + "__CO--" +  wsstag_countryCode + "__PC--" + wsstag_postalCode+ "__SR--"+wsstag_radius;
					} else{ 
						wsstag_searchString ="__SA--" + wsstag_streetAddress + "__CI--" + wsstag_city + "__CO--" +  wsstag_countryCode + "__PC--" + wsstag_postalCode+ "__SR--"+wsstag_radius;
					}
				}
			}
		},

		loadToForm : function(locatorForm) {
			var wsstag_countryCode = "";
			if (locatorForm.countryCode && locatorForm.countryCode.options) {
		      for (var i = 0; i < locatorForm.countryCode.options.length; i++) {
		            if (this.address.country.countryCode == locatorForm.countryCode.options[i].value) {
		                  locatorForm.countryCode.selectedIndex = i;
                          wsstag_countryCode = locatorForm.countryCode.options[i].value;
		                  break;
		            }
		      }      
			}
            var wsstag_streetAddress = "";
			if (locatorForm.streetAddress) {
				locatorForm.streetAddress.value = this.address.streetAddress;
                wsstag_streetAddress = this.address.streetAddress;
			}
			var wsstag_streetAddress2 = "";
			if (locatorForm.streetAddress2) {
				locatorForm.streetAddress2.value = this.address.streetAddress2;
                wsstag_streetAddress2 = this.address.streetAddress2;
			}
            
            var wsstag_city = "";
			if (locatorForm.city) {
				locatorForm.city.value = this.address.city;
                wsstag_city = this.address.city;
			}
            
			if (locatorForm.countrySubDivision) {
				if (this.address.countrySubDivision == "") {
					locatorForm.countrySubDivision.selectedIndex = 0;
				} else {
			      	if(locatorForm.countrySubDivision.options)
					for (var i = 0; i < locatorForm.countrySubDivision.options.length; i++) {
			            if (this.address.countrySubDivision == locatorForm.countrySubDivision.options[i].value) {
			                  locatorForm.countrySubDivision.selectedIndex = i;
			                  break;
			            }
			      	}
			    }
			}
            
            var wsstag_postalCode = "";
			if(locatorForm.postalCode) {
				locatorForm.postalCode.value = this.address.postalCode;
                wsstag_postalCode = this.address.postalCode;
			}
			var wsstag_airportCode = "";
			if (locatorForm.airportCode) {
				locatorForm.airportCode.value = this.address.airportCode;
                wsstag_airportCode = this.address.airportCode;
			}
			var wsstag_firm = "";
			if (locatorForm.firm) {
				locatorForm.firm.value = this.address.firm;
                wsstag_firm = this.address.firm;
			}
			if (locatorForm.maxLocations) {
				locatorForm.maxLocations.value = this.maxLocations;
			}			
			
            var wsstag_merchantName = "";
			if (document.getElementById("merchantName")) {
				document.getElementById("merchantName").value = this.merchantName;
                wsstag_merchantName = this.merchantName;
			}
			
			var wsstag_radius = "";
			if (locatorForm.radius && this.radius != "") {
				if(locatorForm.radius.length) {
					for (var i=0; i < locatorForm.radius.length; i++) {
						if 	(locatorForm.radius[i].value == this.radius) {
							locatorForm.radius.selectedIndex = i;	
						}
					}
				} else {
					locatorForm.radius.value = this.radius;
					wsstag_radius = this.radius;
				}
			}
			
			if (locatorForm.distanceUnitMiles && locatorForm.distanceUnitKilometers) {
				if (this.distanceUnit == locatorDistanceUnitMiles) {
						locatorForm.distanceUnitMiles.checked = true;
				} else if (this.distanceUnit == locatorDistanceUnitKilometers) {
					locatorForm.distanceUnitKilometers.checked = true;
				}
			} else if (locatorForm.distanceUnit) {
				locatorForm.distanceUnit.value = this.distanceUnit;
			}
								
			var wsstag_merchCats = "";
			for (var i=0; i < locatorForm.elements.length; i++) {
			  var element = locatorForm.elements[i];			  
			  if (element.name.indexOf("filter.in.MERCH_CAT") == 0) {
				  if (this.categories[element.name]) {
					var element_regExp = new RegExp ('.*MERCH_CAT_ID\.(.*)') ;
					var elementMatch = element.name.match(element_regExp);
					if(elementMatch){
						wsstag_merchCats += elementMatch[1] + "--";
					}
					element.checked = true;
		  			uncheckSelectAll();
		  		}
			  }	
			  if (element.name.indexOf("filter.in.lserv_LOC_TYPE_ID") == 0) {
				  if (this.categories[element.name]) {
						var element_regExp = new RegExp ('.*LOC_TYPE_ID\.(.*)') ;
						var elementMatch = element.name.match(element_regExp);
						if(elementMatch){
							wsstag_merchCats += elementMatch[1] + "--";
						}
						element.checked = true;
			  			uncheckSelectAll();
			  		}
			  }
			  if (element.name.indexOf("filter.in.AVAIL") == 0) {
				  if (this.categories[element.name]) {
					  var element_regExp = new RegExp ('.*AVAIL\.(.*)') ;
						var elementMatch = element.name.match(element_regExp);
						if(elementMatch){
							wsstag_merchCats += elementMatch[1] + "--";
						}
						element.checked = true;
			  			uncheckSelectAll();
			  		}
			  }
			  if (element.name.indexOf("filter.in.HANDICAP_ACCESSABLE") == 0) {
				  if (this.categories[element.name]) {
					  var element_regExp = new RegExp ('.*HANDICAP_ACCESSABLE\.(.*)') ;
						var elementMatch = element.name.match(element_regExp);
						if(elementMatch){
							wsstag_merchCats += elementMatch[1] + "--";
						}
						element.checked = true;
			  			uncheckSelectAll();
			  		}
			  }
			  if (element.name.indexOf("filter.in.SRCHRG_FREE_ALNC") == 0) {
				  if (this.categories[element.name]) {
						var element_regExp = new RegExp ('.*SRCHRG_FREE_ALNC\.(.*)') ;
						var elementMatch = element.name.match(element_regExp);
						if(elementMatch){
							wsstag_merchCats += elementMatch[1] + "--";
						}
						element.checked = true;
			  			uncheckSelectAll();
			  		}
			  }
			  if (element.name.indexOf("filter.in.SHR_DEPST") == 0) {
				  if (this.categories[element.name]) {
						var element_regExp = new RegExp ('.*SHR_DEPST\.(.*)') ;
						var elementMatch = element.name.match(element_regExp);
						if(elementMatch){
							wsstag_merchCats += elementMatch[1] + "--";
						}
						element.checked = true;
			  			uncheckSelectAll();
			  		}
			  }
			}
				if(wsstag_enabled != undefined && wsstag_enabled){

					if(locatorLocationType != "atm"){
						wsstag_searchString = "MN--" + wsstag_merchantName + "__SA--" + wsstag_streetAddress + "__CI--" + wsstag_city + "__CO--" +  wsstag_countryCode + "__PC--" + wsstag_postalCode;
						wsstag_searchString += "__MC--" + wsstag_merchCats;
						if(typeof(_hbLink) != "undefined" && _hbLink) {
							_hbLink("Merchant Search",wsstag_searchString);
						}
					} else{						
//						if(searchATMType == "Airport"){
//							wsstag_searchString ="__AC--" + wsstag_airportCode+ "__CO--" +  wsstag_countryCode;
//						} else if(searchATMType == "Attraction"){
//							wsstag_searchString ="__AT--" + wsstag_firm + "__CI--" + wsstag_city + "__CO--" +  wsstag_countryCode + "__PC--" + wsstag_postalCode+ "__SR--"+wsstag_radius;
//						} else{ 
//							wsstag_searchString ="__SA--" + wsstag_streetAddress + "__CI--" + wsstag_city + "__CO--" +  wsstag_countryCode + "__PC--" + wsstag_postalCode+ "__SR--"+wsstag_radius;
//						}
					}
				}
			return true;

				
		}
	}	
}

locatorFormState = new LocatorFormState();

function setContents(id, value) {
	if(id=="error" && value!=null){ //added to handle mutiple match
		if(document.getElementById("latitude"))
		document.getElementById("latitude").value = ""; 
		if(document.getElementById("longitude"))
			document.getElementById("longitude").value = "";
		if(document.getElementById("mutipleMatch"))
			document.getElementById("mutipleMatch").value = "";
		
	}
	if(id=="locationTable" && value!=null){ //added to handle mutiple match
		if(document.getElementById("nonMutipleMatch"))
			document.getElementById("nonMutipleMatch").value = "true";
	}
	if (document.getElementById(id)) {
		var elementToSet = document.getElementById(id);
		elementToSet.innerHTML = value;
	}
}

function setContentsByClass(className, value) {
	var elements = getElementsByClassName(document.getElementById(locatorContentDivId), "*", className);
	for (var i = 0; i < elements.length; i++) {
		elements[i].innerHTML = value;
	}
}

function setValue(id, value) {
	if (document.getElementById(id)) {
		var elementToSet = document.getElementById(id);
		elementToSet.value = value;
	}
}

function setTitle(id, value) {
	if (document.getElementById(id)) {
		var elementToSet = document.getElementById(id);
		elementToSet.title = value;
	}
}

function setOptions(selectId, values, displayValues, selectedIndex)  { 
	if (document.getElementById(selectId)) {
	    var element=document.getElementById(selectId);
	    element.options.length = 0;
	    for(var i = 0; i < values.length; i++) {
	        element.options[i] = new Option(displayValues[i], values[i]);
	    }
	    if (element.options[selectedIndex]) { 
	    	element.options[selectedIndex].selected=true;
	    }
	}
	
} 

function clearTableBody(tableId) {
   if (document.getElementById(tableId)) {
	   var tbody = document.getElementById(tableId).getElementsByTagName("tbody")[0];
	   tbody.innerHTML = ""; 
    }
}

function addRowToTable(tableId, values) { 
   var tbody = document.getElementById(tableId).getElementsByTagName("tbody")[0];

   var row = document.createElement("TR");
   for(var i = 0; i < values.length; i++) {
		var cell = document.createElement("TD"); 
  		cell.innerHTML = values[i];
  		row.appendChild(cell); 
  }
  tbody.appendChild(row);
}
function checkSelectAll() {
	
	var isSet = document.getElementById('checkAll');		
	var checkboxArray = document.getElementById('sectionSearchOptionalType').getElementsByTagName('input');		
	
	if (isSet.checked == true) {
		
		for (i = 0; i < checkboxArray.length; i++) {
		
			checkboxArray[i].checked = false;
			
		}
		
	}
	
}	

function uncheckSelectAll() {
	document.getElementById('checkAll').checked = false;
}

var currentLocationAttributeReq = "";
var cachedDropDownListDisplayValues = "";
var cachedDropDownListValues = "";
var cachedSelectIndex = "";

function showResultsFilterDropDown(serviceQuery) {
	var callbackObj = {
		callback: function(responseXml) {
		var dropDownListValues = new Array();
		var dropDownListDisplayValues = new Array();
		var selectIndex=0;

		dropDownListValues[0] = locatorCommon['all'];
		dropDownListDisplayValues[0] = "";
		
		var dropDownListNodes = responseXml.getElementsByTagName("string");
		for (var i = 0; i < dropDownListNodes.length; i++) {
			dropDownListValues[i+1] = dropDownListNodes[i].firstChild.nodeValue;
			dropDownListDisplayValues[i+1] = dropDownListNodes[i].firstChild.nodeValue;
			if (dropDownListValues[i+1] == selectedFilter) {
				selectIndex = i+1;
			}
		}
		
		setOptions("listFilter", dropDownListDisplayValues, dropDownListValues, selectIndex);
		setOptions("listFilter2", dropDownListDisplayValues, dropDownListValues, selectIndex);
		
		cachedDropDownListDisplayValues = dropDownListDisplayValues;
		cachedDropDownListValues = dropDownListValues;
		cachedSelectIndex = selectIndex;

		}
	}
	// Create a new service query that removes the MERCH_NAM filter,
	// so we show all options, even after the filter has been used.
	// Also remove maxLocations.
	var sqArr = serviceQuery.split("&");
	var sq2 = "";
	var selectedFilter = "";
	if(locatorLocationType == "atm"){
	for (var i = 0; i < sqArr.length; i++) {
		if (!(sqArr[i].split("=")[0] == "OWNR_NAM") &&
			!(sqArr[i].split("=")[0] == "MERCH_ATTR_1") && 
		    !(sqArr[i].split("=")[0] == "maxLocations") &&
		    !(sqArr[i].split("=")[0] == "offset")
		    ) {
			if (i > 0) {
				sq2 += "&";
			}
			sq2 += sqArr[i];
		} 
		if (sqArr[i].split("=")[0] == "OWNR_NAM" || sqArr[i].split("=")[0] == "MERCH_ATTR_1" ) {
			selectedFilter = sqArr[i].split("=")[1];
			selectedFilter = unescape(selectedFilter.replace(/\+/g,  " "));
		}
	}
	}else{
	for (var i = 0; i < sqArr.length; i++) {
		if (!(sqArr[i].split("=")[0] == "MERCH_NAM") &&
			!(sqArr[i].split("=")[0] == "MERCH_ATTR_1") && 
		    !(sqArr[i].split("=")[0] == "maxLocations") &&
		    !(sqArr[i].split("=")[0] == "offset")
		    ) {
			if (i > 0) {
				sq2 += "&";
			}
			sq2 += sqArr[i];
		} 
		if (sqArr[i].split("=")[0] == "MERCH_NAM" || sqArr[i].split("=")[0] == "MERCH_ATTR_1" ) {
			selectedFilter = sqArr[i].split("=")[1];
			selectedFilter = unescape(selectedFilter.replace(/\+/g,  " "));
		}
	}
	}
	// Do not execute if the criteria hasn't changed
	// Also, do not execute on location types that do not use the filter.
	if (sq2 != currentLocationAttributeReq && locatorUseResultsFilter) {
		setOptions("listFilter", {1:"a"}, {1:"a"} , 0);
		setOptions("listFilter2", {1:"a"}, {1:"a"}, 0);
		
		var serviceQuery;
		if (locatorLocationType == "hsbc") {
			document.getElementById("filter").name = "filter.equals.MERCH_ATTR_1";
			serviceQuery = sq2 + "&colNames=MERCH_ATTR_1";
		} 
		else if(locatorLocationType == "atm") {
			document.getElementById("filter").name = "filter.equals.OWNR_NAM";
			serviceQuery = sq2 + "&colNames=OWNR_NAM";
		}
		else {
			document.getElementById("filter").name = "filter.equals.MERCH_NAM";
			serviceQuery = sq2 + "&colNames=MERCH_NAM";
		}
		serviceQuery+="&maxLocations=100";
		var service = new ServiceClient("LocationAttributeService", "", serviceQuery);
		service.send(callbackObj);
		currentLocationAttributeReq = sq2;
	} else if (document.getElementById("listFilter").options.length <= 0) {
		setOptions("listFilter", cachedDropDownListDisplayValues, cachedDropDownListValues, cachedSelectIndex);
		setOptions("listFilter2", cachedDropDownListDisplayValues, cachedDropDownListValues, cachedSelectIndex);
	}
}


function displayCountries(selectedCountryCode) {
	var countryCodes = new Array();
	var countryNames = new Array();
	var selectIndex = 0;
	if (document.getElementById("locatorForm").supportsStreetLevelGeocoding) {
		for (var i = 0; i < locatorCountryList.length; i++) {
	
			countryCodes[i] = locatorCountryList[i].countryCode;
			countryNames[i] = locatorCountryList[i].name;
			if(locatorLocationType == "atm")
				countryNames[i] = countryNames[i].toUpperCase();
			if (countryCodes[i].toLowerCase() == selectedCountryCode.toLowerCase()) {
				selectIndex = i;
				if (locatorCountryList[i].supportsStreetLevelGeocoding) {
					document.getElementById("locatorForm").supportsStreetLevelGeocoding.value = "true";
				} else {
					document.getElementById("locatorForm").supportsStreetLevelGeocoding.value = "false";
				}
			}	
		}
	}
	setOptions("countryList", countryCodes, countryNames, selectIndex);
	showFlag(selectedCountryCode);
	if(locatorCommon['footnote.' + selectedCountryCode.toLowerCase()]){
		setContents("footnote",locatorCommon['footnote.' + selectedCountryCode.toLowerCase()]);
	}
	if(document.getElementById("and") != null)
		document.getElementById("and").style.display = "none";
}

function showFlag(countryCode) {

	document.getElementById("flag").src = locatorClientLocation + "images/flags/" + countryCode.toLowerCase() + ".png";
}

function loadCountry(countryCode) {

	var countryCodes = new Array();
	var countryNames = new Array();
	var selectIndex = 0;
	if(document.getElementById("and")!=null)
		document.getElementById("and").style.display = "block";
	document.getElementById("countryList").value = countryCode;
	countryCodes[0] = countryCode;
	countryNames[0] = 'UNITED STATES';
	setOptions("countryList", countryCodes, countryNames, selectIndex);
}

function manageHyperLinks(clickedLink){
	var allLinks= new Array();
	if(clickedLink=="Address"||clickedLink=="Airport"||clickedLink=="Attraction"){
		 allLinks = ["Address","Airport","Attraction","MajorWorld","MajorUS"];
	}else if(clickedLink=="MajorWorld"||clickedLink=="MajorUS"){
		allLinks = ["MajorWorld","MajorUS"];
	}
	for(var i = 0; i < allLinks.length; i++) {
		if(allLinks[i]==clickedLink){
			disableAnchor(clickedLink);
			if(clickedLink=="Address"||clickedLink=="Airport"||clickedLink=="Attraction"){
				document.getElementById(clickedLink).style.fontWeight="bold";
			}
		} else{
			enableAnchor(allLinks[i]);
			if(clickedLink=="Address"||clickedLink=="Airport"||clickedLink=="Attraction"){
				document.getElementById(allLinks[i]).style.fontWeight="normal";
			}
		}
	}
}
function disableAnchor(id){
	object = document.getElementById(id);
	var href = object.getAttribute("href");
	if(href && href != "" && href != null){
		object.setAttribute('href_bak', href);
	}
	object.removeAttribute('href');
	return;
}
function enableAnchor(id){
	object = document.getElementById(id);
	if(object.getAttribute('href_bak')){
	object.setAttribute('href', object.attributes
			['href_bak'].nodeValue);
	}
}
function setSearchType(searchType) {
	searchATMType = searchType;
		if(searchATMType == "Airport")
		{ 
			document.getElementById("sectionSearchOptional").style.display = "none";
			document.getElementById("searchRadiusHeader").style.display = "none";
			document.getElementById("searchRadiusArea").style.display = "none";
			document.getElementById("sectionAirportSearch").style.display = "block";
			document.getElementById("airportDetails").style.display = "none";
			
		} else if(searchATMType == "MajorWorld" || searchATMType == "MajorUS"){ 
			document.getElementById("sectionSearchOptional").style.display = "none";
			document.getElementById("searchRadiusHeader").style.display = "none";
			document.getElementById("searchRadiusArea").style.display = "none";
			document.getElementById("sectionAirportSearch").style.display = "block";
			document.getElementById("airportDetails").style.display = "block";
		} else {
			document.getElementById("sectionSearchOptional").style.display = "block";
			document.getElementById("searchRadiusHeader").style.display = "block";
			document.getElementById("searchRadiusArea").style.display = "block";
			document.getElementById("sectionAirportSearch").style.display = "none";
			document.getElementById("airportDetails").style.display = "none";
			//document.getElementById("streetAddress").style.width = "60";
		}
}
function showAddressFieldsForCountry(divId, countryCode) {
	if(locatorCountry && locatorCountry.length >0){
		document.getElementById("locatorForm").countryCode.value=locatorCountry;
		locatorFormState.address.country.countryCode = locatorCountry;
		countryCode = locatorCountry;
		displayCountries(locatorCountry);
		locatorCountry="";
	}
	var callbackObj = {
		callback: function() {
		if(searchATMType == "Attraction"){
			loadCountry('usa'); 
			showFlag('usa');
		}
		
		if(searchATMType == "Airport"){
		    	 
		    	 if(currentPage=="home"){
		    		 document.getElementById("sectionSearchRequired").style.width="535px";
		    		 document.getElementById("airportCode").style.width="425px";
		    		 document.getElementById("requiredFields").style.display = "none";
		    		 document.getElementById("sectionSearchOptional").style.display = "none";
					 document.getElementById("searchRadiusHeader").style.display = "none";
					 document.getElementById("searchRadiusArea").style.display = "none";
					 document.getElementById("sectionAirportSearch").style.display = "block";
					 document.getElementById("airportDetails").style.display = "none";
		    	 }
		    	 document.getElementById('autoComplete').style.display="none";
		    	 if(currentPage == "results" || currentPage == "details"){
		    		 document.getElementById("autoComplete").className="addressFieldAbbreviatedAirport";
		    		 document.getElementById("airportCode").className="addressFieldAbbreviatedAirport";
		    	 }
	    		document.getElementById("airportCode").onkeyup=showAutoComplete;	    		
	    		document.getElementById("airportCode").onclick=hideAutoComplete;
	    		
				
		} else {
			if(currentPage=="home"){
    		 document.getElementById("requiredFields").className="sectionSearchHeader";
    		 document.getElementById("sectionSearchRequired").style.width="338px";
    		 document.getElementById("requiredFields").style.display = "block";
			}
			
	     }
		if(locatorLocationType == "atm")
			document.getElementById("find").style.backgroundImage = locatorCommon['find'];
		if(currentPage == "home" && locatorLocationType == "atm"){
			manageHyperLinks(searchATMType);
		if(searchATMType == "Airport"){
			document.getElementById("homeDesc").style.display ="none";
	    	 document.getElementById("homeDescUSA").style.display ="none";
	     }else if(searchATMType == "Attraction"){
	    	 document.getElementById("and").style.display = "block";
	    	 document.getElementById("homeDesc").style.display ="block";	    	 
	    	 document.getElementById("homeDescUSA").style.display ="none";
	     }else {
	    	 if(countryCode.toLowerCase() == "usa"){
	    		 document.getElementById("homeDescUSA").style.display ="none";
		    	 document.getElementById("homeDesc").style.display ="block";
	 			
	 		}else{
	 			document.getElementById("homeDesc").style.display ="none";
	 			document.getElementById("homeDescUSA").style.display ="block";
	 		}
	    	 manageHyperLinks('Address');
	     }
		}
		for (var i = 0; i < locatorCountryList.length; i++) {
     
				if (countryCode.toLowerCase() == locatorCountryList[i].countryCode.toLowerCase()) {
				
				    if(locatorCommon['footnote.'+countryCode.toLowerCase()]){
                    	setContents("footnote",locatorCommon['footnote.'+countryCode.toLowerCase()]);
                    } else {
                    	setContents("footnote","");
                    }
					selectIndex = i;
					if (locatorCountryList[i].supportsStreetLevelGeocoding) {
						document.getElementById("locatorForm").supportsStreetLevelGeocoding.value = "true";
						if(document.getElementById("browseCities")) {
							document.getElementById("browseCities").style.display = "none";
								}
						if (locatorLocationType == "atm" && currentPage=="home" && searchATMType != "Airport"){
							document.getElementById("searchRadiusHeader").style.display = "block";
							document.getElementById("searchRadiusArea").style.display = "block";
						}
						}
						else {
						document.getElementById("locatorForm").supportsStreetLevelGeocoding.value = "false";
						if (document.getElementById("browseCities")) {
							document.getElementById("browseCities").style.display = "block";
							if (locatorLocationType == "atm" && currentPage=="home"){
								if(document.getElementById("locatorForm").countryCode.value != "mex"){	
									if (!(locatorLocale == "en_US")){
										document.getElementById("browseCities").style.paddingBottom = "50px";
									} else {
										document.getElementById("browseCities").style.paddingBottom = "25px";
									}
								}else 
									document.getElementById("browseCities").style.paddingBottom = "6px";							
							}
						}
						if (locatorLocationType == "atm" && currentPage=="home"){
							document.getElementById("searchRadiusHeader").style.display = "none";
							document.getElementById("searchRadiusArea").style.display = "none";
							if(document.getElementById("minChars") != null)
								document.getElementById("minChars").style.display="inline";
						}
						}
					if(currentPage == "results" && locatorAlwaysShowCities == true && countryCode.toLowerCase() == "gbr"){
						if (document.getElementById("browseCities")) {
							document.getElementById("browseCities").style.display = "block";
						}
					}
				}
			}
			
			if (document.getElementById("distanceUnitMiles") && document.getElementById("distanceUnitKilometers")) {
				if (locatorDefaultDistanceUnit == "") {
					if(locatorLocationType == "atm"){
						if (countryCode.toLowerCase() == "usa" || countryCode.toLowerCase() == "gbr" || countryCode.toLowerCase() == "ita" || countryCode.toLowerCase() == "esp") {
							document.getElementById("distanceUnitMiles").checked='checked';
						} else {
							document.getElementById("distanceUnitKilometers").checked='checked';
						}
					} else {
						if (countryCode.toLowerCase() == "usa" || countryCode.toLowerCase() == "gbr") {
							document.getElementById("distanceUnitMiles").checked='checked';
						} else {
							document.getElementById("distanceUnitKilometers").checked='checked';
						}
					}
				} else {
					if (locatorDefaultDistanceUnit == locatorDistanceUnitKilometers) {
						document.getElementById("distanceUnitKilometers").checked='checked';
					} else if (locatorDefaultDistanceUnit == locatorDistanceUnitMiles) {
						document.getElementById("distanceUnitMiles").checked='checked';
					} else {
						// Default
						document.getElementById("distanceUnitMiles").checked='checked';
					}
						
				}
			}
			if(document.getElementById("radius") && currentPage=="home"){
				if(locatorLocationType == "atm" || locatorLocationType == "repower-uk"){
					document.getElementById("radius").options[0].selected="selected";
				}
			}
			
			
				locatorFormState.loadToForm(document.getElementById("locatorForm"));
			if((document.getElementById("countryList").value == "usa") || (document.getElementById("countryList").value == ""))
			{
				if(document.getElementById("sectionAttractionSearch"))
				document.getElementById("sectionAttractionSearch").style.display = "inline";
			}
			else{
				if(document.getElementById("sectionAttractionSearch"))
				document.getElementById("sectionAttractionSearch").style.display = "none";
			}
			if(locatorLocationType=="atm" && currentPage=="details"){
				var isGeoCoded = document.getElementById("locatorForm").supportsStreetLevelGeocoding.value;
				//if((document.getElementById("city")) && (isGeoCoded=="false")){
				//	document.getElementById("city").className="addressFieldAbbreviatedDetails";
				//}
				if(document.getElementById("browseCities") && (isGeoCoded=="false")) {
					document.getElementById("browseCities").style.paddingBottom = "10px";
				}
				if((document.getElementById("postalCode")) && (isGeoCoded=="true") && !(document.getElementById("locatorForm").countryCode.value == "usa")  && !(document.getElementById("locatorForm").countryCode.value == "gbr")  && !(document.getElementById("locatorForm").countryCode.value == "can")){
					document.getElementById("postalCode").className="addressFieldAbbreviatedDetails";
				}
			} 
			if(locatorLocationType=="atm" && (currentPage=="results" || currentPage=="details")){
				if(document.getElementById("streetAddress") && document.getElementById("locatorForm").countryCode.value == "gbr"){
					document.getElementById("streetAddress").style.width="150px";
				}
				if(document.getElementById("postalCode") && document.getElementById("locatorForm").countryCode.value == "mex"){
					document.getElementById("postalCode").style.paddingRight="40px";
				}
			}
			if(currentPage=="results"){
				if(isMozilla()){	
					document.getElementById("break").style.display="block";
				}
			}
			
		}
	}
	loadRemotePageWithCallback(divId, locatorMainLocation + "AddressFields.do?locationType=" + locatorLocationType + "&country=" + countryCode + "&locale=" + locatorLocale + "&page=" + currentPage + "&searchType=" + searchATMType, callbackObj);
	
}
function loadPage(object){
	clickedLink = object.id;
	country =  document.getElementById("countryList").value;
	if(clickedLink=="Address"){
		setSearchType('');
		locatorFormState.address.reset(); 
		addHBXTagging('Address','Search');
		showAddressFieldsForCountry('addressFields',country); 
		displayCountries(country); 
		return false;	
	} else if(clickedLink=="Airport"){
		setSearchType('Airport');
		locatorFormState.address.reset();
		addHBXTagging('Airport','Search');
		showAddressFieldsForCountry('addressFields',country); 
		displayCountries(country); 
		return false;
	} else if(clickedLink=="Attraction"){ 
		setSearchType('Attraction'); 
		locatorFormState.address.reset();
		addHBXTagging('Attraction','Search');
		showAddressFieldsForCountry('addressFields', 'usa'); 
		loadCountry('usa'); 
		showFlag('usa');   
		return false;
	} else if(clickedLink=="MajorWorld"){
		manageHyperLinks('MajorWorld'); 
		setSearchType('MajorWorld'); 
		locatorFormState.address.reset(); 
		showAirportList('airportsTable', '', '',0); 
		displayCountries(country); 
		return false;
	} else if(clickedLink=="MajorUS"){	
		manageHyperLinks('MajorUS'); 
		setSearchType('MajorUS'); 
		locatorFormState.address.reset();
		showAirportList('airportsTable', 'usa', '',0); 
		displayCountries(country); 
		return false;
	}
}
function showAirportList(divId, countryCode,cityOrCountryChar,offset) {
	
	var callbackObj = {
		callback: function() {
		if( cityOrCountryChar != null && cityOrCountryChar.length>0){
			document.getElementById(cityOrCountryChar).className="activeLink";
		} else{
			document.getElementById("All").className="activeLink";
		}
//		total=document.getElementById('totalRecords').value;
//		offset=document.getElementById('offset').value;
//		setContents('sectionAirportHeader', getPageHeader(offset, total, cityOrCountryChar,countryCode));
		}
	}
	loadRemotePageWithCallback(divId, locatorMainLocation + "AirportSearch.do?locationType=" + locatorLocationType + "&countryCode=" + countryCode + "&locale=" + locatorLocale + "&page=" + currentPage + "&searchType=" + searchATMType + "&cityOrCountryChar=" +cityOrCountryChar+ "&offset="+offset, callbackObj);
}

function callMajorUS(){
	hideAutoComplete();
	document.getElementById("locatorForm").airportCode.value="";
	setSearchType('MajorUS');
	manageHyperLinks('MajorUS');
	locatorFormState.address.reset();
	showAirportList('airportsTable', 'usa', '',0); 
	return false;
}

function checkSearchType(){
	searchType = searchATMType;
	if(searchType == "MajorUS" || searchType == "MajorWorld"){
		setSearchType("Airport");
	}
	}
function autoCompleteSelect(linkObject,listObject){
	listObject.style.backgroundColor="#316ac5";
	linkObject.style.backgroundColor="#316ac5";
	linkObject.style.color="#ffffff";
}
function autoCompleteDeSelect(linkObject,listObject){
	listObject.style.backgroundColor="ffffff";
	linkObject.style.backgroundColor="ffffff";
	linkObject.style.color="#000";
}
function showAutoComplete(){
	var a = keyHandler();
	var autoCompleteDisplay=document.getElementById("autoComplete").style.display;
	if(a!=null && a==40 && autoCompleteDisplay=="block"){
			document.getElementById("link-1").focus();
	}else{
		var airportCode=document.getElementById('locatorForm').airportCode.value;
		if(airportCode.length!=0){	
			var callbackObj = {
					callback: function() {
						var counter = parseInt(document.getElementById('counter').value);	
						if(counter>0){
							document.getElementById("autoComplete").style.display="block";
						} else {
							hideAutoComplete();
						}
					}
			}
			loadRemotePageWithCallback('autoComplete', locatorMainLocation + "AirportSearch.do?locationType=" + locatorLocationType + "&locale=" + locatorLocale + "&page=" + currentPage + "&searchType=" + searchATMType + "&airportCode=" +airportCode, callbackObj);
		} else{
			hideAutoComplete();
		}
	}
}

function hideAutoComplete(){
	document.getElementById("autoComplete").style.display="none";	
}
function arrowKeyHandler(linkObject){
	var a = keyHandler();
	count = parseInt(document.getElementById('counter').value);
	if(count>10) count=count-1;
	if(a!=null && (a==40 || a==38)&& count>1){
		currentCount=parseInt((linkObject.id).split("-")[1]);
		if(a==40 && currentCount<count){
			linkObject.blur();
			document.getElementById('link-'+(currentCount+1)).focus();
		} else if(a==40 && currentCount==count){
			linkObject.blur();
			document.getElementById('link-1').focus();
		} else if(a==38 && currentCount==1){
			linkObject.blur();
			document.getElementById(('link-'+count)).focus();
		} else if(a==38 && currentCount>1){
			linkObject.blur();
			document.getElementById(('link-'+(currentCount-1))).focus();
		}
	}
	return;
}

function keyHandler(e)
{
	var evt = (evt) ? evt : ((window.event)? window.event : "");
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	return charCode;
}
function showSearch(divId, countryCode) {
	var callbackObj = {
		callback: function() {}
	}
	loadRemotePageWithCallback(divId, locatorMainLocation + "AddressFields.do?locationType=" + locatorLocationType + "&country=" + countryCode + "&locale=" + locatorLocale + "&page=" + currentPage, callbackObj);
}

var categoriesShown = false;

function toggleCategories() {
	
	if (categoriesShown) {
		if (document.getElementById("categoriesInnerContainer")) {
			document.getElementById("categoriesInnerContainer").style.display = "none";
		}
		categoriesShown = false;
	} else {
		if (document.getElementById("categoriesInnerContainer")) {
			document.getElementById("categoriesInnerContainer").style.left = findPos(document.getElementById("categoriesLabel"))[0];
			document.getElementById("categoriesInnerContainer").style.display = "block";
		}
		categoriesShown = true;
	}
	return true;
}

function closeCategories() {
	if (categoriesShown) {
		toggleCategories();
	}
}

function openCategories() {
	if (!categoriesShown) {
		toggleCategories();
	}
}

function getResultsHeaders() {
	var headers = "";
	if (locatorLocationType == "hsbc" || locatorLocationType == "atm") {
	 	headers += "<div class=\"resultsListHeaderNumber\"></div>";
		headers += "<div class=\"resultsListHeaderLocation\" id=\"location\"></div>";
		headers += "<div class=\"resultsListHeaderDistance\" id=\"distance\"></div>";
		headers += "<div class=\"resultsListHeaderCategory\" id=\"category\"></div>";
		headers += "<div class=\"resultsListHeaderFeatures\" id=\"features\"></div>";
		headers += "<div class=\"resultsListHeaderSendTo\" id=\"sendTo\"></div>";
	} 
	else {
	 	headers += "<div class=\"resultsListHeaderNumber\"></div>";
		headers += "<div class=\"resultsListHeaderLocation\" id=\"location\"></div>";
		headers += "<div class=\"resultsListHeaderDistance\" id=\"distance\"></div>";
		headers += "<div class=\"resultsListHeaderCategory\" id=\"category\"></div>";
		headers += "<div class=\"resultsListHeaderSendTo\" id=\"sendTo\"></div>";
	}	
	return headers;
}

//suganthi
function getPageHeader(offSet, total, cityOrCountryChar,countryCode) {
	var heading="";
	if(searchATMType == 'MajorWorld'){
		heading +="World Airports";
	} else if(searchATMType=='MajorUS'){
		heading +="U.S. Airports";
	}
	var offset = parseInt(offSet);
	starting = offset+1;
	ending = offset+25;
	if(offset+25 > total) ending=total;
	prev = offset-25;
	next = ending;
	var headers = "";	
		headers += "<span style=\"font-weight:bold; float:left;\">&nbsp;"+heading+"</span>&nbsp;&nbsp;&nbsp;&nbsp;";
		headers += "<span style=\"width:170px; padding-left:70px;\">Showing "+starting+"-"+ending+" of "+total+"</span>";
	var	navigator="";
		if(offset==0){
			navigator += "&lt; Previous |";
		} else{
			navigator += "<a style=\"color:#ffffff;\" href='#' class='sectionAirportHeader' onclick=\"showAirportList('airportsTable', '"+countryCode+"', '"+cityOrCountryChar+"',"+prev+");\">&lt; Previous</a> | ";
		}
		if(next>=total){
			navigator +="Next &gt;";
		} else{
			navigator += "<a style=\"color:#ffffff;\" href='#' class='sectionAirportHeader' onclick=\"showAirportList('airportsTable', '"+countryCode+"', '"+cityOrCountryChar+"',"+next+");\">Next &gt;</a>";
		}
		headers+="<span style=\"padding-left:80px;\">"+navigator+"</span>";
		return "<span>"+headers+"</span>";	
	
}

//Table content for results page
function showLocations(locationList) {
	var tableBody = "";
	var directions = "";
	var ownedBy = "";
	var printUrl = "";
	var smsUrl = "";
	for (var i = 0; i < locationList.length; i++) {
		if(locatorLocationType == "atm"){
			directions = locatorCommon['directions'];
			ownedBy = locatorCommon['ownedBy'];
			printUrl = locatorCommon['printIconLabel'];
			smsUrl = locatorCommon['smsIconLabel'];
		}
		if(document.getElementById("mutipleMatch"))
			document.getElementById("mutipleMatch").value = "false"; 
		var locatorLocation = locationList[i];
		var row = "";
		if (i%2 == 0) {
			row += '<div class="resultsItemEven" >';
		} else {
			row += '<div class="resultsItemOdd" >';
		}
		row += '<div class="resultsItemNumber"><span class="rowNumber">' + (i+1 + offset) + '.</span></div>';
		if (locatorLocationType == "usbank") {
			row += '<div class="resultsItemLocation"><a href="' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '" target="controller" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details"><span class="title">' + locatorLocation.attributes["MERCH_LOC_DESC"].toTitleCase() + '</span></a>';
		} else if(locatorLocationType == "atm"){		
			row += '<div class="resultsItemLocation"><a href="' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '" target="controller" onclick="addHBXTagging(\'Details\',\'Results\');"><span class="title"><b>' + locatorLocation.name + '</b></span></a>';
		} else {		
			row += '<div class="resultsItemLocation"><a href="' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '" target="controller" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details"><span class="title">' + locatorLocation.name + '</span></a>';
		}
		
		row += '<br />';
		row += locatorLocation.address.streetAddress + '<br />';
		row += locatorLocation.address.city + ', ' + locatorLocation.address.countrySubDivision + ' ' + locatorLocation.address.postalCode;
		if (locatorLocationType == "atm"){
			locStringCount = (locatorLocation.name).length;
			if(locStringCount > 40){
				row += '<br /><br />'+ownedBy+(locatorLocation.attributes["OWNR_NAM"]).toUpperCase().substring(0,20);
			}else{
				row += '<br /><br />'+ownedBy+(locatorLocation.attributes["OWNR_NAM"]).toUpperCase().substring(0,30);
			}
		}
		if (locatorLocationType == "prepaidtravel"){
			row += '<br/><br/>' + locatorCommon['phoneNumber'] + formatPhoneNumber(locatorLocation.attributes["MERCH_PHN_NUM"], "prepaidtravel", locatorLocation.address.country.countryCode);
		}
		row +='</div>';
		if (document.getElementById("locatorForm").supportsStreetLevelGeocoding.value=="true") {
			row += '<div class="resultsItemDistance">' + locatorLocation.distance + ' ' + locatorCommon[locatorLocation.distanceUnit];
			if (locatorLocationType == "atm") {
				row += '<br><a href="' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '" target="controller" onclick="addHBXTagging(\'Directions\',\'Results\');">'+directions+'</a>';
			}
            row += '</div>'; 
		} else {
			document.getElementById("distance").style.display = "none";
			if(document.getElementById("detailsValue")){
				document.getElementById("detailsValue").style.display = "none";
			}
		
		}
		if (locatorLocationType == "paypass") {
			row += '<div class="resultsItemCategory">' + getCategoryNameForId(locatorLocation.attributes["MERCH_CAT_ID"]) + '</div>'; 
		} else if (locatorLocationType == "repower") {
			row += '<div class="resultsItemCategory"><span class="MERCH_ATTR_1.' + locatorLocation.attributes["MERCH_ATTR_1"] + '"></span></div>';
		} else if (locatorLocationType == "hsbc") {
			row += '<div class="resultsItemCategory">' + locatorLocation.attributes["MERCH_ATTR_1"] + '</div>';
		}	else if (locatorLocationType == "atm") {
			row += '<div class="resultsItemCategory">'+locatorLocation.attributes["LOC_TYPE_DESC"]+'</div>';
		}
		
		if (locatorLocationType == "hsbc") {
			row += '<div class="resultsItemFeatures">';
			if (locatorLocation.attributes["MERCH_ATTR_1"] && locatorLocation.attributes["MERCH_ATTR_1"] == "Drive Up ATM") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_drive-thru.gif" id="MERCH_ATTR_1">';
			}
			
			if (locatorLocation.attributes["MERCH_ATTR_3"] && locatorLocation.attributes["MERCH_ATTR_3"] == "1") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_clock.gif" id="MERCH_ATTR_3">';
			}
			
			if (locatorLocation.attributes["MERCH_ATTR_7"] && locatorLocation.attributes["MERCH_ATTR_7"] == "1") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_handicap.gif" id="MERCH_ATTR_7">';
			}
			// FIXME: Surcharge Free and Deposit Sharing not implemented because not present in current data.
			row += '</div>';
		} else if (locatorLocationType == "atm") {
			if(document.getElementById("locatorForm").supportsStreetLevelGeocoding.value == "false"){
				row += '<div class="resultsItemFeatures" style="width:130px">';
			}else{
				row += '<div class="resultsItemFeatures">';
			}
			if (locatorLocation.attributes["LOC_TYPE_ID"] && locatorLocation.attributes["LOC_TYPE_ID"] == "15") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_drive-thru.gif" id="MERCH_ATTR_1">';
			}
			
			if (locatorLocation.attributes["AVAIL"] && locatorLocation.attributes["AVAIL"] == "1") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_clock.gif" id="MERCH_ATTR_3">';
			}
			
			if (locatorLocation.attributes["HANDICAP_ACCESSABLE"] && locatorLocation.attributes["HANDICAP_ACCESSABLE"] == "0") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_handicap.gif" id="MERCH_ATTR_7">';
			}
			
			if (locatorLocation.attributes["SRCHRG_FREE_ALNC"] && locatorLocation.attributes["SRCHRG_FREE_ALNC"] == "Y") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_surcharge.gif" id="MERCH_ATTR_7">';
			}
			if (locatorLocation.attributes["SHR_DEPST"] && locatorLocation.attributes["SHR_DEPST"] == "0") {
				row += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_deposit.gif" id="MERCH_ATTR_7">';
			}
			row += '</div>';
		}
		if(locatorLocationType == "rpps"){
				row += '<div class="rppsResultsItemSendTo">';}
		else if(document.getElementById("locatorForm").supportsStreetLevelGeocoding.value == "false" && locatorLocationType == "atm"){
			//row += '<div class="resultsItemSendTo" style="padding-left=43px;">';
			row += '<div class="resultsItemSendTo">';
		} else{
				row += '<div class="resultsItemSendTo">';
				}
		
		if (locatorShowSMS) {
			if(locatorLocale == "fr"){	
				row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=sms\'" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details SMS"><div class="smsImage" ></div><div class="smsIconLabelFr">' + locatorCommon['smsIconLabel'] + '</div></div>';
				}
			else if(locatorLocationType == "atm"){
				if(!(locatorLocale == "fa" || locatorLocale == "us")){
				row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=sms\'; addHBXTagging(\'SMS\',\'Results\');" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer"><div class="smsImage"></div><div class="smsIconLabel" style="background-image:'+smsUrl+';"></div></div>';
				} else{
					row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=sms\'; addHBXTagging(\'SMS\',\'Results\');" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" style="width:100px; padding-top:1px;"><div class="smsIconLabel" style="height:60px; width:120px; background-image:'+smsUrl+';"></div></div>';	
				}	
			}
			else{
				row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=sms\'" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details SMS"><div class="smsImage" ></div><div class="smsIconLabel">' + locatorCommon['smsIconLabel'] + '</div></div>';
			}	
		}
		if(locatorLocationType == "atm"){
			if(locatorShowSMS == true){
				if(!(locatorLocale == "fa" || locatorLocale == "us")){
					row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=print\'; addHBXTagging(\'Print_ATM\',\'Results\');" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer"><div class="printImage"></div><div class="printIconLabel" style="background-image:'+printUrl+';"></div></div>';
				} else {
					row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=print\'; addHBXTagging(\'Print_ATM\',\'Results\');" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer" style="width:100px; padding-top:15px;"><div class="printIconLabel" style="height:40px; width:120px; background-image:'+printUrl+';"></div></div>';
				}
			} else{
				if(locatorLocale == "en_US" || locatorLocale=="bg" || locatorLocale=="sr")
					row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=print\'; addHBXTagging(\'Print_ATM\',\'Results\');" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer"><div class="printImage" style="width:120px;"></div><div class="printIconLabel" style="width:120px; background-image:'+printUrl+';"></div></div>';
				else	
					row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=print\'; addHBXTagging(\'Print_ATM\',\'Results\');" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer"><div class="printIconLabel" style="height:40px; width:120px; background-image:'+printUrl+';"></div></div>';
			}
		} else {
			row += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(i) + '&action=print\'" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id  + '&lpos=Merchant Details Print"><div class="printImage"></div><div class="printIconLabel">' + locatorCommon['printIconLabel'] + '</div></div>';
		}
		row += '</div>';
		
		row += '</div>';
		tableBody += row;
		
	}
	setContents("locationTable", tableBody);
		if(document.getElementById("locatorForm").supportsStreetLevelGeocoding.value == "false" && locatorLocationType == "atm"){
			document.getElementById("sendTo").style.width="140px";
			document.getElementById("features").style.width="130px";
		}
		if(locatorLocationType == "atm" && (locatorLocale.toLowerCase()=="el" || locatorLocale.toLowerCase()=="as" || locatorLocale.toLowerCase()=="jp" || locatorLocale.toLowerCase()=="kr" ||locatorLocale.toLowerCase()=="ja" || locatorLocale.toLowerCase()=="bg")){
			document.getElementById("search1").style.paddingLeft="320px";
			document.getElementById("search2").style.paddingLeft="320px";
		}
		if(locatorLocationType == "atm" && locatorLocale == "bg"){
			document.getElementById("sendTo").style.width="130px";
		}
		if(locatorLocationType == "paypass" && locatorLocale == "ro"){
			document.getElementById("search1").style.width ="180px";
			document.getElementById("search2").style.width ="180px";
			document.getElementById("view1").style.width ="180px";
			document.getElementById("view2").style.width ="180px";
			document.getElementById("navigationContainer1").style.height ="30px";
			document.getElementById("navigationContainer2").style.height ="30px";
		}
}
function getDetailsHeaders() {
	var headers = "";
	if (locatorLocationType == "hsbc" || locatorLocationType == "paypass") {
		headers += '<div class="detailedListHeaderLocation" id="location"></div>';
		headers += '<div class="detailedListHeaderDistance" id="distance"></div>';
		headers += '<div class="detailedListHeaderCategory" id="category"></div>';
		headers += '<div class="detailedListHeaderTypes" id="types"></div>';
		headers += '<div class="detailedListHeaderSendTo" id="sendTo"></div>';
	} else if(locatorLocationType == "atm"){ 
		headers += '<div class="detailedListHeaderLocation" id="location"></div>';
		headers += '<div class="detailedListHeaderNetwork" id="network"></div>';
		headers += '<div class="detailedListHeaderCategory" id="category"></div>';
		headers += '<div class="detailedListHeaderTypes" id="types"></div>';
	}
	else {
	 	headers += '<div class="detailedListHeaderNumber"></div>';
		headers += '<div class="detailedListHeaderLocation" id="location"></div>';
		headers += '<div class="detailedListHeaderDistance" id="distance"></div>';
		headers += '<div class="detailedListHeaderCategory" id="category"></div>';
		headers += '<div class="detailedListHeaderSendTo" id="sendTo"></div>'
	}
	return headers;
}


// for details page
function showLocation(locatorLocation) {
	var locationDetails = '<div class="detailedItemLocation" id="detailedItemLocation">';
	// Name and Address column
	locationDetails += '<div id="locationName">';
	if (locatorLocationType == "usbank") {
		locationDetails += locatorLocation.attributes["MERCH_LOC_DESC"].toTitleCase();
	} else {		
		locationDetails += locatorLocation.name;
	}	
	locationDetails += "</div>";
	
	locationDetails += '<div id="locationAddress">';
	if (locatorLocationType == "prepaidtravel"){
		locationDetails +=  locatorLocation.address.streetAddress + "<br/>" + locatorLocation.address.city + " " + locatorLocation.address.countrySubDivision + " " + locatorLocation.address.postalCode + "<br/><br/>" + locatorCommon['phoneNumber'] + formatPhoneNumber(locatorLocation.attributes["MERCH_PHN_NUM"], "prepaidtravel", locatorLocation.address.country.countryCode);
	} else {		
		locationDetails += locatorLocation.address.streetAddress + "<br/>" + locatorLocation.address.city + " " + locatorLocation.address.countrySubDivision + " " + locatorLocation.address.postalCode;
	}
	locationDetails += '</div>';
	locationDetails += '</div>';
	
	// Distance column
	if (document.getElementById("locatorForm").supportsStreetLevelGeocoding.value == "true") {
		if (locatorLocationType != "atm" ){
		locationDetails += '<div class="detailedItemDirections" id="detailsValue">';
		locationDetails += '<div id="locationDistance">	';
		locationDetails += locatorLocation.distance + " " + locatorCommon[locatorLocation.distanceUnit];
		locationDetails += '</div>';
		locationDetails += '</div>';
		}
	}
	
	// Network Column
	if (locatorLocationType == "atm" ){
		locationDetails += '<div class="detailedItemNetwork" id="locationNetwork">';
		locationDetails += locatorLocation.attributes["OWNR_NAM"];
		locationDetails += '</div>';
	}
	
	// Category column
	if (locatorLocationType != "rpps" ){
	locationDetails += '<div class="detailedItemCategory" id="locationCategory">';}
	if (locatorLocationType == "paypass") {
		locationDetails += getCategoryNameForId(locatorLocation.attributes["MERCH_CAT_ID"]);
	} else if (locatorLocationType == "repower") {
		locationDetails += '<span id="MERCH_ATTR_1.' +  locatorLocation.attributes["MERCH_ATTR_1"] + '"></span>';
	} else if (locatorLocationType == "hsbc" ) {
		locationDetails += locatorLocation.attributes["MERCH_ATTR_1"];
	} else if (locatorLocationType == "atm") {
		locationDetails += locatorLocation.attributes["LOC_TYPE_DESC"];
	}
	
	locationDetails += '</div>';
	// Types/Attributes column
	locationDetails += '<div class="detailedItemTypes" id="locationAttributes">';
	if (locatorLocationType == "paypass") {
		for (var i = 1; i < 14; i++) {
			if (locatorLocation.attributes["MERCH_ATTR_" + i] && locatorLocation.attributes["MERCH_ATTR_" + i] == "1") {
				locationDetails += '<img src="' + locatorClientLocation + 'images/attribute-icons/paypass/MERCH_ATTR_' + i + '.gif" id="MERCH_ATTR_' + i + '">';
			}
		}
	} else if (locatorLocationType == "hsbc") {
		if (locatorLocation.attributes["MERCH_ATTR_1"] && locatorLocation.attributes["MERCH_ATTR_1"] == "Drive Up ATM") {
			locationDetails += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_drive-thru.gif" id="MERCH_ATTR_1">';
		}
		
		if (locatorLocation.attributes["MERCH_ATTR_3"] && locatorLocation.attributes["MERCH_ATTR_3"] == "1") {
			locationDetails += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_clock.gif" id="MERCH_ATTR_3">';
		}
		
		if (locatorLocation.attributes["MERCH_ATTR_7"] && locatorLocation.attributes["MERCH_ATTR_7"] == "1") {
			locationDetails += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_handicap.gif" id="MERCH_ATTR_7">';
		}
		// FIXME: Surcharge Free and Deposit Sharing not implemented because not present in current data.
		}else if (locatorLocationType == "atm") {
			if(locatorShowSMS == true){
				if(!(locatorLocale == "fa" || locatorLocale == "us")){				
					locationDetails += '<a style="text-decoration:none;" href="#smsContainer" title="" class="smsIcon pointer"><div class="smsImage" ></div><div class="smsIconLabel" id="smsIconLabel"></div></a>';
					locationDetails += '<a style="text-decoration:none;" href="javascript:window.print();" title="" class="printIcon pointer"><div class="printImage"></div><div class="printIconLabel" id="printIconLabel"></div></a>';
				} else {
					locationDetails += '<a style="text-decoration:none;" href="#smsContainer" title="" class="smsIcon pointer" id="smsIcon"><div class="smsIconLabel" id="smsIconLabel" style="height:60px; width:120px; background-image:'+locatorCommon['smsIconLabel']+'"></div></a>';
					locationDetails += '<a style="text-decoration:none;" href="javascript:window.print();" title="" class="printIcon pointer" id="printIcon"><div class="printIconLabel" id="printIconLabel" style="height:50px; width:120px;"></div></a>';
				}
			} else {
				if(locatorLocale == "en_US" || locatorLocale == "bg" || locatorLocale == "sr")
					locationDetails += '<a style="text-decoration:none;" href="javascript:window.print();" title="" class="printIcon pointer"><div class="printImage" style="width:120px;"></div><div class="printIconLabel" id="printIconLabel" style="width:120px;"></div></a>';
				else
					locationDetails += '<a style="text-decoration:none;" href="javascript:window.print();" title="" class="printIcon pointer"><div class="printIconLabel" id="printIconLabel" style="height:40px; width:120px;"></div></a>';
			}
		} 
	locationDetails += '</div>';
	
	// Send To column
	if(locatorLocationType == "rpps"){
		locationDetails += '<div class="rppsDetailedItemSendTo" id="rppsDetailedItemSendTo">';
	}else if(locatorLocationType == "atm"){
		
	}
	else{
		locationDetails += '<div class="detailedItemSendTo" id="detailedItemSendTo">';}

	if (locatorShowSMS) {
		if(locatorLocale == "fr"){	
			locationDetails += '<div onclick="window.location.hash=\'sms\'" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details SMS"><div class="smsImage"></div><div class="smsIconLabelFr">' + locatorCommon['smsIconLabel'] + '</div></div>'; 
		}
		else if(locatorLocationType != "atm"){
			locationDetails += '<div onclick="window.location.hash=\'sms\'" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details SMS"><div class="smsImage"></div><div class="smsIconLabel">' + locatorCommon['smsIconLabel'] + '</div></div>'; 
		}
	}
	if(locatorLocationType != "atm")
		locationDetails += '<div onclick="printDetails()" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer" ><div class="printImage"></div><div class="printIconLabel" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details Print">' + locatorCommon['printIconLabel'] + '</div></div>';
	locationDetails += '</div>';
	
	setContents("locationDetails", locationDetails);
	
	// Final cleanup

	document.getElementById("smsForm").locationId.value = locatorLocation.id;
	document.getElementById("smsForm").locationType.value = locatorLocation.Type;
	if (document.getElementById("locatorForm").supportsStreetLevelGeocoding.value != "true") {
		if(document.getElementById("directionsContainer")){
			document.getElementById("directionsContainer").style.display = "none";
		}
	}
	if(locatorLocationType == "atm"){
		if(locatorLocale == "fa")  //fix for invalid argument error
			document.getElementById("printIconLabel").style.backgroundImage = 'url(/interactivelocator/clients/merchant-default/images/fr/icon_print.gif)';
		else
			document.getElementById("printIconLabel").style.backgroundImage = locatorCommon['printIconLabel'];
		if(locatorLocale == "us" && locatorShowSMS == true){
			document.getElementById("smsIcon").style.width="100px";
			document.getElementById("smsIcon").style.paddingTop="1px";
			document.getElementById("printIcon").style.paddingTop="10px";
			document.getElementById("locationDetailsContainer").style.height="128px";
			document.getElementById("detailedItemLocation").style.height="100px";
			document.getElementById("locationNetwork").style.height="100px";
			document.getElementById("locationCategory").style.height="100px";
			document.getElementById("locationAttributes").style.height="100px";
			document.getElementById("smsContainer").style.height="210px";
		}
	}
	if((locatorLocationType == "repower" && locatorLocale == "sp")||(locatorLocationType == "paypass" && locatorLocale == "ro")){
		document.getElementById("break").style.display="block";
	}
	if(locatorLocationType == "paypass"){
		if(locatorLocale == "ro"){
			 document.getElementById("smsContainer").style.height="210px";
			 document.getElementById("locationDetailsContainer").style.height="110px";
			 document.getElementById("detailsHeaders").style.height="27px";
			 document.getElementById("mainHeader").style.height="30px";
		 }
		if (document.getElementById("locatorForm").supportsStreetLevelGeocoding.value == "false") {
			document.getElementById("distance").style.display = "none";
			
			if(locatorLocale == "ro"){
				document.getElementById("locationAttributes").style.width = "165px";
				document.getElementById("types").style.width = "180px";
			}
		}
	}
}

function getMapPopupContents(locatorLocation, locIndex, page) {
	var printUrl = locatorCommon['printIconLabel'];
	var smsUrl = locatorCommon['smsIconLabel'];
	var popupContents = '<div style="text-align: left; height: 110px; width: 220px;">';
	popupContents += '<div><b>' + locatorLocation.name + '</b></div>';
	popupContents += '<div>' + locatorLocation.address.streetAddress + '</div>';
	popupContents += '<div>' + locatorLocation.address.city + ',&nbsp;' + locatorLocation.address.countrySubDivision + '&nbsp;<span style="white-space: nowrap">' + locatorLocation.address.postalCode + '</span>';
	if(locatorLocationType == "prepaidtravel")
	{
		popupContents += '<br/><br/>' + locatorCommon['phoneNumber'] + formatPhoneNumber(locatorLocation.attributes["MERCH_PHN_NUM"], "prepaidtravel", locatorLocation.address.country.countryCode);
	}
	popupContents += '</div>';

	if (page == "results") {
	popupContents += '<div style="margin-top: 10px; width: 220px;">';
	popupContents += '<div style="float: left; margin-top: 13px"><a href="' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '" target="controller" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details GMap">' + locatorCommon['details'] + '</a></div>';
	
	if(locatorLocationType == "atm" && locatorLocale == "us" && locatorShowSMS == true){
		popupContents += '<div style="float: right; width:210px;">';
	} else {
		popupContents += '<div style="float: right;">';
	}
	if(locatorLocationType == "atm"){
		if (locatorShowSMS == true){ 
			if(!(locatorLocale == "us")){
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=sms\'" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details SMS GMap"><div class="smsImage"></div><div class="smsIconLabel" style="background-image:'+smsUrl+';"></div></div>';
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=print\'" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer"><div class="printImage"></div><div class="printIconLabel" style="background-image:'+printUrl+';"></div></div>';
			} else {
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=sms\'; addHBXTagging(\'SMS\',\'Results\');" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" style="width:100px; padding-top:1px;"><div class="smsIconLabel" style="height:60px; width:100px; background-image:'+smsUrl+';"></div></div>';
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=print\'; addHBXTagging(\'Print_ATM\',\'Results\');" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer" style="width:100px; padding-top:15px;"><div class="printIconLabel" style="height:45px; width:100px; background-image:'+printUrl+';"></div></div>';
			}
		} else{
			if(locatorLocale == "en_US" || locatorLocale == "bg" || locatorLocale == "sr")
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=print\'; addHBXTagging(\'Print_ATM\',\'Results\');" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer"><div class="printImage"></div><div class="printIconLabel" style="background-image:'+printUrl+';"></div></div>';
			else
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=print\'" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer" style="width:100px;"><div class="printIconLabel" id="printIconLabel" style="height:40px; width:100px; background-image:'+printUrl+';"></div></div>';
		}
	} else {
		if (locatorShowSMS) {
			if(locatorLocale == "fr"){		
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=sms\'" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details SMS GMap"><div class="smsImage"></div><div class="smsIconLabelFr">' + locatorCommon['smsIconLabel'] + '</div></div>';
			}
			else{
				popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=sms\'" title="' + locatorCommon['smsTooltip'] + '" class="smsIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details SMS GMap"><div class="smsImage"></div><div class="smsIconLabel">' + locatorCommon['smsIconLabel'] + '</div></div>';
			}		
		} 
		popupContents += '<div onclick="frames[\'controller\'].location.href=\'' + locatorMainLocation + 'AddressSearch.do' + getSingleLocationQueryString(locIndex) + '&action=print\'" title="' + locatorCommon['printTooltip'] + '" class="printIcon pointer" name="&lid=' + locatorLocation.name + '|' + locatorLocation.id + '&lpos=Merchant Details Print GMap"><div class="printImage"></div><div class="printIconLabel">' + locatorCommon['printIconLabel'] + '</div></div>';
	}
	popupContents += '</div>';

	if (locatorLocationType == "hsbc") {
		popupContents += '<div class="popupFeatures">';
		if (locatorLocation.attributes["MERCH_ATTR_1"] && locatorLocation.attributes["MERCH_ATTR_1"] == "Drive Up ATM") {
			popupContents += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_drive-thru.gif" id="MERCH_ATTR_1">';
		}
		
		if (locatorLocation.attributes["MERCH_ATTR_3"] && locatorLocation.attributes["MERCH_ATTR_3"] == "1") {
			popupContents += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_clock.gif" id="MERCH_ATTR_3">';
		}
		
		if (locatorLocation.attributes["MERCH_ATTR_7"] && locatorLocation.attributes["MERCH_ATTR_7"] == "1") {
			popupContents += '<img src="' + locatorClientLocation + 'images/attribute-icons/atm/icon_handicap.gif" id="MERCH_ATTR_7">';
		}
		// FIXME: Surcharge Free and Deposit Sharing not implemented because not present in current data.
		popupContents += '</div>';
	}	
	
	popupContents += '</div>';
	}
	
	return popupContents;
}

function showNextResults() {
	var newOffset = offset + locatorLocationsPerPage;
	if(wsstag_enabled && typeof(_hbLink) != "undefined"){
			_hbLink(newOffset,'Next Results');
	}
	moveLocatonListToOffset(newOffset);
}

function showPreviousResults() {
	var newOffset = offset - locatorLocationsPerPage;
	if(wsstag_enabled && typeof(_hbLink) != "undefined"){
			_hbLink(newOffset,'Previous Results');
	}		
	moveLocatonListToOffset(newOffset);
}

function showNextLocation() {
	var newOffset = offset + 1;
	if(wsstag_enabled && typeof(_hbLink) != "undefined"){
			_hbLink(newOffset,'Next Location');
	}	
	moveLocatonListToOffset(newOffset);
}

function showPreviousLocation() {
	var newOffset = offset - 1;
	if(wsstag_enabled && typeof(_hbLink) != "undefined"){
			_hbLink(newOffset,'Previous Location');
	}	
	moveLocatonListToOffset(newOffset);
}

function showLocationsDropNavigator(elementId, resultsSize) {
	var perPage = locatorLocationsPerPage - 0;
	var values = new Array();
	var displayValues = new Array();
	var selectedIndex = 0;
	if(document.getElementById(elementId)) {
		for (var i = 0; i < resultsSize; i = i + perPage) {
			values[values.length] = i;
			if (i == offset && offset != 0) {
				selectedIndex = i/perPage;
			}
			if (i + perPage + 1 <= resultsSize) {
				displayValues[displayValues.length] = (i+1) + " - " + (i+perPage);
			} else {
				displayValues[displayValues.length] = (i+1) + " - " + resultsSize;
			}
		}
		
	}
	setOptions(elementId, values, displayValues, selectedIndex);
}

function moveLocatonListToOffset(newOffset) {
	var currentQueryString = controller.document.location.search;
	var newQueryString = currentQueryString.replace("&offset="+offset,"") + "&offset=" + newOffset;
	newQueryString = newQueryString.replace("&page=home", "");
	newQueryString = newQueryString.replace("&page=results", "");
	newQueryString = newQueryString.replace("&page=details", "");
	newQueryString = newQueryString + "&page=" + currentPage;
	if(wsstag_enabled && typeof(_hbLink) != "undefined") {
		_hbLink(newOffset,'View More Results');
	}
	controller.document.location.href = locatorMainLocation + 'AddressSearch.do' + newQueryString;	
}

function setPreviousNext(newOffset, totalResults) {
	if (newOffset == 0) {
		if(locatorLocationType == "atm"){
			document.getElementById("previousLink1ATM").style.display = 'none';
			document.getElementById("previousLink2ATM").style.display = 'none';
		}else{
			document.getElementById("previousLink1").style.display = 'none';
			document.getElementById("previousLink2").style.display = 'none';
		}
	} else {
		if(locatorLocationType == "atm"){
			document.getElementById("previousLink1ATM").style.display = 'inline';
			document.getElementById("previousLink2ATM").style.display = 'inline';
		}else{
			document.getElementById("previousLink1").style.display = 'inline';
			document.getElementById("previousLink2").style.display = 'inline';
		}
	}
	if ((newOffset + locatorLocationsPerPage + 1) > 100) {
		if(locatorLocationType == "atm"){
			document.getElementById("nextLink1ATM").style.display = 'none';
			document.getElementById("nextLink2ATM").style.display = 'none'; 
		}
	}
	if ((newOffset + locatorLocationsPerPage + 1) > totalResults) {
		if(locatorLocationType == "atm"){
			document.getElementById("nextLink1ATM").style.display = 'none';
			document.getElementById("nextLink2ATM").style.display = 'none'; 
		}else{
			document.getElementById("nextLink1").style.display = 'none';
			document.getElementById("nextLink2").style.display = 'none';
		}
	} else {
		if(locatorLocationType == "atm"){
			if ((newOffset + locatorLocationsPerPage + 1) < 100){
				document.getElementById("nextLink1ATM").style.display = 'inline';
				document.getElementById("nextLink2ATM").style.display = 'inline';
			}
		}else{
			document.getElementById("nextLink1").style.display = 'inline';
			document.getElementById("nextLink2").style.display = 'inline';
		}	
	}	
}
function setPreviousNextLocation(newOffset, totalResults) {
	if (newOffset == 0) {
		document.getElementById("previousLocationLink").style.display = 'none';
	} else {
		document.getElementById("previousLocationLink").style.display = 'inline';
	}
	if ((newOffset + 1) >= totalResults) {
		document.getElementById("nextLocationLink").style.display = 'none';
	} else {
		document.getElementById("nextLocationLink").style.display = 'inline';
	}	
	
}

function getSingleLocationQueryString(locationNumber) {
	var currentQueryString = controller.document.location.search;
	var newOffset = offset + locationNumber;
	var newQueryString = currentQueryString.replace("&offset="+offset,"") + "&offset=" + newOffset;
	
	newQueryString = newQueryString.replace("&maxLocations="+locatorLocationsPerPage,"") + "&maxLocations=1";
	newQueryString = newQueryString.replace("&page=home", "");
	newQueryString = newQueryString.replace("&page=results", "");
	newQueryString = newQueryString.replace("&page=details", "");
	newQueryString = newQueryString + "&page=" + currentPage;
	return newQueryString;	
}



function loadDrivingDirectionAndRoute(startPoint, destinationPoint, startAddress, destinationAddress) {
	
	var callbackObj = {
		callback: function(responseXml) {
			var html = "<ol>";
			var directionList = new Array();
			var pointNode= new Array();
			var routeArray = new Array();
			directionList=responseXml.getElementsByTagName("directionList");
			for(var i = 0; i < directionList.length; i++){
				html += "<li>";
				html += directionList[i].getElementsByTagName("directions")[0].firstChild.nodeValue;
				html += "</li>";
				routeLongitudes = directionList[i].getElementsByTagName("longtitude");
				routeLatitudes = directionList[i].getElementsByTagName("latitude");
				for (var j = 0; j < routeLongitudes.length; j++) {
				//Adding the latitude and longitude of the Route to routeArray
					var routePoint = new Point();
					routePoint.longitude=routeLongitudes[j].firstChild.nodeValue;
					routePoint.latitude=routeLatitudes[j].firstChild.nodeValue;
					routeArray[routeArray.length]=routePoint;
				}
			}
			html += "</ol>";
			setContents("drivingDirections", html);
			startAddressStr = "";
			if(startAddress.streetAddress != "") {
				startAddressStr += startAddress.streetAddress + ", "
			}
			if(startAddress.city != "") {
				startAddressStr += startAddress.city + ",&nbsp;"
			}
			
			startAddressStr += startAddress.countrySubDivision + "&nbsp; " + startAddress.postalCode;

			destinationAddressStr = "";
			if(destinationAddress.streetAddress != "") {
				destinationAddressStr += destinationAddress.streetAddress + ", "
			}
			if(destinationAddress.city != "") {
				destinationAddressStr += destinationAddress.city + ",&nbsp;"
			}
			
			destinationAddressStr += destinationAddress.countrySubDivision + "&nbsp; " + destinationAddress.postalCode;
			
			setContents("startingAddress", startAddressStr);
			setContents("destinationAddress", destinationAddressStr);
			showRoute(routeArray);
		}
	}
	var service = new ServiceClient("RouteService", "", "longitude="+startPoint.longitude+"&latitude="+startPoint.latitude+"&destLongitude="+destinationPoint.longitude+"&destLatitude="+destinationPoint.latitude+"&countryCode=" + startAddress.country.countryCode.toLowerCase() +"&distanceUnit=" + locatorFormState.distanceUnit);
	service.send(callbackObj);
	
}

function showRoute(routePoints) {
	var polyLines = new Array();
	var polylinePoints = new Array();
    for (j = 0; j < routePoints.length; j++) {
        polylinePoints[j] = new GLatLng(routePoints[j].latitude, routePoints[j].longitude);
    }
   	var polyline = new GPolyline(polylinePoints, "#0000ff", 6, .5);
    
    loadRoute(polyline);
}

function showLocatorDialog(width, height) {
	locatorBg = document.getElementById('locatorDialog-background');
	locatorBg.style.display = "block";
	locatorBg.style.position = "absolute";
    locatorBg.height = document.body.clientHeight;
    locatorBg.width = document.body.clientWidth;
	locatorDialogContents = document.getElementById('locatorDialog-contents');
	locatorDialogContents.style.display = "block";
	locatorDialogContents.style.height = height + "px";
	locatorDialogContents.style.width = width + "px";
	locatorDialogContents.style.position = "absolute";
	locatorDialogContents.style.left = (findPos(document.getElementById('locator-content'))[0]+100) + "px";
	locatorDialogContents.style.top = (findPos(document.getElementById('locator-content'))[1]+50) + "px";
}


function hideLocatorDialog() {
	document.getElementById('locatorDialog-background').style.display = "none";
	document.getElementById('locatorDialog-contents').style.display = "none";
}

function setCity(cityVal) {
	locatorFormState.address.city = cityVal;
	document.getElementById('locatorForm').city.value = cityVal;
}


function submitMutipleMatch(latitude, longitude, postalCode, city, street){
	document.getElementById('locatorForm').latitude.value = latitude;
	document.getElementById('locatorForm').longitude.value = longitude;
	if(document.getElementById('locatorForm').postalCode)
		document.getElementById('locatorForm').postalCode.value = postalCode;
	if(document.getElementById('locatorForm').zipCode)
		document.getElementById('locatorForm').zipCode.value = postalCode;
	if(document.getElementById('locatorForm').city)
		document.getElementById('locatorForm').city.value = city;
	if(document.getElementById('locatorForm').town)
		document.getElementById('locatorForm').town.value = city;
	if(document.getElementById('locatorForm').streetAddress){
		document.getElementById('locatorForm').streetAddress.value = street;}
	document.getElementById('locatorForm').mutipleMatch.value = "true";
}
function submitMutipleMatchAirport(latitude, longitude, country, airportName){
	document.getElementById('locatorForm').latitude.value = latitude;
	document.getElementById('locatorForm').longitude.value = longitude;
	if(document.getElementById('locatorForm').airportCode){
		document.getElementById('locatorForm').airportCode.value = airportName.substring(0,3);
	}
	displayCountries(country);
	document.getElementById('locatorForm').mutipleMatch.value = "true";
}

function showBrowseCities(countryCode, locale) {
	setContents("locatorDialog-contents", "");
	showLocatorDialog("380", "330");
	loadRemotePage("locatorDialog-contents", locatorMainLocation + "BrowseCities.do?locationType=" + locatorLocationType + "&countryCode=" + countryCode + "&offset=0&letter=&numOfCities=" + locatorCitiesPerPage + "&locale=" + locale);
}

function showBrowseCities(countryCode, locale) {
	setContents("locatorDialog-contents", "");
	showLocatorDialog("380", "330");
	var callbackObj = {
			callback: function() {
			if((locatorLocationType == "atm"  || (locatorLocationType == "paypass" && locatorLocale == "ro")) && isIE7()){
				if(document.getElementById("browseCitiesHeader")){
					document.getElementById("browseCitiesHeader").style.height="50px";
				}
				if(document.getElementById("browseCitiesHeaderLine2")){
					document.getElementById("browseCitiesHeaderLine2").className="browseCitiesHeaderLine2IE7";
				}
			} 
		}
	}
	loadRemotePageWithCallback("locatorDialog-contents", locatorMainLocation + "BrowseCities.do?locationType=" + locatorLocationType + "&countryCode=" + countryCode + "&offset=0&letter=&numOfCities=" + locatorCitiesPerPage + "&locale=" + locale, callbackObj);
}	

function searchCities(letter, offset, countryCode, locale){
	countryCode=document.browseActionForm.countryCode.value;
	numOfCities=document.browseActionForm.numOfCities.value;
	
	document.browseActionForm.action= locatorMainLocation + "BrowseCities.do?locationType=" + locatorLocationType + "&countryCode="+countryCode+"&offset="+offset+"&letter="+letter+"&numOfCities="+numOfCities+ "&locale=" + locale;
	document.browseActionForm.letter.value=letter;
	document.browseActionForm.offset.value=offset;
	showLocatorDialog("370", "330");
	loadRemotePage("locatorDialog-contents", document.browseActionForm.action);
}

function showNextCity(letter, offset, countryCode, locale){

	countryCode=document.browseActionForm.countryCode.value;
	numOfCities=document.browseActionForm.numOfCities.value;
	offset=parseInt(offset) + locatorCitiesPerPage;
	document.browseActionForm.action = locatorMainLocation + "BrowseCities.do?locationType=" + locatorLocationType + "&countryCode="+countryCode+"&offset="+offset+"&letter="+letter+"&numOfCities="+numOfCities+"&locale="+locale;
	document.browseActionForm.letter.value=letter;
	document.browseActionForm.offset.value=offset;
	
	showLocatorDialog("370", "330");
	loadRemotePage("locatorDialog-contents", document.browseActionForm.action);
}

function showPreviousCity(letter, offset, countryCode, locale){
	countryCode=document.browseActionForm.countryCode.value;
	numOfCities=document.browseActionForm.numOfCities.value;
	offset=parseInt(offset) - locatorCitiesPerPage;
	
	document.browseActionForm.action= locatorMainLocation + "BrowseCities.do?locationType=" + locatorLocationType + "&countryCode="+countryCode+"&offset="+offset+"&letter="+letter+"&numOfCities="+numOfCities+"&locale="+locale;
	document.browseActionForm.letter.value=letter;
	document.browseActionForm.offset.value=offset;
	
	showLocatorDialog("370", "330");
	loadRemotePage("locatorDialog-contents", document.browseActionForm.action);
}

// Currently not handling locationType or countryCode,
// but added as parameters for future configurability
function formatPhoneNumber(phoneNumber, locationType, countryCode) {
  	var phoneOut;
   	if (phoneNumber.length == 11) {
	   	phoneOut = phoneNumber.substring(0, 1);
	   	phoneOut += " (" + phoneNumber.substring(1, 4) + ") ";
	   	phoneOut += phoneNumber.substring(4, 7) + "-";
	   	phoneOut += phoneNumber.substring(7, 11);
   	} else if (phoneNumber.length == 10) {
	   	phoneOut = "(" + phoneNumber.substring(0, 3) + ") ";
	   	phoneOut += phoneNumber.substring(3, 6) + "-";
	   	phoneOut += phoneNumber.substring(6, 10);
	} else if (phoneNumber.length == 7) {
	   	phoneOut = phoneNumber.substring(0, 3) + "-";
	   	phoneOut += phoneNumber.substring(3, 7);
	} else {
		phoneOut = phoneNumber;
	}
	
	return phoneOut; 
}

function printDetails() {
	// Wait a while, so hopefully the page finishes rendering
    setTimeout("window.print()", 2500);
}

// Start the locator
function extendOnload() {
	initLocator();
	if(locatorLocationType!= "atm"){
		if(typeof(_hbLink) != "undefined") {
			_hbLink("Merchant Search", wsstag_searchString);
		}
	} else{
//		if(searchATMType == "Airport"){
//			addHBXTagging("Airport Search", wsstag_searchString);
//		} else if(searchATMType == "Attraction"){
//			addHBXTagging("Attraction Search", wsstag_searchString);
//		} else{ 
//			addHBXTagging("Address Search", wsstag_searchString);
//		}
	}

    if(window.extraOnload) { 
        window.extraOnload(); 
    }
}

if(window.addEventListener) {
    window.addEventListener( 'load', extendOnload, false );
} else if(document.addEventListener) {
    document.addEventListener('load' , extendOnload, false );
} else if(window.attachEvent) {
    window.attachEvent( 'onload', extendOnload );
} else {
    if(window.onload) {
        window.extraOnload = window.onload;
    }
    window.onload = extendOnload;
}


// The code below loads all script dependencies.
document.writeln("<div id='controllerWrapper'></div>");

function initLocator() {
	if (!document.getElementById("controller")) {
		var controller = '<iframe id="controller" name="controller" height="0" width="0" style="display: none" src="' + locatorMainLocation + 'Home.do?locationType=' + locatorLocationType + '&locale=' + locatorLocale + '"></iframe>';
		document.getElementById("controllerWrapper").innerHTML = controller;
	} else {
		document.getElementById("controller").src = locatorMainLocation + 'Home.do?locationType=' + locatorLocationType + '&locale=' + locatorLocale;
	}
}

var currentLocation = window.location.href;

if (currentLocation.indexOf("http://www.dev.mastercard.com/us/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRQCrFbMvaR67VgvfGBLDBCSHM5-jhTO3Ga073xTU0vax8y-tx_Nnor-Qw&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.stage.mastercard.com/us/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRSSroD-tIGxSXsw8LSR0fVKnZnr8hRyGG5W0srXe5hzF2_ILIS7PYWTNQ&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.mastercard.com/us/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRRvQotbhQhqfvSaOxWjkxRnXc82IBTU52k6qTgKLD8hMKS5hWR8JXqyOw&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.mastercard.com/interactivelocator/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRShuCHMlCZlYO6Owtw8CJIHRo7fdxRVcFP9zCxDvv9iOvAHAVDyD9JrTg&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.dev.mastercard.com/interactivelocator/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRSSNf0FjV7hRwrX-affABvdGE303hSqyIZTr6UFdyGGOyxI91xDAXvSgw&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.stage.mastercard.com/interactivelocator/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRQlwhcn9f2Jd9XP_Yd_0jl_H5XTYBRrWun-TYp5hHuFbFnLmD7Jho8r-w&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.dev.mastercard.com/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRQY2CqD-3FHzDvgfPzLP9V4tILohBQrhvttCTYbradYF8va-BHT_hBbpg&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.stage.mastercard.com/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRRc_l6Io-8dX8nwBxiF4nZ75tsxwBSqEUsgMiFx1PMxuOv0hmp1v4Kobg&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else if (currentLocation.indexOf("http://www.mastercard.com/") != -1) {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAjCncxDvyGgHmoW88FmsovRR1NBo-YE9QWIepz4jv360ARKeLeRSVVtyPEvEXDWxFMI9lEfLWbBhodA&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
} else {
	document.writeln('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAkD7tOAJz8rC-jvPwkFOP0hR0DqsoCaNd9yt_AXrjYzlbaGmN8BRkpALwIWhvdMKUByZloig4dXpqqw&hl=' + locatorLocale + '" type="text/javascript"><\/script>');
}

document.writeln('<script src="' + locatorClientLocation + 'googlemaps/scripts/google-wrapper.js" type="text/javascript"><\/script>');
document.writeln('<script src="' + locatorClientLocation + 'googlemaps/scripts/gscale.js" type="text/javascript"><\/script>');

function showSumitButton(){
	document.getElementById("find").style.display = "block";
}	

function addHBXTagging(lid, lpos) {
	if(locatorLocationType == "atm"){
		if(wsstag_enabled && typeof(_hbLink) != "undefined"){
			_hbLink(lid,lpos);
		}
	}
}

function setFilter(filter){
	document.getElementById('filter').value=filter.value; 
	document.getElementById("listFilter2").value=filter.value;
	document.getElementById("listFilter").value=filter.value;
	document.getElementById("mutipleMatch").value="true";
	document.getElementById('locatorForm').submit();

	if(locatorLocationType=="atm"){
		addHBXTagging(filter.value,"Results");
	}
}
function resetFilter(){
	if(currentPage=="results"){
		document.getElementById("listFilter2").value='';
		document.getElementById("listFilter").value='';
		document.getElementById('filter').value='';
	}
}
function submitResultForm(){
	document.getElementById("listFilter2").value='';
	document.getElementById("listFilter").value='';
	document.getElementById('filter').value='';
	document.getElementById('offset').value='0'; 
	locatorFormState.saveFromForm(document.getElementById('locatorForm'));
	setHBX();
}
function isIE7(){
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=b_version.indexOf("MSIE 7.0");
	if (version>0){
		return true;
	}
	return false;
}

function resetCategories(){
	var locatorForm = document.getElementById("locatorForm");	
	for (var i=0; i < locatorForm.elements.length; i++) {
		  var element = locatorForm.elements[i];
		  if (element.name.indexOf("filter.in.MERCH_CAT") == 0) {
			  element.checked = false;
			  locatorFormState.categories[element.name]=false;
		  }
		 if (element.name.indexOf("filter.in.lserv_LOC_TYPE_ID") == 0) {
			 element.checked = false;
			 locatorFormState.categories[element.name]=false;
		  }
		 if (element.name.indexOf("filter.in.AVAIL") == 0) {
			 element.checked = false;
			 locatorFormState.categories[element.name]=false;
		  }
		 if (element.name.indexOf("filter.in.HANDICAP_ACCESSABLE") == 0) {
			 element.checked = false;
			 locatorFormState.categories[element.name]=false;
		  }
		 if (element.name.indexOf("filter.in.SRCHRG_FREE_ALNC") == 0) {
			 element.checked = false;
			 locatorFormState.categories[element.name]=false;
		  }
		 if (element.name.indexOf("filter.in.SHR_DEPST") == 0) {
			 element.checked = false;
			 locatorFormState.categories[element.name]=false;
		  }
	}
}

function changeCountry(countryObject){
	if(locatorLocationType == "atm"){
		var locatorForm = document.getElementById("locatorForm");
		locatorFormState.reset();
		locatorCountry=countryObject.value;
		locatorForm.action="/interactivelocator/Home.do?locationType=" +locatorLocationType + "&locale=" + locatorLocale;
		locatorForm.submit();
	} else{
		showFlag(countryObject.value);
		resetCategories(); 
		locatorFormState.address.reset();
		showAddressFieldsForCountry('addressFields', countryObject.value);
	}
}

function isMozilla(){
	var browser=navigator.appName;
	if(browser=="Netscape"){
		return true;
	}
	return false;
}
function setHBX(){
	if(locatorLocationType == "atm"){
		if(searchATMType == "Airport"){
			addHBXTagging("Airport Search", wsstag_searchString);
		} else if(searchATMType == "Attraction"){
			addHBXTagging("Attraction Search", wsstag_searchString);
		} else{ 
			addHBXTagging("Address Search", wsstag_searchString);
		}
	}	
}