var suncalc_updated var HA_for_calibrated_position,SetLocation,Lat,Lon,LatDir,LonDir var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction,SatNameCurrentIndex,SitePosCurrentIndex var output_angles= new Array() var month_string= new Array() var autoupdate,SatLon,autoprintupdate,htmleclipsecalc_updated,orbital_period,rsat rsat=42164.57; //km orbital_period=2*Math.PI*Math.sqrt(rsat*rsat*rsat/398600.5)/(60*60*24); // in days //alert(orbital_period); month_string[1]="January"; month_string[2]="February"; month_string[3]="March"; month_string[4]="April"; month_string[5]="May"; month_string[6]="June"; month_string[7]="July"; month_string[8]="August"; month_string[9]="September"; month_string[10]="October"; month_string[11]="November"; month_string[12]="December"; autoupdate=0; autoprintupdate=0; eclipsecalc_updated="Calculator script updated 09-10-2006
"; htmleclipsecalc_updated="Updated 09 October 2006
"; //window.setInterval CalculateAngles(),5000 //window.setInterval "update()",1000,JavaScript function date_and_time(){ date_and_time=Date(); //alert(Date()); } function ShowCredit() { var credittext credittext="First uploaded 27092006 " credittext=credittext+"\nProgrammed by Jens T. Satre" credittext=credittext+"\nScript for satellite eclipse calculation" credittext=credittext+"\n2709-2006: First version, Javascript" credittext=credittext+"\n2809-2006: Some small fixes in satellite distance and earth radius" credittext=credittext+"\n0910-2006: Correction to orbital period of satellite (set to 23h56m05s)" credittext=credittext+"\n1707-2017: Corrected error in eclipse time calculations" credittext=credittext+"\n1807-2017: Made the time calculations much faster" alert(credittext); } function SelectSatellite() { // position in east format. document.OrbitPosition.Degrees.value=formatvalue(document.Satellite.Position.value,5); document.OrbitPosition.West_angle.value=formatvalue((360-document.OrbitPosition.Degrees.value),5); document.OrbitPosition.Direction.value="East"; } function printresult(){ var d,Day,Month,Year,Hour,Minute,Seconds var SunAltitude,ElevationDifference var beta,T_orbit_period,r_earth,r_sat,t,R var satellite_time,start_eclipse,end_eclipse,total_eclipse,west_position,satlon_plus_180 r_earth=6378.14; //km //r_sat=42241; //km r_sat=42164.57; //km Day=1*document.TimeAndDate.Day.value; Month=1*document.TimeAndDate.Month.value; Year=1*document.TimeAndDate.Year.value; d=daynumber(Day,Month,Year,0,0,0); R=r_earth/r_sat; // satellite_time = 0 deg. = 00:00 ,90 deg.=06:00, 180 deg. = 12:00, 270 deg. = 18:00 satellite_time=Rev(document.OrbitPosition.West_angle.value)*(24/360)/24; // ok in days west_position=document.OrbitPosition.West_angle.value; d=Math.floor(d); // find time when sunlon equals SatLon+180 //satlon_plus_180=360-west_position; d=d+satellite_time; d=sun_angles(west_position,d); document.Angles.SunDeclination.value=Deg(sun_decl(d)); // i radianer beta=sun_decl(d); // calc at "satellite local midnight" t= Math.acos( Math.sqrt(1-R*R)/Math.cos(beta) ) * (orbital_period/Math.PI) ; // ok ,in days so far so good //alert(t); // two periodes from 1.September-15 Oktober and from 27. Februar -12 April start_eclipse=d-t/2; end_eclipse=d+t/2; total_eclipse=t; //alert(d_to_date_and_time(start_eclipse)); listing="" listing+="" listing+="" listing+="" listing+="Satellite Eclipse" listing+="" listing+="" //listing+="" listing+=""; listing+="

 

