function sfCityState()
{
if(ConfirmGoLock())
{
sfLock();
document.getElementById('byCityState').submit();
}
}
function sfZipCode()
{
if(ConfirmGoLock())
{
sfLock();
document.getElementById('byZipCode').submit();
}
}
function sfAddress(selectedAddressIndex, formattedSearchAddress)
{
if(ConfirmGoLock())
{
sfLock();
document.getElementById('addressesForm').selectedAddressIndex.value = selectedAddressIndex;
document.getElementById('addressesForm').formattedSearchAddress.value = formattedSearchAddress;
document.getElementById('addressesForm').submit();
}
}
function sfBranch(selectedBranchIndex)
{
if(ConfirmGoLock())
{
sfLock();
document.getElementById('blGetDirectionsForm').selectedBranchIndex.value = selectedBranchIndex;
document.getElementById('blGetDirectionsForm').submit();
}
}
function submitForm(formName)
{
if(ConfirmGoLock())
{
document.getElementById(formName).submit();
}
}
function ConfirmGoLock()
{
var subappBusy = isSubappBusy();
if (subappBusy)
{
if (lockType == LOCK)
{
alert (displayPhrase);
return false;
}
}
return true;
}
function getlocations(nextPrevious)
{
if(ConfirmGoLock())
{
sfLock();
document.getElementById('blGetLocationsForm').nextPrevious.value = nextPrevious;
document.getElementById('blGetLocationsForm').submit();
}
}
function selectedZoom(zoomLevel)
{
if(ConfirmGoLock())
{
var zoomLevelDiff = document.getElementById('blNavigationForm').zoomLevel.value  - zoomLevel;
document.getElementById('blNavigationForm').zoomLevel.value = zoomLevel;
document.getElementById('blNavigationForm').zoomValue.value = zoomLevelDiff;
document.getElementById('blNavigationForm').navigationDirection.value = "";
document.getElementById('blNavigationForm').submit();
}
}
function change_image(img_name, img_src)
{
document[img_name].src = img_src;
}
function openOverlayBranch(event)
{
var xcord = (event ? ((typeof(event.pageX) != 'undefined') ? event.pageX : (event.clientX)) : 0);
var ycord = (event ? ((typeof(event.pageY) != 'undefined') ? event.pageY : (event.clientY)) : 0);
document.getElementById('overlayBranch').style.top = ycord + 10;
document.getElementById('overlayBranch').style.left = xcord-100;
document.getElementById('overlayBranch').style.display = 'block';
document.getElementById('overlayBLForm').zipCode.value="";
if(document.getElementById('overlayBLForm').city != undefined)
{
document.getElementById('overlayBLForm').city.value="";
}
if(document.getElementById('overlayBLForm').state != undefined)
{
document.getElementById('overlayBLForm').state.value="";
}
}
function openOverlayBranch1(event)
{
var xcord = (event ? ((typeof(event.pageX) != 'undefined') ? event.pageX : (event.clientX)) : 0);
var ycord = (event ? ((typeof(event.pageY) != 'undefined') ? event.pageY : (event.clientY)) : 0);
document.getElementById('overlayBranch1').style.top = ycord + 10;
document.getElementById('overlayBranch1').style.left = xcord-100;
document.getElementById('overlayBranch1').style.display = 'block';
document.getElementById('overlayBLForm1').zipCode.value="";
if(document.getElementById('overlayBLForm1').city != undefined)
{
document.getElementById('overlayBLForm1').city.value="";
}
if(document.getElementById('overlayBLForm1').state != undefined)
{
document.getElementById('overlayBLForm1').state.value="";
}
}
function closeOverlayBranch()
{
document.getElementById('overlayBranch').style.display = 'none';
}
function closeOverlayBranch1()
{
document.getElementById('overlayBranch1').style.display = 'none';
}
function populateLatLng(latitude, longitude)
{
branches.push(new google.maps.LatLng(latitude, longitude));
}
function branchesMap(startIndex, branchLabelColor)
{
var markers = [];
var marker;
var noOfBranches = branches.length;
var bounds = new google.maps.LatLngBounds();
var mapOptions = {	panControl: true,
zoomControl: true,
zoom:12,
center: branches[0],
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("branches_map"),
mapOptions);
var branchNumber = startIndex;
for (var i = 0; i < noOfBranches; i++)
{
branchNumber = branchNumber + 1;
var image = new google.maps.MarkerImage(window.location.protocol+'//chart.googleapis.com/chart?chst=d_map_pin_letter&chld='+branchNumber+'|'+branchLabelColor+'|FFFFFF');
marker = new google.maps.Marker({
position: branches[i],
draggable: false,
icon:image
});
bounds.extend(branches[i]);
map.fitBounds(bounds);
marker.setMap(map);
markers.push(marker);
}
}
function showDirections(startLatitude, startLongitude, branchLatitude, branchLongitude, unitOfDistance)
{
var directionsDisplay = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService();
var originLatLng = new google.maps.LatLng(startLatitude, startLongitude);
var destinationLatLng = new google.maps.LatLng(branchLatitude, branchLongitude);
var mapOptions = {	panControl: true,
zoomControl: true,
zoom:12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: originLatLng
}
var map = new google.maps.Map(document.getElementById("directions_map"),
mapOptions);
var directionsPanel = document.getElementById("driving_directions");
directionsPanel.innerHtml = "";
directionsDisplay.setPanel(directionsPanel);
directionsDisplay.setMap(map);
var distanceUnit = google.maps.UnitSystem.IMPERIAL;
if (unitOfDistance == 'kilometer')
{
distanceUnit = google.maps.UnitSystem.METRIC;
}
var request = {
origin: originLatLng,
destination: destinationLatLng,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: distanceUnit
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}

