Sub ChangeBgColor(tdCol1,tdCol2,strType)	
	set td1 = tdCol1
	set td2 = tdCol2
	if strType = 1 then
		td1.style.backgroundColor = "#98BBE3"
		td2.style.backgroundColor = "#98BBE3"
	else
		td1.style.backgroundColor = ""
		td2.style.backgroundColor = ""
	end if
End Sub

Sub DivmouseOver(divItemID)
dim ObjDiv
	set ObjDiv = divItemID 
	dim strheight
	strheight = ObjDiv.style.height
	ObjDiv.style.clip = "rect(0px auto " & strheight &" auto)"
End Sub

Sub DivMouseOut(divItemID)
	set ObjDiv = divItemID 
	divItemID.style.clip = "rect(0px auto 20px auto)"
End Sub

	Function GetListItemValues(pstrFormName)
	dim strValue 
	dim strListItem
		strValue = ""
		with pstrFormName
			For intCntr = 0 To .length - 1
				If Mid(.elements(intCntr).name,1,3) = "lst" Then				
					strValue = strValue + "$" 
					set strListItem = .elements(intCntr)
					for i=0 To strListItem.length - 1
						if i =  strListItem.length - 1 then
							strValue = strValue + strListItem.item(i).value
						else
							strValue = strValue + strListItem.item(i).value + ";" 
						end if
					next 
				end if
			next
			strValue = Mid(strValue,2)			
		end with
		GetListItemValues = strValue
	End Function
'---------------------------------------------------------------------------------------------------------------------------------------			
	Sub AddToList(strItem,strPartFieldId)
	dim strSelected
	dim strName
		strName = strItem.name
		strSelected = GetListItemIds(strItem)	
		call OpenRelWindow("../App/MultiSelectList.aspx?strItem="&strName&"&strPartFieldId="&strPartFieldId&"&strSelected="&strSelected,MultiSelect,300,400)
	End Sub
'---------------------------------------------------------------------------------------------------------------------------------------			
Function GetListItemIds(Source)
Dim strValue
Dim strSep
	strSep = ""
	if (Source.length > 1) then
		for intCntr = 0 to Source.length -1 
			strValue = strValue + strSep + source.item(intCntr).value		
		next
	end if		
	GetListItemIds = strValue
	
End Function
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub Add(Source,pstrText,pstrValue)	
	set oOption = document.createElement("OPTION")
		oOption.text  = pstrText
		oOption.Value = pstrValue
		Source.add(oOption)
End sub
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub Remove(Source)
	if Source.selectedIndex > -1 then
		for i = Source.length - 1 to 0 step -1 						
			if Source.options(i).selected then
				Source.remove(i)
			end if
		next
	end if 
End Sub

Sub RemoveAll(Source)
	for i = Source.length - 1 to 0 step -1
		Source.remove(i)			
	next
End Sub

'---------------------------------------------------------------------------------------------------------------------------------------		
Sub OpenRelWindow(pstrUrl, pstrWindowName, pintHeight, pintWidth)
	Dim strFeature
	Dim wndOpenRelatedWindow
		intLeft = (screen.availWidth - pintWidth) / 2
		intTop = (screen.availHeight - pintHeight) / 2
		strFeature = "left=" & intLeft & ",top=" & intTop & ",width=" & pintWidth & ",height=" & pintHeight& ",status = no, scrollbars =no"
		
		Set wndOpenRelatedWindow = window.open(pstrURL, pstrWindowName, strFeature)
		wndOpenRelatedWindow.Focus
End  Sub
'---------------------------------------------------------------------------------------------------------------------------------------
Sub OpenRelWindowWithStatus(pstrUrl, pstrWindowName, pintHeight, pintWidth, pbytScrool, pbytResizable)
Dim strFeature
Dim intWidth, intHeight
	if (pintWidth = -1) Then
		pintWidth = screen.availWidth - (screen.availWidth / 5)
	end if
	if (pintHeight = -1) Then
		pintHeight = screen.availHeight - (screen.availHeight / 5)
	end if

	intLeft = (screen.availWidth - pintWidth) / 2
	intTop = (screen.availHeight - pintHeight) / 2
	strFeature = "left=" & intLeft & ",top=" & intTop & ",width=" & pintWidth & ",height=" & pintHeight & ", scrollbars = " & pbytScrool & ", resizable = " & pbytResizable
	Set wndOpenRelatedWindow = window.open(pstrURL, pstrWindowName, strFeature)
	wndOpenRelatedWindow.Focus		