"; listing+="
Eclipse for Satellite Position "+document.OrbitPosition.Degrees.value+" East ("+west_position+" West) "+Day+" "+month_string[Month]+" "+Year+"
" listing+="
"; listing+="" //listing+="
Start time: "+d_to_date_and_time(start_eclipse)+"
" //listing+="
End time: "+d_to_date_and_time(end_eclipse)+"
" //listing+="
Total eclipse period: "+d_to_hms(total_eclipse)+"
" listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+="
" listing+="
" //listing+="
Satellite Position:"+document.Angles.SatelliteLongitude.value+"
" listing+="
" //listing+="
Sun/Satellite Azimuth:"+document.Angles.SunAzimuth.value+"
" //listing+="
Sun Elevation:"+document.Angles.SunElevation.value+"
" listing+="
" //listing+="
Satellite Elevation:"+document.Angles.SatelliteElevation.value+"
" listing+="
" //listing+="
|Satellite Elevation-Sun Elevation|:"+document.Angles.SunSatElDifference.value+"
" listing+="
Start timeEnd timeMiddle timeDuration
"+d_to_date_and_time(start_eclipse)+""+d_to_date_and_time(end_eclipse)+""+d_to_date_and_time(d)+""+d_to_hms(total_eclipse)+"
"; listing+="

"+Year+" Jens T. Satre

"; listing+="" PrintWindow=window.open("","Print_window") //PrintWindow =window.open("","Print_window","menubar=yes,status=yes,toolbar=yes,scrollbars=yes"); //height=800,width=1000 PrintWindow.oldWindow = top //PrintWindow.document.write(document.Output.Satpos.value) PrintWindow.document.write(listing) PrintWindow.document.close() } function printallpositionsforselecteddate(){ var d,Day,Month,Year,Hour,Minute,Seconds,west_position var SunAltitude,ElevationDifference var beta,T_orbit_period,r_earth,r_sat,t,R,NextDay var satellite_time,start_eclipse,end_eclipse,total_eclipse,satlon_plus_180 r_earth=6378.14; //km //r_sat=42241; //km r_sat=42164.57; //km Day=1*document.TimeAndDate.Day.value; Month=1*document.TimeAndDate.Month.value; Year=1*document.TimeAndDate.Year.value; d=daynumber(Day,Month,Year,0,0,0); R=r_earth/r_sat; NextDay=Day+1; // satellite_time = 0 deg. = 00:00 ,90 deg.=06:00, 180 deg. = 12:00, 270 deg. = 18:00 //alert(d_to_date_and_time(start_eclipse)); listing="" listing+="" listing+="" listing+="" listing+="Satellite Eclipse" listing+="" listing+="" listing+=""; listing+="

 

"; listing+="
Eclipse for "+Day+"&"+NextDay+" "+month_string[Month]+" "+Year+"
" listing+="
"; listing+="" listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; for (i = 0; i <= 359; i++) { west_position=360-i; satellite_time=Rev(360-i)*(24/360)/24; // ok in days d=Math.floor(d); d=d+satellite_time; d=sun_angles(west_position,d); // fails afteri=8 , all outage dates/positions increase by one day document.Angles.SunDeclination.value=Deg(sun_decl(d)); // i radianer beta=sun_decl(d); //alert(orbital_period); // in days t= Math.acos( Math.sqrt(1-R*R)/Math.cos(beta) ) * (orbital_period/Math.PI) ; // ok ,in days so far so good // two periodes from 1.September-15 Oktober and from 27. Februar -12 April start_eclipse=d-t/2; end_eclipse=d+t/2; total_eclipse=t; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; } listing+="
" listing+="
" listing+="
" listing+="
" listing+="
" listing+="
PositionStart timeEnd timeMiddle timeDuration
"+i+" East ("+west_position+" West)"+d_to_date_and_time(start_eclipse)+""+d_to_date_and_time(end_eclipse)+""+d_to_date_and_time(d)+""+d_to_hms(total_eclipse)+"
"; listing+="

"+Year+" Jens T. Satre

"; listing+="" PrintWindow=window.open("","Print_window") //PrintWindow =window.open("","Print_window","menubar=yes,status=yes,toolbar=yes,scrollbars=yes"); //height=800,width=1000 PrintWindow.oldWindow = top //PrintWindow.document.write(document.Output.Satpos.value) PrintWindow.document.write(listing) PrintWindow.document.close() } function printyearforselectedsatellite(){ var d,Day,Month,Year,Hour,Minute,Seconds var SunAltitude,ElevationDifference var beta,T_orbit_period,r_earth,r_sat,t,R var satellite_time,start_eclipse,end_eclipse,total_eclipse,i,last_d,west_sat r_earth=6378.14; //km //r_sat=42241; //km r_sat=42164.57; //km Day=1*document.TimeAndDate.Day.value; Month=1*document.TimeAndDate.Month.value; Year=1*document.TimeAndDate.Year.value; d=daynumber(1,1,Year,0,0,0); R=r_earth/r_sat; // satellite_time = 0 deg. = 00:00 ,90 deg.=06:00, 180 deg. = 12:00, 270 deg. = 18:00 //alert(d_to_date_and_time(start_eclipse)); listing="" listing+="" listing+="" listing+="" listing+="Satellite Eclipse" listing+="" listing+="" //listing+="" listing+=""; listing+="

 

