dim title
title = " AFRAH - eAdmin"
dateYear = 1900

Function validateSearch1(txt, obj, startDate, endDate,chkDateRange, myform)
    validateText(myform)
	pos = instr(1, txt.value, "/")
	pos = pos - 1
	'msgbox txt.value & ":" & pos &":" & obj.selectedIndex
	
    if txt.value = "" then
		msgbox "Please enter your search criteria.", vbInformation, title
	elseif len(txt.value) > 60 then
		msgbox "The search criteria entered is too long, it should be less than 60 characters.", vbInformation, title				
	elseif((obj.selectedIndex = 0) and (len(txt.value) > 15)) then
		msgbox "The search criteria entered for application ID is too long, it should be less the 15 characters.", vbInformation, title
	elseif (obj.selectedIndex = 1) then
		if not validateDate(txt) then
			msgbox "The date entered for search criteria is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900.", vbInformation, title
		end if
	elseif chkDateRange.checked then
	    if len(startDate.value) <= 0 then
	        msgbox "Please enter Start Date.", vbInformation, title
	    elseif not validateDate(startDate) then
	        msgbox "The date entered as Start Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900.", vbInformation, title
	    elseif len(endDate.value) <= 0 then
	        msgbox "Please enter End Date.", vbInformation, title
	    elseif not validateDate(endDate) then
	        msgbox "The date entered as End Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900.", vbInformation, title
	    else
   		    window.location.href = "listSearched.asp?pageno=1&tab=1&searchFor=" & txt.value &_ 
			"&searchBy=" & obj.selectedIndex & "&startDate=" & startDate.value & "&endDate=" & endDate.value & "&location=eAdmin > Search Results"
'			"&searchBy=" & obj.selectedIndex &_
''			"&startDate="& startdate.value &_
''			"&endDate="& enddate.value &_
'            "&startDate=safsdf"
'			"&endDate=6546"
'			"&location=" & "eAdmin > Search Results"
	    end if
	else
	    
		myform.search.disabled = true
		myform.search.value = "Please wait"				
		window.location.href = "listSearched.asp?pageno=1&tab=1&searchFor=" & txt.value &_ 
        "&searchBy=" & obj.selectedIndex & "&startDate=" & startDate.value & "&endDate=" & endDate.value & "&location=eAdmin > Search Results"
'			"&startDate="& startdate.value &_
'			"&endDate="& enddate.value &_
			
	end if
end function
Function validateSearch(txt, obj, myform)
	validateText(myform)
	pos = instr(1, txt.value, "/")
	pos = pos - 1
	'msgbox txt.value & ":" & pos &":" & obj.selectedIndex
	if txt.value = "" then
		msgbox "Please enter your search criteria.", vbInformation, title
	elseif len(txt.value) > 60 then
		msgbox "The search criteria entered is too long, it should be less than 60 characters.", vbInformation, title				
	elseif((obj.selectedIndex = 0) and (len(txt.value) > 15)) then
		msgbox "The search criteria entered for application ID is too long, it should be less the 15 characters.", vbInformation, title
	elseif (obj.selectedIndex = 1) then
		if not validateDate(txt) then
			msgbox "The date entered for search criteria is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900.", vbInformation, title
		else
		    window.location.href = "listSearched.asp?pageno=1&tab=1&searchFor=" & txt.value &_ 
			"&searchBy=" & obj.selectedIndex & "&location=eAdmin > Search Results"
'			"&searchBy=" & obj.selectedIndex &_
''			"&startDate="& startdate.value &_
''			"&endDate="& enddate.value &_
'            "&startDate=safsdf"
'			"&endDate=6546"
'			"&location=" & "eAdmin > Search Results"
		end if
	else
		myform.search.disabled = true
		myform.search.value = "Please wait"				
		window.location.href = "listSearched.asp?pageno=1&tab=1&searchFor=" & txt.value &_ 
        "&searchBy=" & obj.selectedIndex & "&location=eAdmin > Search Results"
'			"&startDate="& startdate.value &_
'			"&endDate="& enddate.value &_
			
	end if
end function



Function validateBasicSearch(txt, obj, myform)
	validateText(myform)
	pos = instr(1, txt.value, "/")
	pos = pos - 1
	'msgbox txt.value & ":" & pos &":" & obj.selectedIndex
	if txt.value = "" then
		msgbox "Please enter your search criteria.", vbInformation, title
	elseif len(txt.value) > 60 then
		msgbox "The search criteria entered is too long, it should be less than 60 characters.", vbInformation, title				
	else
		myform.search.disabled = true
		myform.search.value = "Please wait"				
		window.location.href = "listSearched.asp?pageno=0&tab=1&searchFor=" & txt.value &_ 
			"&searchBy=" & obj.selectedIndex &_
			"&location=" & "eAdmin > Search Results"
	end if
end function


Function validateInstituteSearch(txt, myform)
	validateText(myform)
	pos = instr(1, txt.value, "/")
	pos = pos - 1
	'msgbox txt.value & ":" & pos &":" & obj.selectedIndex
	if txt.value = "" then
		msgbox "Please enter your search criteria.", vbInformation, title
	elseif len(txt.value) > 60 then
		msgbox "The search criteria entered is too long, it should be less than 60 characters.", vbInformation, title				
	else
		myform.search.disabled = true
		myform.search.value = "Please wait"				
		window.location.href = "ListAllInstitute.asp?pageno=0&tab=5&temptext=" & txt.value
	end if
end function

'TODO Modified to change date formt to British on 03072005
Function validateDate(myDate)
    'msgbox "here"
    'myDay = Day(myDate.value)
    'msgbox myDay
    pos = instr(1, myDate.value, "/")
	pos1 = instr(pos+1, myDate.value, "/")
	pos1 = pos1
	pos2 = len(myDate.value)
	validateDate = true
	pos = pos - 1
	if not isDate(myDate.value) then
		validateDate = false
	elseif len(mid(myDate.value, pos1+1, pos2)) < 4 then				
		validateDate = false
	'elseif (myDay > 12) then				
	'	validateDate = false
	else
		validateDate = true
	end if		
end function
Function IsEmailValid(strEmail) 
  
    Dim strArray 
    Dim strItem 
    Dim i 
    Dim c 
    Dim blnIsItValid 
  
    ' assume the email address is correct  
    blnIsItValid = True 
    
    ' split the email address in two parts: name@domain.ext 
    strArray = Split(strEmail, "@") 
  
    ' if there are more or less than two parts  
    If UBound(strArray) <> 1 Then 
        blnIsItValid = False 
        IsEmailValid = blnIsItValid 
        Exit Function 
    End If 
  
    ' check each part 
    For Each strItem In strArray 
        ' no part can be void 
        If Len(strItem) <= 0 Then 
            blnIsItValid = False 
            IsEmailValid = blnIsItValid 
            Exit Function 
        End If 
        
        ' check each character of the part 
        ' only following "abcdefghijklmnopqrstuvwxyz_-." 
        ' characters and the ten digits are allowed 
        For i = 1 To Len(strItem) 
               c = LCase(Mid(strItem, i, 1)) 
               ' if there is an illegal character in the part 
               If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then 
                   blnIsItValid = False 
                   IsEmailValid = blnIsItValid 
                   Exit Function 
               End If 
        Next 
   
      ' the first and the last character in the part cannot be . (dot) 
        If Left(strItem, 1) = "." Or Right(strItem, 1) = "." Then 
           blnIsItValid = False 
           IsEmailValid = blnIsItValid 
           Exit Function 
        End If 
    Next 
  
    ' the second part (domain.ext) must contain a . (dot) 
    If InStr(strArray(1), ".") <= 0 Then 
        blnIsItValid = False 
        IsEmailValid = blnIsItValid 
        Exit Function 
    End If 
  
    ' check the length oh the extension  
    i = Len(strArray(1)) - InStrRev(strArray(1), ".") 
    ' the length of the extension can be only 2, 3, or 4 
    ' to cover the new "info" extension 
    If i <> 2 And i <> 3 And i <> 4 Then 
        blnIsItValid = False 
        IsEmailValid = blnIsItValid 
        Exit Function 
    End If 

    ' after . (dot) cannot follow a . (dot) 
    If InStr(strEmail, "..") > 0 Then 
        blnIsItValid = False 
        IsEmailValid = blnIsItValid 
        Exit Function 
    End If 
  
    ' finally it's OK  
    IsEmailValid = blnIsItValid 
    
 End Function 