End  Sub
'---------------------------------------------------------------------------------------------------------------------------------------
Sub ShowGroupDetail(strParameter1,strParameter2)
	Dim strFeatures
		intLeft = (window.screen.availWidth - 358) / 2
		intTop = (window.screen.availHeight - 550) / 2
		strFeatures = "left= " & intLeft & ", top=" & intTop & ", width=475px, height=600px"
		Set wndGrpDetail = window.open("ExpertDetail.aspx?" & strParameter1 & "&" & strParameter2 , "wndDetail", strFeatures)
		wndGrpDetail.focus									
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------
Sub TopToList(Source)
dim Selected
dim intCntr
	selected = source.SelectedIndex
	if (Source.length > 1 And selected > 0) then 			
		for intCntr = selected to 1  step -1
			Call SwapUp(Source.Options,intCntr)
		next
	end if
	source.SelectedIndex = 0
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------				
Sub BottomToList(Source)
dim Selected
dim intCntr
	selected = source.SelectedIndex
	if (Source.length > 1 And selected > -1 and selected < source.length -1) then 
		for intCntr = selected to source.length -2
			Call SwapDown(Source.Options,intCntr)
		next
	end if
	source.SelectedIndex = source.length -1
End Sub

'---------------------------------------------------------------------------------------------------------------------------------------				
Sub UpToList(Source)		
dim Selected
	if Source.length > 1 then 
	intCntr = 0
		for intCntr2 = 0 to Source.length - 1
			if (Source.selectedIndex = intCntr2) then 					
				Selected = intCntr2
				exit for
			end if
		next		
		if 	Selected <> 0 Then 	
			call SwapUp(Source.options,selected)
			Source.options(selected).selected	= false
			Source.options(selected - 1).selected= true
		end if
	end if 
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub DownToList(Source)
dim Selected
	if Source.length > 1 then 
		intCntr = 0
		Selected = 0
		for intCntr2 = 0 to Source.length - 1 
			if (Source.selectedIndex = intCntr2) then
				Selected = intCntr2
				exit for
			end if
		next
		if selected <> Source.length - 1 then
			call SwapDown(Source.options,selected)
			Source.options(selected).selected	= false
			Source.options(selected + 1).selected= true
		end if
	end if
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub SwapUp(oOptions,index)
dim oOption2
	set oOption2 = document.createElement("OPTION")
	oOption2.text  = oOptions(index-1).text
	oOption2.value = oOptions(index -1).value

	oOptions(index-1).text = oOptions(index).text
	oOptions(index-1).Value = oOptions(index).value
	oOptions(index).text = oOption2.text
	oOptions(index).Value = oOption2.value

End Sub
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub SwapDown(oOptions,index)
	dim oOption2
	set oOption2 = document.createElement("OPTION")
	oOption2.text  = oOptions(index+1).text
	oOption2.value = oOptions(index+1).value
	oOptions(index+1).text = oOptions(index).text
	oOptions(index+1).Value = oOptions(index).value
	
	oOptions(index).text = oOption2.text
	oOptions(index).Value = oOption2.value
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------		
Function GetDetailSelected(objForm, objItemAll)
Dim intCntr, intCntr2, strValue, strSep
Dim strParamater
	intCntr2 = 0
	strSep = "$"
	With objForm
		For intCntr = 0 To .length - 1
		strItem	= objForm.elements(intCntr).name
			If .elements(intCntr).type = "checkbox" Then
				if  (strItem <> objItemAll.name) AND (Mid(strItem,1,Len(strItem)-1)= objItemAll.name) Then					
					If .elements(intCntr).checked And Not .elements(intCntr).disabled And _
						Trim(.elements(intCntr).value) <> "" Then
						strValue = strValue & strSep & .elements(intCntr).value
						intCntr2 = intCntr2 + 1
					End If					
				end if
			End If
		Next 
	End With	
	GetDetailSelected = strValue
End Function
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub CheckDetail(objForm, objItemAll)
	Dim intCntr
	Dim strItem
		For intCntr	= 0 To objForm.length - 1
		strItem	= objForm.elements(intCntr).name
			If (objForm.elements(intCntr).type = "checkbox") Then
				If objForm.elements(intCntr).disabled = False Then
					if (strItem = objItemAll.name) or (Mid(strItem,1,Len(strItem)-1)= objItemAll.name) Then						
						objForm.elements(intCntr).checked = objItemAll.checked
					end if
				End If
			End If
		Next
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub CheckAll(objForm)
	Dim intCntr
		For intCntr	= 0 To objForm.length - 1
			If (objForm.elements(intCntr).type = "checkbox") Then
				If objForm.elements(intCntr).disabled = False Then
					objForm.elements(intCntr).checked = objForm.chkSelectedAll.checked
				End If
			End If
		Next
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------
Sub Message(strMessage,strType)
Dim strParams
	strParams = "strMsg="+strMessage+"&strType="+strType
	Call OpenRelWindow("../App/Message.aspx?"+strParams,windowMsg,185,350)
End Sub

Sub Hierarchy1Clicked(pstrField)
	dim objItem 
	set objItem =  pstrField
	Call OpenRelWindow("../LookUp/LookUp.aspx?from=Hierarchy1&strFieldName="+objItem.name,Hierarchy1,450,470)