"; listing+="
Eclipse for Satellite Position "+document.OrbitPosition.Degrees.value+" East ("+document.OrbitPosition.West_angle.value+" West)
" listing+="
"; listing+="" //listing+="
Start time: "+d_to_date_and_time(start_eclipse)+"
" //listing+="
End time: "+d_to_date_and_time(end_eclipse)+"
" //listing+="
Total eclipse period: "+d_to_hms(total_eclipse)+"
" listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; for (i = 0; i <= 366; i++) { d=daynumber(1,1,Year,0,0,0); satellite_time=Rev(document.OrbitPosition.West_angle.value)*(24/360)/24; // ok in days d=Math.floor(d)+i; d=d+satellite_time; west_sat=1*document.OrbitPosition.West_angle.value; d=sun_angles(west_sat,d); document.Angles.SunDeclination.value=Deg(sun_decl(d)); // i radianer beta=sun_decl(d); t= Math.acos( Math.sqrt(1-R*R)/Math.cos(beta) ) * (orbital_period/Math.PI) ; // ok ,in days so far so good //alert(t); // two periodes from 1.September-15 Oktober and from 27. Februar -12 April start_eclipse=d-t/2; end_eclipse=d+t/2; total_eclipse=t; // if (i==20) { // listing+=""; // listing+=""; // listing+=""; // listing+=""; // listing+=""; // listing+=""; // } if (i==180) { listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; } if (total_eclipse>0) { listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; listing+=""; } } last_d=d; listing+="
" listing+="
" //listing+="
Satellite Position:"+document.Angles.SatelliteLongitude.value+"
" listing+="
" //listing+="
Sun/Satellite Azimuth:"+document.Angles.SunAzimuth.value+"
" //listing+="
Sun Elevation:"+document.Angles.SunElevation.value+"
" listing+="
" //listing+="
Satellite Elevation:"+document.Angles.SatelliteElevation.value+"
" listing+="
" //listing+="
|Satellite Elevation-Sun Elevation|:"+document.Angles.SunSatElDifference.value+"
" listing+="
Start timeEnd timeMiddle timeDuration
-
-
-
-
"+d_to_date_and_time(start_eclipse)+""+d_to_date_and_time(end_eclipse)+""+d_to_date_and_time(d)+""+d_to_hms(total_eclipse)+"
"; listing+="

"+Year+" Jens T. Satre