Function validateStudentAddForm(myform, from)
	
	addValid = false
	addQulificationValid = false
	
	if from = "AddStudent" or from = "EditStudent" then
		if  myform.name.value = "" then
			msgbox "Please enter first name.", vbInformation, title
		elseif myform.fathername.value = "" then
			msgbox "Please enter last name.", vbInformation, title
		elseif not validateDate(myform.DOB) then
			msgbox "The date entered for date of birth is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		elseif not validateDate(myform.dateInitiated) then 
			msgbox "The date entered for date initiated is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		elseif len(myform.name.value) > 30 then
			msgbox "First name entered is too large, it can be upto 30 characters long.", vbInformation, title
		elseif len(myform.fathername.value) > 30 then
			msgbox "Last name entered is too large, it can be upto 30 characters long.", vbInformation, title
		'elseif len(myform.address.value) > 100 then
			'msgbox "Student Address entered is too large, it can be upto 100 characters long.", vbInformation, title
		'elseif len(myform.addressAus.value) > 100 then
		'	msgbox "Student Address(AUS) entered is too large, it can be upto 100 characters long.", vbInformation, title
	   elseif len(myform.fileNo.value) > 20 then
			msgbox "File No entered is too large, it can be upto 20 characters long.", vbInformation, title
		elseif len(myform.Tel.value) > 30 then
			msgbox "Student phone number entered is too large, it can be upto 30 characters long.", vbInformation, title
	    elseif len(myform.mobileNo.value) = 0  then
			msgbox "Please Enter student Mobile Number.", vbInformation, title
		elseif len(myform.mobileNo.value) > 20 then
			msgbox "Student phone number entered is too large, it can be upto 20 characters long.", vbInformation, title
		elseif len(myform.email.value) > 100 then
			msgbox "Student email entered is too large, it can be upto 100 characters long.", vbInformation, title
		elseif len(myform.email.value) = 0 then
			msgbox "Please enter student email.", vbInformation, title
		elseif not IsEmailValid(myform.email.value) then
			msgbox "Please enter valid student email.", vbInformation, title
		elseif len(myform.fileNo.value) = 0 then
			msgbox "Please enter file number.", vbInformation, title			
		elseif IsEmailValid(myform.email.value) = false then
			msgbox "Please enter Valid Email Address.", vbInformation, title			
		elseif len(myform.passportNo.value) > 20 then
			msgbox "PassPort No. entered is too large, it can be upto 20 characters long.", vbInformation, title
		elseif (myform.relatedOffice.length < 1) then
			msgbox "Please Select any related Office", vbInformation, title
		elseif (myform.assignedAdmissionOfficer.value = 0) then
			msgbox "Please Select any assigned admission officer", vbInformation, title
			
			
		elseif len(myform.HomeStreet1.value) = 0 then
			msgbox "Please enter street1 for Home Address.", vbInformation, title			
		elseif len(myform.HomeStreet2.value) = 0 then
			msgbox "Please enter street2 for Home Address.", vbInformation, title			
		elseif len(myform.HomeZipCode.value) = 0 then
			msgbox "Please enter Zip Code for Home Address.", vbInformation, title					
		elseif len(myform.HomeState.value) = 0 then
			msgbox "Please enter State For Home Address", vbInformation, title			
		elseif len(myform.HomeCity.value) = 0 then
			msgbox "Please enter City For Home Address", vbInformation, title	
	    elseif (myform.HomeCountry.value = 0) then
			msgbox "Please Select any Country For Home Address", vbInformation, title					
			 
	    elseif len(myform.HomeStreet1.value) > 200 then
			msgbox "HomeStreet1 entered is too large, it can be upto 200 characters long.", vbInformation, title			
		elseif len(myform.HomeStreet2.value) > 100 then
			msgbox "HomeStreet2 entered is too large, it can be upto 100 characters long.", vbInformation, title			
		elseif len(myform.HomeZipCode.value) > 100 then
			msgbox "Zip Code entered is too large, it can be upto 100 characters long.", vbInformation, title			
		elseif myform.HomeCountry.length < 1 then
			msgbox "Please Select any Country For Home Address", vbInformation, title			
		elseif len(myform.HomeState.value) > 100 then
			msgbox "State entered is too large, it can be upto 100 characters long.", vbInformation, title			
		elseif len(myform.HomeCity.value) > 100 then
			msgbox "City entered is too large, it can be upto 100 characters long.", vbInformation, title	
			elseif len(myform.DestinationStreet1.value) > 200 then
			msgbox "street1 entered is too large, it can be upto 200 characters long.", vbInformation, title			
		elseif len(myform.DestinationStreet2.value) > 100 then
			msgbox "street2 entered is too large, it can be upto 100 characters long.", vbInformation, title			
		elseif len(myform.DestinationZip.value) > 100 then
			msgbox "Zip Code entered is too large, it can be upto 100 characters long.", vbInformation, title			
		elseif myform.DestinationCountry.length < 1 then
			msgbox "Please Select any Country For Destination Address", vbInformation, title			
		elseif len(myform.DestinationState.value) > 100 then
			msgbox "State entered is too large, it can be upto 100 characters long.", vbInformation, title			
		elseif len(myform.DestinationCity.value) > 100 then
			msgbox "City entered is too large, it can be upto 100 characters long.", vbInformation, title			
		
		'elseif (myform.intendedInstitution(1).length) < 1 then
		 '   msgbox "Please Select the intendetd Institution", vbInformation, title				
		'elseif (myform.intendedProgram(1).length) < 1 then
		 '   msgbox "Please Select the intended program from list", vbInformation, title					    
		'elseif (myform.intendedSemester(1).length) < 1 then
		 '   msgbox "Please Select the intended semester from list", vbInformation, title					    
		else
			addValid = true
		end if
	end if
	
	if from="AddStudent" and addValid = true then	
	addValid = false
	if (myform.intendedInstitution(0).length) < 1 then
		    msgbox "Please Select the intendetd Institution", vbInformation, title				
		elseif (myform.intendedProgram(0).length) < 1 then
		    msgbox "Please Select the intended program from list", vbInformation, title					    
		elseif (myform.intendedSemester(0).length) < 1 then
		    msgbox "Please Select the intended semester from list", vbInformation, title					    
	    elseif (myform.intendedInstitution(0).length) < 1 then
		    msgbox "Please Select the intendetd Institution", vbInformation, title				
		elseif (myform.intendedProgram(0).length) < 1 then
		    msgbox "Please Select the intended program from list", vbInformation, title					    
		elseif (myform.intendedSemester(0).length) < 1 then
		    msgbox "Please Select the intended semester from list", vbInformation, title					    		
		else
			addValid = true
		end if
	
	end if
	
	
	dim i
	addQulificationValid = false
	if from = "AddStudent"  then
		for i = 0 to 1
			addQulificationValid = false
			'msgbox(myform.elements("AddProgram" & i+1).checked)
			'exit for
			if myform.elements("AddProgram" & i+1).checked then
				if len(myform.intendedInstitution(i).value) > 50 then
					msgbox "Student institution entered is too large, it can be upto 50 characters long.", vbInformation, title
					exit for
				elseif len(myform.intendedSemester(i).value) > 15 then				
					msgbox "Student semester entered is too large, it can be upto 15 characters long.", vbInformation, title
					exit for
				'elseif len(myform.uniRef(i).value) > 50 then
					'msgbox "Student university refrence no. entered is too large, it can be upto 50 characters long.", vbInformation, title						
					'exit for
				'elseif len(myform.ALDate(i).value) > 0 then
					'if not validateDate(myform.ALDate(i)) then
					'	msgbox "The date entered for Lodgment Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
					'	exit for
					'end if
				else
					addQulificationValid = true
				end if
			else
				addQulificationValid = true
			end if
		next
	end if
	
	
	if from = "EditStudent" and addValid = true then
		myform.Add.value = "Please wait"
		myform.Add.disabled = true
		validateText(myform) 				
		myform.submit
	end if
	
	editQual = true
	
	if (from="AddStudent"  and addQulificationValid = true) or (from="EditQualification") then				
		for i = 0  to myform.Qualification.length - 1
			if len(trim(myform.Qualification(i).value)) > 0 then
				if len(myform.Qualification(i).value) > 100 then
					msgbox "Student qualification entered is too large, it can be upto 100 characters long.", vbInformation, title
					addValid = false
					editQual = false
				elseif len(myform.YearStarted(i).value) <> 4 then
					msgbox "Year started entered is too large/small, it should be 4 digits long.", vbInformation, title
					addValid = false
					editQual = false
				elseif len(myform.YearEnded(i).value) <> 4  then
					msgbox "Year ended entered is too large/small, it should be 4 digits long.", vbInformation, title
					addValid = false
					editQual = false
				elseif len(myform.Institution(i).value) > 50 then
					msgbox "Institution entered is too large, it can be upto 50 characters long.", vbInformation, title
					addValid = false
					editQual = false
				elseif not isNumeric(myform.YearStarted(i).value)  and len(myform.YearStarted(i).value) > 0 then
					msgbox "Year started entered is not valid, It must be numeric.", vbInformation, title
					addValid = false
					editQual = false
				elseif not isNumeric(myform.YearEnded(i).value) and len(myform.YearEnded(i).value) > 0 then
					msgbox "Year ended entered is not valid, It must be numeric", vbInformation, title
					addValid = false
					editQual = false
				end if 
			end if
		next
	end if
	
	if from = "EditQualification" and editQual = true then
		myform.Add.value = "Please wait"
		myform.Add.disabled = true
		validateText(myform)
		myform.submit
	end if
	
	if from="AddStudent" and addValid = true then
		if len(myform.visaOffice.value) > 100 then
			msgbox "Visa office name entered is too large, it can be upto 100 characters long.", vbInformation, title
			exit function
		elseif len(myform.visaOffice.value) > 0 and len(myform.DOVA.value) > 0 then		
			if not validateDate(myform.DOVA) then
				msgbox "The date entered for visa application is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
				exit function						
			end if
			
			if len(myform.VSC.value) > 20 then
				msgbox "Visa sub class entered is too large, it can be upto 20 characters long.", vbInformation, title
				exit function
			end if
			
			if len(myform.VFSNo.value) > 20 then
				msgbox "VFS No. entered is too large, it can be upto 20 characters long.", vbInformation, title
				exit function
			end if
		end if
		
		'if len(myform.charges.value) > 50 then
			'msgbox "Description for charges entered is too large, it can be upto 50 characters long.", vbInformation, title
		'	exit function
	'	elseif len(myform.charges.value) > 0 then
