var numStations=36;			//The number of stations, necessary for the array
var numElements=7;			//The number of elements for each station, 0 will be folder name/station name, 1 will be station ID, 2 will be station call sign,  3 will be station type, 4 will be start year,  5 will be lat/long string, 6 will be elevation and accuracy
var data=new Array(numStations);
for (i=0; i< data.length; i++)
	data[i]= new Array(numElements);


var curImg=new Image();
var ID;					//Global variable for the ID of the current station
var direction=0;			//Global variable for the compass point chosen, 0=north, 1=northeast, 2=east, 3=southeast, 4=south, 5=southwest, 6=west, 7=northwest
var toOrAway=1;				// 1 if towards, 0 if outwards.
var num2heading=new Array(8);		//num2heading[0]="NORTH", num2heading[1]="NORTHEAST" etc.

populate();				//Populates the data array with station information

num2heading[0]="NORTH";
num2heading[1]="NORTHEAST";
num2heading[2]="EAST";
num2heading[3]="SOUTHEAST";
num2heading[4]="SOUTH";
num2heading[5]="SOUTHWEST";
num2heading[6]="WEST";
num2heading[7]="NORTHWEST";

function jump(menu)
{
ref=menu.choice.options[menu.choice.selectedIndex].value;
change(ref);
}
function change(ref)
{
ID=ref;
document.getElementById('title').innerHTML = data[ref][0];

document.getElementById('name').innerHTML = 'Station Name: '+data[ref][0];
document.getElementById('ID').innerHTML = 'Station ID: '+data[ref][1];
document.getElementById('sign').innerHTML = 'Call Sign: '+data[ref][2];
document.getElementById('type').innerHTML = 'Type: '+data[ref][3];
document.getElementById('start').innerHTML = 'Start Year: '+data[ref][4];
document.getElementById('lat').innerHTML = 'Lat/Long: '+data[ref][5];
document.getElementById('elev').innerHTML = 'Elevation (m): '+data[ref][6];

document.getElementById('allimages').href='allimages.php?stn='+data[ref][0];

changeImage(0);
}
function updateCompass()
{	
	document.getElementById('compass').src="compass/compass_"+num2heading[direction]+".jpg";
}
function updateRadioButtons()
{
	if (toOrAway==1)
		document.getElementById('toward').checked=true;
	else if (toOrAway==0)
		document.getElementById('away').checked=true;
}
function changeImage(dir)
{
direction=dir;
document.getElementById('pic').src="loading.gif";
curImg.src="image.php?stn="+data[ID][0]+"&dir="+direction+"&toward="+toOrAway;
curImg.onload=function(){imgOnLoad()};
updateCompass();
updateRadioButtons();
}
function imgOnLoad()
{
	document.getElementById('pic').src=curImg.src;
}
function changeToOrAway(towards)
{
toOrAway=towards;
document.getElementById('pic').src="loading.gif";
curImg.src="image.php?stn="+data[ID][0]+"&dir="+direction+"&toward="+toOrAway;
curImg.onload=function(){imgOnLoad()};
updateCompass();
}
function viewsatimg()
{
document.getElementById('pic').src="loading.gif";
curImg.src="satimg.php?stn="+data[ID][0];
curImg.onload=function(){imgOnLoad()};

document.getElementById('compass').src="compass/compass.jpg";
document.getElementById('toward').checked=false;
document.getElementById('away').checked=false;
}
