<!--#include virtual="NRConfig/Shared/ProgrammingConstants.inc"-->
<% 
'*****************************************************************************
' Copyright (C) 2001 Microsoft Corporation. All rights reserved.
'
' File:  /SCA/Shared/shared.inc
' Author: Microsoft Corporation
'
' Purpose:
'   Define functions that are shared by 
'   the whole application
'
'Public Methods and Properties Exposed:
'	- Sub VerifyIsSupportedBrowser()
'	- BoolToString(bCurrentSetting)
'	- GetSelectedStated(bCurrentSetting, bDropDownBoxOption)
'	- GetCheckeddState(bCurrentSetting, bRadioButtonValue)
'	- ValidateLicenseType(eLicenseType)
'	- InitSCAMsgbox()
'	- ResServerIndexExist(ResServerIndex)
'	- Bool2LCaseStr(bASPBoolean)
'
'*****************************************************************************

	
'*************************************************
'Purpose: 	Check browser version 
'         
'Input:		None
'
'Output:  	Warning message if browser version is wrong
' 			
'************************************************* 
    
Public Function VerifyIsSupportedBrowser()

	Dim strVersionInfo
	strVersionInfo = CheckBrowserVersion
	'-- if Netscape, show error message
	If strVersionInfo = IDS_NETSCAPE_VERSION Then

		'Return Error message
		VerifyIsSupportedBrowser= IDS_UI_WARNING_NETSCATE_MESSAGE
		Exit Function
		
	'-- if lower than 4, show error message 
	ElseIf strVersionInfo = IDS_LOWER_THAN_IE4 Then
	
		'Return Error message
		VerifyIsSupportedBrowser = IDS_UI_WARNING_IE3_MESSAGE
		Exit Function 

	Else
		strVersionInfo = "OK"			
	End If



End Function
    		
' ---- [Private] Check browser version
Private Function CheckBrowserVersion()

	Dim strUA
	Dim nVersion

    'Found out which browser user is using
	strUA = Request.ServerVariables("HTTP_USER_AGENT")

	If Instr(strUA, "MSIE") Then
	       nVersion =CInt(Mid(strUA, Instr(strUA,"MSIE") + 5, 1))    
		   '--right version	
	   If  nVersion >= 4 Then
		   CheckBrowserVersion = IDS_RIGHT_BROWSER_VERSION

	   '--lower than version 4
	       ElseIf nVersion < 4 Then
		   CheckBrowserVersion = IDS_LOWER_THAN_IE4
	       End If
	Else
	   'Browser is NS
	       CheckBrowserVersion = IDS_NETSCAPE_VERSION     
	End If

End Function

'*************************************************
'Purpose: 	Convert true or false to yes or no for UI reason
'         
'Input:		bCurrentSetting which needs to be transfer to Yes Or No
'
'Output:  	Yes if True or No if False
' 			
'************************************************* 

Public Function BoolToString(bCurrentSetting)
	    	
	Dim YesOrNo
	If bCurrentSetting = True Then
		YesOrNo = IDS_UI_YES
	
	Elseif bCurrentSetting = false Or bCurrentSetting = False Then
		YesOrNo = IDS_UI_NO
	Else
		On Error Resume Next
		Err.Raise 8   
		YesOrNo = Err.Description
	End If
	
	'Return value
	BoolToString = YesOrNo

End Function				    

'*************************************************
'Purpose: 	Choose selected default value for drop down box
'         
'Input:		1)bCurrentSetting, which is a value from API
'		2)bDropDownBoxOption, which is true or false option in drop down box
'
'Output:  	return "Selected" or ""
' 			
'************************************************* 

Public Function GetSelectedStated(bCurrentSetting, bDropDownBoxOption)
	
	Dim  strSelectedValue
	If  bCurrentSetting <>"" Then
	
		If bCurrentSetting  Then
			If bDropDownBoxOption Then
				strSelectedValue = IDS_DROPDOWNBOX_SELECTED		
			Else
				strSelectedValue = ""
			End If
		ElseIf Not bCurrentSetting Then
			If bDropDownBoxOption Then
				strSelectedValue = ""
			Else
				strSelectedValue = IDS_DROPDOWNBOX_SELECTED		
			End If
		Else
			
			StrSelectedValue = IDS_UNEXPEXTED_ERROR

		End If
	End If
	'--Return Value
	GetSelectedStated = strSelectedValue
	
End Function

'*************************************************
'Purpose: 	Choose checked default value for a radio button group 
'         
'Input:		1)bCurrentSetting, which is a value from API
'		2)bDropDownBoxOption, which is true or false radio button in radio button group
'
'Output:  	Return "Checked" or ""
' 			
'************************************************* 
Public Function GetCheckedState(bCurrentSetting, bRadioButtonValue)
	
	Dim  strSelectedValue
	
	If bCurrentSetting  Then
		If bRadioButtonValue Then	
			strSelectedValue = IDS_RADIOBUTTON_CHECKED 
		Else
			strSelectedValue = ""
		End If
	ElseIf Not bCurrentSetting Then  
		If bRadioButtonValue Then
			strSelectedValue = IDS_RADIOBUTTON_CHECKED 
		Else
			strSelectedValue = IDS_RADIOBUTTON_CHECKED 
		End If
	Else
		
		StrSelectedValue = IDS_UNEXPEXTED_ERROR
	End If

	' -- Return Value
	GetCheckedState= strSelectedValue
	
