function CallPrint()
{
	window.focus();
	Msg = "Please, follow these instructions before you print.\n";
	Msg += "You can Cancel, make the adjustments and print from the browser.\n\n";
	Msg += "In your browser's View menu set the Text Size to Medium.\n\n";
	Msg += "In your browser's File menu, Page Setup do the following adjustments:\n";
	Msg += "\tMake sure to clear Header and Footer.\n";
	Msg += "\tMake Portrait the page orientation.\n";
	Msg += "\tYou may need to adjust all Margins somewhere from 0.25 to 0.75. Try first 0.5.\n";
	Msg += "\tCheck Print Preview to see if the page is correctly positioned.";
	if(confirm(Msg)) window.print();
}

function TranscriptEdit(val)
{
    window.location = val;
}

function TranscriptDelete(val)
{
    var conf =  confirm("Are you sure you want to delete this course?");
    if(!conf) return;
    window.location = val;
}

function sumweight()
{
	var all = document.all ? document.all : document.getElementsByTagName('*');
	var elements = new Array();
	var sum = 0;
	for (var e=0;e<all.length;e++)
		if (all[e].className == 'grayinput')
		{
			var val = all[e].value;
			if (!IsNumeric(val))
			{
				document.getElementById("lbErr2").innerHTML= "Please make sure weights are valid decimal numbers (00.000 format).";
				return;
			}
			sum+=1*val+0;
		}
	document.getElementById("lbErr2").innerHTML= "";
	if (sum>100)
	{
		var dif=Math.round((sum*1-100)*1000)/1000;
		document.getElementById("tbWS").innerText = "Weights sum:"+sum+" ("+dif+" more than 100.00)";	
		document.getElementById("tbWS").style.color = "red";	
	}
	else if (sum<100)
	{
		var dif=Math.round((100-sum)*1000)/1000;
		document.getElementById("tbWS").innerText = "Weights sum:"+sum+" ("+dif+" missing to 100.00)";	
		document.getElementById("tbWS").style.color = "red";	
	}
	else
	{
		document.getElementById("tbWS").innerText = "Weights sum:"+sum;	
		document.getElementById("tbWS").style.color = "green";	
	}
}



//opens the calendar POP-UP
function opencal(ctl)
{
	var val =  new Date();
	window.open('Calendar.aspx?CTL='+ctl+'&SD='+val,'','scrollbars=no,menubar=no,height=300,width=300,resizable=no,toolbar=no');
}

//writes template in the comment field
function Template()
{
	document.Form1.tbComment.value = document.Form1.ddTemplates.value;
	if (document.Form1.tbComment.value == "Select...")
	{
		document.Form1.tbComment.value = "";
	}
}

function BillingChange()
{
    var select = document.getElementById("ddDesc");
    var selIndex = select.selectedIndex;
    if(selIndex < 0) return;
    var Value = select.options[selIndex].value;
	//var Value = document.Form1.ddDesc.options[document.Form1.ddDesc.selectedIndex].text;
	if (Value.indexOf("$")>0)
	{
		var d = Value.indexOf("$");
		var Amt = Value.substring(d+1,Value.length-1);
		document.Form1.tbValue.value = Amt;
	}
}

function BillingBulk()
{
    var select = document.getElementById("SelectBox");
    var selIndex = select.selectedIndex;
    if(selIndex < 0) return;
    var Value = select.options[selIndex].value;
	//var Value = document.Form1.ddDesc.options[document.Form1.ddDesc.selectedIndex].text;
	if (Value.indexOf("$")>0)
	{
		var d = Value.indexOf("$");
		var Amt = Value.substring(d+1,Value.length-1);
		document.Form1.tbValue.value = Amt;
	}
}

