$(document).ready(function () {
	var childs_dob_holder = "";
	var childs_name_holder = "";
	var childs_year_holder = "";
	var strTemp = "";
	var counter = 0;
	
	today = new Date();
	thisMonth = today.getMonth()+1;
	
	if (thisMonth == 1){
		thisMonth = "January";
	}else if (thisMonth == 2){
		thisMonth="February";
	}else if (thisMonth == 3){
		thisMonth="March";
	}else if (thisMonth == 4){
		thisMonth="April";
	}else if (thisMonth == 5){
		thisMonth="May";
	}else if (thisMonth == 6){
		thisMonth="June";
	}else if (thisMonth == 7){
		thisMonth="July";
	}else if (thisMonth == 8){
		thisMonth="August";
	}else if (thisMonth == 9){
		thisMonth="September";
	}else if (thisMonth == 10){
		thisMonth="October";
	}else if (thisMonth == 11){
		thisMonth="November";
	}else if (thisMonth == 12){
		thisMonth="December";
	};

	$('#birthdayList td.childs_dob').each(function() {
		strTemp=$(this).text();
		if (strTemp.indexOf(thisMonth) > -1){
			
			CDH = $(this).text();
			CDH = CDH.replace(/<div>/g,'');
			CDH = CDH.replace(/<\/div>/g,'');
			CDH = CDH.replace(/^\s*|\s*/g,'');
			
			CNH = $(this).siblings(".childs_name").text();
			CNH = CNH.replace(/<div>/g, "");
			CNH = CNH.replace(/<\/div>/g, "");
			CNH = CNH.replace(/^\s*|\s*/g,'');
			
			CYH = $(this).siblings(".childs_year").text();
			CYH = CYH.replace(/<div>/g, "");
			CYH = CYH.replace(/<\/div>/g, "");
			CYH = CYH.replace(/^\s*|\s*/g,'');
			
			childs_dob_holder = childs_dob_holder + (counter>0?'|':'') + CDH;
			childs_name_holder = childs_name_holder + (counter>0?'|':'') + CNH;
			childs_year_holder = childs_year_holder + (counter>0?'|':'') + CYH;
			counter++;
		};
	});
	
	var noRows = Math.ceil(counter/4);
	var swfHeight = (noRows*200)+40;

	var so = new SWFObject("/_includes/swf/bdbs.swf", "birthdayBalloons", "640", swfHeight, "8", ""); 
	so.addParam("wmode", "transparent");
	so.addVariable("childs_dob", childs_dob_holder);
	so.addVariable("childs_name", childs_name_holder);
	so.addVariable("childs_year", childs_year_holder);
//	so.addVariable("balloonColours", "eeeeee,cccccc");
	so.addParam("menu", "false");
	so.write("birthdayList");
	
	$('#birthdayList').before('<p>We would like to wish a warm and happy birthday to all of the children who have birthdays in <b>' + thisMonth + '</b></p>');
});

