	function CheckNumeric()
{
   // Get ASCII value of key that user pressed
   var key = window.event.keyCode;

   // Was key that was pressed a numeric character (0-9)?
   if ( key > 47 && key < 58 )
      return; // if so, do nothing
   else
      window.event.returnValue = null; // otherwise, 
	                               // discard character
}


function check(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){
			return (false);
		}
	}
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);
		}
	}
}

function checkF(f){

	if(!check(frmAffiliate.Email.value)){
		alert("Invalid email address detected.");
		frmAffiliate.Email.focus();
		if(document.all || document.getElementById){
			frmAffiliate.Email.style.background = "lightblue";
		}
		return (false);
	}

	if(frmAffiliate.InstitutionName.value < 1 || frmAffiliate.InstitutionName.value == 'Institution-Name'){
		frmAffiliate.InstitutionName.focus();
		alert("Please enter your Institution Name");
		if(document.all || document.getElementById){
			frmAffiliate.InstitutionName.style.background = "lightblue";
		}
		return (false);
	}

//----------------------------------------------------------------------------------------
	if(frmAffiliate.EstablishMonth.value < 1 ){
		frmAffiliate.EstablishMonth.focus();
		alert("Please select Established Month");
		if(document.all || document.getElementById){
			frmAffiliate.EstablishMonth.style.background = "lightblue";
		}
		return (false);
	}

	if(frmAffiliate.EstablishDay.value < 1 ){
		frmAffiliate.EstablishDay.focus();
		alert("Please select Established Day");
		if(document.all || document.getElementById){
			frmAffiliate.EstablishDay.style.background = "lightblue";
		}
		return (false);
	}

	if(frmAffiliate.EstablishYear.value < 1 ){
		frmAffiliate.EstablishYear.focus();
		alert("Please select Established Year");
		if(document.all || document.getElementById){
			frmAffiliate.EstablishYear.style.background = "lightblue";
		}
		return (false);
	}
	
	if ( (lastDayOfMonth(document.frmAffiliate.EstablishMonth.selectedIndex,parseInt(document.frmAffiliate.EstablishYear.value)) < parseInt(document.frmAffiliate.EstablishDay.value)) ||  (parseInt(document.frmAffiliate.EstablishDay.value)<1) || isNaN(parseInt(document.frmAffiliate.EstablishDay.value)))
	{	
		document.frmAffiliate.EstablishDay.focus();
		alert ("Invalid Day of Date");
		if(document.all || document.getElementById){
			frmAffiliate.EstablishDay.style.background = "lightblue";
		}
		return (false);
	}
		
	if ( (lastDayOfMonth(document.frmAffiliate.EstablishMonth.selectedIndex,parseInt(document.frmAffiliate.EstablishYear.value)) < parseInt(document.frmAffiliate.EstablishDay.value)) ||  (parseInt(document.frmAffiliate.EstablishDay.value)<1) || isNaN(parseInt(document.frmAffiliate.EstablishDay.value)))
	{	
			document.frmAffiliate.EstablishDay.focus();
			alert ("Invalid Day of Date");
			if(document.all || document.getElementById){
				frmAffiliate.EstablishDay.style.background = "lightblue";
		}
		return (false);
	}

//----------------------------------------------------------------------------------------

	if(frmAffiliate.RegisteredStudent.value < 1 ){
		frmAffiliate.RegisteredStudent.focus();
		alert("Please enter no of registered student");
		if(document.all || document.getElementById){
			frmAffiliate.RegisteredStudent.style.background = "lightblue";
		}
		return (false);
	}
	
	
	if(frmAffiliate.FirstName.value < 1 || frmAffiliate.FirstName.value == 'First-Name'){
		frmAffiliate.FirstName.focus();
		alert("Please enter your First Name");
		if(document.all || document.getElementById){
			frmAffiliate.FirstName.style.background = "lightblue";
		}
		return (false);
	}

	if(frmAffiliate.Zip.value < 1 || frmAffiliate.Zip.value == 'Zip-Code'){
		frmAffiliate.Zip.focus();
		alert("Please enter your Zip code");
		if(document.all || document.getElementById){
			frmAffiliate.Zip.style.background = "lightblue";
		}
		return (false);
	}
	
	

	if ((frmAffiliate.Password.value) != (frmAffiliate.Password1.value)){
		frmAffiliate.Password1.focus();
		alert("Please enter Correct Password");
		if(document.all || document.getElementById){
			//frmAffiliate.Password.style.background = "lightblue";
			frmAffiliate.Password1.style.background = "lightblue";
		}
		return (false);
	}

/*
	if(frmAffiliate.EstablishMonth.value == 2 && frmAffiliate.EstablishDay.value > 29){
		frmAffiliate.EstablishDay.focus();
		alert("Please select correct Date");
		if(document.all || document.getElementById){
			frmAffiliate.EstablishDay.style.background = "lightblue";
		}
		return (false);
	}
*/

		
}

	function lastDayOfMonth(month,year) {
	m = new Array(12);
	m[0] = 31;				//jan
	m[1] = ((year%4)==0 ? 29 : 28 );	//feb	
	m[2] = 31;				//mar	
	m[3] = 30;				//apr
	m[4] = 31;				//may
	m[5] = 30;				//jun
	m[6] = 31;				//jul
	m[7] = 31;				//aug
	m[8] = 30;				//sep
	m[9] = 31;				//oct
	m[10] = 30;				//nov
	m[11] = 31;				//dec
	//m[12] = 30;				//dummy
	
	return m[month];
}

//window.defaultStatus = "Scripts that save you time and money";
