sobreescrever os dados que porventura tiverem sido registrados antes. //*********************************************************************/ function setLatLong(f, index) { // Decimal degrees are passed in the array. Temporarily store these // degs in lat and lon deg and have convLatLong modify them. f["latDeg"].value = City[index].lat; f["lonDeg"].value = City[index].lng; // These are needed to prevent iterative adding of min and sec when // set button is clicked. f["latMin"].value = 0; f["latSec"].value = 0; f["lonMin"].value = 0; f["lonSec"].value = 0; //call convLatLong to convert decimal degrees into table form. convLatLong(f); //Local time zone value set in table f["hrsToGMT"].value = City[index].zoneHr; }//*********************************************************************/// isLeapYear returns 1 if the 4-digit yr is a leap year, 0 if it is not function isLeapYear(yr) { return ((yr % 4 == 0 && yr % 100 != 0) || yr % 400 == 0); }//*********************************************************************/// isPosInteger returns false if the value is not a positive integer, true is// returned otherwise. The code is from taken from Danny Goodman's Javascript// Handbook, p. 372. function isPosInteger(inputVal) { inputStr = ("" + inputVal); for (var i = 0; i < inputStr.length; i++) { var oneChar = inputStr.charAt(i); if (oneChar < "0" || oneChar > "9") return false; } return true; }//*********************************************************************/ function isInteger(inputVal) { inputStr = "" + inputVal; if(inputStr == "NaN") return false; if(inputStr == "-NaN") return false; for (var i = 0; i < inputStr.length; i++) { var oneChar = inputStr.charAt(i); if (i == 0 && (oneChar == "-" || oneChar == "+")) { continue; } if (oneChar < "0" || oneChar > "9") { return false; } } return true; }//*********************************************************************/ function isNumber(inputVal) { var oneDecimal = false; var inputStr = "" + inputVal; for (var i = 0; i < inputStr.length; i++) { var oneChar = inputStr.charAt(i); if (i == 0 && (oneChar == "-" || oneChar == "+")) { continue; } if (oneChar == "." && !oneDecimal) { oneDecimal = true; continue; } if (oneChar < "0" || oneChar > "9") { return false; } } return true; }//*********************************************************************/// isValidInput makes sure valid input is entered before going ahead to // calculate the sunrise and sunset. False is returned if an invalid entry // was made, true is the entry is valid. function isValidInput(f, index, latLongForm) { if (f["day"].value == "") { // see if the day field is empty alert("Voce deve introduzir um dia."); return false; } else if (f["year"].value == "") { // see if the year field is empty alert("Voce deve introduzir um ano."); return false; } else if (!isPosInteger(f["day"].value) || f["day"].value == 0) { alert("O dia deve ser um numero inteiro, positivo."); return false; } else if (!isInteger(f["year"].value)) { alert("O ano deve ser um numero inteiro."); return false; } else if ( (f["year"].value < -1000) || (f["year"].value > 3000) ) { alert("A formula nao e valida para ano menor do que\n -1000 ou maior do que 3000."); return false; } // For the non-February months see if the day entered is greater than // the number of days in the selected month else if ((index != 1) && (f["day"].value > monthList[index].numdays)) { alert("Ha apenas " + monthList[index].numdays + "