﻿//////////////////// Agenda file for CalendarXP 9.0 /////////////////
// This file is totally configurable. You may remove all the comments in this file to minimize the download size.
/////////////////////////////////////////////////////////////////////

//////////////////// Define agenda events ///////////////////////////
// Usage -- fAddEvent(year, month, day, message, action, bgcolor, fgcolor, bgimg, boxit, html, etc);
// Note:
// 1. the (year,month,day) identifies the date of the agenda event.
// 2. the message param will be shown as tooltip and in the status bar.
// 3. setting the action param to null will disable that date with a line-through effect.
// 4. bgcolor is the background color.
// 5. fgcolor is the font color. Setting it to ""(empty string) will hide the date.
// 6. bgimg is the url of the background image file in use with the specific date.
// 7. if boxit is set other than false or null value, the date will be drawn in a box using boxit value as the color, or bgcolor if boxit is true.
// 8. html is the HTML string to be injected into the agenda cell, e.g. an <img> tag.
// 9. etc is any object you would like to associate with the date, so that you can retrieve it later via the fGetEvent().
// ** REMEMBER to unlock corresponding bits of the gAgendaMask option in the theme.
/////////////////////////////////////////////////////////////////////

// fAddEvent(2003,12,2," Click me to active your email client. ","popup('mailto:any@email.address.org?subject=email subject')","#87ceeb","dodgerblue",null,true);
// fAddEvent(2004,4,1," Let's google. ","popup('http://www.google.com','_top')","#87ceeb","dodgerblue",null,"gold");
// fAddEvent(2004,9,23, "Hello World!\nYou can't select me.", null, "#87ceeb", "dodgerblue");




