//calender script


var Days=new Array("Zo","Ma","Di","Wo","Do","Vr","Za");
var Maanden = new Array("Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
var Months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var NewCalender = 0

//number of days in a month
function numDaysIn(m,y) {
 if (m==3 || m==5 || m==8 || m==10) return 30;
 else if ((m==1) && leapYear(y)) return 29;
 else if (m==1) return 28;
 else return 31;
}

//check fo leapyear
function leapYear(y) {
 if (((y % 4 == 0) && y % 100 != 0) || y % 400 == 0)
  return true;
 else
  return false;
}

//fullyerbugfix for netscape 2 and 3
function getFullYear(d){
 yr = d.getYear();
 if (yr < 1000)
	yr+=1900;
 return yr;
}



//check fo an entry
function checkIt(cla,y,m,d){
	for (z=0;z<maxlink;z++){
		if (links[z].cl==cla){
			if (eval(d)==0){
				if ((links[z].year==y) && (links[z].month==eval(m))){
					return z;
				}
			}else{
				if ((links[z].year==y) && (links[z].month==eval(m)) && (links[z].day==eval(d))){
					return z;
				}
			}
		}
	}
	return -1;
}

//drawing the calendar
function DrawCalender(){
	var begin = new Date(Months[currMo]+" 1,"+currYr);
	var firstday = begin.getDay();
	var nodays = numDaysIn(currMo,currYr);
	if (currMo==11){
		var nonmonth= numDaysIn(0,currYr+1);
	}else{
		var nonmonth= numDaysIn(currMo+1,currYr);
	}
	if (currMo==0){
		var nopmonth= numDaysIn(11,currYr-1);
	}else{
		var nopmonth= numDaysIn(currMo-1,currYr);
	}
	var o = 0;
	var item;
	var strHTML="";

	strHTML+='<html><head>\n';
	strHTML+='<LINK HREF="/style/calender.css" TITLE="Janvier huisstijl" TYPE="text/css" REL=stylesheet>\n';
	strHTML+='</head><body leftmargin=5 topmargin=5 marginheight=5 marginwidth=5>\n';
	strHTML+='<table border=0 width="100%" height="100%" cellpadding=0 cellspacing=0>\n';
	strHTML+='<tr><td valign=top>\n';
	strHTML+='<img src="/images/banners/agenda.png" alt="Agenda">\n';
	strHTML+='</td></tr>\n';
	strHTML+='<tr><th><h3>' + Maanden[currMo] + " " + currYr + '</h3></th></tr>\n';
	strHTML+='<tr><td><table border=0 width="100%" height="100%" cellpadding=0 cellspacing=0>\n';
	strHTML+='<tr>\n';

	for (i=0;i<Days.length;i++){
		strHTML+='<th width=15>';
		strHTML+=Days[eval(i)];
		strHTML+='</th>\n';
	}
	strHTML+='</tr>\n';
	for (i=0;i<6;i++){
		strHTML+='<tr height=20>\n';
		for (a=0;a<7;a++){
			//strHTML+=);
			if (o >= firstday && o < nodays + firstday){
				item=checkIt('agenda',currYr,eval(currMo+1),eval(o) - firstday + 1)
				if(item==-1){
					strHTML+='<td width=15 align=center>' + (eval(o) - firstday + 1);
				}
				else{
					strHTML+='<td class="Item" width=15 align=center><A STYLE="width:100%;" HREF="javascript:parent.WriteItem(\'agenda\',' + currYr + ',' + eval(currMo+1) + ',' + (eval(o) - firstday + 1) +');">' + (eval(o) - firstday + 1) + '</A>';
					//strHTML+='<td class="Item"><A STYLE="width:100%;" TARGET="Inhoud" HREF="#" onClick("parent.Inhoud.document.location.href=\'#' + currYr + "-" + eval(currMo+1) + "-" + (eval(o) - firstday + 1) +'\';")>' + (eval(o) - firstday + 1) + '</A>');
				}
			}
			else if(o<firstday){
				strHTML+='<td class="Other" width=15 align=center>' + (nopmonth + eval(o) - firstday + 1);
			}else{
				strHTML+='<td class="Other" width=15 align=center>' + (o-nodays-firstday+1);
			}			
			strHTML+='</td>\n';
			o++
		}
		strHTML+='</tr>\n';
	}
	strHTML+='</table>\n';
	strHTML+='</td></tr>\n';
	strHTML+='<TR><TD VALIGN=TOP height="100%"><CENTER><HR>\n';
	strHTML+='<form action="none" name="chooseMonthForm">\n';
	strHTML+='Maand: <BR>\n';
	//strHTML+='<a href="javascript:parent.prevMonth()"><IMG SRC="/images/buttons/leftarr.gif" alt="<|" border="0" NAME="leftarr1" onMouseOver="swapleft(\'\',\'leftarr1\',\'\' );" onMouseOut="swapleft(\'\',\'leftarr1\',\'1\');"></a>\n';
	strHTML+='<a href="javascript:parent.prevMonth()"><IMG SRC="/images/buttons/leftarr.gif" alt="<|" border="0" NAME="leftarr1"></a>\n';
	strHTML+='<select name="maandKeuze" onChange="parent.goMonth(self.document.chooseMonthForm.maandKeuze.selectedIndex);">\n';
	for (i=0;i < 12;i++){
		if (i != currMo){
			strHTML+='<option value="' + i + '">' + Maanden[i] + '</option>\n';
		}
		else{
			strHTML+='<option selected value="' + i + '">' + Maanden[i] + '</option>\n';
		}
	}
	strHTML+='</select>\n';
//	strHTML+='<a href="javascript:parent.nextMonth();"><IMG SRC="/images/buttons/rightarr1.gif" alt="|>" border="0" NAME="rightarr1" onMouseOver="swapright(\'\',\'rightarr1\',\'\' );" onMouseOut="swapright(\'\',\'rightarr1\',\'1\');"></a>\n';
	strHTML+='<a href="javascript:parent.nextMonth();"><IMG SRC="/images/buttons/rightarr.gif" alt="|>" border="0" NAME="rightarr1"></a><BR>\n';

//	strHTML+='<a href="javascript:parent.prevYear()"><IMG SRC="/images/buttons/leftarr1.gif" alt="<|" border="0" NAME="leftarr2" onMouseOver="swapleft(\'\',\'leftarr2\',\'\' );" onMouseOut="swapleft(\'\',\'leftarr2\',\'1\');"></a>\n';
	strHTML+='<a href="javascript:parent.prevYear()"><IMG SRC="/images/buttons/leftarr.gif" alt="<|" border="0" NAME="leftarr2"></a>\n';
	strHTML+=currYr + '\n';
	//strHTML+='<select name="jaarKeuze" onChange="parent.goYear(self.document.chooseMonthForm.jaarKeuze.value);">\n';
	//for (a=currYr-1;a < currYr+2;a++){
	//	if (a != currYr){
	//		strHTML+='<option value="' + a + '">' + a + '</option>\n';
	//	}
	//	else{
	//		strHTML+='<option selected value="' + a + '">' + a + '</option>\n';
	//	}
	//}
	//strHTML+='</select>\n';
	strHTML+='<a href="javascript:parent.nextYear()"><IMG SRC="/images/buttons/rightarr.gif" alt="|>" border="0" NAME="rightarr2"></a>\n';
//	strHTML+='<a href="javascript:parent.nextYear()"><IMG SRC="/images/buttons/rightarr1.gif" alt="|>" border="0" NAME="rightarr2" onMouseOver="swapright(\'\',\'rightarr2\',\'\' );" onMouseOut="swapright(\'\',\'rightarr2\',\'1\');"></a>\n';
	strHTML+='</form><hr>\n';
	strHTML+='Gebruik <IMG SRC="/images/buttons/leftarr.gif" alt="<==" border="0"> of <IMG SRC="/images/buttons/rightarr.gif" alt="==>" border="0"> om de kalender te wijzigen en volg de \n';
	strHTML+=' links om te zien wat er te doen is.\n';
	strHTML+='</CENTER></TD></TR>\n';
	strHTML+='</table>\n';
	strHTML+='</body></html>\n';
	
	Kalender.document.open();
	Kalender.document.write(strHTML);
	Kalender.document.close();
	
	if (NewCalender == 0){
		if (loc!="" && loc!="http://www.janvierdancemasters.nl/actueel/agenda.html"){
			WriteItem('agenda',currYr,eval(currMo+1),currDy)
		}else{
			if (checkIt('agenda',currYr,eval(currMo+1),0) != -1){
				
				WriteItems('agenda',currYr,eval(currMo+1))
			}else{
				WriteBlank();
			}
		}
	}else{
		if (checkIt('agenda',currYr,eval(currMo+1),0) != -1){
			WriteItems('agenda',currYr,eval(currMo+1))
		}else{
			WriteBlank();
		}
	}
	NewCalender = 1
	
}

//move up a year
function nextYear(){
	currYr++;
	DrawCalender();
}

//move down a year
function prevYear(){
	currYr--;
	DrawCalender();
}

//move up a month
function nextMonth(){
	currMo++;
	if(currMo>11){
		currMo-=12;
		nextYear();
	}
	else{
		DrawCalender();
	}
}

//move down a month
function prevMonth(){
	currMo--;
	if(currMo<0){
		currMo+=12;
		prevYear();
	}
	else{
		DrawCalender();
	}
}

function goMonth(Maand){
	currMo=Maand;
	DrawCalender();
}

function goYear(Jaar){
	currYr=Jaar;
	DrawCalender();
}


//write an item
function WriteItems(cla,y,m){
	var strHTML="";
	
	strHTML+='<html>\n<head>';
	strHTML+='<BASE TARGET="content">';
	strHTML+='<LINK HREF="/style/calender.css" TITLE="janvier huisstijl" TYPE="text/css" REL=stylesheet>';	
	strHTML+='</head>\n';
	strHTML+='<body bgcolor="#ffffff"  leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">';
	strHTML+='<table border=0 width="100%" height="100%" cellpadding=0 cellspacing=0>';
	for (x=maxlink-1;x>-1;x--){
		if (links[x].cl==cla){
			if ((links[x].year==y) && (links[x].month==eval(m))){
				strHTML+='<tr><th valign=top>' + links[x].day + ' ' + Maanden[eval(links[x].month -1)] + ' ' + links[x].year + ': ' + links[x].title + '</th></tr>\n';
				strHTML+='<tr><td valign=top CLASS="Contents">' + links[x].cont + '</td></tr>';
				strHTML+='<tr><th class="bottom"></th></tr>\n';
				strHTML+='<tr><td class="white">&nbsp;</td></tr>';
			}
		}
	}
	strHTML+='<tr><td height="100%"></td></tr></table>';
	strHTML+='</body>\n</html>';
	self.Inhoud.document.open();
	self.Inhoud.document.write(strHTML);
	self.Inhoud.document.close();
}

function WriteItem(cla,y,m,d){
	var strHTML="";
	strHTML+='<html>\n<head>';
	strHTML+='<BASE TARGET="content">';
	strHTML+='<LINK HREF="/style/calender.css" TITLE="janvier huisstijl" TYPE="text/css" REL=stylesheet>';	
	strHTML+='</head>\n';
	strHTML+='<body bgcolor="#ffffff"  leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">';
	strHTML+='<table border=0 width="100%" height="100%" cellpadding=0 cellspacing=0>';
	for (x=0;x<maxlink;x++){
		if (links[x].cl==cla){
			if ((links[x].year==y) && (links[x].month==eval(m))&& (links[x].day==eval(d))){
				strHTML+='<tr><th valign=top>' + links[x].day + ' ' + Maanden[eval(links[x].month -1)] + ' ' + links[x].year + ': ' + links[x].title + '</th></tr>\n';
				strHTML+='<tr><td valign=top CLASS="Contents">' + links[x].cont + '</td></tr>';
				strHTML+='<tr><th class="bottom"></th></tr>\n';
				strHTML+='<tr><td class="white">&nbsp;</td></tr>';
			}
		}
	}
	strHTML+='<tr><td height="100%"></td></tr></table>';
	strHTML+='</body>\n</html>';
	Inhoud.document.open();
	Inhoud.document.write(strHTML);
	Inhoud.document.close();
}
function WriteBlank(){
	var strHTML="";
	strHTML+='<html>\n<head>';
	strHTML+='<BASE TARGET="content">';
	strHTML+='<LINK HREF="/style/calender.css" TITLE="janvier huisstijl" TYPE="text/css" REL=stylesheet>';	
	strHTML+='</head>\n';
	strHTML+='<BODY bgcolor="#ffffff"  leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">';
	strHTML+='<table border=0 width="100%" height="100%" cellpadding=0 cellspacing=0>';
	strHTML+='<tr height="100%"><td height="100%">&nbsp;</td></tr></table>';
	strHTML+='</body>\n</html>';
	Inhoud.document.open();
	Inhoud.document.write(strHTML);
	Inhoud.document.close();
}