function checkForm(){

var frm = document.order;
	var error_msg = "";
	var re = new RegExp("^[A-Za-z0-9_|-]+([.]?[A-Za-z0-9_|-]+)+@[A-Za-z0-9|-]+([.][A-Za-z0-9|-]+)*[.][A-Za-z0-9]+$","ig");

	bDay = "";
	if (frm.CALC_BIRTHYEAR_BOX.value != "" && frm.CALC_BIRTHYEAR_BOX.value != 0) 
	bDay = bDay + frm.CALC_BIRTHYEAR_BOX.value;
	if (frm.CALC_BIRTHMONTH_BOX.value != "" && frm.CALC_BIRTHMONTH_BOX.value != 0) 
	bDay = bDay + frm.CALC_BIRTHMONTH_BOX.value;	
	if (frm.CALC_BIRTHDAY_BOX.value != "" && frm.CALC_BIRTHDAY_BOX.value != 0) 
	bDay = bDay + frm.CALC_BIRTHDAY_BOX.value;

	/* Extensive date check including check for leap year */

		sDay   = frm.CALC_BIRTHDAY_BOX.value;
		sMonth = frm.CALC_BIRTHMONTH_BOX.value;
		sYear  = frm.CALC_BIRTHYEAR_BOX.value;

		sDateError = false;
		isLeapYear = false;
		
		if ((sDay > 30) && (sMonth == 4 || sMonth == 6 || sMonth == 9 || sMonth == 11)) {
			sDateError = true;
		}

		if (sMonth == 2) {

			if (sYear % 4 == 0) {
				isLeapYear = true;
					
				if (sYear % 100 == 0) {
					isLeapYear = false;
						
					if (sYear % 400 == 0) {
						isLeapYear = true;
					}
				}
			}

			if ((sDay > 28 && isLeapYear == false) || (sDay > 29 && isLeapYear == true)) {
				sDateError = true;
			}
		}

		if (sDateError) {
			error_msg = error_msg + "\tBarnets födelsedata er fel\n";
		}

	// date check	
	today = new Date();
	todayYear = today.getFullYear()
	todayMonth = today.getMonth()
	todayDate = today.getDate()
	
	if (todayMonth >= 3){ // make date, nine months from now
		futureYear = todayYear+1
		futureMonth = (todayMonth+9)-12
		futureDate = todayDate
	} else { 
		futureYear = todayYear
		futureMonth = todayMonth+9
		futureDate = todayDate
	}
        

	if (todayMonth <= 5){ // make date, six months before now
		pastYear = todayYear-1
		pastMonth = (todayMonth-6)+11
		pastDate = todayDate
	} else { 
		pastYear = todayYear
		pastMonth = todayMonth-6
		pastDate = todayDate
	}

	pastDate   = new Date(pastYear, pastMonth, pastDate);
	futureDate = new Date(futureYear, futureMonth, futureDate);
	expectedDate = new Date(parseInt(frm.CALC_BIRTHYEAR_BOX.value), parseInt(frm.CALC_BIRTHMONTH_BOX.value)-1, parseInt(frm.CALC_BIRTHDAY_BOX.value));


	if( ( futureDate - expectedDate ) <= 0 || ( pastDate - expectedDate ) >= 0 ){
	        error_msg = error_msg + "\tBarnet beräknas födas\n";
	}
        
	if (error_msg != ""){
		alert("Kom ihåg att fylla i alla fält:    \n\n" + error_msg);
		return false;
	}	
	else {
		return true;
	}
}