"; listing+=""; PrintWindow=window.open("","Print_window") //PrintWindow =window.open("","Print_window","menubar=yes,status=yes,toolbar=yes,scrollbars=yes,height=best-fit,width=best-fit"); PrintWindow.oldWindow = top //PrintWindow.document.write(document.Output.Satpos.value) PrintWindow.document.write(listing) PrintWindow.document.close() } function CalculateAngles(){ var d,Day,Month,Year,Hour,Minute,Seconds var SunAltitude,ElevationDifference var beta,T_orbit_period,r_earth,r_sat,t,R var satellite_time,start_eclipse,end_eclipse,total_eclipse r_earth=6378.14; //km //r_sat=42241; //km r_sat=42164.57; //km Day=1*document.TimeAndDate.Day.value; Month=1*document.TimeAndDate.Month.value; Year=1*document.TimeAndDate.Year.value; d=daynumber(Day,Month,Year,0,0,0); R=r_earth/r_sat; // satellite_time = 0 deg. = 00:00 ,90 deg.=06:00, 180 deg. = 12:00, 270 deg. = 18:00 satellite_time=Rev(document.OrbitPosition.West_angle.value)*(24/360)/24; // ok in days d=Math.floor(d); d=d+satellite_time; document.Angles.SunDeclination.value=Deg(sun_decl(d)); // i radianer /* beta=sun_decl(d); t= Math.acos(Math.sqrt(1-R*R)/Math.cos(beta) ) * (1/Math.PI) ; // ok ,in days so far so good //alert(t); // two periodes from 1.September-15 Oktober and from 27. Februar -12 April start_eclipse=d-t/2; end_eclipse=d+t/2; total_eclipse=t; //alert(d_to_date_and_time(start_eclipse)); listing="" listing+="" listing+="" listing+="" listing+="Satellite Eclipse" listing+="" listing+="" listing+="" listing+="
Start time:"+d_to_date_and_time(start_eclipse)+"
" listing+="
End time:"+d_to_date_and_time(end_eclipse)+"
" listing+="Middle time:"+d_to_date_and_time(d)+""; listing+="
Total period:"+d_to_hms(total_eclipse)+"
" listing+="
" listing+="
" //listing+="
Satellite Position:"+document.Angles.SatelliteLongitude.value+"
" listing+="
" //listing+="
Sun/Satellite Azimuth:"+document.Angles.SunAzimuth.value+"
" //listing+="
Sun Elevation:"+document.Angles.SunElevation.value+"
" listing+="
" //listing+="
Satellite Elevation:"+document.Angles.SatelliteElevation.value+"
" listing+="
" //listing+="
|Satellite Elevation-Sun Elevation|:"+document.Angles.SunSatElDifference.value+"
" listing+="" PrintWindow=window.open("","Print_window") //PrintWindow =window.open("","Print_window","menubar=yes,status=yes,toolbar=yes,scrollbars=yes"); //height=800,width=1000 PrintWindow.oldWindow = top //PrintWindow.document.write(document.Output.Satpos.value) PrintWindow.document.write(listing) PrintWindow.document.close() */ return(t); } function set_todays_date(){ var today,Day,Month,Year,Hour,Minute,Seconds today = new Date(); Month= today.getMonth()+1; Day= today.getDate() ; Year= today.getUTCFullYear(); Hour=today.getUTCHours(); Minute=today.getUTCMinutes(); Seconds=today.getUTCSeconds(); document.TimeAndDate.Day.value=Day; document.TimeAndDate.Month.value=Month; document.TimeAndDate.Year.value=Year; } function d_to_date_and_time(d) { var today,t var MinMilli = 1000 * 60; var HrMilli = MinMilli * 60; var DyMilli = HrMilli * 24; today = new Date(); // d+10956= Date() format //window.alert('d= '+d ); d=d+10956; d*DyMilli; today.setTime(d*DyMilli); //t=((today.getTime()/DyMilli)-10956); //window.alert('t= '+t ); time_offset=today.getTimezoneOffset() ; Hour= today.getUTCHours() ; Minute=today.getUTCMinutes() ; Second=today.getUTCSeconds() ; Month= today.getUTCMonth()+1; Day= today.getUTCDate() ; Year= today.getUTCFullYear(); return(today) } function d_to_hms(d) { var today,t var MinMilli = 1000 * 60; var HrMilli = MinMilli * 60; var DyMilli = HrMilli * 24; var return_string today = new Date(); // d+10956= Date() format //window.alert('d= '+d ); d=d+10956; d*DyMilli; today.setTime(d*DyMilli); //t=((today.getTime()/DyMilli)-10956); //window.alert('t= '+t ); time_offset=today.getTimezoneOffset() ; Hour= today.getUTCHours() ; Minute=today.getUTCMinutes() ; Second=today.getUTCSeconds() ; Month= today.getUTCMonth()+1; Day= today.getUTCDate() ; Year= today.getUTCFullYear(); if (Hour<10) Hour='0'+Hour; if (Minute<10) Minute='0'+Minute; if (Second<10) Second='0'+Second; return_string=Hour+' hours '+Minute+' minutes '+Second+' seconds'; return(return_string) } // get the time for more days, function sun_decl(d){ var SunSouth,HourAngle,SIDEREALTIME,SatAz,SunSat,Tst,SatelliteAzimuth,pi,NewRA var w,a,e,M,L,oblecl,E,x,y,r,v,sunlon,z,xequat,yequat,zequat,RA,Decl,GMST0,UT,SIDTIME,HA var SunElevation,xhor,yhor,zhor,SunSatElevationDifference,SatElevation,GeometricElevation pi=Math.PI; var angles= new Array(); //*********CALCULATE SUN DATA ********************* w=282.9404 + 4.70935E-5 * d ; //OK a=1; e= 0.016709 - 1.151E-9 *d ; M= 356.0470 + 0.9856002585 * d; oblecl=23.4393 -3.563E-7 * d ; L=w+Rev(M); L=Rev(L); E=M+ (180/pi)*e*Math.sin(Radians(M))*( 1+e * Math.cos(Radians(M)) ); E=Rev(E); // OK x= Math.cos(Radians(E)) -e ; y= Math.sin(Radians(Rev(E)))*Math.sqrt(1-e*e); r=Math.sqrt(x*x+y*y); v=Deg(Math.atan2(y,x)); sunlon=Rev(v+w); // trolig ok x=r*Math.cos(Radians(sunlon)); y=r*Math.sin(Radians(sunlon)); z=0; xequat=x; yequat=y*Math.cos(Radians(oblecl)) +z*Math.sin(Radians(oblecl)); zequat=y*Math.sin(Radians(oblecl)) +z*Math.cos(Radians(oblecl)); RA=Rev(Deg(Math.atan2(yequat,xequat))); // OK Decl=Math.atan2(zequat,Math.sqrt(xequat*xequat + yequat*yequat ) ); // trolig OK return(Decl); } function sun_angles(SatLon,d){ var SunSouth,HourAngle,SIDEREALTIME,SatAz,SunSat,Tst,SatelliteAzimuth,pi,NewRA,dstart,dcalc var w,a,e,M,L,oblecl,E,x,y,r,v,sunlon,z,xequat,yequat,zequat,RA,Decl,GMST0,UT,SIDTIME,HA,SatLong,SolLong var SunElevation,xhor,yhor,zhor,SunSatElevationDifference,SatElevation,GeometricElevation,min,sec,sign,EarthLonx10Floored,SatLonx10Floored,timediff,timediff_min pi=Math.PI; var angles= new Array(); // alert("sun_angles d="+d) ; SatLon=360-SatLon; //dstart=d-(1800/(60*60*24)); // back one hour //alert("minus one hour d="+dstart) ; dcalc=d; //for (sec = 0; sec < 3600; sec++) { //2016 //dcalc=dstart+(sec/(60*60*24)); // starts one hour before first computed time // alert("d loop="+d) ; //*********CALCULATE SUN DATA ********************* w=282.9404 + 4.70935E-5 * dcalc; a=1; //a=6.6107940559473451507806351067866; //a=0; //a=149476000; //km average distance e= 0.016709 - 1.151E-9 * dcalc ; M= 356.0470 + 0.9856002585 * dcalc; oblecl=23.4393 -3.563E-7 * dcalc ; L=w+Rev(M); L=Rev(L); E=M+ (180/pi)*e*Math.sin(Radians(M))*( 1+e * Math.cos(Radians(M)) ); E=Rev(E); // OK x= a*Math.cos(Radians(E)) -e ; y= a*Math.sin(Radians(Rev(E)))*Math.sqrt(1-e*e); r=Math.sqrt(x*x+y*y); v=Deg(Math.atan2(y,x)); sunlon=Rev(v+w); // trolig ok x=r*Math.cos(Radians(sunlon)); y=r*Math.sin(Radians(sunlon)); z=0; xequat=x; yequat=y*Math.cos(Radians(oblecl)) +z*Math.sin(Radians(oblecl)); zequat=y*Math.sin(Radians(oblecl)) +z*Math.cos(Radians(oblecl)); RA=Rev(Deg(Math.atan2(yequat,xequat))); // OK Decl=Deg(Math.atan2(zequat,Math.sqrt(xequat*xequat + yequat*yequat ) )); // trolig OK GMST0=(L+180); //*********CALCULATE TIME ********************* UT=dcalc-Math.floor(dcalc); var EarthLon,EarthLat EarthLon=Rev(0*180+RA-GMST0-UT*360); SatLong=parseFloat(SatLon); SolLong=parseFloat(Rev(EarthLon+180)); // test alternative algo UT=Rev(0*180+RA-GMST0-SatLon+180)/360; // ok works !!! dcalc=Math.floor(dcalc)+UT; return(dcalc); } //********WORKS OK function SetCookie() { var CookieValue var MyCookieVal var ValArray=new Array(); var SubArray=new Array(); SitePosCurrentIndex =1073 ; // Used only if there are not any cookie stored //SatNameCurrentIndex =40 ; MyCookieVal=document.cookie; //alert(MyCookieVal); if (MyCookieVal !== "") // If cookie has value then set users defaults { ValArray=MyCookieVal.split(":"); //' Reads 6 cookie values in to the array Lat=ValArray[0]; LatDir=ValArray[1]; Lon=ValArray[2]; LonDir=ValArray[3]; SitePosCurrentIndex=ValArray[4]; SatNameCurrentIndex=ValArray[5]; SetLocation= ValArray[6]; Calibrate_pulsevalue=ValArray[7]; Calibrate_pulse_per_ha_degree=ValArray[8]; calibrate_inc_direction=ValArray[9]; HA_for_calibrated_position=ValArray[10]; } SatNameCurrentIndex=document.Satellite.Position.selectedIndex; CookieValue=Lat+":"+LatDir+":"+Lon+":"+LonDir+":"+SitePosCurrentIndex+":"+SatNameCurrentIndex+":"+SetLocation+":"+Calibrate_pulsevalue+":"+Calibrate_pulse_per_ha_degree+":"+calibrate_inc_direction+":"+HA_for_calibrated_position+":"+ValArray[11]+":"+ValArray[12]+":"+ValArray[13]+":"+ValArray[14]+":"+ValArray[15]+":"+ValArray[16]+":"+ValArray[17]+":"+ValArray[18]+":"+ValArray[19]+":"+ValArray[20]+";expires=Tue, 10 Jul 2040 23:59:59 UTC;"; deleteAllCookies(); document.cookie =CookieValue ; // Store cookie } function open_single_satellite_view() { var catalog; var tmpstring; var satarray=new Array(); tmpstring=document.Satellite.Position.value; satarray=tmpstring.split(":"); //' Reads value array which is separated by ":", satcatid at index 3 satcatid=satarray[3]; //SingleSatPath,satcatid //alert("http://www.online.no"); //catalog="Catalog\"; //open2("http://www.online.no",1); //ondblclick= window.open("Catalog/"+satcatid+".htm",satcatid,''); //ondblclick="open2(window.location.href+'#38095',1)" } function ReadCookie() { var CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); SitePosCurrentIndex =1073 ; // Used only if there are not any cookie stored //SatNameCurrentIndex =40 ; MyCookieVal=document.cookie; //alert(MyCookieVal); if (MyCookieVal !== "") // If cookie has value then set users defaults { ValArray=MyCookieVal.split(":"); //' Reads 6 cookie values in to the array Lat=ValArray[0]; LatDir=ValArray[1]; Lon=ValArray[2]; LonDir=ValArray[3]; SitePosCurrentIndex=ValArray[4]; SatNameCurrentIndex=ValArray[5]; SetLocation= ValArray[6]; Calibrate_pulsevalue=ValArray[7]; Calibrate_pulse_per_ha_degree=ValArray[8]; calibrate_inc_direction=ValArray[9]; HA_for_calibrated_position=ValArray[10]; } document.Satellite.Position.selectedIndex=SatNameCurrentIndex; // ok } // end function function Rev(number) { var x x= number -Math.floor(number/360.0)*360 ; return(x) } function Radians(number) { var rad rad=number*Math.PI/180; return(rad) } function Deg(number) { var rad rad=number*180/Math.PI; return(rad) } function daynumber(Day,Month,Year,Hour,Minute,Second) { //window.alert(Day+" "+Month+" "+Year+" "+Hour+" "+Minute+" "+Second); d=367*Year - Div( (7*(Year+(Div((Month+9),12)))),4 ) + Div((275*Month),9) + Day - 730530 // d is correct //window.alert(d); d=d+ Hour/24 + Minute/(60*24) + Second/(24*60*60) // OK return(d) } function Div(a,b) { return((a-a%b)/b) //OK } function formatvalue(input, rsize) // Desimal avrunding { var invalid = "**************************"; var nines = "999999999999999999999999"; var strin = "" + input; var fltin = parseFloat(strin); if (strin.length <= rsize) return strin; if (strin.indexOf("e") != -1 || fltin > parseFloat(nines.substring(0,rsize)+".4")) return invalid.substring(0, rsize); var rounded = "" + (fltin + (fltin - parseFloat(strin.substring(0, rsize)))); return rounded.substring(0, rsize); } function formatnumber(num,places) { var strOP,i,decimals,newdecimals,integer,newstring,numcopy var ss=new Array() numcopy=num; var a = Math.pow(10,Math.abs(places) == places ? places : 2); strOP=String(Math.round(num * a) / a).replace(/^(\d)/," $1"); if (num<0) strOP=" "+strOP; // put " " on negative numbers //num=parseFloat(strOP); ss = strOP.split(".");// split string by . what about zero..? if ((num!==0)&&(ss.length>1)) { decimals=ss[1]; integer=ss[0]; if (decimals.length=0) strOP=" "+strOP; return(strOP) }