// Do the ajax call to get pay stations from the CFC
function getCityPayStations(cityID,dropBox, mode) {
	//initiate the proxy with a local var
	var r = new sbAjax();
	//define the response function
	r.setCallbackHandler(displayCityPayStations);
	//define the error handler
	r.setErrorHandler(errorHandler);
	//call the getOrders function from the CFC
	r.getCityPayStations(cityID,dropBox, mode);
}

// Display data that came back from the Ajax call
function displayCityPayStations(payStations) {
	if (payStations.DATA.length > 0) {
		var htmlText = '<h3>Address</h3><br />';
		for(var i=0;i<payStations.DATA.length;i++) {
			var payStation = payStations.DATA[i][1];
			var locationTxt = payStations.DATA[i][2];
			var addressTxt = payStations.DATA[i][3];
			var otherTxt = payStations.DATA[i][9];			
			var directionsTxt = payStations.DATA[i][10];
			var phoneTxt = payStations.DATA[i][4];
			var daysTxt = payStations.DATA[i][5];
			var timesTxt = payStations.DATA[i][6];			
			
		htmlText += '<p class="bold">'+payStation+'<br />';
		if (locationTxt != '') 
			htmlText += '<span class="bold">'+locationTxt+'</span><br />';				
		if (addressTxt != '')				
			htmlText += addressTxt+'<br />';
		if (phoneTxt != '')
			htmlText += phoneTxt+'<br />';
		
		if (daysTxt != '' || timesTxt != '')
			{
			htmlText += '<span class="bold green">Operation Hours</span><br />';
			if (daysTxt != '')
				htmlText += '<span class="standard">'+daysTxt+'</span><br />';	
			if (timesTxt != '')
				htmlText += '<span class="standard">'+timesTxt+'</span><br />';					
			}
		if (otherTxt != '')
			htmlText += '<span class="standard">'+otherTxt+'</span><br />';							
		
		if (directionsTxt != '')
			{
			htmlText += '<span class="bold green">Directions</span><br /><span class="standard">'+directionsTxt+'</span>';	
			}
		
		htmlText += '</p><br />';
		}
		document.getElementById('payStationsDiv').innerHTML = htmlText;
	}
}

// Do the ajax call to get pay stations from the CFC
function getAgencyInfo(cityID) {
	if (cityID != "") {
	//initiate the proxy with a local var
	var r = new sbAjax();
	//define the response function
	r.setCallbackHandler(displayAgencyInfo);
	//define the error handler
	r.setErrorHandler(errorHandler);
	//call the getOrders function from the CFC
	r.getAgencyInfo(cityID);
	} else {
		document.getElementById('agencyLocations').innerHTML = "";
	}
}

// Display data that came back from the Ajax call
function displayAgencyInfo(agencyInfo) {
	document.getElementById('agencyLocations').innerHTML = agencyInfo;
}

// Error handler for the ajax functions
function errorHandler(statusCode,statusMsg) {
	alert(statusCode+': '+statusMsg)
}