// JavaScript Document
loaded = true;  //indicates library is loaded, set to false at top of each page
//navformstart() called from document

//<script language="JavaScript">
//if (loaded) {
//  document.write(navformstart());
//  document.write(weatherNav());
//  document.write(navformend());
//}
//< /script>

function weatherNav() {
  return (
	opt('USAK0012', 'Alaska') +
	opt('BFXX0005', 'Bahamas') +
	opt('EIXX0014', 'Ireland') +
    opt('JMXX0006', 'Jamaica') +
	opt('UKXX0085', 'London') +
	opt('SPXX0050', 'Madrid') +
	opt('BRXX0201', 'Rio de Janiero') +
	opt('ITXX0067', 'Rome') +
	opt('USVI0004', 'St. Croix')
	);
}

function navformstart() {
  return ('<form method="GET" target="_blank"><p>What is the weather in... <select size="1" name="selNav" class="selnav" onchange="popUpWindow(this.form.selNav.options[this.form.selNav.selectedIndex].value)">');
}

function opt(val, name, sel) {
  var seltext = '';
  if (sel == 0) {
    seltext = '';
  }
  else {
    if ( ((val.length > 0) && (self.location.pathname.indexOf(val) != -1)) || (sel == 1) ) {
      seltext = ' selected';
    }
  }
  return ('<option value="http://www.weather.com/outlook/travel/local/' + val + '"' + seltext + '>' + name + '</option>');
}

function navformend() {
  return ('</select> <input type="button" value="Display" name="B1" onclick="popUpWindow(this.form.selNav.options[this.form.selNav.selectedIndex].value)"></p></form>');
}

var popUpWin=0;
function popUpWindow(URLStr) //, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin');
//'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var weatherWin=0;
function weatherWindow(dest) {
	if(weatherWin) {
		if (!weatherWin.closed) weatherWin.close();
	}
	weatherWin = open('http://www.weather.com/outlook/travel/local/'+dest, 'weatherWin');
}