// Event Calendar
// copyright Stephen Chapman, 10th June 2006, 22nd January 2010


var headbg = '#';  // table heading background colour
var eventbg = '#4400ab'; // current selected date background colour
var todaybg = '#e8e7dd'; // current selected date background colour
var textclr = '#000000'; // text colour
var linkclr = '#ffffff'; // link text colour
var todayclr = '#000000'; // link text colour
var noMessage =  'No event messages to display for today'; // message to display when no entry in array
var noEventLink = '';

var dA = new Array(); var x = 0;

// first 8 characters in ccyymmdd format for single date events
// first 8 characters in 0000mmdd format for every year events

dA[x++] = "20101007 calhtml/ekim1.html";
dA[x++] = "20101009 calhtml/ekim9.html";
dA[x++] = "20101014 calhtml/ekim14.html";
dA[x++] = "20101021 calhtml/ekim21.html";
dA[x++] = "20101028 calhtml/ekim28.html";
dA[x++] = "20101104 calhtml/kasim4.html";
dA[x++] = "20101111 calhtml/kasim11.html";
dA[x++] = "20101125 calhtml/kasim25.html";
dA[x++] = "20101126 calhtml/kasim26.html";
dA[x++] = "20101202 calhtml/aralik2.html";
dA[x++] = "20101209 calhtml/aralik9.html";
dA[x++] = "20101210 calhtml/aralik10.html";
dA[x++] = "20101216 calhtml/aralik16.html";
dA[x++] = "20101217 calhtml/aralik17.html";
dA[x++] = "20101223 calhtml/aralik23.html";
dA[x++] = "20101224 calhtml/aralik24.html";
dA[x++] = "20101229 calhtml/aralik29.html";
dA[x++] = "20110106 calhtml/ocak6.html";
dA[x++] = "20110113 calhtml/ocak13.html";
dA[x++] = "20110120 calhtml/ocak20.html";
dA[x++] = "20110121 calhtml/ocak21.html";
dA[x++] = "20110125 calhtml/ocak25.html";
dA[x++] = "20110127 calhtml/ocak27.html";
dA[x++] = "20110128 calhtml/ocak28.html";
dA[x++] = "20110203 calhtml/subat3.html";
dA[x++] = "20110210 calhtml/subat10.html";
dA[x++] = "20110217 calhtml/subat17.html";
dA[x++] = "20110222 calhtml/subat22.html";
dA[x++] = "20110218 calhtml/subat18.html";
dA[x++] = "20110224 calhtml/subat24.html";
dA[x++] = "20110301 calhtml/mart1.html";
dA[x++] = "20110303 calhtml/mart3.html";
dA[x++] = "20110308 calhtml/mart8.html";
dA[x++] = "20110310 calhtml/mart10.html";
dA[x++] = "20110312 calhtml/mart12.html";
dA[x++] = "20110315 calhtml/mart15.html";
dA[x++] = "20110317 calhtml/mart17.html";
dA[x++] = "20110322 calhtml/mart22.html";
dA[x++] = "20110324 calhtml/mart24.html";
dA[x++] = "20110325 calhtml/mart25.html";
dA[x++] = "20110329 calhtml/mart29.html";
dA[x++] = "20110331 calhtml/mart31.html";
dA[x++] = "20110405 calhtml/nisan5.html";
dA[x++] = "20110407 calhtml/nisan7.html";
dA[x++] = "20110412 calhtml/nisan12.html";
dA[x++] = "20110414 calhtml/nisan14.html";
dA[x++] = "20110419 calhtml/nisan19.html";
dA[x++] = "20110421 calhtml/nisan21.html";
dA[x++] = "20110426 calhtml/nisan26.html";
dA[x++] = "20110428 calhtml/nisan28.html";
dA[x++] = "20110503 calhtml/mayis3.html";
dA[x++] = "20110505 calhtml/mayis5.html";
dA[x++] = "20110510 calhtml/mayis10.html";
dA[x++] = "20110512 calhtml/mayis12.html";
dA[x++] = "20110517 calhtml/mayis17.html";
dA[x++] = "20110519 calhtml/mayis19.html";
dA[x++] = "20110617 calhtml/haziran17.html";