End Function

'*************************************************
'Purpose: 	Convert license type from number to text
'         
'Input:		1)eLicenseType, which is a number indicates different type		
'
'Output:  	Return a string describe license type
' 			
'************************************************* 

'-- [Public] Validate License Type for license tab and configuation
Public Function ValidateLicenseType(eLicenseType)
	
	Dim strLicenseTypeMessage
	
	' -- Figure out license type
	If eLicenseType = IDS_CMS_LICENSE_TYPE_ENTERPRISE Then
		strLicenseTypeMessage = IDS_UI_LICENSE_ENTERPRISE
	ElseIf eLicenseType = IDS_CMS_LICENSE_TYPE_DEVELOPER Then
		strLicenseTypeMessage = IDS_UI_LICENSE_DEVELOPER
	ElseIf eLicenseType = IDS_CMS_LICENSE_TYPE_EVALUATION Then
		strLicenseTypeMessage = IDS_UI_LICENSE_EVALUATION
	Else	
		strLicenseTypeMessage = IDS_UI_LICENSE_INVALID
	End If
		
	' -- Return Value
	ValidateLicenseType = strLicenseTypeMessage 

End Function

'*************************************************
'Purpose: 	Init SCAMsgbox Control
'         
'Input:		None
'
'Output:  	None
' 			
'************************************************* 

Public Function InitMsgbox()

	Dim SCAMsgbox
	Set SCAMsgbox = New CNCDialogModalControl
	'-- Set Porperties

	'-- HTML color code for example "#000000"
	SCAMsgbox.TitleBgColor = "#330066"
	'-- HTML color code for example "#ffffff"
	SCAMsgbox.ContentBgColor = "#ffffe0"
	'-- true or false
	SCAMsgbox.BorderLine = "True"
	'-- HTML code for example "<img ...>"
	SCAMsgbox.IcoImagePath = ""
	'-- HTML code for example "<img ...>"
	SCAMsgbox.OKButtonImagePath = IDS_OK_BUTTON_FOR_MESSAGE_BOX


	'--Return object
	Set InitMsgbox = SCAMsgbox

End Function

'*************************************************
'Purpose: 	Redirect ASP Page to Main ASP if no MCMS Index
'         
'Input:		None
'
'Output:  	None
' 			
'************************************************* 
Public Sub ResServerIndexExist(ResServerIndex)
	
	If ResServerIndex = "" Then
		' --  redirect to main ASP Page
		Response.Redirect("../" & IDS_MAIN_CONFIGASPPAGE & "?" & IDS_QUERYSTRING_SKIPSSL_WARNING & "=true")
	End If
End Sub

'*************************************************
'Purpose: 	Convert ASP boolean to Javascript boolean
'			The ASP boolean may not be "true" and "false" in some OS. 
'			E.g. In German OS "wahr"="true" and "falscht"="false". This function
'			is to make sure the ASP boolean returning "true" and "false" 
'			in order to	use it when calling the Javascript function.
'         
'Input:		bAspBoolean - an ASP boolean based on the OS
'
'Output:  	return "true" if the ASP boolean is meaning "true"; otherwise, returns "false"
' 			
'************************************************* 
Public Function Bool2LCaseStr(bASPBoolean)
	If bASPBoolean Then
		Bool2LCaseStr = "true"
	Else
		Bool2LCaseStr = "false"
	End If
End Function

'*************************************************
'Purpose: 	Renderer a message box 
'         
'Input:		None
'
'Output:  	a DHTML Message box for each tab
' 			
'************************************************* 
Public Sub RenderMsgboxForTabControl(strDivID, strTitle,strError,strErrorDetails)
%>
  	<div id="<%=strDivID%>" class="SCAStyleMsgboxforTab">	
		<Table border="0" align="center" width="330"  cellspacing="4" cellpadding="4" >
			<tr>
				<td align="center" Class ="SCAStyleTabMsgboxTitle" bgColor="#330066">
					<%=strTitle%>
				</td>
			</tr>
		</Table>
		<Table border="0" align="center" width="330"  cellspacing="0" cellpadding="2">
			<tr>
				<td class="SCAStyleTabMsgBoxContentFont" >
					<%=IDS_ICO_IMAGE_PATH%><%=strError%>

				</td>
			</tr>
		</Table>	
		<div id="GeneralErrorDetail" class="SCAStyleErrorDetailforTab">
					<%=strErrorDetails%>
		</div>
		<div  align="center">
			<img  class="SCAStyleMsgboxCloseButtonPos" name="btn_OKclose" border="0" src="<%=IDS_IMAGE_BTN_OK_OFF %>" align="right" alt="Close Message Box" onClick="SCA_CloseTabMsgbox('<%=strDivID%>')" align="center">
		</div>	
	</div>
<%
End Sub
%>

