<%
' ********************************************************************
' Copyright (C) 2001 Microsoft Corporation. All rights reserved.
'
'	IMPORTANT.  Please read the legal.txt file, located in the
'	"<MCMS Install Directory>\Server\httpexec\WBC\Internals"
'	directory, governing the use of this internal file."
' ********************************************************************

' ********************************************************************
' File:		SCADialogModalControl.inc		
'
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation
' Purpose:	Responsible for Displaying message box, help box and Dialogbox  
'
' Public Methods and Properties Exposed:
'	- Sub InitDialogModal( nApsPosTop,
'						  nApsPosLeft,
'   					  nWidth,
'                         nHeight)
'						  	
'	- Sub MsgBox(Title, Message)
'	- Sub DialogBox(Title, pContent,OKFunctionName,CancelFunctionName)
'	
'	- Property TitleBgColor	[read/write]
'	- Property ContentBgColor [read/write]
'	- Property BorderLine [read/write]
'	- Property IcoImagePath	[read/write]
'	- Property OKButtonImagePath [read/write]
'	
' ********************************************************************
	
	'Define constants for default values
	Const IDS_TITLE_BGCOLOR = "#000000"
	Const IDS_CONTENT_BGCOLOR = "#ffffff"
	Const IDS_BORDERLINE = True
	Const IDS_TOP_POSITION = 5
	Const IDS_LEFT_POSITION= 5
	Const IDS_MSGBOX_WIDTH = 340
	Const IDS_MSGBOX_HEIGHT = 100
	Const IDS_MSGBOX_POSITION_CHECK = 5
	Const IDS_MSGBOX_WIDTHANDHEIGHT_CHECK = 100
	Const IDS_NAME_MSGBOX = "Msgbox"
	Const IDS_NAME_HELPBOX = "Helpbox"
	Const IDS_NAME_DIALOGBOX = "Dialogbox"
	Const IDS_ID_DIALOG_CONTENT = "CNT"
	