'			if not isNumeric(myform.Amount.value) or  len(myform.Amount.value) > 9 or myform.Amount.value = "" then
'				msgbox "Amount entered for the charges is not valid"
'				exit function
			'end if
			
			if len(myform.chrgesremarks.value) > 50 then
				msgbox "Remarks for charges entered is too large, it can be upto 50 characters long.", vbInformation, title
				exit function
			end if
		'end if
	end if
	
	
	
	if from="AddStudent" then
		if len(myform.remarks.value) > 1000 then
			msgbox "Remarks entered are too large, they can be upto 1000 characters long.", vbInformation, title
			addValid = false
		end if
	end if
	
	if addValid = true and addQulificationValid = true and from = "AddStudent" then				
		if  myform.remarks.value <> "" then
			myform.remarks.value =  myform.remarks.value
		end if
		myform.Add.value = "Please wait"
		myform.Add.disabled = true
		validateText(myform) 
		myform.submit
	end if
	
	editValid = true
	
	if from="EditStatus" then
		for i = 0 to myform.remarks.length - 1
			if len(myform.remarks(i).value) > 1000 then
				msgbox "Remarks entered are too large, they can be upto 1000 characters long.", vbInformation, title
				editValid = false
			end if
		next
	End if
	
	if editValid = true and from = "EditStatus" then
		for i = 0 to myform.remarks.length - 1
			if instr(1, myform.remarks(i).value) = 0 and myform.remarks(i).value <> "" then
				myform.remarks(i).value = myform.remarks(i).value
			end if
		next
		myform.Add.value = "Please wait"
		myform.Add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function valideUserInfo(myform)
	
	if len(myform.name.value) = 0 then
		msgbox "Please enter user name", vbInformation, title
	elseif len(myform.name.value) > 60 then
		msgbox "Name entered is too large, it can be upto 60 characters long.", vbInformation, title
	elseif instr(1, myform.userName.value, " ") <> 0 then
		msgbox "There are space character(s) in user name entered, Please remove space characters(s)", vbInformation, title
	elseif len(myform.userName.value) = 0 then
		msgbox "Please enter user name", vbInformation, title
	elseif len(myform.userName.value) > 10 then
		msgbox "User name entered is too large, it can be upto 10 characters long.", vbInformation, title
	elseif myform.password.value <> myform.cPassword.value then
		msgbox "Password does not match with Confirm Password", vbInformation, title
	elseif len(myform.password.value) < 6 then
		msgbox "Password should be at least 6 characters long", vbInformation, title
	elseif len(myform.password.value) > 10 then
		msgbox "Password entered is too large, it can be upto 10 characters long.", vbInformation, title
	else
		myform.Add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function
function valideRoleInfo(myform)
	
	if len(myform.rolename.value) = 0 then
		msgbox "Please enter Role name", vbInformation, title
	elseif len(myform.rolename.value) > 50 then
		msgbox "Name entered is too large, it can be upto 60 characters long.", vbInformation, title
	else
		myform.Add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function
function valideAddStudyField(myform)
	
	if len(myform.studyField.value) = 0 then
		msgbox "Please enter Field of Study", vbInformation, title
	elseif len(myform.studyField.value) > 50 then
		msgbox "Field of Study entered is too large, it can be upto 50 characters long.", vbInformation, title
	else
		myform.Add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function
