function changeTime(tzId,tzTime){
  document.getElementById("tzTime"+ tzId).innerHTML = tzTime;
}


function changeCurrency(currConv){
  Page.convImg.collapse();
  document.getElementById("currValue").innerHTML = "$" + currConv;
  Page.currValueBox.showBlock();
}


function changeWeatherCities(Ids,Names,pid){
  document.getElementById("cityListHeader").innerHTML = "Search Results";
  Page.frag = document.createDocumentFragment();
  for(i=0; i<Ids.length; i++){
    li = Page.frag.appendChild(document.createElement("li"));
    a = li.appendChild(document.createElement("a"));
    if(pid){
	  a.setAttribute("href","traveltools.php?pid=" + pid + "&tool=weather&location=" + Ids[i]);
	}else{
	  a.setAttribute("href","weather.php?location=" + Ids[i]);
	}
	a.appendChild(document.createTextNode(Names[i]));
  }
  oldList = new Dynamic("cityList");
  oldList.empty();
  oldList.el.appendChild(Page.frag);
}


function changeTravelNews(Ids,Names,Dates){
  document.getElementById("newsListHeader").innerHTML = "Search Results";
  Page.frag = document.createDocumentFragment();
  for(i=0; i<Ids.length; i++){
    li = Page.frag.appendChild(document.createElement("li"));
    a = li.appendChild(document.createElement("a"));
    a.setAttribute("href","news.php?article=" + Ids[i]);
    a.appendChild(document.createTextNode(Names[i]));
	div = li.appendChild(document.createElement("div"));
	div.appendChild(document.createTextNode(Dates[i]));
  }
  oldList = new Dynamic("newsList");
  oldList.empty();
  oldList.el.appendChild(Page.frag);
}


function changeAlmanacCities(States,Cities){
  document.getElementById("cityListHeader").innerHTML = "Please select a city.";
  Page.frag = document.createDocumentFragment();
  for(i=0; i<Cities.length; i++){
    li = Page.frag.appendChild(document.createElement("li"));
    a = li.appendChild(document.createElement("a"));
    a.setAttribute("href","almanac.php?state=" + States[i] + "&city=" + Cities[i]);
    a.appendChild(document.createTextNode(Cities[i] + ", " + States[i]));
  }
  oldList = new Dynamic("cityList");
  oldList.empty();
  oldList.el.appendChild(Page.frag);
}


function changeCallingCodeCountries(Countries,Codes){
  Page.frag = document.createDocumentFragment();
  tb = Page.frag.appendChild(document.createElement("tbody"));
  tr = tb.appendChild(document.createElement("tr"));
  th = tr.appendChild(document.createElement("th"));
  th.appendChild(document.createTextNode("Country"));
  th = tr.appendChild(document.createElement("th"));
  th.appendChild(document.createTextNode("Calling Code"));
  for(i=0; i<Countries.length; i++){
    tr = tb.appendChild(document.createElement("tr"));
    td = tr.appendChild(document.createElement("td"));
    td.appendChild(document.createTextNode(Countries[i]));
    td = tr.appendChild(document.createElement("td"));
    td.appendChild(document.createTextNode(Codes[i]));
  }
  oldList = new Dynamic("callingCodesTable");
  oldList.empty();
  oldList.el.appendChild(Page.frag);
}


function changeElectricityCountries(Countries,Voltage,Frequency){
  Page.frag = document.createDocumentFragment();
  tb = Page.frag.appendChild(document.createElement("tbody"));
  tr = tb.appendChild(document.createElement("tr"));
  th = tr.appendChild(document.createElement("th"));
  th.appendChild(document.createTextNode("Country"));
  th = tr.appendChild(document.createElement("th"));
  th.appendChild(document.createTextNode("Voltage (V)"));
  th = tr.appendChild(document.createElement("th"));
  th.appendChild(document.createTextNode("Frequency (Hz)"));
  for(i=0; i<Countries.length; i++){
    tr = tb.appendChild(document.createElement("tr"));
    td = tr.appendChild(document.createElement("td"));
    td.appendChild(document.createTextNode(Countries[i]));
    td = tr.appendChild(document.createElement("td"));
    td.appendChild(document.createTextNode(Voltage[i]));
    td = tr.appendChild(document.createElement("td"));
    td.appendChild(document.createTextNode(Frequency[i]));
  }
  oldList = new Dynamic("electricityTable");
  oldList.empty();
  oldList.el.appendChild(Page.frag);
}


