		/* Objects */

		function item_array(n)
		{
			this.length = n;
			return this;
		}

		function earth_station_item(name, latitude, longitude)
		{
			this.name = name;
			this.latitude = latitude;
			this.longitude = longitude;
		}

		function satellite_item(name, longitude)
		{
			this.name = name;
			this.longitude = longitude;
		}

		function outage_item(outage_date, start_time, end_time, duration)
		{
			this.outage_date = outage_date;
			this.start_time = start_time;
			this.end_time = end_time;
			this.duration = duration;
		}

		/* Earth station list */

		EARTH_STATION_COUNT = 86;
		var ES_list = new item_array(EARTH_STATION_COUNT);

		ES_list[1] = new earth_station_item('Abidjan',5.32,-4.02);
		ES_list[2] = new earth_station_item('Abuja',9.2,7.18);
		ES_list[3] = new earth_station_item('Alma-Ata',43.32,76.92);
		ES_list[4] = new earth_station_item('Anadyr',64.67,177.53);
		ES_list[5] = new earth_station_item('Antananarivo',-18.92,47.52);
		ES_list[6] = new earth_station_item('Arkhangelsk',64.53,41.17);
		ES_list[7] = new earth_station_item('Ashkhabad',37.97,58.4);
		ES_list[8] = new earth_station_item('Astana',51.18,71.42);
		ES_list[9] = new earth_station_item('Athens',37.98,23.7);
		ES_list[10] = new earth_station_item('Baghdad',33.33,44.43);
		ES_list[11] = new earth_station_item('Bangalore',12.97,77.58);
		ES_list[12] = new earth_station_item('Bangkok',13.75,100.58);
		ES_list[13] = new earth_station_item('Bangui',4.38,18.62);
		ES_list[14] = new earth_station_item('Beijing',39.92,116.42);
		ES_list[15] = new earth_station_item('Belgrade',44.82,20.47);
		ES_list[16] = new earth_station_item('Berlin',52.53,13.42);
		ES_list[17] = new earth_station_item('Bhopal',23.28,77.47);
		ES_list[18] = new earth_station_item('Blagoveshchensk',50.32,127.5);
		ES_list[19] = new earth_station_item('Cape Town',-33.92,18.45);
		ES_list[20] = new earth_station_item('Chelyabinsk',55.17,61.42);
		ES_list[21] = new earth_station_item('Chita',52.02,113.58);
		ES_list[22] = new earth_station_item('Colombo',6.92,79.87);
		ES_list[23] = new earth_station_item('Dakar',14.63,-17.45);
		ES_list[24] = new earth_station_item('Delhi',28.67,77.23);
		ES_list[25] = new earth_station_item('Dhakka',23.72,90.42);
		ES_list[26] = new earth_station_item('Douala',4.08,9.72);
		ES_list[27] = new earth_station_item('Dublin',53.35,-6.3);
		ES_list[28] = new earth_station_item('Gwadar',25.15,62.35);
		ES_list[29] = new earth_station_item('Havana',23.12,-82.42);
		ES_list[30] = new earth_station_item('Helsinki',60.13,20);
		ES_list[31] = new earth_station_item('Herat',34.35,62.17);
		ES_list[32] = new earth_station_item('Hong Kong',22.5,114.17);
		ES_list[33] = new earth_station_item('Hyderabad',17.37,78.43);
		ES_list[34] = new earth_station_item('Irkutsk',52.3,104.25);
		ES_list[35] = new earth_station_item('Islamabad',33.67,73.13);
		ES_list[36] = new earth_station_item('Istanbul',41.03,28.97);
		ES_list[37] = new earth_station_item('Jakarta',-6.13,106.75);
		ES_list[38] = new earth_station_item('Kabul',34.5,69.17);
		ES_list[39] = new earth_station_item('Karachi',24.83,67.03);
		ES_list[40] = new earth_station_item('Khabarovsk',48.53,135.13);
		ES_list[41] = new earth_station_item('Khartum',15.55,32.58);
		ES_list[42] = new earth_station_item('Kiev',50.47,30.48);
		ES_list[43] = new earth_station_item('Krasnoyarsk',56.08,92.77);
		ES_list[44] = new earth_station_item('Kuala Lumpur',3.13,101.7);
		ES_list[45] = new earth_station_item('Lisbon',38.73,-9.13);
		ES_list[46] = new earth_station_item('Luanda',-8.83,13.33);
		ES_list[47] = new earth_station_item('Madrid',40.42,-3.72);
		ES_list[48] = new earth_station_item('Manila',14.6,120.98);
		ES_list[49] = new earth_station_item('Miami',25.75,-80.17);
		ES_list[50] = new earth_station_item('Minsk',53.85,27.5);
		ES_list[51] = new earth_station_item('Monrovia',6.33,-10.77);
		ES_list[52] = new earth_station_item('Moscow',55.75,37.7);
		ES_list[53] = new earth_station_item('Murmansk',68.98,33.13);
		ES_list[54] = new earth_station_item('Nairobi',-1.28,36.83);
		ES_list[55] = new earth_station_item("N'Djamena",12.17,14.98);
		ES_list[56] = new earth_station_item('Norilsk',69.35,88.03);
		ES_list[57] = new earth_station_item('Nouakchott',18.15,-15.97);
		ES_list[58] = new earth_station_item('Novosibirsk',55.07,82.92);
		ES_list[59] = new earth_station_item('Omsk',55,73.37);
		ES_list[60] = new earth_station_item('Oslo',59.93,10.75);
		ES_list[61] = new earth_station_item('Paris',48.87,2.33);
		ES_list[62] = new earth_station_item('Perth',-31.97,115.82);
		ES_list[63] = new earth_station_item('Petr.-Kamchat.',53.05,158.72);
		ES_list[64] = new earth_station_item('Rabat',34.03,-6.85);
		ES_list[65] = new earth_station_item('Rome',41.54,12.27);
		ES_list[66] = new earth_station_item('Rostov-na-Donu',47.25,39.75);
		ES_list[67] = new earth_station_item('Ryiadh',24.65,46.73);
		ES_list[68] = new earth_station_item('Samara',53.17,50.25);
		ES_list[69] = new earth_station_item('St. Petersburg',59.92,30.42);
		ES_list[70] = new earth_station_item('Surgut',61.22,73.33);
		ES_list[71] = new earth_station_item('Syktyvkar',61.7,50.75);
		ES_list[72] = new earth_station_item('Taipei',25.08,121.53);
		ES_list[73] = new earth_station_item('Tehran',35.67,51.43);
		ES_list[74] = new earth_station_item('Tel Aviv',32.08,34.77);
		ES_list[75] = new earth_station_item('Thiruvananthapuram',8.68,76.95);
		ES_list[76] = new earth_station_item('Tripoly',32.97,13.2);
		ES_list[77] = new earth_station_item('Ufa',54.75,55.97);
		ES_list[78] = new earth_station_item('Ulan Baatar',47.9,106.87);
		ES_list[79] = new earth_station_item('Varanasi',25.33,83);
		ES_list[80] = new earth_station_item('Vladivostok',43.15,131.88);
		ES_list[81] = new earth_station_item('Vorkuta',67.45,64);
		ES_list[82] = new earth_station_item('Warsaw',52.25,21);
		ES_list[83] = new earth_station_item('Washington',38.92,-77);
		ES_list[84] = new earth_station_item('Yakutsk',62.17,129.33);
		ES_list[85] = new earth_station_item('Yu.-Sakhalinsk',46.97,142.75);
		ES_list[86] = new earth_station_item('Others',0,0);



		/* Satellite list */

		SATELLITE_COUNT = 11;
		var satellite_list = new item_array(SATELLITE_COUNT);
		
		satellite_list[1] = new satellite_item('ABS-1',75);
	
		
		/* Display default values */
		function Initialize ()
		{
			//Update_Satellite();
			Update_Station();
			var current_date = new Date();
			input_year.value = current_date.getUTCFullYear();
		}
		
		
		
		/* Getting satellite parameters from selection */
		function Update_Satellite()
		{
			input_sat_long.value = satellite_list[input_satellite.options[input_satellite.selectedIndex].value].longitude;
		}
		
		/* Getting ES parameters from selection */
		function Update_Station()
		{ 
			input_es_lat.value = ES_list[input_earth_station.options[input_earth_station.selectedIndex].value].latitude;
			input_es_long.value = ES_list[input_earth_station.options[input_earth_station.selectedIndex].value].longitude;
		}
		
		
		/* Calculating outage times */
		
		/* Global constants */
		var ES_ALTITUDE = 0; 
		var EARTH_FLATTENING = (1/298.26);          
		var EARTH_RADIUS = 6378.245; 
		var GEO_RADIUS = 35786 + EARTH_RADIUS; 
		
		
		var MILLISECONDS_PER_DAY = 60 * 60 * 24 * 1000;
		var MILLISECONDS_PER_HOUR = 60 * 60 * 1000;
		var MILLISECONDS_PER_MINUTE = 60 * 1000;
		
		/* Global variables */
		var G_es_lat;
		var G_es_long;
		var G_sat_long;
		var G_AZ;
		var G_EL;
		
		var G_base_date;
		var G_epoch;
		
		var G_outage_angle;
		
		var G_sun_sat_angle;
		
		var G_sun_dec;
		var G_sat_dec;
		
		var G_outage_found;
		var G_outage_count;
		
		var G_outage_start;
		var G_outage_end;
		
		/* Conversion functions */
		function Rad( degrees )
		{
			return ( degrees * ((Math.PI)/180));
		}

		function Deg( radians )
		{
			return ( radians / ((Math.PI)/180));
		}

		/* Launches the calculation of the outages + print */
		function Calculate_p()
		{
			// Strore the coordinates in the variables
			G_es_lat = input_es_lat.value;
			G_es_long = - input_es_long.value;
			G_sat_long = - 75;
			//G_sat_long = -input_sat_long.value;
		
			// Calculate elevation and azimuth of the satellite
			CalculateAZEL();
			
			// determine the G_epoch, i.e. the day to start looking for outage
			CaclulateEpoch();
			
			// Calculate the angle within which the outage occurs
			OutageAngle();
			
			ShowHeader();
						
			G_outage_found = false;
			G_outage_count = 0;
			while ((G_outage_count == 0 || G_outage_found == true))
			{
				LookForOutage();
			}
			
			ShowFooter();
			
			window.print();
			
			
		}



		/* Launches the calculation of the outages */
		function Calculate()
		{
			// Strore the coordinates in the variables
			G_es_lat = input_es_lat.value;
			G_es_long = - input_es_long.value;
			G_sat_long = - 75;
			//G_sat_long = -input_sat_long.value;
		
			// Calculate elevation and azimuth of the satellite
			CalculateAZEL();
			
			// determine the G_epoch, i.e. the day to start looking for outage
			CaclulateEpoch();
			
			// Calculate the angle within which the outage occurs
			OutageAngle();
			
			ShowHeader();
						
			G_outage_found = false;
			G_outage_count = 0;
			while ((G_outage_count == 0 || G_outage_found == true))
			{
				LookForOutage();
			}
			
			ShowFooter();
			
		}
		
		/* 
		Calculates the azimuth and the elevation of the satellite
		Updates G_AZ, G_EL
		*/
		function CalculateAZEL() 
		{
			R = EARTH_RADIUS/Math.sqrt(1-EARTH_FLATTENING*(2-EARTH_FLATTENING)*Math.pow((Math.sin(Rad(G_es_lat))),2));     
				
			Ra = (R+ES_ALTITUDE)*Math.cos(Rad(G_es_lat));                                     
			Rz = (R*Math.pow((1-EARTH_FLATTENING),2)+ES_ALTITUDE)*Math.sin(Rad(G_es_lat));                 
				
			dRx = GEO_RADIUS*Math.cos(Rad(G_sat_long-G_es_long))-Ra;                              
			dRy = GEO_RADIUS*Math.sin(Rad(G_sat_long-G_es_long));                                
			dRz = -Rz;  
																			
			dRnorth = -dRx*Math.sin(Rad(G_es_lat))+dRz*Math.cos(Rad(G_es_lat));         
			dRzenith = dRx*Math.cos(Rad(G_es_lat))+dRz*Math.sin(Rad(G_es_lat));          

			G_AZ = (720 - (Deg(Math.atan2(dRy,dRnorth))) )%360;
			G_AZ = Math.round(G_AZ*1000)/1000;
				
			G_EL = Deg(Math.atan(dRzenith/Math.sqrt(dRnorth*dRnorth+dRy*dRy))); 
			G_EL = Math.round(G_EL*1000)/1000;
		}
		
		/* 
		Caclulates the G_epoch, i.e. the day for 
		which the coordinates of the objects are calculated
		Updates G_base_date, G_epoch
		*/
		function CaclulateEpoch() 
		{
			//midnight 1.1.1904
			G_base_date = new Date();
			G_base_date.setUTCFullYear(1904);
			G_base_date.setUTCMonth(0);
			G_base_date.setUTCDate(1);
			G_base_date.setUTCHours(0);
			G_base_date.setUTCMinutes(0);
			G_base_date.setUTCSeconds(0);


			   
			// Number of days from 1 Jan 1904 to 1 Jan [Year]
			G_epoch = (eval("input_year.value") - 1904) * 365.25;  
			  
			// Move the G_epoch to the vicinity of the respective equinox
			if (input_season[0].checked)
				// Vernal equinox
				G_epoch += 45;
			else
				// Autumnal equinox
				G_epoch += 229;
			   
			// Drop the fractional part of the G_epoch
			G_epoch = Math.floor(G_epoch);
		}
		
		
		/* 
		Calculates the angle within which the outage occurs
		Updates G_outage_angle
		*/
		function OutageAngle() 
		{
			if (input_band[0].checked)
				// C-band
				G_outage_angle = 70 * 300000000/(3.95*1000000000)/input_diameter.value;
			else
				// Ku-band
				G_outage_angle = 70 * 300000000/(11.95*1000000000)/input_diameter.value;
				
				
		}
		
		
		/* 
		Calculates the equatorial coordinates of the objects at the specified G_epoch
		Updates G_sun_dec, G_sat_dec, G_sun_sat_angle
		*/
		function UpdateCoordinates(local_epoch)
		{
			var h = (local_epoch + 1460.5)/36525;
			
			var earth_orbit_ecc = 0.01675104 - (0.0000418 * h);
			var mean_anomaly = 358.475874 + (35999.04975 * h);
			var sun_mean_longitude = 279.6964 + (36000.769 * h);
			var ecliptic_mean_obliquity = 23.4523 - (0.013 * h);
			
			m = (99.81347 + 0.9856462 * (local_epoch - 27759) + 360 * ((local_epoch - 27759) - Math.floor(local_epoch - 27759))) % 360;
			d_es_long = (m - G_es_long + 360) % 360;
			d_sat_long = (m - G_sat_long + 360) % 360;
			
			
     		var cc = Deg((2 * earth_orbit_ecc * Math.sin(Rad(mean_anomaly)) 
						+ 1.25 * earth_orbit_ecc * earth_orbit_ecc * Math.sin(2* Rad(mean_anomaly))));
			   
			var sun_true_longitude = sun_mean_longitude + cc;
			   
			var sun_apparent_right_ascension = Math.atan2((Math.cos(Rad(ecliptic_mean_obliquity)) * Math.sin(Rad(sun_true_longitude))), 
															Math.cos(Rad(sun_true_longitude)));
			
			sun_apparent_right_ascension = (Deg(sun_apparent_right_ascension)+ 360) %360;
			   
			dr = Deg(Math.atan(Math.tan(Rad(ecliptic_mean_obliquity)) * Math.sin(Rad(sun_apparent_right_ascension))));
			
			G_sun_dec = Deg(Math.atan((Math.sin(Rad(dr)) * (149504200 * (1 - earth_orbit_ecc * Math.cos(Rad(mean_anomaly)) 
						- earth_orbit_ecc * earth_orbit_ecc / 2 * (Math.cos(2 * Rad(mean_anomaly)) - 1))) 
						- Math.sin(Rad(G_es_lat)) * EARTH_RADIUS) / 
						Math.sqrt(Math.pow(Math.cos(Rad(sun_apparent_right_ascension)) * Math.cos(Rad(dr)) * (149504200 * (1 - earth_orbit_ecc * Math.cos(Rad(mean_anomaly)) - earth_orbit_ecc * earth_orbit_ecc / 2 * (Math.cos(2 * Rad(mean_anomaly)) - 1))) - Math.cos(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) * EARTH_RADIUS,2) + Math.pow(Math.sin(Rad(sun_apparent_right_ascension)) 
						* Math.cos(Rad(dr)) * (149504200 * (1 - earth_orbit_ecc * Math.cos(Rad(mean_anomaly)) - earth_orbit_ecc * earth_orbit_ecc / 2 * (Math.cos(2 * Rad(mean_anomaly)) - 1))) - Math.sin(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) 
						* EARTH_RADIUS,2))));
			
			G_sat_dec = Deg(Math.atan((-Math.sin(Rad(G_es_lat)) * EARTH_RADIUS) / Math.sqrt(Math.pow(Math.cos(Rad(d_sat_long)) * GEO_RADIUS - Math.cos(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) * EARTH_RADIUS,2)+ Math.pow((Math.sin(Rad(d_sat_long)) * GEO_RADIUS) - (Math.sin(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) * EARTH_RADIUS),2))));
			
			G_sun_sat_angle = Deg(Math.acos(Math.sin(Rad(G_sat_dec)) * Math.sin(Rad(G_sun_dec)) 
								+ Math.cos(Rad(G_sat_dec)) * Math.cos(Rad(G_sun_dec)) * Math.cos(Rad(((Deg(Math.atan2(((Math.sin(Rad(d_sat_long)) * GEO_RADIUS) - (Math.sin(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) * EARTH_RADIUS)),(Math.cos(Rad(d_sat_long)) * GEO_RADIUS - Math.cos(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) * EARTH_RADIUS))) + 360) % 360) 
								- ((Deg(Math.atan2(Math.sin(Rad(sun_apparent_right_ascension)) * Math.cos(Rad(dr)) * (149504200 * (1 - earth_orbit_ecc * Math.cos(Rad(mean_anomaly)) - earth_orbit_ecc * earth_orbit_ecc / 2 * (Math.cos(2 * Rad(mean_anomaly)) - 1))) 
								- Math.sin(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) * EARTH_RADIUS,(Math.cos(Rad(sun_apparent_right_ascension)) * Math.cos(Rad(dr)) * (149504200 * (1 - earth_orbit_ecc * Math.cos(Rad(mean_anomaly)) - earth_orbit_ecc * earth_orbit_ecc / 2 * (Math.cos(2 * Rad(mean_anomaly)) - 1))) - Math.cos(Rad(d_es_long)) * Math.cos(Rad(G_es_lat)) * EARTH_RADIUS))) + 360) % 360)))));
			
	
		}
		
		
		
		
		
		/* 
		Look for the outage based on the current G_epoch 
		Updates G_outage_count, G_epoch
		*/
		function LookForOutage()
		{
			CalculateOutageStart(); // find outage start time
			if (G_outage_found)
			{
			
				G_outage_count++; // indicate that an outage was found
				CalculateOutageEnd(); // find outage end time
				ShowResult(); // show the outage timing
				
				G_epoch = G_outage_end + 0.9; // move the G_epoch to the next day
				
				
				UpdateCoordinates(G_outage_start); // calculate the coordinates of the objects at the current G_epoch
			}
		}
		
		/* 
		Look for the outage start within one day from the current epoch
		Updates G_outage_start, G_outage_found, G_Epoch
		*/
		function CalculateOutageStart()
		{
			G_outage_start = G_epoch;
			   
			UpdateCoordinates (G_outage_start); // calculate the coordinates of the objects
			   
			G_outage_found = false;
			   
			/*search until the angle between the sun and the satellite is less than the
			outage angle. stop the search if we go beyond one day after the epoch*/ 
		
			while  (G_sun_sat_angle > G_outage_angle && (G_outage_start - G_epoch) < 1)
			{	
		
				if(Math.abs(G_sat_dec  - G_sun_dec) - G_outage_angle > 0.005)
				{
					G_outage_start +=  (Math.abs(G_sat_dec  - G_sun_dec) - G_outage_angle + 0.005) /0.4;
					UpdateCoordinates(G_outage_start); // calculate the coordinates of the objects
				}
										
				G_outage_start = G_outage_start +0.0001; //+ 0.00005787; // move the outage start 1/2 of a second forward
				
				UpdateCoordinates(G_outage_start); // calculate the coordinates of the objects
			}
			
			if (G_sun_sat_angle < G_outage_angle)
			{
				G_outage_found = true; // the outage occurs
			}
			
			G_epoch = G_outage_start; //move the epoch forward
			
		}
		
		/*
		Find the time of the outage end
		Updates G_outage_end 
		*/
		function CalculateOutageEnd()
		{
			G_outage_end = G_outage_start; // start the search from the outage start time
			UpdateCoordinates(G_outage_end); // calculate the coordinates of the objects
			
			// Carry on the search until the angle between the satellite and the sun
			// gets greater than the outage angle
			while (G_sun_sat_angle < G_outage_angle)
			{
				G_outage_end = G_outage_end + 0.00005787; // 0.00005787 = 1/2 of a second
				UpdateCoordinates(G_outage_end); // Calculate the coordinates of the objects
			}
			G_outage_end = G_outage_end - 0.00005787; // Move the time of the outage end 1/2 of a second backwards
			UpdateCoordinates(G_outage_end);
		}
		
	
		
		
		/* Displaying results */
		function ShowHeader()
		{
			text_results.value = "";
			text_results.value = text_results.value + "Sun transit outage forecast for"
			if (input_season[0].checked)
				text_results.value = text_results.value + " spring";
			else 
				text_results.value = text_results.value + " fall";
			text_results.value = text_results.value + " " + input_year.value + "\r\n";
			
			text_results.value = text_results.value + "\r\nABS-1 longitude: "
			if (75>0)
				 text_results.value = text_results.value + 75 + "E";
			else
				text_results.value = text_results.value + (-1* 75) + "W";
				
			text_results.value = text_results.value + "\r\n\r\nES latitude: "
			if (input_es_lat.value>0)
				 text_results.value = text_results.value + input_es_lat.value + "N";
			else
				text_results.value = text_results.value + (-1* input_es_lat.value) + "S";
				
			text_results.value = text_results.value + "\tES longitude: "
			if (input_es_long.value>0)
				 text_results.value = text_results.value + input_es_long.value + "E";
			else
				text_results.value = text_results.value + (-1* input_es_long.value) + "W";
				
				
			text_results.value = text_results.value + "\r\n\r\nBand: "
			if (input_band[0].checked)
				 text_results.value = text_results.value + "C ";
			else
				text_results.value = text_results.value + "Ku";
				
				
			text_results.value = text_results.value + "\t\tES antenna diameter: " + input_diameter.value + " m" 
			
			text_results.value = text_results.value + "\r\n\r\n"
			text_results.value = text_results.value + "Predicted date | Start    | End      | Duration |" + "\r\n";
			text_results.value = text_results.value + "dd/mm/yyyy     | GMT      | GMT      |          |" +  "\r\n";
			text_results.value = text_results.value + "               | hh:mm:ss | hh:mm:ss | mm:ss    |\r\n";
			text_results.value = text_results.value + "---------------|----------|----------|----------| " + "\r\n";
		}
		
		function ShowResult()
		{
			outage_start_date = new Date();
			//outage_start_date.setTime(G_base_date.getTime() + (G_outage_start * MILLISECONDS_PER_DAY));
			

outage_start_date.setTime(Date.UTC(G_base_date.getUTCFullYear(), G_base_date.getUTCMonth(), G_base_date.getUTCDate(), G_base_date.getUTCHours(), G_base_date.getUTCMinutes(), G_base_date.getUTCSeconds()) + (G_outage_start * MILLISECONDS_PER_DAY));

outage_start_date.setTime(outage_start_date.getTime() + outage_start_date.getTimezoneOffset()*60000)

			outage_end_date = new Date();
			
//outage_end_date.setTime( G_base_date.getTime() + (G_outage_end * MILLISECONDS_PER_DAY));

outage_end_date.setTime(Date.UTC(G_base_date.getUTCFullYear(), G_base_date.getUTCMonth(), G_base_date.getUTCDate(), G_base_date.getUTCHours(), G_base_date.getUTCMinutes(), G_base_date.getUTCSeconds()) + (G_outage_end * MILLISECONDS_PER_DAY));

outage_end_date.setTime(outage_end_date.getTime() +outage_end_date.getTimezoneOffset()*60000)



			var t_date = FormatDate(outage_start_date);
			        
			var begin_time = FormatTime(outage_start_date);

			var end_time = FormatTime(outage_end_date);

			var duration = FormatDuration(outage_start_date, outage_end_date);

			text_results.value = text_results.value + t_date + "     | " + begin_time + " | " + end_time + " | " + duration + "    | " + "\r\n";

		}
		
		function ShowFooter()
		{
			text_results.value = text_results.value + "\r\n\r\n\"Asia Broadcast Satellite\""
			//text_results.value = text_results.value + "\r\n\r\n IOSC \"INTERSPUTNIK\"   www.intersputnik.com"
		}
		
		
		
		function FormatDate(raw_date)
		{
			// + convert to strings
			var month = "" + (raw_date.getMonth() + 1);
			var day = "" + raw_date.getDate();
			    
			// apply two-digit format
			month = (month.length == 1) ? "0" + month + "/" : month + "/";
			day = (day.length == 1) ? "0" + day + "/" : day + "/";
			year = raw_date.getYear(); 
			   
			return day + month + year;
		}

		function FormatTime(raw_time)
		{
			//  + convert to srings
			var hours = "" + raw_time.getHours();
			var minutes = "" + raw_time.getMinutes();
			var seconds = "" + raw_time.getSeconds();
			
			// apply two digit format
			hours = (hours.length == 1) ? "0" + hours + ":" : hours + ":";
			minutes = (minutes.length == 1) ? "0" + minutes + ":" : minutes + ":";
			seconds = (seconds.length == 1) ? "0" + seconds : seconds;
			   
			return hours + minutes + seconds;
		}

		function FormatDuration(start_time, end_time)
		{
		
			var start_minutes = start_time.getMinutes();
			var start_seconds = start_time.getSeconds();
			   
			var end_minutes = end_time.getMinutes();
			var end_seconds = end_time.getSeconds();
			   
			var minute_correction = 0;
			   
			var duration_seconds = end_seconds - start_seconds;
			if (duration_seconds < 0)
			{
				duration_seconds += 60;
				minute_correction = 1;
			}
			   
			var duration_minutes = end_minutes - start_minutes - minute_correction;
			if (duration_minutes < 0)
				duration_minutes += 60;
			      
			// convert to strings
			duration_minutes += "";
			duration_seconds += "";
			
			// apply two-digit format
			duration_minutes = (duration_minutes.length == 1) ? "0" + duration_minutes + ":" : duration_minutes + ":";
			duration_seconds = (duration_seconds.length == 1) ? "0" + duration_seconds : duration_seconds;
			      
			return  duration_minutes + duration_seconds;
		}
		
		function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER 
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