function valideStudentSearch(myform, ArrCheckBoxes)
	dim name
'    msgbox ArrCheckBoxes, vbInformation, title
'    msgbox document.all("applicationidcheckbox").checked, vbInformation, title
    flag = true
    name = Split(ArrCheckBoxes, ",")
    For i=0 to UBound(name) 
'        msgbox document.all(name(i)).checked, vbInformation, title
        if (document.all(name(i)).checked) then
            flag = false
        end if
    Next
    if (flag) then
        msgbox "Please Select atleast one column....", vbInformation, title
        exit function
    end if
	if len(myform.courseField.value) = 0 then
		msgbox "Please Select Field of Study", vbInformation, title
	
	else
		myform.Add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function
function validatePassword(myform)
	if myform.password.value <> myform.cPassword.value then
		msgbox "Password does not match with Confirm Password.", vbInformation, title
	elseif len(myform.password.value) < 6 then
		msgbox "Password should be at least 6 characters long.", vbInformation, title
	elseif len(myform.password.value) > 10 then
		msgbox "Password entered is too large, it can be upto 10 characters long.", vbInformation, title
	else				
		myform.Edit.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateOfficeInfo(myform)
	if len(myform.officeName.value) = 0 then
		msgbox "Please enter office name.", vbInformation, title
	elseif len(myform.officeName.value) > 50 then
		msgbox "Office name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.officeAbb.value) = 0 then
		msgbox "Please enter short office name", vbInformation, title
	elseif len(myform.officeAbb.value) > 6 then
		msgbox "Short office name entered is too large, it can be upto 6 characters long.", vbInformation, title
	elseif len(myform.officeStreet.value) > 100 then
		msgbox "Street address entered is too large, it can be upto 100 characters long.", vbInformation, title
	elseif len(myform.officeCity.value) = 0 then
		msgbox "Please enter city name.", vbInformation, title
	elseif len(myform.officeCity.value) > 50 then
		msgbox "City name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.officePostCode.value) > 15 then
		msgbox "Post code entered is too large, it can be upto 15 characters long.", vbInformation, title
	elseif len(myform.officeCountry.value) = 0 then
		msgbox "Please enter country name.", vbInformation, title
	elseif len(myform.officeCountry.value) > 50 then
		msgbox "Country name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.officePhone.value) > 30 then
		msgbox "Phone number entered is too large, it can be upto 30 characters long.", vbInformation, title
	elseif len(myform.officeFax.value) > 30 then
		msgbox "Fax number entered is too large, it can be upto 30 characters long.", vbInformation, title
	elseif len(myform.officeEmail.value) = 0 then
		msgbox "Please enter email address.", vbInformation, title
	elseif len(myform.officeEmail.value) > 50 then
		msgbox "Email address entered is too large, it can be upto 50 characters long.", vbInformation, title
	else
		myform.add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateVisaOfficeInfo(myform)

	if len(myform.visaOfficeName.value) = 0 then
		msgbox "Please enter office name.", vbInformation, title
	elseif len(myform.visaOfficeName.value) > 50 then
		msgbox "Office name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.address.value) > 100 then
		msgbox "Street address entered is too large, it can be upto 100 characters long.", vbInformation, title
	elseif len(myform.visaOfficeCity.value) = 0 then
		msgbox "Please enter city name.", vbInformation, title
	elseif len(myform.visaOfficeCity.value) > 50 then
		msgbox "City name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.visaOfficeCountry.value) = 0 then
		msgbox "Please enter country name.", vbInformation, title
	elseif len(myform.visaOfficeCountry.value) > 50 then
		msgbox "Country name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.visaOfficeEmail.value) = 0 then
		msgbox "Please enter email address.", vbInformation, title
	elseif len(myform.visaOfficeEmail.value) > 50 then
		msgbox "Email address entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.visaOfficePhone.value) > 30 then
		msgbox "Phone number entered is too large, it can be upto 30 characters long.", vbInformation, title
	elseif len(myform.visaOfficeFax.value) > 30 then
		msgbox "Fax number entered is too large, it can be upto 30 characters long.", vbInformation, title
	
	else
		myform.add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
		
	end if
end function

function validateSponsoringBody(myform)
'	if len(myform.KSPNo.value) = 0 then
'		msgbox "Please enter KSP No.", vbInformation, title
'	elseif len(myform.KSPNo.value) > 20 then
'		msgbox "KSP No. entered is too large, it can be upto 20 characters long.", vbInformation, title
	if len(myform.sponsoringbody.value) = 0 then
		msgbox "Please enter Sponsoring Body", vbInformation, title
	elseif len(myform.sponsoringbody.value) > 100 then
		msgbox "Sponsoring Body entered is too large.", vbInformation, title
'	elseif len(scholarship.value) = 0 then
'		msgbox "Please enter Scholarship", vbInformation, title
'	elseif len(scholarship.value) > 100 then
'		msgbox "Sponsoring Body entered is too large.", vbInformation, title
	else
		myform.add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validatePassword(myform)
	if myform.password.value <> myform.cPassword.value then
		msgbox "Password does not match with Confirm Password.", vbInformation, title
	elseif len(myform.password.value) < 6 then
		msgbox "Password should be at least 6 characters long.", vbInformation, title
	elseif len(myform.password.value) > 10 then
		msgbox "Password entered is too large, it can be upto 10 characters long.", vbInformation, title
	else				
		myform.Edit.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateInstitutionInfo(myform)
	if len(myform.instName.value) = 0 then
		msgbox "Please enter Institution name.", vbInformation, title
	elseif len(myform.instName.value) > 50 then
		msgbox "Institution name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.instContactName.value) > 60 then
		msgbox "Contact name entered is too large, it can be upto 60 characters long.", vbInformation, title
	elseif len(myform.instStreet.value) > 100 then
		msgbox "Street address entered is too large, it can be upto 100 characters long.", vbInformation, title
	elseif len(myform.instCity.value) = 0 then
		msgbox "Please enter city name.", vbInformation, title
	elseif len(myform.instCity.value) > 50 then
		msgbox "City name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.instState.value) > 50 then
		msgbox "State entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.instPostCode.value) > 15 then
		msgbox "Post code entered is too large, it can be upto 15 characters long.", vbInformation, title
	elseif len(myform.instCountry.value) = 0 then
		msgbox "Please enter country name.", vbInformation, title
	elseif len(myform.instCountry.value) > 50 then
		msgbox "Country name entered is too large, it can be upto 50 characters long.", vbInformation, title
	elseif len(myform.instPhone.value) > 30 then
		msgbox "Phone number entered is too large, it can be upto 30 characters long.", vbInformation, title
	elseif len(myform.instFax.value) > 30 then
		msgbox "Fax number entered is too large, it can be upto 30 characters long.", vbInformation, title
	elseif len(myform.instEmail.value) > 50 then
		msgbox "Email address entered is too large, it can be upto 50 characters long.", vbInformation, title
	'elseif not isNumeric(myform.instCommission.value) then
		'msgbox "Commission entered is not valid", vbInformation, title
	'elseif len(myform.instCommission.value) > 8 then
		'msgbox "Commission entered is too large, it can be upto 8 characters long.", vbInformation, title
	else
		myform.add.value = "Please wait"
		myform.add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateCourse(myform)
	if len(myform.courseName.value) <= 0 then
		msgbox "Please enter course name.", vbInformation, title
	elseif len(myform.courseName.value) > 100 then	
		msgbox "Course name entered is too large, it can be upto 100 characters long.", vbInformation, title
	elseif len(myform.fees.value) > 0  and  not isNumeric(myform.fees.value) then
		msgbox "Fees entered is not valid.", vbInformation, title		
	elseif myform.commissionType.selectedIndex = 0 and len(myform.cFixedAmount.value) > 0 and not isNumeric(myform.cFixedAmount.value) then
		msgBox "Commission Fixed Amount entered is not valid."
	elseif myform.commissionType.selectedIndex = 1 and len(myform.cPercentage.value) > 0 and not isNumeric(myform.cPercentage.value) then
		msgBox "Commission Percentage entered is not valid."
	else
		myform.done.value = "Please wait"
		myform.done.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function setEdit(myform)
	for i = 0 to myform.cID.length-1
		if myform.elements("edit" & i+1).checked then
			myform.elements("eCourseName" & i+1).disabled = false
			myform.elements("eCourseLevel" & i+1).disabled = false
		else
			myform.elements("eCourseName" & i+1).disabled = true
			myform.elements("eCourseLevel" & i+1).disabled = true
		end if
	next
