function popupImgWin(url,w,h) 
{
  win = window.open('','popupWin','width=' + w + ',height=' + h + ',toolbars=0, statusbar=0, resizable=1');
  win.moveTo((screen.availWidth/2) - (w/2),(screen.availHeight/2) - (h/2));
  
  win.document.body.innerHTML = '';
  
  win.document.open();
  win.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3c.org/TR/xhtml11/DTD/xhtml11.dtd">');
  win.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">');
  win.document.writeln('<head>');
  win.document.writeln('	<title>Popup window</title>');
  win.document.writeln('	<style type="text/css">');
  win.document.writeln('		*, body { padding: 0; border: 0; margin: 0; text-align: center; height: 100%;}');
  win.document.writeln('		a {border :0; display: block; vertical-align: middle; height: 100%;}');
  win.document.writeln('		img {display: block; border :0; margin: auto; vertical-align: middle; height: auto;}');
  win.document.writeln('	</style>');
  win.document.writeln('</head>');
  win.document.writeln('<body style="padding: 0; border: 0; margin: 0; text-align: center;">');
  //win.document.writeln('	<a onclick="window.close();" href="#" title="close"><img src="'+ url +'" width="'+ w +'" height="'+ h +'" alt="popup image" /></a>');
  win.document.writeln('	<a onclick="window.close();" href="#" title="close"><img src="'+ url +'" alt="popup image" /></a>');
  win.document.writeln('</body>');
  win.document.writeln('</html>');
  win.document.close();
  
  return false;
}

function CheckBirthDate()
{
//debugger;
	var year  = document.getElementById("DateOfBirthYear");
	var month = document.getElementById("DateOfBirthMonth");
	var day   = document.getElementById("DateOfBirthDay");
	
	var dateField = document.getElementById("Date_ofBirth_iso");
	
	var yearStr = "";
	var monthStr = "";
	var dayStr = "";
	
	var message = 'Registration for kids under the age of 13 is under construction.  Please check back soon!';
	
	//if there is a classic dropdown date 
	if(year != null && month != null && day != null)
	{
		if(year.value != "0000" && month.value != "00" && day.value != "00")
		{
			yearStr = year.value;
			monthStr = month.value;
			dayStr = day.value;
		}
		else
		{
			alert('Date of Birth is required field.');
			return false;
		}
	}//if there is an Ektron calendar
	else if(dateField != null)
	{
		if(dateField.value != "")
		{
			yearStr = dateField.value.substr(0,4);
			monthStr = dateField.value.substr(5,2);
			dayStr = dateField.value.substr(8,2);
		}
		else
		{
			alert('Date of Birth is required field.');
			return false;
		}
	}//it seems that there is no birthdate field so just continue
	else
	{
		return true;
	}
		
	var today = new Date();
	var birthDate = new Date();
	
	birthDate.setFullYear(yearStr - 0);
	birthDate.setMonth(monthStr - 1);
	birthDate.setDate(dayStr - 0);
	birthDate.setHours(0);
	birthDate.setMinutes(0);
	birthDate.setSeconds(0);

	
	if(birthDate.getDate() != (dayStr - 0))
	{
		alert('Birthdate is invalid. Check it please.');
		return false;
	}

	var yearDiff = today.getFullYear() - birthDate.getFullYear();
	var monthDiff = today.getMonth() - birthDate.getMonth();
	var dayDiff = today.getDate() - birthDate.getDate();


	if(yearDiff < 13)
	{
		alert(message);
		return false;
	}
	else if(yearDiff == 13)
	{
		if(monthDiff < 0)
		{
			alert(message);
			return false;
		}
		else if(monthDiff == 0)
		{
			if(dayDiff < 0)
			{
				alert(message);
				return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}

	
	return true;	
}