Function RandomImage(path)
	dim strBasePath
	dim strImage()
	dim x
	dim objFolder
	dim objFile
	dim objFSO
	dim fso
	dim n
	dim imgsrc
	dim strFileName
	dim strHyperlinkPath
	
	x = 1
	strBasePath = path  'path to the random images
	
	'create the FSO
	    Set fso = Server.CreateObject("Scripting.FileSystemObject")
	    Set objFolder = fso.GetFolder(Server.MapPath(strBasePath))
		
	'loop through every file in the current folder
  		For Each objFile in objFolder.Files

			strFileName = objFile.Name                      'get filename

			strHyperlinkPath = strBasePath & strFileName
				
			RemoveSpaces strHyperlinkPath    'Allow spaces in filenames by replacing spaces with %20 in hyperlink
					
			ReDim Preserve strImage(x)
			strImage(x) = strHyperlinkPath
			x = x+1	
					
		Next

	Randomize

	 x = UBound(strImage) + 1
	 n = int(rnd * x)  

	n = cstr(n)
	RandomImage = strImage(n)

	set fso = Nothing
	set objFolder = Nothing
	set objFile = Nothing

End Function

Function RemoveSpaces(strString)
	dim strHyperlinkPath
	
	strHyperlinkPath = Replace(strHyperlinkPath," ","%20")
		
End Function

function CheckData(value,stype)
	dim dteEarliest
	select case stype

		case "Email"
			if instr(1,value,"@") then
				checkData = true
			else
				checkData = false
			end if

		case "String"
			if instr(1, value, "'" ) > 0  then 
				checkData = false	
			else
				if IsNumeric(value)= true then
					checkData = false
				else
					checkData = true
				end if
			end if	
	
		case "Date"
			checkData = true
			if len(trim(value)) = 0 then
				checkData = true
				exit function
			end if	
			if isdate(value) then 
				dteLatest = date()
				if isnumeric(mid(value, 4, 2)) then
					if mid(value, 4, 2) > 12 then
						checkData = false	
					end if
				 else
					if isnumeric(mid(value, 3, 2)) then
						if mid(value, 3, 2) > 12 then
							checkData = false	
						end if
					end if
				end if
			else 
				checkData = false
			end if

		case "Number"
			if IsNumeric(Replace(value," ",""))= false then
				checkData = false
			else
				if Replace(value," ","") < 0 then 
					checkData = false
					exit function
				end if
				'to prevent more than 2DPs
				intPoint = instr(Replace(value," ",""), ".") 
				if intPoint > 0 then
					if len(Replace(value," ","")) - intPoint > 2 then 
						checkData = false
					 else
						checkData = true
					end if					
				 else
					checkData = true
				end if
			end if

	end select
end function

'Function ShowHide(strID)
'	if document.getElementById(strID).style.display ="none" then
'		document.getElementById(strID).style.display =""
'	else
'		document.getElementById(strID).style.display ="none"
'	end if
'End Function

'Function Hide(strID)
'	document.getElementById(strID).style.display ="none"
'End Function

'Function Show(strID)
'	document.getElementById(strID).style.display =""
'End Function