function vCommunicationAdd()
{
	if(document.Form1.tbDate.value == "" || document.Form1.tbHour.value == "")
	{
		document.getElementById("lbErr").innerHTML= "Please enter a Date and Time.";
		return false;
	}
	
	if(isFutureDate(document.Form1.tbDate.value, 1) == 0) 
	{
		document.getElementById("lbErr").innerHTML= "The date must be in the MM/DD/YYYY format.";
		return false;
	}
		
	if(isFutureDate(document.Form1.tbDate.value, 1) == 2) 
	{
		document.getElementById("lbErr").innerHTML= "The communication date cannot be in the future.";
		return false;
	}
	
	if(!IsValidTime(document.Form1.tbHour.value))
	{
		document.getElementById("lbErr").innerHTML= "The communication time must be in the HH:MM AM (or PM) format.";
		return false;
	}
	
	if((document.Form1.tbDate.value != "" && isFutureDate(document.Form1.tbDate.value, 1) != 1) || (document.Form1.tbHour.value != "" && !IsValidTime(document.Form1.tbHour.value)))
	{
		if(document.Form1.tbDate.value != "")
        {
            if(isFutureDate(document.Form1.tbDate.value, 1) == 0)
            {
				document.getElementById("lbErr").innerHTML= "The communication date must be in the MM/DD/YYYY format.";
				return false;
			}
		    else if(isFutureDate(document.Form1.tbDate.value, 1) == 2)
		    {
				document.getElementById("lbErr").innerHTML= "The communication date cannot be in the future.";
				return false;
			}
        }
		if(document.Form1.tbHour.value != "" && !IsValidTime(document.Form1.tbHour.value))
		{
			document.getElementById("lbErr").innerHTML= "The communication time must be in the HH:MM AM (or PM) format.";
			return false;
		}
		return false;
	}
	
	
	return true;
}

function vStudentTranscript()
{
	//check if all items are there
	if(document.Form1.tbDate.value == "")
	{
		document.getElementById("lbErr").innerHTML= "Please enter a Date in any format.";
		return false;
	}
	
	if (document.Form1.ddSA.options[document.Form1.ddSA.selectedIndex].text=="Select...")
	{
		document.getElementById("lbErr").innerHTML= "Please select a Department.";
		return false;
	}
	
	if(document.Form1.tbFG.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter a Final Grade.";
		return false;
	}
	
	if(document.Form1.tbCourse.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the Course Name.";
		return false;
	}
	
	if (document.Form1.ddCredits.options[document.Form1.ddCredits.selectedIndex].text=="Select...")
	{
		document.getElementById("lbErr").innerHTML= "Please select the amount of credits earned.";
		return false;
	}
	
	if(document.Form1.tbTakenAt.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter where the Course was taken.";
		return false;
	}
	
	if (document.Form1.ddGradeLevel.options[document.Form1.ddGradeLevel.selectedIndex].text=="Select...")
	{
		document.getElementById("lbErr").innerHTML= "Please select the grade level.";
		return false;
	}
	
	if (document.Form1.ddSemester.options[document.Form1.ddSemester.selectedIndex].text=="Select...")
	{
		document.getElementById("lbErr").innerHTML= "Please select the semester.";
		return false;
	}
	
	return true;
}