///////////// Recurring Events /////////////////////////
// fHoliday() provides you a flexible way to create recurring events easily.
// Once defined, it'll be used by the calendar engine to render each date cell.
// An agenda array [message, action, bgcolor, fgcolor, bgimg, boxit, html, etc] 
// is expected as return value, which are similar to the params of fAddEvent().
// Returning null value will result in default style as defined in the theme.
// ** REMEMBER to unlock corresponding bits of the gAgendaMask option in the theme.
////////////////////////////////////////////////////////
function fHoliday(y,m,d) {
	var rE=fGetEvent(y,m,d), r=null;
	var yy=y, mm=m, dd=d; dni=10;
	var dzien_tyg=[2,4,5,6,7,2,3,4,5,7,1,2,3,5,6,7,1,3,4,5,6,1,2,3,4,6,7,1,2,4,5,6,7,2,3,4,5,7,1,2,3,5,6,7,1,3,4,5,6,1,2];
	
	var dzien_pocz = dzien_tyg[yy-1980];
	
	if (m==1)
		dni = dd;
	if (m==2)
		dni=dd+31;
	if (m==3)
		dni= dd+ 31+28;
	if (m==3&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))
		dni= dd+ 31+29;
	if (m==4)
		dni= dd+ 31+28+31;
	if (m==4&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31;
	if (m==5)
		dni= dd+ 31+28+31+30;	
	if (m==5&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30;
	if (m==6)
		dni= dd+ 31+28+31+30+31;
	if (m==6&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30+31;
	if (m==7)
		dni= dd+ 31+28+31+30+31+30;
	if (m==7&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30+31+30;
	if (m==8)
	 	dni= dd+ 31+28+31+30+31+30+31;
	if (m==8&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30+31+30+31;
	if (m==9)
		dni= dd+ 31+28+31+30+31+30+31+31;
	if (m==9&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30+31+30+31+31;
	if (m==10)
		dni= dd+ 31+28+31+30+31+30+31+31+30;
	if (m==10&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30+31+30+31+31+30;
	if (m==11)
		dni= dd+ 31+28+31+30+31+30+31+31+30+31;
	if (m==11&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30+31+30+31+31+30+31;
	if (m==12)
		dni= dd+ 31+28+31+30+31+30+31+31+30+31+30;
	if (m==12&&(y==1980||y==1984||y==1988||y==1992||y==1996||y==2000||y==2004||y==2008||y==2008||y==2012||y==2016||y==2020||y==2024||y==2028))

		dni= dd+ 31+29+31+30+31+30+31+31+30+31+30;


	var b_m, b_d, w_m, w_d;
	
	var bozecialoD=[5,18,10,2,21,6,29,18,2,25,14,30,18,10,2,15,6,29,11,3,22,14,30,19,10,26,15,7,22,11,3,23,7,20,19,4,26,15,31,20,11,3,16,8,30,19,4,27,15,31,20];
	var bozecialoM=[6,6,6,6,6,6,5,6,6,5,6,5,6,6,6,6,6,6,6,6,6,6,5,6,6,5,6,6,5,6,6,6,6,5,6,6,5,6,5,6,6,6,6,6,5,6,6,6,6,5,6];
	
	b_d=bozecialoD[y-1980];
	b_m=bozecialoM[y-1980];

	var wielkanocD=[6,19,11,3,22,7,30,19,3,26,15,31,19,11,3,16,7,30,12,4,23,15,31,20,11,27,16,8,23,12,4,24,8,31,20,5,27,16,1,21,12,4,17,9,31,20,5,28,16,1,21];
	var wielkanocM=[4,4,4,4,4,4,3,4,4,3,4,3,4,4,4,4,4,3,4,4,4,4,3,4,4,3,4,4,3,4,4,4,4,3,4,4,3,4,4,4,4,4,4,4,3,4,4,3,4,4,4];

	w_d=wielkanocD[y-1980];
	w_m=wielkanocM[y-1980];
	
	var x=(dni+dzien_pocz)%7;   ///0 sobota
		
	var dzien_10, dzien_15, dzien_20, dzien_25, dzien_28, dzien_31;


	if (d==11&&x==2)
		dzien_10=11;
	if (m==b_m && d==11 && b_d==10 &&x>2)
		dzien_10=11;
	if (d==12 && x==2)
		dzien_10=12;
	if (d==12 && x==3 && m==11)
		dzien_10=12;
	if (m==b_m && d==13 && b_d==10 &&x==2)
		dzien_10=13;
	if (d==10 &&x>1)
		dzien_10=10;
	
	if (d==16&&x==2)
		dzien_15=16;
	if (d==16&&x>2&&x<7&&m==8)
		dzien_15=16;
	if (m==b_m && d==16 && b_d==15 &&x>2)
		dzien_15=16;
	if (d==17 && x==2)
		dzien_15=17;
	if (d==18 && x==2 && m==8)
		dzien_15=18;
	if (m==b_m && d==19 && b_d==15 &&x==2)
		dzien_15=19;
	if (d==15 &&x>1)
		dzien_15=15;
	
	if (d==21&&x==2)
		dzien_20=21;
	if (m==b_m && d==21 && b_d==20 &&x>2)
		dzien_20=21;
	if (d==22 && x==2)
		dzien_20=22;
	if (m==b_m && d==23 && b_d==20 &&x==2)
		dzien_20=23;
	if (d==20 &&x>1)
		dzien_20=20;
	
	if (d==26&&x==2)
		dzien_25=26;
	if (m==b_m && d==26 && b_d==25 &&x>2)
		dzien_25=26;
	if (d==27 && x==2)
		dzien_25=27;
	if (d==27 && x>1 &&x<7 &&m==12)
		dzien_25=27;	
	if (d==28 && x==2&&m==12)
		dzien_25=28;
	if (d==29 && x==2&&m==12)
		dzien_25=29;
	if (m==b_m && d==28 && b_d==25 &&x==2)
		dzien_25=28;
	if (d==25 &&x>1)
		dzien_25=25;
	if(d==30 && m==1 && x==6)
		dzien_31=30;
	if(d==29 && m==1 && x==6)
		dzien_31=29;
	if(d==31 && m==1 && x>1)
		dzien_31=31;

	if(d==28 && m==2 && x>1)
		dzien_28=28;
	if(d==27 && m==2 && x==6)
		dzien_28=27;
	if(d==26 && m==2 && x==6)
		dzien_28=26;
	
	


	// you may have sophisticated holiday calculation set here, following are only simple examples.
	if (m==1&&d==1)
		r=["1 Stycznia "+y+" \n Szczęliwego Nowego Roku! ","gsAction","skyblue","red"];
	else if (m==5&&d==1)
		r=["Święto Państwowe",gsAction,"skyblue","red"];
	else if (m==5&&d==3)
		r=["Święto Narodowe Trzeciego Maja",gsAction,"skyblue","red"];
	else if (m==8&&d==15)
		r=["Święto wniebowzięcia Najświętszej Maryi Panny, \n Święto Wojska Polskiego",gsAction,"skyblue","red"];
	else if (m==11&&d==1)
		r=["Wszystkich Świętych ",gsAction,"skyblue","red"];
	else if (m==b_m&&d==b_d)
		r=["Boże Ciało",gsAction,"skyblue","red"];
	else if (m==w_m&&d==w_d)
		r=["Niedziela Wielkanocna",gsAction,"skyblue","red"];
	else if (m==w_m&&d==w_d+1)
		r=["Poniedziałek Wielkanocny",gsAction,"skyblue","red"];
	else if (m==11&&d==11)
		r=["Narodowe Święto Niepodległości ",gsAction,"skyblue","red"];
	else if (m==12&&d==25)
		r=["Święta Bożego Narodzenia",gsAction,"skyblue","red"];
	else if (m==12&&d==26)
		r=["Święta Bożego Narodzenia ",gsAction,"skyblue","red"];
	else if (d==dzien_10)
		r=[" ZUS – Jednoosobowa działalność gospodarcza, wspólnicy spółki cywilnej oraz wspólnicy spółek jawnych, nie zatrudniający pracowników.",onmousedown='parent.window.location = "kalendarz.html"',"#D1A41F","red"];
	else if (d==dzien_15)
		r=[" ZUS – Jednoosobowa działalność gospodarcza, wspólnicy spółki cywilnej oraz wspólnicy spółek jawnych, zatrudniający minimum jednego pracownika",onmousedown='parent.window.location = "kalendarz.html"',"#D17C5F","red"];
	else if (d==dzien_20)
		r=[" zaliczka na podatek dochodowy od osób fizycznych PIT-5, PIT-4 PIT-8AR, \n zryczałtowany podatek od osób fizycznych PPE, \n zaliczka na podatek dochodowy od osób prawnych CIT 2",onmousedown='parent.window.location = "kalendarz.html"',"#7CD956","red"];
        else if (d==dzien_25)
		r=[" zapłata podatku VAT-7",onmousedown='parent.window.location = "kalendarz.html"',"#7595FF","red"];
	
	else if (y==gToday[0]&&m==gToday[1]&&d==gToday[2])
		r=["",gsAction,"#AAAAAA","red"];
	else 
	r=["",onmousedown='parent.window.location = "kalendarz.html"',"#AAAAAA","red"];

        


	return rE?rE:r;	// favor events over holidays
}



