// JavaScript Document
<!--
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
//################################################
//FUNCTION TO VALIDATE FORM
//################################################
function checkrequired(which){
	

	
	if ((which.title.value =="") || (which.title.value !=""))
    {
        alert("You must select one of the links above" +
			  "\nThat is select either" +
			  "\nSINLGE EVENT" +
			  "\nMONTHLY EVENT" +
			  "\nOR WEEKLY EVENT"); 
        which.title.focus();
        return false;
    }
	

	/*if ((which.start_day.value =="") || (which.start_month.value =="") || (which.start_year.value ==""))
    {
        alert("The Start date is required"); 
        which.title.focus();
        return false;
    }*/
    return true;
}
//#########################################################################################
//-->

//################################################
//FUNCTION TO VALIDATE FORM IF SINGLE MONTH 
//################################################
function checkrequiredsingle(which){
	
	if (which.title.value =="")
    {
        alert("Please Enter a Title, you cannot proceed without it:"); 
        which.title.focus();
        return false;
    }
	
	if (which.author.value =="")
    {
        alert("The author field is required"); 
        which.author.focus();
        return false;
    }
	
	if ((which.dd.value =="") || (which.mm.value =="") || (which.yy.value ==""))
    {
        alert("The Start date is required"); 
        which.dd.focus();
        return false;
    }
	
	if ((which.enddd.value =="") || (which.endmm.value =="") || (which.endyy.value ==""))
    {
        alert("The End date is required"); 
        which.enddd.focus();
        return false;
    }
    return true;
}
//#########################################################################################
//-->


//################################################
//FUNCTION TO VALIDATE FORM IF MONTHlyy 
//################################################
function checkrequiredmonthly(which){
	
	if (which.title.value =="")
    {
        alert("Please Enter a Title, you cannot proceed without it:"); 
        which.title.focus();
        return false;
    }
	
	if (which.author.value =="")
    {
        alert("The author field is required"); 
        which.author.focus();
        return false;
    }
	
	if (which.dayevent.value =="")
    {
        alert("You have not selected the day of the event"); 
        which.dayevent.focus();
        return false;
    }
	
	if (which.monthevent.value =="")
    {
        alert("You have not selected the month this event ends"); 
        which.monthevent.focus();
        return false;
    }
    return true;
}
//#########################################################################################
//-->

//################################################
//FUNCTION TO VALIDATE FORM IF WEEKLY 
//################################################
function checkrequiredweeks(which){
	
	if (which.title.value =="")
    {
        alert("Please Enter a Title, you cannot proceed without it:"); 
        which.title.focus();
        return false;
    }
	
	if (which.author.value =="")
    {
        alert("The author field is required"); 
        which.author.focus();
        return false;
    }
	
	if (which.weekly.value =="")
    {
        alert("You have not selected the day of the event"); 
        which.weekly.focus();
        return false;
    }
	
	if (which.weeklymonth.value =="")
    {
        alert("You have not selected the month this event ends"); 
        which.weeklymonth.focus();
        return false;
    }
    return true;
}
//#########################################################################################
//-->
/*################################################
THE SECTION BELOW IS TO CHECK
EMAILS AND SEE IF IT IS VALID
DO NOT NEED TO MAKE ANY CHANGES 
###########################################*/
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		    alert("The E-mail address is Invalid ." +
			  "\nPlease Provide us with a valid E-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		    alert("The E-mail address is Invalid ." +
			  "\nPlease Provide us with a valid E-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("The E-mail address is Invalid ." +
			  "\nPlease Provide us with a valid E-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		     alert("The E-mail address is Invalid ." +
			  "\nPlease Provide us with a valid E-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		     alert("The E-mail address is Invalid ." +
			  "\nPlease Provide us with a valid E-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("The E-mail address is Invalid ." +
			  "\nPlease Provide us with a valid E-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("The E-mail address is Invalid ." +
			  "\nPlease Provide us with a valid E-mail address")
		    return false
		 }

 		 return true					
	}


//################################################
//FUNCTION TO VALIDATE for front end  
//################################################
function checkevents(which){
	
	if (which.title.value =="")
    {
        alert("Please Enter a Title, you cannot proceed without it:"); 
        which.title.focus();
        return false;
    }
	
	if (which.author.value =="")
    {
        alert("You have not entered your full name"); 
        which.author.focus();
        return false;
    }
	
	if ((which.dd.value =="") || (which.mm.value =="") || (which.yy.value ==""))
    {
        alert("The Start date is required"); 
        which.dd.focus();
        return false;
    }
	
	if ((which.enddd.value =="") || (which.endmm.value =="") || (which.endyy.value ==""))
    {
        alert("The End date is required"); 
        which.enddd.focus();
        return false;
    }
	
	var emailID=document.eventform.address
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Specify Recipient E-mail Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
    return true;
}
//#########################################################################################
//-->
//################################################
//FUNCTION TO VALIDATE for front end  
//################################################
function checkedit(which){
	
	
	if ((which.dd.value !="") && (which.mm.value !="") && (which.yy.value !="") &&  (which.weekly.value !="") && (which.weeklymonth.value !=""))
    {
       alert("Multiple Entries" +
			  "\nYou cannot select dates and weekly dates at the same time" +
     			"\nClick OK and try again.")
		which.dd.focus();
        return false;
    }
	
	/*if ((which.enddd.value =="") || (which.endmm.value =="") || (which.endyy.value ==""))
    {
        alert("The End date is required"); 
        which.enddd.focus();
        return false;
    }*/
	
    return true;
}
//#########################################################################################
//-->