function vCreateAccount()
{
	//check if all items are there
	if(document.Form1.tbName.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your Full Name.";
		return false;
	}
	if(document.Form1.tbEM.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your E-mail.";
		return false;
	}
	if(document.Form1.tbUserID.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your User ID.";
		return false;
	}
	if(document.Form1.tbPwd.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your Password.";
		return false;
	}
	if(document.Form1.tbPss2.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please confirm your Password.";
		return false;
	}
	
	//check pwd
	if(document.Form1.tbPss2.value != document.Form1.tbPwd.value) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter the same Password twice.";
		return false;
	}
	
	//check for valid e-mails
	if(document.Form1.tbEM.value.indexOf("@")<0) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid e-mail.";
		return false;
	}
	
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbName.value))||(CheckSQ(document.Form1.tbEM.value))||(CheckSQ(document.Form1.tbUserID.value))||
		(CheckSQ(document.Form1.tbPwd.value))||(CheckSQ(document.Form1.tbPss2.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}

function vAdministrationAddUser()
{
	//check if all items are there
	if(document.Form1.tbName.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your Full Name.";
		return false;
	}
	if(document.Form1.tbEmail.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your E-mail.";
		return false;
	}
	if(document.Form1.tbUserID.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your User ID.";
		return false;
	}
	if(document.Form1.tbPassword.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your Password.";
		return false;
	}
	
	//check for valid e-mails
	if(document.Form1.tbEmail.value.indexOf("@")<0) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid e-mail.";
		return false;
	}
	
	//check for valid DOB
	if((document.Form1.tbDOB.value !="")&&(!isDate(document.Form1.tbDOB.value,1)))
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid Date of Birth (mm/dd/yyyy).";
		return false;
	}

	
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbName.value))||(CheckSQ(document.Form1.tbEmail.value))||(CheckSQ(document.Form1.tbUserID.value))||
		(CheckSQ(document.Form1.tbPassword.value))||(CheckSQ(document.Form1.tbPhone.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}

function vApplication()
{
	//check student items
	if(document.Form1.tbGoesBy.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student official Name.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student official Name.";
		return false;
	}
	if(document.Form1.tbStudentName.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student Name.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student Name.";
		return false;
	}
	if(document.Form1.tbDOB.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student Date of Birth.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student Date of Birth.";
		return false;
	}
	if(document.Form1.tbStudentAddress.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student Street Address.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student Street Address.";
		return false;
	}
	if(document.Form1.tbStudentCity.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student City.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student City.";
		return false;
	}
	if(document.Form1.tbStudentZIP.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student ZIP.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student ZIP.";
		return false;
	}
	if(document.Form1.tbStudentPhone.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student Telephone number.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student Telephone number.";
		return false;
	}
	if(document.Form1.tbStudentEmail.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student Email.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student Email.";
		return false;
	}
	
	//check guardian items
	if(document.Form1.tbG1N.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian name.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian name.";
		return false;
	}
	if(document.Form1.tbG1R.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian relationship.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian relationship.";
		return false;
	}
	if(document.Form1.tbG1P.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian Telephone number.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian Telephone number.";
		return false;
	}
	if(document.Form1.tbG1E.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian Email.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian Email.";
		return false;
	}
	
	//check for valid DOB
	if(!isDate(document.Form1.tbDOB.value,1))
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid Date of Birth (mm/dd/yyyy).";
		document.getElementById("lbErr2").innerHTML= "Please make sure you enter a valid Date of Birth (mm/dd/yyyy).";
		return false;
	}
	
	//check for valid e-mails
	if(document.Form1.tbStudentEmail.value.indexOf("@")<0) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid student Email.";
		document.getElementById("lbErr2").innerHTML= "Please make sure you enter a valid student Email.";
		return false;
	}
	if(document.Form1.tbG1E.value.indexOf("@")<0) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid guardian Email.";
		document.getElementById("lbErr2").innerHTML= "Please make sure you enter a valid guardian Email.";
		return false;
	}
	
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbStudentName.value))||(CheckSQ(document.Form1.tbDOB.value))||(CheckSQ(document.Form1.tbStudentAddress.value))||
		(CheckSQ(document.Form1.tbStudentCity.value))||(CheckSQ(document.Form1.tbStudentZIP.value))||(CheckSQ(document.Form1.tbStudentPhone.value))||
		(CheckSQ(document.Form1.tbStudentEmail.value))||(CheckSQ(document.Form1.tbLSN.value))||(CheckSQ(document.Form1.tbLSA.value))||
		(CheckSQ(document.Form1.tbG1N.value))||(CheckSQ(document.Form1.tbG1R.value))||(CheckSQ(document.Form1.tbG1P.value))||
		(CheckSQ(document.Form1.tbG1E.value))||(CheckSQ(document.Form1.tbStudentMobile.value))||(CheckSQ(document.Form1.tbG2N.value))||
		(CheckSQ(document.Form1.tbG2R.value))||(CheckSQ(document.Form1.tbG2P.value))||(CheckSQ(document.Form1.tbG2E.value))||
		(CheckSQ(document.Form1.tbComments.value))||(CheckSQ(document.Form1.tbGoesBy.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		document.getElementById("lbErr2").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}


function vStudentInfo()
{
	//check student items
	if(document.Form1.tbName.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter a student Name.";
		document.getElementById("lbErr2").innerHTML= "Please enter a student Name.";
		return false;
	}
	if(document.Form1.tbEM.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student Email.";
		document.getElementById("lbErr2").innerHTML= "Please enter the student Email.";
		return false;
	}
		
	//check guardian items
	if(document.Form1.tbG1N.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian name.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian name.";
		return false;
	}
	if(document.Form1.tbG1R.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian relationship.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian relationship.";
		return false;
	}
	if(document.Form1.tbG1P.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian Telephone number.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian Telephone number.";
		return false;
	}
	if(document.Form1.tbG1EM.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter at least one Guardian Email.";
		document.getElementById("lbErr2").innerHTML= "Please enter at least one Guardian Email.";
		return false;
	}
	
	//check for valid DOB
	if(!isDate(document.Form1.tbBirthday.value,1))
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid Date of Birth (mm/dd/yyyy).";
		document.getElementById("lbErr2").innerHTML= "Please make sure you enter a valid Date of Birth (mm/dd/yyyy).";
		return false;
	}
	
	//check for valid e-mails
	if(document.Form1.tbEM.value.indexOf("@")<0) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid student Email.";
		document.getElementById("lbErr2").innerHTML= "Please make sure you enter a valid student Email.";
		return false;
	}
	if(document.Form1.tbG1EM.value.indexOf("@")<0) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter a valid guardian Email.";
		document.getElementById("lbErr2").innerHTML= "Please make sure you enter a valid guardian Email.";
		return false;
	}
	
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbName.value))||(CheckSQ(document.Form1.tbBirthday.value))||(CheckSQ(document.Form1.tbEM.value))||
		(CheckSQ(document.Form1.tbAdd.value))||(CheckSQ(document.Form1.tbCity.value))||(CheckSQ(document.Form1.tbState.value))||
		(CheckSQ(document.Form1.tbZIP.value))||(CheckSQ(document.Form1.tbPhone.value))||(CheckSQ(document.Form1.tbMobile.value))||
		(CheckSQ(document.Form1.tbSMS.value))||(CheckSQ(document.Form1.tbLocker.value))||
		(CheckSQ(document.Form1.tbCom.value))||(CheckSQ(document.Form1.tbG1N.value))||(CheckSQ(document.Form1.tbG1R.value))||
		(CheckSQ(document.Form1.tbG1P.value))||	(CheckSQ(document.Form1.tbG1EM.value))||(CheckSQ(document.Form1.tbG2N.value))||
		(CheckSQ(document.Form1.tbG2R.value))||(CheckSQ(document.Form1.tbG2P.value))||(CheckSQ(document.Form1.tbG2EM.value))||
		(CheckSQ(document.Form1.tbLSA.value))||(CheckSQ(document.Form1.tbLSN.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		document.getElementById("lbErr2").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}

function vChangePassword()
{
	//check if all items are there
	if(document.Form1.tbCur.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the current password.";
		return false;
	}
	if(document.Form1.tbNP.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter your new password.";
		return false;
	}
	if(document.Form1.tbCNP.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please confirm your new password.";
		return false;
	}
	
	//check pwd
	if(document.Form1.tbNP.value != document.Form1.tbCNP.value) 
	{
		document.getElementById("lbErr").innerHTML= "Please make sure you enter the same Password twice.";
		return false;
	}
	
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbCur.value))||(CheckSQ(document.Form1.tbNP.value))||(CheckSQ(document.Form1.tbCNP.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}

function vStudentAdd()
{
	//check if all items are there
	if(document.Form1.tbName.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the student name.";
		return false;
	}
	
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbName.value))||(CheckSQ(document.Form1.tbCom.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}

function vEvents()
{
	//check Date
	var Date = document.Form1.tbDate.value;
	if(!isDate(Date,1))
	{
		document.getElementById("lbErr").innerHTML= "Please enter the event date (mm/dd/yyyy).";
		return false;
	}

	//short description
	if (document.Form1.tbSDesc.value == "")
	{
		document.getElementById("lbErr").innerHTML= "Please enter a short description";
		return false;
	}
	
	return true;
}

function vSlots()
{
	//check from
	var From = document.Form1.tbStart.value;
	var To = document.Form1.tbEnd.value;
	if ((From == "") ||(To == ""))
	{
		document.getElementById("lbErr").innerHTML= "Please enter the Start and End times.";
		return false;
	}

	//len	
	if ((From.length!=5)||(To.length!=5))
	{
		document.getElementById("lbErr").innerHTML= "Please make sure Start and End times are in the HH:MM format.";
		return false;
	}
	
	//index of :
	if ((From.indexOf(":")!=2)||(To.indexOf(":")!=2))
	{
		document.getElementById("lbErr").innerHTML= "Please make sure Start and End times are in the HH:MM format.";
		return false;
	}
	
	//numbers
	if ((!IsNumeric(From.substring(0,2)))||(!IsNumeric(To.substring(3,5))))
	{
		document.getElementById("lbErr").innerHTML= "Please make sure Start and End times are in the HH:MM format.";
		return false;
	}
	
	
	return true;
}

function vMidTerm()
{
	//check if grade is there
	if(document.Form1.tbSem1.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the 1st semester grade.";
		return false;
	}
	
	return true;
}

function vReportCard()
{
	//check if all items are there
	if(document.Form1.tbFG.value == "") 
	{
		document.getElementById("lbErr2").innerHTML= "Please enter the final grade.";
		return false;
	}
	
	return true;
}


function vCourseAdd()
{
	//check if all items are there
	if(document.Form1.tbName.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter the course name.";
		return false;
	}
	
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbName.value))||(CheckSQ(document.Form1.tbCom.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}

function vAssignmentAdd()
{
	//check if all items are there
	if(document.Form1.tbName.value == "") 
	{
		document.getElementById("lbErr").innerHTML= "Please enter an assignment name.";
		return false;
	}
		
	//check for Single-Quotes
	if ((CheckSQ(document.Form1.tbName.value))||(CheckSQ(document.Form1.tbDesc.value)))
	{
		document.getElementById("lbErr").innerHTML= "Please do not use single quotes ( ' ) on these fields.";
		return false;
	}
	
	return true;
}

function setToPaid()
{
	if (document.Form1.ddStatus.value=="PAID")
	{
		var now = new Date();
		var mth = now.getMonth()*1+1;
		var day = now.getDate();
		var yr = now.getFullYear();
		//set paidon date
		//document.getElementById("tbPaidOn").value = mth+"/"+day+"/"+yr;
		
		//set value
		document.getElementById("tbPaid").value = document.Form1.tbValue.value;
	}
}

function Balance_Validate()
{
    if((document.Form1.ddStudent.value=="Select..."))
	 {
	 var ErrMsg = "";
	    if(document.Form1.ddStudent.value=="Select...") ErrMsg += "Select a student.<br>";
	    document.getElementById("lbErr").style.color = "red";
	    document.getElementById("lbErr").innerHTML = ErrMsg;
	    return false;
	 }
	 document.getElementById("lbErr").innerHTML = "";	
	 return true;
}

function Bill_Validate()
{
    if((document.Form1.ddStudent.value=="Select...") ||
	   (document.Form1.tbValue.value == "") ||
	   (document.Form1.tbCalendar.value == "") ||
	   (isFutureDate(document.Form1.tbCalendar.value, 1) == 0) ||
	   (!IsNumeric(document.Form1.tbValue.value)) ||
	   (CheckSQ(document.Form1.tbCom.value)))
	 {
	 var ErrMsg = "";
	    if(document.Form1.ddStudent.value=="Select...") ErrMsg += "Select a student.<br>";
	    if(document.Form1.tbValue.value == "") ErrMsg += "Enter the billing amount.<br>";
		if(document.Form1.tbValue.value != "" && !IsNumeric(document.Form1.tbValue.value)) ErrMsg += "Make sure you enter a numeric amount for the billing item.<br>";
		if(document.Form1.tbCalendar.value == "") ErrMsg += "Make sure you enter a due date for the billing item.<br>";
	    if(document.Form1.tbCalendar.value != "" && isFutureDate(document.Form1.tbCalendar.value, 1) == 0) ErrMsg += "Make sure to enter a valid billing due date in the MM/DD/YYYY format.<br>";
	    if ((CheckSQ(document.Form1.tbCom.value))) ErrMsg += "Please do not use single quotes ( ' ) on the comments.";
	    document.getElementById("lbErr").style.color = "red";
	    document.getElementById("lbErr").innerHTML = ErrMsg;
	    return false;
	 }
	 document.getElementById("lbErr").innerHTML = "";	
	 return true;
}

function Payment_Validate()
{
    if((document.Form1.ddStudent.value=="Select...") ||
	   (document.Form1.tbPaid.value == "") ||
	   (document.Form1.tbCalendar.value == "") ||
	   (isFutureDate(document.Form1.tbCalendar.value, 1) == 0) ||
	   (!IsNumeric(document.Form1.tbPaid.value)) ||
	   (CheckSQ(document.Form1.tbCom.value)))
	 {
	 var ErrMsg = "";
	    if(document.Form1.ddStudent.value=="Select...") ErrMsg += "Select a student.<br>";
	    if(document.Form1.tbPaid.value == "") ErrMsg += "Enter the payment amount.<br>";
		if(document.Form1.tbPaid.value != "" && !IsNumeric(document.Form1.tbPaid.value)) ErrMsg += "Make sure you enter a numeric amount for the payment.<br>";
		if(document.Form1.tbCalendar.value == "") ErrMsg += "Make sure you enter a payment date in theMM/DD/YYYY format.<br>";
	    if(document.Form1.tbCalendar.value != "" && isFutureDate(document.Form1.tbCalendar.value, 1) == 0) ErrMsg += "Make sure to enter a valid payment date in the MM/DD/YYYY format.<br>";
	    if ((CheckSQ(document.Form1.tbCom.value))) ErrMsg += "Please do not use single quotes ( ' ) on the comments.";
	    document.getElementById("lbErr").style.color = "red";
	    document.getElementById("lbErr").innerHTML = ErrMsg;
	    return false;
	 }
	 document.getElementById("lbErr").innerHTML = "";	
	 return true;
}

function CheckSQ(str)
{
	if (str.indexOf("'")>=0) return true;
	return false;
}

/**********************************************************************/ 
/*Function name :isDate(s,f) */ 
/*Usage of this function :To check s is a valid format */ 
/*Input parameter required:s=input string */ 
/* f=input string format */ 
/* =1,in mm/dd/yyyy format */ 
/* else in dd/mm/yyyy */ 
/*Return value :if is a valid date return 1 */ 
/* else return 0 */ 
/*Function required :isPositiveInteger() */ 
/**********************************************************************/ 
function isDate(s,f) 
{var a1=s.split("/"); 
var a2=s.split("-"); 
var e=true; 
if ((a1.length!=3) && (a2.length!=3)) 
{ 
e=false; 
} 
else 
{if (a1.length==3) 
var na=a1; 
if (a2.length==3) 
var na=a2; 
if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2])) 
{ if (f==1) 
{var d=na[1],m=na[0]; 
} 
else 
{var d=na[0],m=na[1]; 
} 
var y=na[2]; 
if (((e) && (y<1000)||y.length>4)) 
e=false 
if (e) 
{ 
v=new Date(m+"/"+d+"/"+y); 
if (v.getMonth()!=m-1) 
e=false; 
} 
} 
else 
{ 
e=false; 
} 
} 
return e 
}

