var month=new Array(12);
month[0]="Januar";
month[1]="Februar";
month[2]="M&auml;rz";
month[3]="April";
month[4]="Mai";
month[5]="Juni";
month[6]="Juli";
month[7]="August";
month[8]="September";
month[9]="Oktober";
month[10]="November";
month[11]="Dezember";

$(document).ready(function(){
	$('#submenu li.li_act_l1 li:last a').css("border-bottom","1px solid #fc0");
	$('#submenu li.li_act_l2 li:last a').css("padding-bottom","15px");
	$('#submenu li.li_act_l3 li:last a').css("padding-bottom","12px");
	$('#col2 .teaser:last').css("border-top","0px solid red");
	$('#col2 .teaser:last').css("border-top","1px solid red");

	if ($('div.csc-header-n1').next().attr('class') == 'csc-subheader csc-subheader-0') {
		$('p.csc-subheader-0').addClass('csc-firstHeader');
		$('div.csc-header-n1 h1.csc-firstHeader').css('margin-bottom','2px')
	}
	if ($('p.csc-subheader-0').html() == null && $('div.indikationen-wrap').html() != null) {
		$('div.indikationen-wrap').css('margin-top','44px');
	}

/*	$('#submenu').find('a.li_shortcut').each(function(i) {
		$(this).click(function(i) {
			if ($(this).text() == 'RehaCentrum Hamburg') {
				$(this).attr('href',"javascript:void(0);");
				$(this).attr('href',"javascript:window.open('index.php?id=reha_visit','','width=952,height=595');");
				$(this).attr("onclick","window.open('index.php?id=reha_visit','','width=952,height=595');return false;");
			} else if ($(this).text() == 'Klinikum Bad Bramstedt') {
				$(this).attr('href',"javascript:void(0);");
				$(this).attr('onclick',"window.open('index.php?id=kbb_visit','','width=952,height=595');");
			} else if ($(this).text() == 'FitnessClinic Bad Bramstedt' || $(this).text() == 'FitnessClinic') {
				$(this).attr('href',"javascript:void(0);");
				$(this).attr('onclick',"window.open('index.php?id=fitness_visit','','width=952,height=595');");
			}
		});
	});*/

	$('table.vcard-tbl2 tr.tr-telefon').find('td:last-child').each(function(i) {
		if ($(this).html() == '') {
			$(this).parent().css('display','none');
		}
	});
	$('table.vcard-tbl2 tr.tr-fax').find('td:last-child').each(function(i) {
		if ($(this).html() == '') {
			$(this).parent().css('display','none');
		}
	});
	$('table.vcard-tbl2 tr.tr-email').find('td:last-child').each(function(i) {
		if ($(this).html() == '') {
			$(this).parent().css('display','none');
		}
	});

	$('#sidesearch input').attr('value',"Suche");
	$('#sidesearch input').attr('onfocus',"if (this.value=='Suche') this.value='';");
	$('#sidesearch input').attr('onblur',"if (this.value=='') this.value='Suche';");

	/// Cal
	checkyear = '';
	$('.cal-list-date').find('.list-startdate').each(function(i) {
		thestr = $(this).html();
/*		theyear = thestr.substr(-4,4);
		themonth = thestr.substr(-7,2);*/
		theyear = thestr.substring(12,16);
		themonth = thestr.substring(9,11);
		thedate = new Date(theyear,themonth-1,1);
		parenttbl = $(this).parents('.cal-list-table');
//		alert(thestr + ' - ' + theyear +' - ' + thedate.getMonth());
		if (checkyear != theyear) {
			$(this).parents('tr').before('<tr class="year-insert"><td colspan="5"><h2>'+theyear+'</h2></td></tr>');
			checkmonth = '';
		}
		if (checkmonth != themonth) {
			$(this).parents('tr').before('<tr class="month-insert"><td colspan="5"><h4>'+month[thedate.getMonth()]+'</h4></td></tr>');
		}
		checkyear = theyear;
		checkmonth = themonth;
//		parenttbl.siblings('.cal-list-year').html('<h2>'+theyear+'</h2>');
	});
	$('.cal-list-table').find('.cal-list-anm').each(function(i) {
		anm_link = $(this).html();
//		if (parseInt(anm_link) != 0) {
		if (anm_link != '') {
//			$(this).html('<a href="index.php?id='+anm_link+'">Anmeldung</a>');
				$(this).html('<i>erforderlich</i>');
		} else {
			//alert($(this).prev('.csc-uploads-fileName').html());
			//alert($(this).prev('td').find('.csc-uploads-fileName:contains("Anmeld")').html());
			if ($(this).prev('td').find('.csc-uploads-fileName:contains("Anmeld")').html() != null || $(this).prev('td').find('.csc-uploads-fileName:contains("anmeld")').html() != null) {
				$(this).html('<i>erforderlich</i>');
			} else {
				$(this).html('<i>nicht erforderlich</i>');
			}
		}
	});
	$('.cal-list-table').find('.cal-list-info').each(function(i) {
		info_link = $(this).text();
		if (info_link != '') {
			if (!parseInt(info_link)) {
				$(this).html('<a href="http://'+info_link+'" target="_blank">'+info_link+'</a>');
			} else {
				$(this).html('<a href="index.php?id='+info_link+'" target="_blank">Mehr Infos</a>');
			}
		} else {
			$(this).html('-');
		}
	});

});