end function

function validateExistingCourses(myform)
	coursesValid = true
	for i = 0 to myform.cID.length-1
		if myform.elements("edit" & i+1).checked then
			if len(myform.elements("eCourseName" & i+1).value) = 0 then
				coursesValid = false
				msgbox "Please enter course name.", vbInformation, title
				exit for
			elseif len(myform.elements("eCourseName" & i+1).value) > 100 then
				coursesValid = false
				msgbox "Course name entered is too large, it can be upto 100 characters long.", vbInformation, title
				exit for
			end if
		end if
	next
	
	if coursesValid then
		myform.done.value = "Please wait"
		myform.addCourse.value = "modifyCourses"
		myform.done.disabled = true
		myform.back.disabled = true
		myform.add.disabled = true	
		validateText(myform) 
		myform.submit
	end if
end function

function validateEmail(myform)
	if len(myform.eSubject.value) < 1 or len(myform.eSubject.value) > 50 then
		msgbox "Subject entered is too large/small, it must be less than 50 characters", vbInformation, title
	elseif len(myform.eMessage.value) < 1 or len(myform.eMessage.value) > 500 then	
		msgbox "Message entered is too large/small, it must be less than 500 characters", vbInformation, title
	else
		myform.Done.value = "Please wait"
		myform.Done.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateInvoiceInfo(myform)
	if len(myform.institutions.value) < 1 or len(myform.institutions.value) > 50 then
		msgbox "Institution entered is too large/small, it can be upto 50 characters", vbInformation, title
	elseif len(myform.amount.value) < 1  or len(myform.amount.value) > 10 then	
		msgbox "Amount entered is too large/small, it can be upto 10 characters", vbInformation, title
	elseif not isNumeric(myform.amount.value)then	
		msgbox "Amount entered is not valid", vbInformation, title
	elseif not validateDate(myform.date) then
		msgbox "The date entered is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
	elseif len(myform.description.value) < 1 or len(myform.description.value) > 400 then
		msgbox "Description entered is too large/small, it can be upto than 400 characters", vbInformation, title
	else
		myform.Add.value = "Please wait"
		myform.Add.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateSettings(myform)
	settingsValid = true
	if len(myform.bname.value) > 100 then	
		msgbox "Business name entered is too large, it can be upto 100 characters", vbInformation, title
		settingsValid = false
	elseif len(myform.smtpServerURL.value) > 500 then	
		msgbox "SMTP server name entered is too large, it can be upto 500 characters", vbInformation, title
		settingsValid = false
	elseif len(myform.userName.value) > 50 then	
		msgbox "SMTP user name entered is too large, it can be upto 50 characters", vbInformation, title				
		settingsValid = false
	elseif len(myform.password.value) > 50 then	
		msgbox "SMTP password entered is too large, it can be upto 50 characters", vbInformation, title								
		settingsValid = false
	elseif len(myform.bab.value) > 10 then	
		msgbox "Business abrivation entered is too large, it can be upto 10 characters", vbInformation, title								
		settingsValid = false	
	elseif len(myform.bwebsite.value) > 100 then	
		msgbox "Business website URL entered is too large, it can be upto 100 characters", vbInformation, title								
		settingsValid = false
	elseif len(myform.msgtxt.value) > 500 then	
		msgbox "Alert message text entered is too large, it can be upto 500 characters", vbInformation, title								
		settingsValid = false
	elseif len(myform.footerImage.value) > 50 then	
		msgbox "Alert footer image file name entered is too large, it can be upto 50 characters", vbInformation, title								
		settingsValid = false
	elseif len(myform.abn.value) > 11 then	
		msgbox "ABN entered is too large, it can be upto 11 characters", vbInformation, title								
		settingsValid = false
	elseif not isNumeric(myform.abn.value) then	
		msgbox "ABN entered is invalid", vbInformation, title								
		settingsValid = false
	elseif len(myform.gst.value) > 5   then	
		msgbox "GST Rate entered is too large, it can be upto 2 digits long.", vbInformation, title								
		settingsValid = false
	elseif not isNumeric(myform.gst.value) then	
		msgbox "GST Rate entered is invalid.", vbInformation, title								
		settingsValid = false
	elseif len(myform.logo.value) > 50 then	
		msgbox "Logo image file name entered is too large, it can be upto 50 characters", vbInformation, title								
		settingsValid = false
	elseif len(myform.invoicetxt.value) > 500 then	
		msgbox "Invoice Note entered is too large, it can be upto 500 characters", vbInformation, title								
		settingsValid = false			
	end if
	
	for i = 0 to myform.h.length -1 
		if len(myform.h(i).value) < 1 or len(myform.h(i).value) > 25 then
			msgbox "Heading value entered is too large/small", vbInformation, title
			settingsValid = false
		end if
		if len(myform.hUrl(i).value)  > 50 then
			msgbox "URL entered is too large, it must be less than 50 characters", vbInformation, title	
			settingsValid = false
		end if				
	next
	
	if settingsValid then
		myform.done.value = "Please wait"
		myform.done.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateText(myform)
	validateText = true
	for i = 0 to myform.elements.length-1
		if (myform.elements(i).type = "hidden" or myform.elements(i).type = "password" or myform.elements(i).type = "text" or myform.elements(i).type = "textarea") and  instr(myform.elements(i).value, "'") > 0 then
			
			do while not instr(myform.elements(i).value, "''") = 0
				myform.elements(i).value = replace(myform.elements(i).value, "''", "'")
			loop
			myform.elements(i).value = replace(myform.elements(i).value, "'", "''")
			'msgbox "i m in"					
		end if
	next 
	
end function


function removeQouts()
	myform = document.forms.length
	if document.forms.length > 0 then
		for i = 0 to document.forms.length-1
			set myform = document.forms(i)
			
			for j = 0 to myform.elements.length-1
				'msgbox myform.name & "i m in" & myform.elements(0).type
				if (myform.elements(j).type = "hidden" or myform.elements(j).type = "password" or myform.elements(j).type = "text" or myform.elements(j).type = "textarea") and  instr(myform.elements(j).value, "''") > 0 then
					do while not instr(myform.elements(j).value, "''") = 0
						myform.elements(j).value = replace(myform.elements(j).value, "''", "'")
					loop
					'msgbox "i m in"					
				end if
			next 
							
		next 				
	end if