/**********************************************************************/ 
/*Function name :isFutureDate(s,f) */ 
/*Usage of this function :To check s is a valid format and if s is future date*/ 
/*Input parameter required:s=input string */ 
/* f=input string format */ 
/* =1,in mm/dd/yyyy format */ 
/* else in dd/mm/yyyy */ 
/*Return value :if is a valid date not in the future return 1 */ 
/*Return value :if is a valid date in the future return 2 */ 
/* else return 0 */ 
/*Function required :isPositiveInteger() */ 
/**********************************************************************/ 
function isFutureDate(s,f) 
{
    var a1=s.split("/"); 
    var a2=s.split("-"); 
    var e=true;
    var r=0; 
    if ((a1.length==3) || (a2.length==3)) 
    {
        if (a1.length==3) 
            var na=a1; 
        if (a2.length==3) 
            var na=a2; 
        if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2])) 
        {
            if (f==1) 
            {
                var d=na[1],m=na[0]; 
            } 
            else 
            {
                var d=na[0],m=na[1]; 
            } 
            var y=na[2];
            if (y>1000 && y.length==4) 
            { 
                v=new Date(m+"/"+d+"/"+y); 
                if (v.getMonth()==m-1 && v.getDate()==d) 
                {
                    var today = new Date();
                    if(v <= today) r = 1;
                    else r = 2;    
                }                
            } 
        } 
    } 
    return r 
}
 