Class CNCDialogModalControl

	'Define Property 
	
	'Set Message box title color
	Public TitleBgColor
	
	'Set Message box back ground color
	Public ContentBgColor
	
	'Set Message box border line 
	Public BorderLine
	
	'Set Message box icon path (in HTML) 
	Public IcoImagePath
	
	'Set Message box Ok button image path (in HTML)
	Public OKButtonImagePath
	
	'Define Private variable
	Private m_MsgboxID
	Private m_HelpboxID
	Private m_DialogboxID
	Private m_MsgboxIDIndex
	Private m_HelpboxIDIndex
	Private m_DialogboxIDIndex
	Private m_nApsPosTop
	Private m_nApsPosLeft
	Private m_nWidth
	Private m_nHeight
    Private m_nTableWidth
    
    ' ---- [Private] Standard Class_Initialize
    Private Sub Class_Initialize()
    	' -- init all member with default values
 		m_MsgboxIDIndex = 0
 		m_HelpboxIDIndex = 0
		m_DialogboxIDIndex = 0
		
    End Sub
    
	'****************************************************
	'Purpose:	Set message box postion and site 
	'
	'Input:		Top position, left position, message box width,
	'			message box height
	'
	'Output:	none
	'*****************************************************
		
	Public Sub InitDialogModal(nApsPosTop, nApsPosLeft, nWidth, nHeight)
			
		'--Set default values
			
		'--Convert value to members
		m_nApsPosTop = Cstr(nApsPosTop) 
		m_nApsPosLeft = Cstr(nApsPosLeft)  
		m_nWidth = Cstr(nWidth) 
		m_nHeight = Cstr(nHeight) 
		
		'--Set background color
		If TitleBgColor = "" Then
			TitleBgColor = IDS_TITLE_BGCOLOR
		End If
			
		If ContentBgColor = "" Then
			ContentBgColor = IDS_CONTENT_BGCOLOR
		End If
			
		'--Set border line
		If Ucase(BorderLine) <> "FALSE" Then
			BorderLine = IDS_BORDERLINE
		End If
			
		'--Set position 
			
		If CLng(m_nApsPosTop) <= CLng(IDS_MSGBOX_POSITION_CHECK) Then
			m_nApsPosTop = IDS_TOP_POSITION
			
		End If
		If CLng(m_nApsPosLeft) <= CLng(IDS_MSGBOX_POSITION_CHECK) Then
			m_nApsPosLeft = IDS_LEFT_POSITION
		End If
			
		'--Set size
		If CLng(m_nWidth) <= CLng(IDS_MSGBOX_WIDTHANDHEIGHT_CHECK)  Then
			m_nWidth = IDS_MSGBOX_WIDTH
		End If
		If CLng(m_nHeight) <= CLng(IDS_MSGBOX_WIDTHANDHEIGHT_CHECK) Then
			m_nHeight = IDS_MSGBOX_HEIGHT
		End If
			
		'--Set Table width to make table smaller than div width
		m_nTableWidth = m_nWidth - 10
		
	End Sub
	
	'****************************************************
	'Purpose:	Render Dialog box 
	'
	'Input:		Dialog box title and Dialog content
	'
	'Output:	HTML content, style classes and java script function
	'
	'*****************************************************
		
	Public Sub DialogBox(Title, pContent,OKFunctionName,CancelFunctionName)
		
				
		'--Set Table width to make table smaller than div width
		m_nTableWidth = m_nWidth - 50
		
		'--Set message box id
		m_DialogboxID = IDS_NAME_DIALOGBOX & Cstr(m_DialogboxIDIndex)
		
		'--Render style sheet to set format for this message box
		Call RenderDialogBoxStyleClasses()
		
		'--Render dialog box in html
		Call RenderDialogbox (Title,pContent,OKFunctionName,CancelFunctionName)
		
		'--Change index id
		m_DialogboxIDIndex = m_DialogboxIDIndex + 1
		
	End Sub
	
	'****************************************************
	'Purpose:	Display message box 
	'
	'Input:		Message box title and message content
	'
	'Output:	HTML content, style classes and java script function
	'
	'*****************************************************
		
	Public Sub Msgbox(Title ,Message,Detail)
		
				
		'--Set Table width to make table smaller than div width
		m_nTableWidth = m_nWidth - 10
		
		'--Set message box id
		m_MsgboxID = IDS_NAME_MSGBOX & Cstr(m_MsgboxIDIndex)
		
		'--Render a java script function to cancel this message box
		If m_MsgboxIDIndex = 0 Then
			Call RenderJavaScriptCloseMsgbox()
		End If
		
		'--Render style sheet to set format for this message box
		Call RenderMsgBoxStyleClasses()
		
		'--Render message box in html
		Call RenderMsgbox (Title,Message,Detail)
		
		'--Change index id
		m_MsgboxIDIndex = m_MsgboxIDIndex + 1
		
	End Sub
	
	'--[Private] Render message box in html
	Private Sub RenderMsgbox(Title,Message,Detail)
		%>
		<div id="<%=m_MsgboxID%>" >
		
			<Table border="0" align="center" width="<%=m_nTableWidth%>"  cellspacing="0" cellpadding="6">
				<tr>
					<td>
						<table border="0" width="<%=m_nTableWidth%>" cellspacing="0" cellpadding="0" bgcolor=<%=TitleBgColor%> >
							<tr bgcolor=<%=TitleBgColor%> >
								<td valign="middle">													 							
									<%'--Ico for message box and title
										'--Check ico iamge path
									If IcoImagePath = "" Then
									  	IcoImagePath = "&nbsp;"
									End If
									%>
									<%=IcoImagePath%>
								</td>
								<td  align="center" id="SCAStyleMsgboxTitle">
									<%=Title%>
								</td>
						    </tr>
						</table>
					</td>
				</tr>
			</Table>
			<Table border="0" align="center" width="<%=m_nTableWidth%>"  cellspacing="0" cellpadding="2">
				<tr>
					<td>
						<table border="0" cellspacing="1" cellpadding="1">
							<tr>
								<%'--Message content%>
								<td id="SCAStyleMsgboxContent"> <%=Message%>
								</td>
							</tr>
						</table>
						
					</td>
				</tr>
			</Table>
			<%
			if Detail <> "" Then
				%>
				<div id="ErrorDetail"><%=Detail%></div>
				<div id="OKbuttonPos">
				<%
			Else 
			    %>
			    <div >
			    <%
			End If
			%>
			
			
			<Table border="0" align="center" width="<%=m_nTableWidth%>"  cellspacing="0" cellpadding="5">
				<tr>
					
					<%
					'--ok button
					If OKButtonImagePath = "" Then
					%>
					<form>
		 				<td  align="center" ><INPUT type="button" value="   OK    "  name="btn_OK" onClick="SCA_closeMsgbox('Msgbox')">
						</td>
					</form>		
					<%
					Else 
					%>
					<td  align="center" ><a href="javascript:SCA_closeMsgbox('<%=m_MsgboxID%>')"><%=OKButtonImagePath%></a>
					</td>
					<%
					End If
					%>
				</tr>
			</table>
			</div>
		</div>
		<%
	End Sub
		
	'--[Private] Render Style sheet classes for the format of message box
	Private Sub RenderMsgBoxStyleClasses()
	
		'--style sheet starts
		Response.Write "<style type=text/css>" & vbCrLf
	    Response.Write "<!--"  & vbCrLf
	   	
	   	'--Check border line property
	   	If Ucase(BorderLine) = "TRUE" Then %>
		   	#<%=m_MsgboxID%>{POSITION:absolute; TOP:<%=m_nApsPosTop%> px; Zindex: -3;LEFT:<%=m_nApsPosLeft %> px;WIDTH:<%=m_nWidth%> px; HEIGHT:<%=m_nHeight%> px;LAYER-BACKGROUND-COLOR:<%=ContentBgColor %>;BACKGROUND-COLOR:<%=ContentBgColor%>;BORDER: solid <%=TitleBgColor%> 2px; }
	   	<% 
	   	Else 
	   	%> 
	   	#<%=m_MsgboxID%>{POSITION:absolute; TOP:<%=m_nApsPosTop%> px; Zindex: -3;LEFT:<%=m_nApsPosLeft%> px;WIDTH:<%=m_nWidth%> px; HEIGHT:<%=m_nHeight%> px;LAYER-BACKGROUND-COLOR:<%=ContentBgColor %>;BACKGROUND-COLOR:<%=ContentBgColor %>}
	   	<% 
	   	End If 
	   	%>
	   	#SCAStyleMsgboxTitle {FONT-FAMILY: Arial,Verdana,Helvetica, sans-serif; FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: <%=ContentBgColor %>; }
	   	#SCAStyleMsgboxContent {FONT-FAMILY: Arial,Verdana,Helvetica, sans-serif;FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: <%=TitleBgColor %>;}
	   	#ErrorDetail { POSITION: absolute; LEFT: 10px; TOP: 85px; HEIGHT: 70px;WIDTH: 340; COLOR: #330066; BORDER-LEFT:black inset 1px; BORDER-TOP:black inset 1px;  BACKGROUND-COLOR:#ffffff; FONT-FAMILY: Arial,Verdana,Helvetica, sans-serif; FONT-SIZE: 10px;  OVERFLOW: auto;}
	   	#OKbuttonPos { POSITION: absolute; LEFT: 5px; TOP: 155px; }
	   	<%
		
		'--End style sheet
		Response.Write "-->"  & vbCrLf
		Response.Write "</style>"  & vbCrLf
	
	End Sub
	
	
    '----[Private] Render JavaScript Cancel Function to cancel message box 
     Private Sub RenderJavaScriptCloseMsgbox()
     
		'--Write java script head	
 		Response.Write "<script language=""javascript"" type=""text/javascript"" >" & vbCrLf
 		%>
			var IDS_BROWSER_TYPE = navigator.appName;
			var IDS_IE = "Microsoft Internet Explorer";
			var IDS_NETSCAPE = "Netscape";
		
			function SCA_closeMsgbox(ModalID) 
			{
			        if (IDS_BROWSER_TYPE == IDS_NETSCAPE) {
			                document.layers[ModalID].visibility = 'hidden';
		   	     }
			        else if (IDS_BROWSER_TYPE == IDS_IE) {
			                document.all[ModalID].style.visibility = 'hidden';
			        }
			}
		
			<%
		'--Write java script head end
		Response.Write "</script>" & vbCrLf
				    
   End Sub
   
   '--[Private]Render a dialog box 
   Private Sub RenderDialogbox (Title,DialogContent,OKFunctionName,CancelFunctionName)
		
   %>
		<div id="<%=m_DialogboxID%>" >
			<div id="<%=IDS_ID_DIALOG_CONTENT & m_DialogboxID%>">
				<Table border="0" align="center" width="<%=m_nTableWidth%>"  cellspacing="0" cellpadding="0">
					<tr>
						<td  id="SCAStyleDialogboxTitle">
							<%=Title%>
						</td>
					</tr>					
					</tr>
					
					<tr id='SCAStyleDialogboxContent'>
						<%=DialogContent%>
					</tr>	
					<tr>
						<td>				
							<table border="0"  width ="<%=m_nTableWidth%>" cellspacing="1" cellpadding="2">
								
								<tr>
									<td align="right" style="CURSOR: hand;">
										<img  name="btn_OK<%=m_DialogboxID%>" border="0" src="<%=IDS_IMAGE_BTN_OK_OFF%>"  width="120" height="24" alt="<%=IDS_UI_IMAGE_ALT_POPUP_OK%>"
										onMouseOut="SCA_swapImgRestore()" onMouseOver="SCA_swapImage('btn_OK<%=m_DialogboxID%>','','<%=IDS_IMAGE_BTN_OK_ON%>',0)" 
										onClick="<%=OKFunctionName%>('<% =m_DialogboxID%>')" >
									</td>		
									<td   style="CURSOR: hand;">
										<img  name="btn_Cancel<%=m_DialogboxID%>" border="0" src="<%=IDS_IMAGE_BTN_CANCEL_OFF%>"  width="120" height="24" alt="<%=IDS_UI_IMAGE_ALT_POPUP_CLOSE%>"
										onMouseOut="SCA_swapImgRestore()" onMouseOver="SCA_swapImage('btn_Cancel<%=m_DialogboxID%>','','<%=IDS_IMAGE_BTN_CANCEL_ON%>',1)"
										onClick="<%=CancelFunctionName%>('<% =m_DialogboxID%>')" >
									</td>	
								</tr>
							</table>
						</td>	
					</tr>
				</table>
			</div>
		</div>
		<%
   End Sub
   
   '--[Private]Create a style sheet for dialog box to define
   'position and size
   Private Sub RenderDialogBoxStyleClasses()
		
		'--style sheet starts
		Response.Write "<style type=text/css>" & vbCrLf
	    Response.Write "<!--"  & vbCrLf
	   	
	   	'--Check border line property
	   	If Ucase(BorderLine) = "TRUE" Then %>
		   	#<%=m_DialogboxID%>{POSITION:absolute; TOP:<%=m_nApsPosTop%> px; Zindex: -3;LEFT:<%=m_nApsPosLeft%> px;WIDTH:<%=m_nWidth%> px; HEIGHT:<%=m_nHeight%> px;
		   		BACKGROUND-COLOR:#ffffff;
		   		BORDER-LEFT: outset #ffffff 5px;BORDER-TOP:#ffffff outset 5px; ; 
		   		BORDER-BOTTOM:#330066 outset 4px; BORDER-RIGHT:#330066 outset 4px; ;
		   		VISIBILITY: hidden;}
	   	<% 
	   	Else 
	   	%> 
	   	#<%=m_DialogboxID%>{POSITION:absolute; TOP:<%=m_nApsPosTop%> px; Zindex: -3;LEFT:<%=m_nApsPosLeft%> px;WIDTH:<%=m_nWidth%> px; HEIGHT:<%=m_nHeight%> px;LAYER-BACKGROUND-COLOR:<%=ContentBgColor %>;BACKGROUND-COLOR:<%=ContentBgColor %>;
	   		VISIBILITY: hidden;}
	   	<% 
	   	End If 
	   	%>
	   	#<%=IDS_ID_DIALOG_CONTENT & m_DialogboxID%>{POSITION:absolute; TOP:5px; Zindex: -3;LEFT:5 px;WIDTH:<%=m_nWidth-23%> px; HEIGHT:<%=m_nHeight-22%> px;
		   		BACKGROUND-COLOR:#ccccdd; BORDER:solid #330066 1px;}
	   	#SCAStyleDialogboxTitle {FONT-FAMILY: Arial,Verdana,Helvetica, sans-serif; FONT-SIZE: 12px; COLOR: <%=TitleBgColor %>; }
	   	#SCAStyleDialogboxContent {FONT-FAMILY: Arial,Verdana,Helvetica, sans-serif;FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: <%=TitleBgColor %>;}
	   	<%
		'--End style sheet
		Response.Write "-->"  & vbCrLf
		Response.Write "</style>"  & vbCrLf
	
   End Sub
   
End Class
%>