end function

function convertToCurrency(textField)
	if len(trim(textField.value)) <= 0 then
		textField.value = round("0.00", 2)
	elseif not isnumeric(textField.value) then
		msgbox "Commission entered is not numeric", vbInformation, title
	else
		textField.value = round(cdbl(textField.value), 2)
	end if
end function

function changeAllCheckBoxes(myform)
	j = 1
	for i = 0 to myform.elements.length-1
		if myform.elements(i).name = "include"&j then
			if myform.includeAll.checked = true then
				myform.elements("include"&j).checked= true
			else
				myform.elements("include"&j).checked = false
			end if
			j = j + 1
		end if
	next
end function

function changeMainCheckBoxes(myform)
	allChecked = true
	j = 1
	for i = 0 to myform.elements.length-1
		if myform.elements(i).name = "include"&j then
			if myform.elements("include"&j).checked = false then
				allChecked = false
				exit for
			end if
			j = j+1
		end if
	next
	myform.includeAll.checked = allChecked
end function

function validateInvoiceItems(myform)
	anySelected = false
	j = 1
	for i = 0 to myform.elements.length-1
		if myform.elements(i).name = "include"&j then
			if myform.elements("include"&j).checked = true then
				anySelected = true
				exit for
			end if
			j = j + 1
		end if
	next
	
	if not anySelected then
		msgbox "There are no item(s) selected for the invoice or there are no item in the list.", vbInformation, title
	else
		myform.Generate.value = "Please wait"
		myform.Generate.disabled = true
		validateText(myform) 
		myform.submit
	end if
end function

function validateEditInvoice(myform, submit)
	valid = true
	dim i
	for i = 0 to myform.description.length-1
		if Len(myform.description(i).value) > 1then
			if len(myform.description(i).value) > 400 then
				msgbox "Description entered is too large, it can be upto than 400 characters", vbInformation, title
				exit function
			elseif len(myform.amount(i).value) > 10 or len(myform.amount(i).value) < 1 then
				msgbox "amount entered is too large/small, it can be upto 10 characters", vbInformation, title
				exit function
			elseif not isNumeric(myform.amount(i).value)then
				msgbox "Amount entered is invalid", vbInformation, title
				exit function
			end if
		end if
	next
			
	if submit then
		if not validateDate(myform.date) then
			msgbox "The date entered is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
			exit function
		end if
	end if
	
	if submit then
		if cDbl(myform.txtGrossTotals.value) <> 0 then
			myform.Done.value = "Please wait"
			myform.Done.disabled = true
			validateText(myform) 
			myform.submit
		else
			msgbox "Sorry, Invoice could not be created with $0.0 amount", vbInformation, title
		end if
	end if
	validateEditInvoice = true
end function

function calculateTotals(myform, submit)	
	if validateEditInvoice(myform, submit) then		
		dim i
		for i = 0  to myform.amount.length - 1
			if len(myform.description(i).value) > 0 then
				if Len(myform.amount(i).value) > 0 then
					total = total + CDbl(myform.amount(i).value)
				end if
			end if
		next
		
		myform.txtGrossTotals.value = formatNumber(cDbl(total), 2)
		myform.txtGST.value = formatNumber(cDBL(total) * cdbl(myform.hgst.value), 2)
		myform.txtNetTotals.value = formatNumber(cDbl(total) + cdbl(myform.txtGST.value), 2)
		myform.total.value = formatNumber(cDbl(total) + cdbl(myform.txtGST.value), 2)
		
		if not myform.paid.checked then
			myform.txtBal.value = formatNumber(cDbl(total) + cdbl(myform.txtGST.value), 2)
		else
			myform.txtBal.value = formatNumber(0, 2)
		end if
	end if
end function


function validateCalSubmit(myfrom)
	call calculateTotals(myfrom, false)
	call calculateTotals(myfrom, true)
end function


function validatestudentProgram(myform)
	if len(myform.intendedProgram.value) > 100 then
		msgbox "Student program entered is too large, it can be upto 100 characters long.", vbInformation, title
		exit function
	elseif len(trim(myform.intendedProgram.value)) = 0 then
		msgbox "Please enter student program.", vbInformation, title
		exit function
	elseif len(myform.intendedInstitution.value) > 50 then
		msgbox "Student institution entered is too large, it can be upto 50 characters long.", vbInformation, title
		exit function
	elseif len(intendedSemester.textfield.value) > 15 then
		msgbox "Student semester entered is too large, it can be upto 15 characters long.", vbInformation, title
		exit function
	elseif len(myform.referenceNo.value) > 50 then
		msgbox "Student refrence no. entered is too large, it can be upto 50 characters long.", vbInformation, title						
		exit function
	elseif len(myform.UniRef.value) > 50 then
		msgbox "Student university refrence no. entered is too large, it can be upto 50 characters long.", vbInformation, title						
		exit function
	elseif len(InstitutionContact.textfield.value) > 50 then
		msgbox "The email address  entered is too large, it can be upto 50 characters long.", vbInformation, title						
		exit function
	elseif len(myform.Fee.value) < 1 then
		msgbox "Please enter course Fee.", vbInformation, title
		exit function
	elseif len(myform.Fee.value) > 9 then
		msgbox "Course Fee entered is too large, it can be upto 9 digits long.", vbInformation, title
		exit function		
	elseif not isNumeric(myform.Fee.value) then
		msgbox "Course Fee entered is not valid.", vbInformation, title						
		exit function
	elseif len(myform.Commence.value) > 0 then
		if not validateDate(myform.Commence) then
			msgbox "The date entered for Program Commencement is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
			exit function
        end if
	end if
	if len(myform.referenceNo.value) > 30 then
	    msgbox "The date entered for Sponsoring Body Reference No. is too large, it can be upto 30 characters long.", vbInformation, title
		exit function			
	end if		
	
	if myform.prgHistory.value then
		for a = 0  to myform.dateN.length - 2
			if not validateDate(myform.dateN(a)) then
				msgbox "The date entered for stage is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
				exit function
			end if
			
			if len(myform.remarksN(a).value) > 50 then
				msgbox "Remarks for stage entered is too large, it can be upto 50 characters long.", vbInformation, title						
				exit function
			end if
		next
		
		if myform.addStage.checked then
			if not validateDate(myform.dateN(myform.dateN.length-1)) then
				msgbox "The date entered for new stage is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
				exit function
			end if
			
			if len(myform.remarksN(myform.dateN.length-1).value) > 50 then
				msgbox "Remarks for new stage entered is too large, it can be upto 50 characters long.", vbInformation, title						
				exit function
			end if
		end if
	end if
	
	validateText(myform) 				
	myform.submit
end function

