//Populate region array for dropdowns. When user selects a particular region, zoom to selected region
//Store n, region name, longitude and latitude of center point, and zoom factor to send to Google.

//Populate Ferry array for dropdowns. Need to store org name since different for each
//takes org name and facility name

var iCurrentID = "";
var iPreviousID = ""
var iArrayIndex = 0;
var resetID = true;

var regionArray = new Array();
regionArray[0] = new Array();
regionArray[1] = new Array();
regionArray[2] = new Array();
regionArray[3] = new Array();
regionArray[4] = new Array(); 

var ferryArray = new Array();
ferryArray[0] = new Array();
ferryArray[1] = new Array();
ferryArray[2] = new Array();

var tempLatArray = new Array();
var tempLonArray = new Array();
var latArray = new Array();
var lonArray = new Array();
 

function populateRegionArray (n, regionName, longitude, latitude, zoomFactor) {

	regionArray[0][n] = n;
	regionArray[1][n] = regionName;
	regionArray[2][n] = longitude;
	regionArray[3][n] = latitude;
	regionArray[4][n] = zoomFactor;

}

function populateFerryArray (n, facilityName, orgName) {
	
	regionArray[0][n] = n;
	regionArray[1][n] = facilityName;
	regionArray[2][n] = orgName;

}

function storeLatLongInArrays(i, linkID, lat, lon, linkSpeed) {
    var linkColor;
    
						
    iCurrentID = linkID;
    if (resetID) {
        //initialize
        initializeArray();
    }
    
    if (iPreviousID == iCurrentID) {
        tempLatArray.push(new GLatLng(lat, lon));
        //tempLonArray.push(lon);
        resetID = false;
    }
    else {
        //get linkSpeed and then define linkColor
        if (linkSpeed < 30) {
			linkColor = "#FF0000";
		}
		else if ((linkSpeed >= 30) && (linkSpeed < 50)) {
			linkColor = "#FFFF00";
		}
		else if (linkSpeed >= 50) {
			linkColor = "#00FF00";
		}	
		else {
			linkColor = "#DDDDDD";
		}
	
        latArray[iArrayIndex] = tempLatArray;
        //lonArray[iArrayIndex] = tempLonArray;
        //GLog.write("lonArray[" + iArrayIndex + "]: " + lonArray[iArrayIndex]);
        tempLatArray = new Array();
        //tempLonArray = new Array();
        tempLatArray.push(new GLatLng(lat, lon));
        //tempLonArray.push(lon);
        resetID = true;
        iArrayIndex++;
    }
}

function initializeArray() {
    iPreviousID = iCurrentID;
}