End Sub	
'---------------------------------------------------------------------------------------------------------------------------------------
'Sub Hierarchy2Clicked(pstrField,pstrParentValue)
'	dim objItem 
'	set objItem =  pstrField
'	Call OpenRelWindow("../LookUp/LookUp.aspx?from=Hierarchy2&value="+pstrParentValue+"&strFieldName="+objItem.name,Hierarchy1,450,470)
'End Sub	
'---------------------------------------------------------------------------------------------------------------------------------------
Sub AccountClicked(pstrField)
	dim objItem 
	set objItem =  pstrField
	Call OpenRelWindow("../LookUp/LookUp.aspx?from=Acc&strFieldName="+objItem.name,Account,450,470)
End Sub		
'---------------------------------------------------------------------------------------------------------------------------------------
Sub UserClicked(pstrField)
	dim objItem
	set objItem =  pstrField	
	Call OpenRelWindow("../LookUp/LookUp.aspx?from=User&strFieldName="+objItem.name,User,450,470)
End Sub 
'---------------------------------------------------------------------------------------------------------------------------------------
Sub ContactClicked(pstrField)
	dim objItem 
	set objItem =  pstrField
	Call OpenRelWindow("../LookUp/LookUp.aspx?from=Conn&strFieldName="+objItem.name,Contact,450,470)
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------	
Sub DateClicked(pstrField)
Dim objItem
set objItem = pstrField		
	Call OpenRelWindow("../Home/Calendar.aspx?from=Acc&strFieldName="+objItem.name,"Calendar",175,225)
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------	
Sub PickDate1Clicked(pstrField)
	dim objItem
	set objItem =  pstrField	
	Call OpenRelWindow("../Home/Calendar.aspx?from=CalendarEvent1&strFieldName="+objItem.name,"Calendar",175,225)
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------		
Sub PickDate2Clicked(pstrField)
	dim objItem 
	set objItem =  pstrField
	Call OpenRelWindow("../Home/Calendar.aspx?from=CalendarEvent2&strFieldName="+objItem.name,"Calendar",175,225)
End Sub	
'---------------------------------------------------------------------------------------------------------------------------------------	
'Sub InviteClicked()
'	Call OpenRelWindow("InviteUser.aspx",Contact,250,300)
'End Sub


'------------------------------------------------------------------------------------------------------------
Function AllowNull(strFormName, source,hstrValue)
	dim astrHidden,astrCouple
	dim strField,strLabel
	
	
	if Len(hstrValue) > 0 then 
		astrHidden = Split(hstrValue,"$")
			for intCntr = 1 To UBound(astrHidden) 
				astrCouple = Split(astrHidden(intCntr),"|")
				
				
				
				if document.forms(strFormName).elements(astrCouple(1)).type = "text" then 
					if Trim(document.forms(strFormName).elements(astrCouple(1)).value) = "" then
						strMsg =  astrCouple(0) & " " & WriteErr(source,"1")
						document.forms(strFormName).elements(astrCouple(1)).focus
						Call Message(strMsg,"btnOk")
						AllowNull = 1
						exit function
					end if 
				elseif  document.forms(strFormName).elements(astrCouple(1)).type = "select-one" then 
					if document.forms(strFormName).elements(astrCouple(1)).selectedIndex = 0 then						
						strMsg =  astrCouple(0) & " " & WriteErr(source,"1")
						document.forms(strFormName).elements(astrCouple(1)).focus
						Call Message(strMsg,"btnOk")
						AllowNull = 1
						exit function
					end if 					
				end if
			next
	else
		AllowNull = 0
	end if
	AllowNull = 0
End Function

'------------------------------------------------------------------------------------------------------------
Sub ReturnMsg1(strValue)

End Sub
'------------------------------------------------------------------------------------------------------------
Function CheckNumber(strFormName,strFields)
dim astrFields
dim strRetVal
	astrFields = Split(strFields,",")
	strRetVal = ""
	for intCntr = 1 to UBound(astrFields)		
		if (Mid(astrFields(intCntr),1,3) = "mon")  or (Mid(astrFields(intCntr),1,3) = "int") then		
			if (Trim(document.forms(strFormName).elements(astrFields(intCntr)).value) <> "")  then
				if Not IsNumeric(document.forms(strFormName).elements(astrFields(intCntr)).value) then 
					strRetVal = strRetVal +"," +astrFields(intCntr)
				end if
				
			end if
		end if
	next	
	CheckNumber = strRetVal
End Function
'------------------------------------------------------------------------------------------------------------
Function WriteErr(source,pstrMsgId)
Dim astrMsg,astrItem
Dim intcntr
Dim intMsgId	
	astrMsg = Split(source.hstrMsg.value,"@")
	WriteErr = ""
	for intCntr = 0 To UBound(astrMsg)
		astrItem = Split(astrMsg(intCntr),"|")		
		if pstrMsgId = astrItem(0)  then
			WriteErr = astrItem(1)
			exit function	
		end if 
	next
End Function