function validatestudentProgramAdd(myform)
	
	if len(myform.intendedProgram.value) > 100 then
		msgbox "Student program entered is too large, it can be upto 100 characters long.", vbInformation, title
		exit function
	elseif len(myform.intendedInstitution.value) > 50 then
		msgbox "Student institution entered is too large, it can be upto 50 characters long.", vbInformation, title
		exit function
	elseif len(myform.intendedSemester.value) > 15 then
		msgbox "Student semester entered is too large, it can be upto 15 characters long.", vbInformation, title
		exit function
	elseif len(myform.UniRef.value) > 50 then
		msgbox "Student university refrence no. entered is too large, it can be upto 50 characters long.", vbInformation, title						
		exit function
    elseif len(myform.Fee.value) < 1 then
		msgbox "Please enter course Fee.", vbInformation, title						
		exit function
	elseif len(myform.Fee.value) > 9 then
		msgbox "Course Fee entered is too large, it can be upto 9 digits long.", vbInformation, title						
		exit function		
	elseif not isNumeric(myform.Fee.value) then
		msgbox "Course Fee entered is not valid.", vbInformation, title						
		exit function
	elseif len(myform.Commence.value) > 0 then
		if not validateDate(myform.Commence) then
			msgbox "The date entered for Program Commencement is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
			exit function
        end if
	end if
	if len(myform.referenceNo.value) > 30 then
	    msgbox "The date entered for Sponsoring Body Reference No. is too large, it can be upto 30 characters long.", vbInformation, title
		exit function			
	end if		
	
	if myform.addStage.checked then		
		if not validateDate(myform.dateN) then
			msgbox "The date entered for new stage is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
			exit function
		end if
		if len(myform.remarksN.value) > 50 then
			msgbox "Remarks for new stage entered is too large, it can be upto 50 characters long.", vbInformation, title						
			exit function
		end if
	end if
	
	validateText(myform) 				
	myform.submit
end function

function validatestudentProgramClone(myform)
	
	
		if not validateDate(myform.dateN) then
			msgbox "The date entered for new stage is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
			exit function
		end if
		if len(myform.remarksN.value) > 50 then
			msgbox "Remarks for new stage entered is too large, it can be upto 50 characters long.", vbInformation, title						
			exit function
		end if
'	    if len(myform.referenceNo.value) > 30 then
'	    msgbox "The date entered for Sponsoring Body Reference No. is too large, it can be upto 30 characters long.", vbInformation, title
'		exit function			
'	end if		
	
	validateText(myform) 				
	myform.submit
end function

function validateVisaApplication(myform)
	if len(visaOffice.textfield.value) > 100 then
		msgbox "Visa Office name entered is too large, it can be upto 100 characters long.", vbInformation, title
		exit function
	elseif len(trim(visaOffice.textfield.value)) = 0 then
		msgbox "Please enter visa office name."
		exit function
	elseif not validateDate(myform.DOVA) then
		msgbox "The date entered for visa application is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		exit function
	elseif len(trim(myform.VSC.value)) = 0 then
		msgbox "Please enter visa sub class."
		exit function
	elseif len(trim(myform.VSC.value)) > 20 then
		msgbox "Visa sub class entered is too large, it can be upto 20 characters long.", vbInformation, title
		exit function
	elseif len(trim(myform.VFSNo.value)) = 0 then
	    msgbox "Please enter VFS No."
	exit function
	elseif len(trim(myform.VFSNo.value)) > 20 then
		msgbox "VFS No. entered is too large, it can be upto 20 characters long.", vbInformation, title
		exit function	
	end if
	
	if myform.visaHistory.value then
		if myform.addStage.checked then	
			if len(trim(myform.dateN.value)) = 0 then
				msgbox "The date entered for new stage is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
				exit function
			end if
			if not validateDate(myform.dateN) then
				msgbox "The date entered for new stage is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
				exit function
			end if
			if len(myform.remarksN.value) > 50 then
				msgbox "Remarks for new stage entered is too large, it can be upto 50 characters long.", vbInformation, title						
				exit function
			end if
		end if
	end if
	
	validateText(myform) 				
	myform.submit
end function

function validateStudentCharges(myform)
	
	for i = 0 to myform.amount.length-2
		if Len(myform.amount(i).value) > 0 then
			if not isNumeric(myform.amount(i).value) then
				msgbox "Amount entered for " & myform.charges(i).value & " is not valid.", vbInformation, title
				exit function
			elseif len(myform.remarks(i).value) > 50 then
				msgbox "Remarks for " & myform.charges(i).value & " entered is too large, it can be upto 50 characters long.", vbInformation, title
				exit function
			end if
		end if
	next
	if  Len(myform.amount(myform.amount.length-1).value) > 0 then
		if len(charges.textfield.value) > 50 or len(charges.textfield.value) < 1 then
			msgbox "Name entered for new charge is too large/small, it can be upto 50 characters long.", vbInformation, title
			exit function
		elseif not isNumeric(myform.amount(myform.amount.length-1).value) then
			msgbox "Amount entered for " & charges.textfield.value & " is not valid.", vbInformation, title
			exit function
		elseif len(myform.remarks(myform.amount.length-1).value) > 50 then
			msgbox "Remarks for " & charges.textfield.value & " entered is too large, it can be upto 50 characters long.", vbInformation, title
			exit function
		end if
	end if
	validateText(myform)
	myform.done.disabled = true
	myform.done.value = "Please Wait." 				
	myform.submit
end function

Function validateInvoiceSearch(txt, obj, myform)
	validateText(myform)
	pos = instr(1, txt.value, "/")
	pos = pos - 1
	'msgbox txt.value & ":" & pos &":" & obj.selectedIndex
	if txt.value = "" then
		msgbox "Please enter your search criteria.", vbInformation, title
	elseif len(txt.value) > 50 then
		msgbox "The search criteria entered is too long, it should be less than 60 characters.", vbInformation, title				
	elseif((obj.selectedIndex = 0) and (len(txt.value) > 15)) then
		msgbox "The search criteria entered for invoice number is too long, it can be upto the 15 characters.", vbInformation, title
	elseif((obj.selectedIndex = 1) and (len(txt.value) > 50)) then
		msgbox "The search criteria entered for institution is too long, it can be upto the 50 characters.", vbInformation, title
	elseif (obj.selectedIndex = 2) then
		if not validateDate(txt) then
			msgbox "The date entered for search criteria is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900.", vbInformation, title
		else
			window.location.href = "InvoiceManagerListSearched.asp?pageno=0&tab=4&searchFor=" & txt.value  &_ 
			"&searchBy=" & obj.selectedIndex &_
			"&location=" & "eAdmin > Search Results"
		end if
	else
		myform.search.disabled = true
		myform.search.value = "Please wait"				
		window.location.href = "InvoiceManagerListSearched.asp?pageno=0&searchFor=" & txt.value & "&tab=4" &_ 
			"&searchBy=" & obj.selectedIndex &_
			"&location=" & "eAdmin > Invoice Manager > Search Results"
	end if
end function

Function validateUserSearch(txt, obj, myform)
	validateText(myform)
	if txt.value = "" then
		msgbox "Please enter your search criteria.", vbInformation, title
	elseif len(txt.value) > 50 then
		msgbox "The search criteria entered is too long, it should be less than 60 characters.", vbInformation, title				
	elseif((obj.selectedIndex = 0) and (len(txt.value) > 100)) then
		msgbox "The search criteria entered for name is too long, it can be upto the 100 characters.", vbInformation, title
	elseif (obj.selectedIndex = 1) and (len(txt.value) > 15) then
		msgbox "The search criteria entered for username is too long, it can be upto the 50 characters.", vbInformation, title
	elseif (obj.selectedIndex = 2) and (len(txt.value) > 20) then
		msgbox "The search criteria entered for access level is too long, it can be upto the 20 characters.", vbInformation, title
	else
		myform.search.disabled = true
		myform.search.value = "Please wait"				
		window.location.href = "UserManagerListSearched.asp?pageno=0&searchFor=" & txt.value & "&tab=2" &_ 
			"&searchBy=" & obj.selectedIndex &_
			"&location=" & "eAdmin > User Manager > Search Results"
	end if
