Dim msSelObj
Dim mlngObjs
Dim mlngObjNum

Function MouseOver()

	Set objE = Window.Event.SrcElement
	If objE.GetAttribute("sel") = 0 Then
		objE.Style.BorderColor = "cccccc"
	End If



End Function

Function MouseLeave()
	Set objE = Window.Event.SrcElement

	If objE.GetAttribute("sel") = "0" Then
		objE.Style.BorderColor = "ffffff"
	End If



End Function

Function SelectObj()
	Set objE = Window.Event.SrcElement

	If Len(msSelObj) > 0 Then
		Set objOld = Document.All(msSelObj)

		objOld.SetAttribute "sel", "0"
		objOld.Style.BorderColor = "ffffff"
	End If

	objE.SetAttribute "sel", "1"
	objE.Style.BorderColor = "blue"

	txtText.Value = objE.innerText
	cmbSize.Value = Replace(objE.Style.fontSize, "pt", "")
	cmbFamily.Value = objE.Style.fontFamily
	cmbAlign.Value = objE.Style.textAlign
	cmbColor.Value = objE.Style.color

	chkBold.Checked = (objE.Style.fontWeight = "bold")
	chkItalic.Checked = (objE.Style.fontStyle = "italic")
	chkUnder.Checked = (objE.Style.textDecoration = "underline")

	msSelObj = objE.Name

	Set objE = Nothing
	Set objOld = Nothing

	cmdInsert.Disabled = False
	cmdDelete.Disabled = False



End Function

Function InsertObj()



	mlngObjs = mlngObjs + 1
	mlngObjNum = mlngObjNum + 1



	Set objNew = document.createElement("span")



	With objNew
		.className = "obj"
		.id = "obj" & mlngObjNum
		.setAttribute "name", CStr("obj" & mlngObjNum)
		.innerText = "new text"
		.setAttribute "sel", "0"
		.style.borderColor = "ffffff"
		.attachEvent "onclick", getRef("selectObj")
		.attachEvent "onmouseover", getRef("mouseOver")
		.attachEvent "onmouseleave", getRef("mouseLeave")
		.style.width = "100%"
		.style.padding = "2px"
		.style.fontSize = "12pt"
		.style.color = "black"
		.style.fontFamily = "arial"
		.style.textAlign = "left"
		.style.fontWeight = "normal"
		.style.fontStyle = "normal"
		.style.textDecoration = "none"
	End With

	If mlngObjs = 1 Or Len(msSelObj) = 0 Then
		Set objPar = Document.All("divBuffer")

		Call objPar.appendChild(objNew)

		'Set objBR = Document.CreateElement("br")
		'Call objPar.appendChild(objBR)

		'Set objBR = Document.CreateElement("br")
		'Call objPar.appendChild(objBR)

		Call document.all("obj" & mlngObjNum).fireEvent("onclick")
	Else
		Set objSel = Document.All(msSelObj)

		objSel.insertAdjacentElement "beforeBegin", objNew

		'Set objBR = Document.CreateElement("br")
		'objSel.insertAdjacentElement "beforeBegin", objBR

		'Set objBR = Document.CreateElement("br")
		'objSel.insertAdjacentElement "beforeBegin", objBR


	End If



End Function

Sub DeleteObj()

	If Len(msSelObj) > 0 Then
		Set objSel = Document.All(msSelObj)



		Call objSel.removeNode(True)

		Set objSel = Nothing

		mlngObjs = mlngObjs - 1
		msSelObj = ""


	End If

End Sub

Sub ShowHTML()

	Alert frmMain.hidHtml.Value

End Sub

Sub UpdateHtml()



	sTemp = Document.All("divView").innerHtml

	'sTemp = Replace(sTemp, "onclick=selectObj", "")
	'sTemp = Replace(sTemp, "onmouseover=mouseOver", "")
	'sTemp = Replace(sTemp, "onmouseleave=mouseLeave", "")
	'sTemp = Replace(sTemp, "class=obj", "")
	'sTemp = Replace(sTemp, "border-color:blue;", "border-color:ffffff;")

	frmMain.hidHtml.Value = sTemp

End Sub

Sub cmbSize_OnChange()

	If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)
	objSel.Style.FontSize = cmbSize.Value & "pt"
	Set objSel = Nothing



End If

End Sub

Sub cmbFamily_OnChange()

	If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)
	objSel.Style.FontFamily = cmbFamily.Value
	Set objSel = Nothing


End If

End Sub

Sub txtText_OnChange()

	If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)
	objSel.innerText = txtText.Value
	Set objSel = Nothing


End If

End Sub

Sub cmbAlign_OnChange()

	If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)
	objSel.Style.textAlign = cmbAlign.Value
	Set objSel = Nothing


End If

End Sub

Sub cmbColor_OnChange()

	If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)
	objSel.Style.color = cmbColor.Value
	Set objSel = Nothing


End If

End Sub

Sub chkBold_OnClick()

If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)

	If chkBold.Checked = True Then
		objSel.Style.fontWeight = "bold"
	Else
		objSel.Style.fontWeight = "normal"
	End If

	Set objSel = Nothing


End If
End Sub

Sub chkItalic_OnClick()
If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)

	If chkItalic.Checked = True Then
		objSel.Style.fontStyle = "italic"
	Else
		objSel.Style.fontStyle = "normal"
	End If

	Set objSel = Nothing


