datum = new Date();
  with(datum){
  h = getHours();
  n = getMinutes();
  s = getSeconds();


  d = getDate();
  m = getMonth()+1;
  if (document.all)
  r = getYear()
  else r = getYear() + 1900


  

  }

  function cass(){

  datum = new Date();
  with(datum)
	{
  	current_year = getUTCFullYear();
  	start_day = (31 - ((((5 * current_year) / 4) + 4) % 7));
  	SUMMER_start = new Date(Date.UTC(current_year,2,start_day,1,0,0));
  	end_day = (31 - ((((5 * current_year) / 4) + 1) % 7)); 
  	SUMMER_end = new Date(Date.UTC(current_year,9,end_day,1,0,0)); 
  	if (datum > SUMMER_start && datum < SUMMER_end) bst_or_gmt = "letní";
 	else bst_or_gmt = "zimní"; 
 	}
}



  function DegreeToRadian(angle)
        {
            return Math.PI * angle / 180.0;
        }

  function RadianToDegree(angle)
        {
            return angle * (180.0 / Math.PI);
        }
 
  
  function vychod(){
  latitude= 49.1833;
  longitude=16.6;
  
  zenith= 90.83;

  N1=Math.floor(275*m/9);
  N2 = Math.floor((m + 9) / 12);
  N3 = (1 + Math.floor((r - 4 * Math.floor(r / 4) + 2) / 3));
  N = N1 - (N2 * N3) + d - 30;

  lngHour = longitude / 15;
  t = N + ((6 - lngHour) / 24);
  M = (0.9856 * t) - 3.289;
  L = M + (1.916 * Math.sin(DegreeToRadian(M))) + (0.020 * Math.sin(2 * DegreeToRadian(M))) + 282.634;
  L = L-360;
  RA = Math.atan((0.91764 * Math.tan(DegreeToRadian(L))));
  RA = RadianToDegree(RA);
  Lquadrant  = (Math.floor( L/90)) * 90;
  RAquadrant = (Math.floor(RA/90)) * 90;
  RA = RA + (Lquadrant - RAquadrant);
  RA = RA / 15;
  sinDec = 0.39782 * Math.sin(DegreeToRadian(L));
  cosDec = Math.cos(Math.asin(sinDec));
  cosH = (Math.cos(DegreeToRadian(zenith)) - (sinDec * Math.sin(DegreeToRadian(latitude)))) / (cosDec * Math.cos(DegreeToRadian(latitude)));
  H = 360 - RadianToDegree(Math.acos(cosH));
  H = H / 15;
  T = H + RA - (0.06571 * t) - 6.622;
  UT = T - lngHour;
  localT = UT + 1;
  if (localT < 0) { localT = localT + 24; }


  return localT
  }

  function zapad(){
  latitude= 49.1833;
  longitude=16.6;
  
  zenith= 90.83;

  N1=Math.floor(275*m/9);
  N2 = Math.floor((m + 9) / 12);
  N3 = (1 + Math.floor((r - 4 * Math.floor(r / 4) + 2) / 3));
  N = N1 - (N2 * N3) + d - 30;

  lngHour = longitude / 15;
  t1 = N + ((6 - lngHour) / 24);
  M1 = (0.9856 * t1) - 3.289;
  L1 = M1 + (1.916 * Math.sin(DegreeToRadian(M1))) + (0.020 * Math.sin(2 * DegreeToRadian(M1))) + 282.634;
  L1 = L1-360;
  RA1 = Math.atan((0.91764 * Math.tan(DegreeToRadian(L1))));
  RA1 = RadianToDegree(RA1);
  Lquadrant1  = (Math.floor( L1/90)) * 90;
  RAquadrant1 = (Math.floor(RA1/90)) * 90;
  RA1 = RA1 + (Lquadrant1 - RAquadrant1);
  RA1 = RA1 / 15;
  sinDec1 = 0.39782 * Math.sin(DegreeToRadian(L1));
  cosDec1 = Math.cos(Math.asin(sinDec1));
  cosH1 = (Math.cos(DegreeToRadian(zenith)) - (sinDec1 * Math.sin(DegreeToRadian(latitude)))) / (cosDec1 * Math.cos(DegreeToRadian(latitude)));
  H1 = RadianToDegree(Math.acos(cosH1));
  H1 = H1 / 15;
  T1 = H1 + RA1 - (0.06571 * t1) - 6.622;
  UT1 = T1 - lngHour;
  localT1 = UT1 + 1;
  localT1 = 24 + localT1;
  if (localT1 > 24) { localT1 = localT1 - 24; }


  return localT1
  }