function changeWaittimeAirports(Ids,Names,Cities,States,pid){
  Page.viewAllStates.collapse();
  Page.allStates.collapse();
  document.getElementById("airportListHeader").innerHTML = "Please select an airport.";
  Page.frag = document.createDocumentFragment();
  for(i=0; i<Ids.length; i++){
    li = Page.frag.appendChild(document.createElement("li"));
    a = li.appendChild(document.createElement("a"));
    if(pid){
	  a.setAttribute("href","traveltools.php?pid=" + pid + "&tool=tsa&state=" + States[i] + "&airport=" + Ids[i]);
	}else{
	  a.setAttribute("href","waittimes.php?state=" + States[i] + "&airport=" + Ids[i]);
	}
	a.appendChild(document.createTextNode(Names[i]));
    div = li.appendChild(document.createElement("div"));
    div.appendChild(document.createTextNode(Cities[i] + ", " + States[i]));
  }
  oldList = new Dynamic("airportList");
  oldList.empty();
  oldList.el.appendChild(Page.frag);
}


function valFlightTrackerForm(form) {
  flightVendor = new FormField(form.flightVendor);
  flightNumber = new FormField(form.flightNumber);
  if(!flightVendor.valAlphaNum("Please select an airline.")) return false;
  if(!flightNumber.valNum("Please enter a flight number.")) return false;
  flightVendor = null;
  flightNumber = null;
  return true;
}


function valWaittimesForm(form) {
  day = new FormField(form.day);
  time = new FormField(form.time);
  if(!day.valAlpha("Please select a day.")) return false;
  if(!time.valNum("Please select a time.")) return false;
  day = null;
  time = null;
  return true;
}


function partnerValidate(form) {
	WebUrl = new FormField(form.webUrl);
	WebName = new FormField(form.webName);
	Email = new FormField(form.email);
	VerifyEmail = new FormField(form.verifyEmail);
	Password = new FormField(form.password);
	VerifyPassword = new FormField(form.verifyPassword);
	TermsAgree = new FormField(form.agree);
	
	if(!WebUrl.valAlphaNumExtra("Please enter a valid website URL address")) return false;
	if(!WebUrl.valMaxLength(75,"The website URL address you entered is longer than the 75 letters allowed")) return false;
	if(!WebName.valAlphaNumExtra("Please enter a valid website name")) return false;
	if(!WebName.valMaxLength(125,"The website name you entered is longer than the 125 letters allowed")) return false;
	if(!Email.valEmail("Please enter a valid email address")) return false;
	if(!VerifyEmail.valEqualTo(Email.fieldValue,"Please make sure the email and verify email fields match")) return false;
	if(!Email.valMaxLength(75,"The email address you entered is longer than the 75 characters allowed")) return false;
	if(!Password.valAlphaNum("Please enter a password with the characters a-z, A-Z, and 0-9")) return false;
	if(!Password.valMinLength(6,"Please enter a password that is at least 6 characters long")) return false;
	if(!Password.valMaxLength(25,"Please enter a password that is at most 25 characters long")) return false;
	if(!VerifyPassword.valEqualTo(Password.fieldValue,"Please make sure the password and verify password fields match")) return false;
	if(!TermsAgree.valChecked("You must agree to our terms of service in order to register")) return false;
	
	WebUrl = null;
	WebName = null;
	Email = null;
	VerifyEmail = null;
	Password = null;
	VerifyPassword = null;
	TermsAgree = null;
	return true;
}


function valPartnerChangePassword() {
	Newpass = new FormField(document.getElementById("newpass"));
	Verifypass = new FormField(document.getElementById("newpassb"));
	if(!Newpass.valAlphaNum("Please enter a new password with the characters a-z, A-Z, and 0-9.")) return false;
	if(!Newpass.valMinLength(6,"The new password requires 6 characters.")) return false;
	if(!Verifypass.valAlphaNum("Please verify the password with the characters a-z, A-Z, and 0-9.")) return false;
	if(!Verifypass.valMinLength(6,"The verified password requires 6 characters.")) return false;
	if(!Verifypass.valEqualTo(Newpass.fieldValue,"Please make sure the password and verified password matches.")) return false;
	Newpass = null;
	Verifypass = null;
	return true;
}