end function

Function validateRODA(myform, ArrCheckBoxes)
	valid = true
	anySelected = false
	j = 0
	dim name
'    msgbox ArrCheckBoxes, vbInformation, title
'    msgbox document.all("applicationidcheckbox").checked, vbInformation, title
    flag = true
    name = Split(ArrCheckBoxes, ",")
    For i=0 to UBound(name) 
'        msgbox document.all(name(i)).checked, vbInformation, title
        if (document.all(name(i)).checked) then
            flag = false
        end if
    Next
    if (flag) then
        msgbox "Please Select atleast one column....", vbInformation, title
        exit function
    end if
	for i = 0  to myform.elements.length - 1
		if myform.elements(i).name = "include"&j+1 then
			if myform.elements(i).checked then
				if not isNumeric(myform.days(j).value) then
					msgbox "Number of Days entered is invalid.", vbInformation, title
					valid = false
					exit for
				elseif len(myform.days(j).value) > 3 then
					msgbox "Number of Days entered is too long, it should be less than 3 digits.", vbInformation, title
					valid = false
					exit for
				end if
				anySelected = true
			end if
			j = j + 1
		end if
	next
	
	if not anySelected then
		msgbox "Please select at least one course to generate this report", vbInformation, title
	end if
	
	if valid and anySelected then
		myform.Generate.value = "Please Wait"
		myform.Generate.disabled = true
		myform.submit
	end if
end function

function validateRPS(myform, ArrCheckBoxes)
    dim name, i
'    msgbox ArrCheckBoxes, vbInformation, title
'    msgbox document.all("applicationidcheckbox").checked, vbInformation, title
    flag = true
    name = Split(ArrCheckBoxes, ",")
    For i=0 to UBound(name) 
'        msgbox document.all(name(i)).checked, vbInformation, title
        if (document.all(name(i)).checked) then
            flag = false
        end if
    Next
    if (flag) then
        msgbox "Please Select atleast one column....", vbInformation, title
        exit function
    end if
    
	if not validateDate(myform.fromDate) then
		msgbox "The date entered for from Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		exit function
	elseif not validateDate(myform.toDate) then
		msgbox "The date entered for To Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		exit function
	end if
	myform.generate.value = "Please Wait"
	myform.generate.disabled = true
	myform.submit
end function

function validateRUTS(myform)
	if not validateDate(myform.fromDate) then
		msgbox "The date entered for from Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		exit function
	elseif not validateDate(myform.toDate) then
		msgbox "The date entered for To Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		exit function
	end if
	myform.generate.value = "Please Wait"
	myform.generate.disabled = true
	myform.submit
end function

function validateUTS(myform)
    
    dim name, i
'    msgbox ArrCheckBoxes, vbInformation, title
'    msgbox document.all("applicationidcheckbox").checked, vbInformation, title
    if not validateDate(myform.fromDate) then
		msgbox "The date entered for from Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		exit function
	elseif not validateDate(myform.toDate) then
		msgbox "The date entered for To Date is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		exit function
	end if
	myform.generate.value = "Please Wait"
	myform.generate.disabled = true
	myform.submit
end function

function validateText(myform)
	dim len, j
	len = myform.elements.length
	for j = 0 to myform.elements.length - 1

		if myform.elements(j).type = "textarea" or myform.elements(j).type = "text" or myform.elements(j).type = "password" then			
			if instr(myform.elements(j).value, "'") > 0 then				
				myform.elements(j).value = replace(myform.elements(j).value, "'", "''")
			end if
		end if
	next
end function

Function validateNewMessageForm(myform)
	
	If len(myForm.newMessage.value) = 0 Then
		msgbox "Please enter message text.", vbInformation, title
		Exit Function
	End If
	
	If len(myForm.newMessage.value) > 4000 Then
		msgbox "Text entered for message is too large, it can be upto 4000 charactars long.", vbInformation, title
		Exit Function
	End If
	
	If len(myForm.messageSubject.value) > 100 Then
		msgbox "Text entered for subject is too large, it can be upto 100 charactars long.", vbInformation, title
		Exit Function
	End If
	
	If myForm.Users.selectedIndex = -1 Then
		msgbox "Please select at least one user from the list.", vbInformation, title
		Exit Function
	End If

	validateText(myform)
	myform.sendMessage.value = "Please Wait"
	myform.sendMessage.disabled = true
	myform.submit

End Function
































Function validateStudentAddFormPersonal(myform, from)	
	
	addValid = false
	addQulificationValid = false
	
	if from = "AddStudent" or from = "EditStudent" then
		if  myform.name.value = "" then
			msgbox "Please enter first name.", vbInformation, title
		elseif myform.fathername.value = "" then
			msgbox "Please enter last name.", vbInformation, title
		elseif not validateDate(myform.DOB) then
			msgbox "The date entered for date of birth is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		elseif not validateDate(myform.dateInitiated) then 
			msgbox "The date entered for date initiated is not in the required format, please enter date in (dd/mm/yyyy) format and year should be greater than 1900 or the date might be missing.", vbInformation, title
		elseif len(myform.name.value) > 30 then
			msgbox "First name entered is too large, it can be upto 30 characters long.", vbInformation, title
		elseif len(myform.fathername.value) > 30 then
			msgbox "Last name entered is too large, it can be upto 30 characters long.", vbInformation, title		
	   elseif len(myform.fileNo.value) > 20 then
			msgbox "File No entered is too large, it can be upto 20 characters long.", vbInformation, title
		elseif len(myform.Tel.value) > 30 then
			msgbox "Student phone number entered is too large, it can be upto 30 characters long.", vbInformation, title
	    elseif len(myform.mobileNo.value) = 0  then
			msgbox "Please Enter student Mobile Number.", vbInformation, title
		elseif len(myform.mobileNo.value) > 20 then
			msgbox "Student phone number entered is too large, it can be upto 20 characters long.", vbInformation, title
		elseif len(myform.email.value) > 100 then
			msgbox "Student email entered is too large, it can be upto 100 characters long.", vbInformation, title
		elseif len(myform.email.value) = 0 then
			msgbox "Please enter student email.", vbInformation, title
		elseif not IsEmailValid(myform.email.value) then
			msgbox "Please enter valid student email.", vbInformation, title
		elseif len(myform.fileNo.value) = 0 then
			msgbox "Please enter file number.", vbInformation, title			
		elseif IsEmailValid(myform.email.value) = false then
			msgbox "Please enter Valid Email Address.", vbInformation, title			
	   elseif IsEmailValid(myform.email2.value) = false and len(myform.email2.value) > 0 then
	        msgbox "Please enter Valid Email Address in email2.", vbInformation, title			
		elseif len(myform.passportNo.value) > 20 then
			msgbox "PassPort No. entered is too large, it can be upto 20 characters long.", vbInformation, title
		elseif (myform.relatedOffice.length < 1) then
			msgbox "Please Select any related Office", vbInformation, title
		elseif (myform.assignedUser.length < 1) then
			msgbox "Please Select any assigned admission officer", vbInformation, title
		else
			addValid = true
		end if
	end if		
	
	if from = "EditStudent" and addValid = true then
		myform.Add.value = "Please wait"
		myform.Add.disabled = true
		validateText(myform) 				
		myform.submit
	end if


End Function