function slunce(){

datum = new Date();
with(datum){

h = getHours();
n = getMinutes();
s = getSeconds();


d = getDate();
m = getMonth()+1;
if (document.all)
r = getYear()
else r = getYear() + 1900
}



vysl=vychod();
hod=Math.floor(vysl);
if(bst_or_gmt=="letní") hod = hod +1;
min=Math.floor(60*(vysl%1));
if (min < 10){
min = "0" + min
}


vysl2= zapad();
hod2=Math.floor(vysl2);
if(bst_or_gmt=="letní") hod2 = hod2 +1;
min2=Math.floor(60*(vysl2%1));
if (min2 < 10){
min2 = "0" + min2
}

var hh=0;
var mm=0;


if((hod-h)<0){
vych_hh = -1*(hod - h);
vych_mm = -1*(min - n);
if(vych_mm<0){vych_hh=vych_hh-1; vych_mm=60+vych_mm;}
//if (vych_mm < 10){vych_mm = "0" + vych_mm; }
vych_stav ="před";
vych_hod =" hodinami ";
vych_min =" minutami ";
}

else if((hod-h)==0){
	if((min - n)<0){
	vych_hh = (hod - h);
	vych_mm = -1*( min - n); vych_stav ="před";
        vych_hod =" hodinami ";
	vych_min =" minutami ";   
	}

	else{
	vych_hh = (hod - h);
	vych_mm = ( min - n); vych_stav ="za";
	vych_hod =" hodin ";
	vych_min =" minut "; 
	}
        //if (vych_mm < 10){vych_mm = "0" + vych_mm; }
}

else{
vych_hh = (hod - h);
vych_mm = (min - n);
if(vych_mm<0){vych_hh=vych_hh-1; vych_mm=60+vych_mm;}
//if (vych_mm < 10){vych_mm = "0" + vych_mm; }
vych_stav ="před";
vych_hod =" hodinami ";
vych_min =" minutami ";
}





if((hod2-h)>0){
zap_hh = (hod2 - h);
zap_mm = ( min2 - n);
if(zap_mm<0){zap_hh=zap_hh-1; zap_mm=60+zap_mm;}
//if (zap_mm < 10){zap_mm = "0" + zap_mm; }
zap_stav ="za";
zap_hod =" hodin ";
zap_min =" minut ";
}

else if((hod2-h)==0){
	if((min2 - n)<0){
	zap_hh = (hod2 - h);
	zap_mm = -1*( min2 - n); zap_stav ="před";
        zap_hod =" hodinami ";
	zap_min =" minutami ";   
	}

	else{
	zap_hh = (hod2 - h);
	zap_mm = ( min2 - n); zap_stav ="za";
	zap_hod =" hodin ";
	zap_min =" minut "; 
	}
        //if (zap_mm < 10){zap_mm = "0" + zap_mm; }
}

else{
zap_hh = -1*(hod2 - h);
zap_mm = -1*(min2 - n);
if(zap_mm<0){zap_hh=zap_hh-1; zap_mm=60+zap_mm;}
//if (zap_mm < 10){zap_mm = "0" + zap_mm;}
zap_stav ="před";
zap_hod =" hodinami ";
zap_min =" minutami ";
}

}   //slunce