End If
End Sub

Sub chkUnder_OnClick()
If Len(msSelObj) > 0 Then
	Set objSel = Document.All(msSelObj)

	If chkUnder.Checked = True Then
		objSel.Style.textDecoration = "underline"
	Else
		objSel.Style.textDecoration = "none"
	End If

	Set objSel = Nothing


End If
End Sub

Sub cmdUpdate_OnClick()

	UpdateHtml

	frmMain.Submit

End Sub

Function LinkOver(iOver)

	Set oEle = Window.Event.SrcElement

	Do Until LCase(oEle.Tagname) = "tr"
		Set oEle = oEle.ParentElement
	Loop

	iRow = oEle.RowIndex

	If iOver = 1 Then
		tblNav.Rows(iRow).Cells(0).Style.Visibility = ""
	Else
		tblNav.Rows(iRow).Cells(0).Style.Visibility = "hidden"
	End If
End Function

Function cmbReport_OnChange
	Dim sSQL

	Select Case frmRunSQL.cmbReport.Value
		Case 0
			sSQL = ""

		Case 1 'Active Members
			sSQL = "SELECT [LName] AS [Last Name], [FName] AS [First Name], [Email] AS [Email Address], [PaidThru] AS [Paid Thru], [CFPaidThru] AS [CF Paid Thru] FROM [Member] WHERE [Status] = -1 ORDER BY [LName]"

		Case 2 'Username/Password
			sSQL = "SELECT [LName] AS [Last Name], [FName] AS [First Name], [Username], [Password] FROM [Member] ORDER BY [LName]"

		Case 3 'Members by Join Date
			sSQL = "SELECT [LName] AS [Last Name], [FName] AS [First Name], [JoinDate] AS [Date Joined] FROM [Member] ORDER BY [JoinDate] DESC"

		Case 4 'Duplicate Members
			sSQL = "SELECT LName AS [Last Name], FName AS [First Name] FROM Member GROUP BY LName, FName HAVING COUNT(*) > 1"

		Case 5 'Voting Results
			sSQL = "select m.lname + ', ' + m.fname as Name,  iif(v.vote > 0, iif(v.vote = 1, 'Yes', 'No'), 'No Response') as Vote, v.comments as Comments, format(v.edate, 'm/d/yy h:nn ampm') as Entered from vote as v inner join member as m on m.idmember = v.memberid where edate > #04/01/2005# order by m.lname"

		Case 6 'Voting Breakdown
			sSQL = "select min(m.lname + ', ' + m.fname) as Name, sum(iif(v.vote = 1, 1,0)) as [Yes Votes],sum( iif(v.vote = 2,1,0)) as [No Votes],sum(iif(v.vote > 0,0,1)) as [No Response Votes] ,count(*) as [Total Votes]  from vote as v inner join member as m on m.idmember = v.memberid where edate > #04/01/2005# group by m.idmember order by min(m.lname)"

		Case 7 'Voting Totals
			sSQL = "select sum(iif(v.vote = 1, 1,0)) as [Yes Votes],sum( iif(v.vote = 2,1,0)) as [No Votes],sum(iif(v.vote > 0,0,1)) as [No Response Votes] ,count(*) as [Total Votes]  from vote as v where edate > #04/01/2005# and len(memberID) > 0"

		Case 8 'Members coming due
			sSQL = "SELECT [LName] AS [Last Name], [FName] AS [First Name], [Email] AS [Email Address], [PaidThru] AS [Paid Thru], [CFPaidThru] AS [CF Paid Thru] FROM Member WHERE Status=-1 AND ( (PaidThru Between (Date()+30) And (Date()-30) ) OR (CFPaidThru Between (Date()+30) And (Date()-30) ) ) ORDER BY LName"

		Case 9 'Coach Finders coming due
			sSQL = "SELECT [LName] AS [Last Name], [FName] AS [First Name], [Email] AS [Email Address], [PaidThru] AS [Paid Thru], [CFPaidThru] AS [CF Paid Thru] FROM Member WHERE (webactive=-1 AND (CFPaidThru Between (Date()+30) And (Date()-30) ) ) and (status = 0) ORDER BY LName"
		
		Case 10 'Clear out all of the votes
			sSQL = "DELETE from [Vote] WHERE 1=1"
	End Select

	frmRunSQL.sql.InnerText = sSQL

	If Len(sSQL) > 0 Then
		frmRunSQL.sql.ReadOnly = True

		frmRunSQL.sql.Style.Color = "blue"
	Else
		frmRunSQL.sql.ReadOnly = False
		frmRunSQL.sql.Style.Color = "000000"
	End If

End Function

Function DeleteMem(lMemberID)

	lReturn = MsgBox("Are you sure you want to delete this member?" & vbCrLf & vbCrLf & "This action is not reversible! Member data will be lost!", vbExclamation Or vbOkCancel)

	If lReturn = 1 Then
		Window.Navigate "sp_deletemember.asp?mi=" & lMemberID
	End If

End Function

Function DeleteEvent(lEventID)

	lReturn = MsgBox("Are you sure you want to delete this event?" & vbCrLf & vbCrLf & "This action is not reversible! Event data will be lost!", vbExclamation Or vbOkCancel)

	If lReturn = 1 Then
		Window.Navigate "sp_deleteevent.asp?ei=" & lEventID
	End If

End Function