dA[x++] = "20111004 calhtml/S12/ekim4.html";
dA[x++] = "20111014 calhtml/S12/ekim14.html";
dA[x++] = "20111020 calhtml/S12/ekim20.html";
dA[x++] = "20111027 calhtml/S12/ekim27.html";
dA[x++] = "20111103 calhtml/S12/kasim3.html";
dA[x++] = "20111117 calhtml/S12/kasim17.html";
dA[x++] = "20111124 calhtml/S12/kasim24.html";
dA[x++] = "20111125 calhtml/S12/kasim25.html";
dA[x++] = "20111202 calhtml/S12/aralik2.html";
dA[x++] = "20111206 calhtml/S12/aralik6.html";
dA[x++] = "20111208 calhtml/S12/aralik8.html";
dA[x++] = "20111215 calhtml/S12/aralik15.html";
dA[x++] = "20111219 calhtml/S12/aralik19.html";
dA[x++] = "20111222 calhtml/S12/aralik22.html";
dA[x++] = "20111227 calhtml/S12/aralik27.html";
dA[x++] = "20111229 calhtml/S12/aralik29.html";
dA[x++] = "20120105 calhtml/S12/ocak5.html";
dA[x++] = "20120110 calhtml/S12/ocak10.html";
dA[x++] = "20120112 calhtml/S12/ocak12.html";
dA[x++] = "20120119 calhtml/S12/ocak19.html";
dA[x++] = "20120120 calhtml/S12/ocak20.html";
dA[x++] = "20120126 calhtml/S12/ocak26.html";
dA[x++] = "20120127 calhtml/S12/ocak27.html";
dA[x++] = "20120202 calhtml/S12/subat2.html";
dA[x++] = "20120203 calhtml/S12/subat3.html";
dA[x++] = "20120209 calhtml/S12/subat9.html";
dA[x++] = "20120214 calhtml/S12/subat14.html";
dA[x++] = "20120216 calhtml/S12/subat16.html";
dA[x++] = "20120223 calhtml/S12/subat23.html";
dA[x++] = "20120301 calhtml/S12/mart1.html";
dA[x++] = "20120306 calhtml/S12/mart6.html";
dA[x++] = "20120308 calhtml/S12/mart8.html";
dA[x++] = "20120315 calhtml/S12/mart15.html";
dA[x++] = "20120320 calhtml/S12/mart20.html";
dA[x++] = "20120322 calhtml/S12/mart22.html";
dA[x++] = "20120329 calhtml/S12/mart29.html";
dA[x++] = "20120405 calhtml/S12/nisan5.html";
dA[x++] = "20120410 calhtml/S12/nisan10.html";
dA[x++] = "20120412 calhtml/S12/nisan12.html";
dA[x++] = "20120419 calhtml/S12/nisan19.html";
dA[x++] = "20120420 calhtml/S12/nisan20.html";
dA[x++] = "20120426 calhtml/S12/nisan26.html";
dA[x++] = "20120503 calhtml/S12/mayis3.html";
dA[x++] = "20120504 calhtml/S12/mayis4.html";
dA[x++] = "20120510 calhtml/S12/mayis10.html";
dA[x++] = "20120511 calhtml/S12/mayis11.html";
dA[x++] = "20120515 calhtml/S12/mayis15.html";
dA[x++] = "20120517 calhtml/S12/mayis17.html";
dA[x++] = "20120524 calhtml/S12/mayis24.html";
dA[x++] = "20120525 calhtml/S12/mayis25.html";
dA[x++] = "20120615 calhtml/S12/haziran15.html";



//dA[x++] = "00001206 St Nicholas' Day";
// dA[x++] = "20060610 New Event Calendar Started today";

