
<!--

/* This script is slightly different from the one shown on this page. It doesn't
return any value, but instead writes the outcome of the check into the textarea. */

var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var monthLength2 = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function checkDateDouble(name, name2)
{
	var dateExists = true;
	var dateExists2 = true;
	var x = document.forms.rfp.elements;
	var day = parseInt(x[name+"_date"].options[x[name+"_date"].selectedIndex].value);
	var month = parseInt(x[name+"_month"].options[x[name+"_month"].selectedIndex].value);
	var year = parseInt(x[name+"_year"].options[x[name+"_year"].selectedIndex].value);
	var day2 = parseInt(x[name2+"_date"].options[x[name2+"_date"].selectedIndex].value);
	var month2 = parseInt(x[name2+"_month"].options[x[name2+"_month"].selectedIndex].value);
	var year2 = parseInt(x[name2+"_year"].options[x[name2+"_year"].selectedIndex].value);
	var x_msg = '';

	if (!day || !month || !year)
	{
		//alert('Please fill in a complete date');
		//return false;
		x_msg = "Please fill in a complete Event Start Date.";
		//exit;
	}else{
		if(!day2 || !month2 || !year2){
			x_msg = x_msg + "\nPlease fill in a complete Event End Date.";
			dateExists2 = false;
			
		}

	if (year/4 == parseInt(year/4))
		monthLength[1] = 29; // Means February

	if (day > monthLength[month-1])
		dateExists = false;

	monthLength[1] = 28; // Means February

	if (year2/4 == parseInt(year2/4))
		monthLength2[1] = 29; // Means February

	if (day2 > monthLength2[month2-1])
		dateExists2 = false;

	monthLength2[1] = 28; // Means February

	
	//document.forms[0].results.value = 'Date exists? ' + ((dateExists) ? 'Yes' : 'No') + '\n';
	if(dateExists==true){
	//if (!dateExists) return;

	var now = new Date();
	now = now.getTime(); //NN3

	var dateToCheck = new Date();
	dateToCheck.setYear(year);
	dateToCheck.setMonth(month-1);
	dateToCheck.setDate(day);
	var checkDate = dateToCheck.getTime();

	var futureDate = (now < checkDate);
	var pastDate = (now > checkDate);


		if(now == checkDate || now < checkDate){
			// Future
			//alert("<3");
			//document.forms[0].results.value = "<3";
		}else{
			// History
			//alert("Date earlier than today is not accepted. Please choose again.");
			//document.forms[0].results.value = "No common sense :(";
			//return false;
			x_msg = "Event Start Date earlier than today is not accepted. Please choose again.";
		}
	}else{
		//alert("Invalid date. Please choose again.");
		x_msg = "Invalid Event Start Date. Please choose again.";
		//document.forms[0].results.value = "Date doesnt exist :("; 
		//return false;
	}
	/*document.forms[0].results.value +=
		'In the future? '  + ((futureDate) ? 'Yes' : 'No') + '\n';

	document.forms[0].results.value +=
		'In the past? '  + ((pastDate) ? 'Yes' : 'No');*/
	//}


	if(dateExists2==true){
	//if (!dateExists) return;

	var now2 = new Date();
	now2 = now2.getTime(); //NN3

	var dateToCheck2 = new Date();
	dateToCheck2.setYear(year2);
	dateToCheck2.setMonth(month2-1);
	dateToCheck2.setDate(day2);
	var checkDate2 = dateToCheck2.getTime();

	/*var futureDate = (now < checkDate);
	var pastDate = (now > checkDate);*/


		if(now2 == checkDate2 || now2 < checkDate2){
			// Future
			//alert("<3");
			//document.forms[0].results.value = "<3";
		}else{
			// History
			//alert("Date earlier than today is not accepted. Please choose again.");
			//document.forms[0].results.value = "No common sense :(";
			//return false;
			x_msg = x_msg + "\nEvent End Date earlier than today is not accepted. Please choose again.";
		}
	}else{
		//alert("Invalid date. Please choose again.");
		if(x_msg!='\nPlease fill in a complete Event End Date.'){
			x_msg = "\nInvalid Event End Date. Please choose again.";
		}
		//document.forms[0].results.value = "Date doesnt exist :("; 
		//return false;
	}
	/*document.forms[0].results.value +=
		'In the future? '  + ((futureDate) ? 'Yes' : 'No') + '\n';

	document.forms[0].results.value +=
		'In the past? '  + ((pastDate) ? 'Yes' : 'No');*/
	//}
	
	}
	
	if(dateExists==true&&dateExists2==true){
		if (checkDate > checkDate2) {
			x_msg = "Event End Date cannot be earlier than Event Start Date.";
		}
	}
	
	if(x_msg!=''){
		alert(x_msg);
		return false;
	// }else{
	}

}

// -->
