dias em " + monthList[index].name + "."); return false; } // First see if the year entered is a leap year. If so we have to make sure // the days entered is <= 29. If not a leap year we make sure that the days // entered is <= 28. else if (index == 1) { // month selected is February the screwball month if (isLeapYear(f["year"].value)) { // year entered is a leap year if (f["day"].value > (monthList[index].numdays + 1)) { alert("Ha apenas " + (monthList[index].numdays + 1) + " dias em " + monthList[index].name + "."); return false; } else return true; } else { // year entered is not a leap year if (f["day"].value > monthList[index].numdays) { alert("Ha apenas " + monthList[index].numdays + " dias em " + monthList[index].name + "."); return false; } else return true; } } else return true; }//*********************************************************************///convLatLong converts any type of lat/long input//into the table form and then handles bad input//it is nested in the calcSun function. function convLatLong(f) { if(f["latDeg"].value == "") { f["latDeg"].value = 0; } if(f["latMin"].value == "") { f["latMin"].value = 0; } if(f["latSec"].value == "") { f["latSec"].value = 0; } if(f["lonDeg"].value == "") { f["lonDeg"].value = 0; } if(f["lonMin"].value == "") { f["lonMin"].value = 0; } if(f["lonSec"].value == "") { f["lonSec"].value = 0; } var neg = 0; if(f["latDeg"].value.charAt(0) == '-') { neg = 1; } if(neg != 1) { var latSeconds = (parseFloat(f["latDeg"].value))*3600 + parseFloat(f["latMin"].value)*60 + parseFloat(f["latSec"].value)*1; f["latDeg"].value = Math.floor(latSeconds/3600); f["latMin"].value = Math.floor((latSeconds - (parseFloat(f["latDeg"].value)*3600))/60); f["latSec"].value = Math.floor((latSeconds - (parseFloat(f["latDeg"].value)*3600) - (parseFloat(f["latMin"].value)*60)) + 0.5); } else if(parseFloat(f["latDeg"].value) > -1) { var latSeconds = parseFloat(f["latDeg"].value)*3600 - parseFloat(f["latMin"].value)*60 - parseFloat(f["latSec"].value)*1; f["latDeg"].value = "-0"; f["latMin"].value = Math.floor((-latSeconds)/60); f["latSec"].value = Math.floor( (-latSeconds - (parseFloat(f["latMin"].value)*60)) + 0.5); } else { var latSeconds = parseFloat(f["latDeg"].value)*3600 - parseFloat(f["latMin"].value)*60 - parseFloat(f["latSec"].value)*1; f["latDeg"].value = Math.ceil(latSeconds/3600); f["latMin"].value = Math.floor((-latSeconds + (parseFloat(f["latDeg"].value)*3600))/60); f["latSec"].value = Math.floor((-latSeconds + (parseFloat(f["latDeg"].value)*3600) - (parseFloat(f["latMin"].value)*60)) + 0.5); } neg = 0; if(f["lonDeg"].value.charAt(0) == '-') { neg = 1; } if(neg != 1) { var lonSeconds = parseFloat(f["lonDeg"].value)*3600 + parseFloat(f["lonMin"].value)*60 + parseFloat(f["lonSec"].value)*1; f["lonDeg"].value = Math.floor(lonSeconds/3600); f["lonMin"].value = Math.floor((lonSeconds - (parseFloat(f["lonDeg"].value)*3600))/60); f["lonSec"].value = Math.floor((lonSeconds - (parseFloat(f["lonDeg"].value)*3600) - (parseFloat(f["lonMin"].value))*60) + 0.5); } else if(parseFloat(f["lonDeg"].value) > -1) { var lonSeconds = parseFloat(f["lonDeg"].value)*3600 - parseFloat(f["lonMin"].value)*60 - parseFloat(f["lonSec"].value)*1; f["lonDeg"].value = "-0"; f["lonMin"].value = Math.floor((-lonSeconds)/60); f["lonSec"].value = Math.floor((-lonSeconds - (parseFloat(f["lonMin"].value)*60)) + 0.5); } else { var lonSeconds = parseFloat(f["lonDeg"].value)*3600 - parseFloat(f["lonMin"].value)*60 - parseFloat(f["lonSec"].value)*1; f["lonDeg"].value = Math.ceil(lonSeconds/3600); f["lonMin"].value = Math.floor((-lonSeconds + (parseFloat(f["lonDeg"].value)*3600))/60); f["lonSec"].value = Math.floor((-lonSeconds + (parseFloat(f["lonDeg"].value)*3600) - (parseFloat(f["lonMin"].value)*60)) + 0.5); } //Test for invalid lat/long input if(latSeconds > 324000) { alert("Voce introduziu uma latitude invalida.\n Assumimos 89.8."); f["latDeg"].value = 89.8; f["latMin"].value = 0; f["latSec"].value = 0; } if(latSeconds < -324000) { alert("Voce introduziu uma latitude invalida.\n Assumimos -89.8."); f["latDeg"].value = -89.8; f["latMin"].value = 0; f["latSec"].value = 0; } if(lonSeconds > 648000) { alert("Voce introduziu uma longitude invalida.\n Assumimos 180."); f["lonDeg"].value = 180; f["lonMin"].value = 0; f["lonSec"].value = 0; } if(lonSeconds < -648000) { alert("Voce introduziu uma longitude invalida.\n Assumimos -180."); f["lonDeg"].value = -180; f["lonMin"].value = 0; f["lonSec"].value =0; } }//***********************************************************************///***********************************************************************///* *///*This section contains subroutines used in calculating solar position *///* *///***********************************************************************///***********************************************************************/// Convert