// permission is granted to use this javascript provided that the below code is not altered
var pageLoaded = 0; window.onload = function() {pageLoaded = 1;
}
function loaded(i,f) {if (document.getElementById && document.getElementById(i) != null) f(); else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}
function monthlength(month,year) {var dd = new Date(year, month, 0);
return dd.getDate();
} 
var moy = ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Auğustos','Eylül','Ekim','Kasım','Aralık'];
var today = new Date();
var selDate = today.getFullYear()+getmmdd(today.getMonth()+1,today.getDate());
function dispCal(yy,mm) {
	if (mm < 0 || mm > 12) {
		alert('month must be between 1 and 12'); 
		return false;
	} 
if (yy != 0 && (yy < 1901 || yy > 2100)) {alert('year must be after 1900 and before 2101'); 
return false;
} 
var dow = ['Pzt','Sl','Çrş','Per','Cum','Cmt','Pzr']; 
var calendar = new Date();  var today = calendar.getDate(); calendar.setDate(1); 
if (yy > 1900) calendar.setFullYear(yy);
if (mm > 0) calendar.setMonth(mm - 1); 
var yy = year = calendar.getFullYear(); 
var month = calendar.getMonth(); 
calendar.setDate(today); 
var weekday = calendar.getDay(); 
var daysInMonth = monthlength(month+1,year); 
var hilite_start = '<td width="30" style="background:' + eventbg + '" align="center"><b>'; 
var current_start = '<td width="30" style="background:' + todaybg + '" align="center"><b>'; 
var td_start = '<td width="20" align="center">'; 
var cal = '<div style class="ana_fontgecici" id="cal"><div style="border:0pt solid #cccccc;width:238px"><table width=\"200\" border="0" cellspacing="1" cellpadding="2" align="center"><tr><td colspan="7" style="background:' + headbg + '" align="center"><b>' + moy[month]  + ' ' + year + '<\/b><\/td><\/tr><tr>'; 
for(dex=0; dex < 7; dex++) {
	cal += td_start + dow[dex] + '</td>';
} 
cal += '<\/tr><tr>'; 
var day2 = today; 
for (dex = today; dex > 6; dex -=7) 
	day2 = dex; 
weekday -= day2 ; 
while (weekday < 0) 
	weekday += 7; 
for(dex=0; dex < weekday; dex++) 
	cal += td_start + ' <\/td>'; 
for(dex=1; dex <= daysInMonth; dex++) {
	if(weekday == 7) {
		cal += '</tr><tr>'; 
		weekday = 0;
	} 
//	if(selDate==year+getmmdd(month+1,dex)) 
//		cal += hilite_start +'<span '+clickDate(dex,month,year) + '>'+ dex + '<\/span><\/b><\/td>'; 
//	else cal += td_start + '<span '+clickDate(dex,month,year) + '>' + dex + '<\/span><\/td>'; weekday += 1;

	if(selDate==year+getmmdd(month+1,dex)) 
		cal += current_start + '<span '+clickDate(dex,month,year) + '>' + dex + '<\/span><\/td>';
	else if (isEventDate(dex,month,year))
		cal += hilite_start +'<span '+clickDate(dex,month,year) + '>'+ dex + '<\/span><\/b><\/td>'; 
	else
		cal += td_start + '<span '+clickDate(dex,month,year) + '>' + dex + '<\/span><\/td>';
		
	weekday += 1;

} 
for(dex=weekday; dex < 7; dex++) cal += td_start + ' <\/td>'; cal += '<\/tr><\/table><\/div>';
if (document.getElementById) {var mmb = month;  mm = month + 1; 
var yya = yyb = yy; 
if (mmb <1) {mmb += 12; yyb--;
} 
var mma = month + 2; 
if (mma > 12) {mma -= 12; yya++;} var yb = yy -1; 
var ya = yy +1; 
cal += '<table border="0" cellspacing="0" cellpadding="2" width="200"><tr><td><a href="#" style class=\"SanatciLink\" onclick="if (cala = dispCal('+yyb+','+mmb+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">< Önceki</a></td><td align="right"><a href="#" style class=\"SanatciLink\" onclick="if (cala = dispCal('+yya+','+mma+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">Sonraki ></a></td></tr></table>';
} 
else {cal += '<div> </div>';
} 
cal += '</div>'; 
return cal;
}
function start() {
var y = dispCal(0,0);
document.getElementById('calendar').innerHTML = y; 
closestDate();
}
loaded('calendar',start);
function clickDate(day, month, year) {
	var ct = nextDate(year + getmmdd(month+1,day));
if (ct == '') 
	ct = nextDate('0000' + getmmdd(month+1,day));
var isCurrentDate = selDate==year+getmmdd(month+1,day)
var clr = (ct == '' ? (isCurrentDate ? todayclr : textclr) : linkclr)
if (ct == '') 
	return 'style="color:'+clr+'"'; 
else 
	return 'style="cursor:pointer;color:'+clr+'" onclick="isDate(' + day + ',' + month + ',' + year + ');return false;"';
}
function isEventDate(day, month, year){
var ct = nextDate(year + getmmdd(month+1,day));
if (ct == '') 
	ct = nextDate('0000' + getmmdd(month+1,day));
if (ct == '') 
	return false;
return true;
}
function isDate(dayVal,monthVal,yearVal) {
	var ct = nextDate(yearVal + getmmdd(monthVal+1,dayVal));
	if (ct == '') 
		ct = nextDate('0000' + getmmdd(monthVal+1,dayVal));
	if (ct == '') 
		ct = noMessage;
	displayDate(ct);
return false;
}
function displayDate(lnk){
		document.getElementById('calDate').innerHTML = "<iframe frameborder=\"0\" height=\"315\" width=\"322\" src=\""+lnk+"\"></iframe>"; 
}
function nextDate(yymmdd) {
	var x = dA.length;
	for (var i = 0; i < x; i++) {
		if (dA[i].substr(0,8) == yymmdd) 
		return dA[i].substr(8);
	}
	return '';
}
function closestDate(){
	var today = new Date();
	today.setHours(0,0,0,0);
	var x = dA.length;
	for (var i = 0; i < x; i++){
		if (dA[i].length < 8)
			continue;

		var year = parseFloat(dA[i].substring(0,4));
		if (year == 0)
			year = today.getFullYear();
		var month = parseFloat(dA[i].substring(4,6));
		month -= 1;
		var day = parseFloat(dA[i].substring(6,8));
		
	//	alert(year+' '+month+' '+day);
		
		var date = new Date(year,month,day);
		if (date >= today){
			displayDate(dA[i].substr(8));
			return dA[i].substr(8);
			
		}
	}
	displayDate(noEventLink);	
	return '';
}
function getmmdd(mm,dd) {return (mm > 9 ? '' + mm : '0' + mm) + (dd > 9 ? dd : '0' + dd);
}