function checkDate(v) 
{ 
var s=v.a.value; 
if (isDate(s,0)) //dd/mm/yyyy format 
alert("The inputted date value is valid!"); 
else 
alert("The inputted date value is not valid!"); 
return false; 
} 

/*************************************************************************/ 
/*Function name :isPositiveInteger(theString) */ 
/*Usage of this function :test for an +ve integer */ 
/*Input parameter required:thedata=string for test whether is +ve integer*/ 
/*Return value :if is +ve integer,return true */ 
/* else return false */ 
/*function require :isDigit */ 
/*************************************************************************/ 
function isPositiveInteger(theString) 
{ 
var theData = new String(theString) 

if (!isDigit(theData.charAt(0))) 
if (!(theData.charAt(0)== '+')) 
return false 

for (var i = 1; i < theData.length; i++) 
if (!isDigit(theData.charAt(i))) 
return false 
return true 
}

/**********************************************************************/ 
/*Function name :isDigit(theDigit) */ 
/*Usage of this function :test for an digit */ 
/*Input parameter required:thedata=string for test whether is digit */ 
/*Return value :if is digit,return true */ 
/* else return false */ 
/**********************************************************************/ 
function isDigit(theDigit) 
{ 
var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j; 

for (j = 0; j < digitArray.length; j++) 
{if (theDigit == digitArray[j]) 
return true 
} 
return false 
}

function IsNumeric(sa)
{
	var IsNumber=true;
	var Char;
	var i;
	var ValidChars = "0123456789.";
	var PtCnt = 0;
	for (i = 0; i < sa.length && IsNumber == true; i++)   
	{
		Char = sa.charAt(i);
		if(Char == ".") PtCnt ++;
		if(PtCnt > 1) return false; 
		if (ValidChars.indexOf(Char) == -1) IsNumber = false;
	}
	return IsNumber;
}

function IsIntegerNonZero(sa)
{
	var IsNumber=true;
	var Char;
	var i;
	var ValidChars = "0123456789";
	for (i = 0; i < sa.length && IsNumber == true; i++)   
	{
		Char = sa.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) IsNumber = false;
	}
	if (IsNumber)
	{
		if(sa < 1) return false;
	}
	return IsNumber;
}

function IsValidTime(timeStr)
{
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null)
{
    return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
//alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
//alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
//alert("You can't specify AM or PM for military time.");
return false;
}
if (minute<0 || minute > 59) {
//alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
//alert ("Second must be between 0 and 59.");
return false;
}
return true;
}