<HTML xmlns:source_sites xmlns:copy_option xmlns:move_option>
	<?import namespace="SOURCE_SITES" implementation="../SIM100_ComboBox.htc" />
	<?import namespace="COPY_OPTION" implementation="../SIM100_CheckBox.htc" />
	<?import namespace="MOVE_OPTION" implementation="../SIM100_CheckBox.htc" />
	<HEAD>
		<META name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<LINK rel="stylesheet" type="text/css" href="../SIM100_Common.css">
		<LINK rel="stylesheet" type="text/css" href="../SIM100_TestListSheet.css">
		<PUBLIC:COMPONENT tagname="SELECT_SOURCE" literalcontent="true">
			<PUBLIC:DEFAULTS viewlinkcontent="true" tabstop="true" viewmastertab="false" />
			<PUBLIC:ATTACH event="ondocumentready" handler="fnOnDocumentReady" />
			<PUBLIC:ATTACH event="ondetach" handler="fnDetach" />
			<PUBLIC:PROPERTY name="display" put="fnPutDisplay" />
			<PUBLIC:PROPERTY name="view" put="fnPutView" internalname="m_szView" />
			<PUBLIC:PROPERTY name="sz_source_site" get="fnGetSourceSite" put="fnPutSourceSite" />
			<PUBLIC:PROPERTY name="szReplicationSites" get="fnGetReplicationSites" />
			<PUBLIC:PROPERTY name="szLegacySupport" get="fnGetLegacySupport" put="fnPutLegacySupport" />
			<PUBLIC:PROPERTY name="szMoveToPrevBranch" get="fnGetMoveToPrevBranch" put="fnPutMoveToPrevBranch" />
			<PUBLIC:PROPERTY name="bLegacySupport" get="fnGetLegacySupport_BOOL" />
			<PUBLIC:PROPERTY name="bMoveToPrevBranch" get="fnGetMoveToPrevBranch_BOOL" />
			<PUBLIC:PROPERTY name="bShowDescription" put="fnPutShowDescription" />
			<PUBLIC:PROPERTY name="bShowMoveDescription" put="fnPutShowMoveDescription" />
			<PUBLIC:METHOD name="fnValid" />
			<PUBLIC:METHOD name="fnLoadValues" />
			<PUBLIC:EVENT name="onReady" id="eventID_Ready" />
			<PUBLIC:EVENT name="OnModify" id="eventID_OnModify" />
		</PUBLIC:COMPONENT>
		<SCRIPT language='VBScript' src="SIM110_ListSheet.nrc" onreadystatechange="fnOnReadyStateChange()" charset="utf-8"></SCRIPT>
		<SCRIPT language="JScript">
			var m_szView = "LIST_BOX"
			var m_bFoundHttpSite = false;
			
			function fnOnDocumentReady()
			{
				fnLoadResource();
				if(parent.htcID_SAL.mode != "EPO")
					tableID_MoveToPrevBranch.style.display = "none";
				eventID_Ready.fire();
			}
			
			function fnOnReadyStateChange()
			{
				if(event.srcElement.readyState == "complete")
				{
					inputbtnID_SelectAll.value = L_SelectAllBtn_Button;
					inputbtnID_DeSelectAll.value = L_UnselectAllBtn_Button;
				}
			}
			
			function fnLoadResource()
			{
				buttonID_Name.innerText = parent.nrc_Name;
				buttonID_Type.innerText = parent.nrc_Type;
				buttonID_Configuration.innerText = parent.nrc_Configuration;
				buttonID_Server.innerText = parent.nrc_Server;
				comboboxID_SourceSites.left_text = parent.nrc_SourceSite;
				checkboxID_CopyOption.text = parent.nrc_LegacySupport;
				checkboxID_MoveOption.text = parent.nrc_MoveToPrevious;
			}
			
			function fnPutDisplay(szStr)
			{
				if(szStr == "none")
					defaults.viewLink = null;
				else
					defaults.viewLink = document;
			}
			
			function fnValid()
			{
				var bValid = true;
				
				if(bValid)
				{
					switch(m_szView)
					{
						case "LIST_BOX_EDIT":
						case "LIST_BOX_PULL_NOW":
						case "LIST_BOX":
							if(fnGetSourceSite() == "")
							{
								alert(parent.nrc_NoSource);
								bValid = false;
							}
							break;
						case "REPLICATION_SITES_LIST_BOX":
							if(fnGetReplicationSites() == "")
							{
								alert(parent.nrc_NoReplSites);
								bValid = false;
							}
							break;
					}
				}
				
				return bValid;
			}
			
			function fnAdjustMargins()
			{
				document.body.topMargin = "5";
				document.body.leftMargin = "5";
				document.body.rightMargin = "5";
			}
			
			function fnPutView(szView)
			{
				switch(szView)
				{
					case "REPLICATION_SITES_LIST_BOX":
						fnAdjustMargins();
						divID_ComboBox.style.display = "none";
						tableID_LegacySupport.style.display = "none";
						divID_TableMeta.style.display = "";
						divID_TableData.style.display = "";
						tableID_SelectDeselect.style.display = "";
						tableID_ClickNext.style.display = "";
						labelID_SelectSource.innerText = parent.nrc_PleaseSelectDP;
						inputbtnID_DeSelectAll.style.width = parent.dwWidthSelectButtons;
						inputbtnID_SelectAll.style.width = parent.dwWidthSelectButtons;
						tableID_MoveToPrevBranch.style.display = "none";
						labelID_ClickNext.innerHTML = parent.nrc_ToContinueClickNext;
						m_szView = szView;
						break;
					case "LIST_BOX_PULL_NOW":
						fnAdjustMargins();
						divID_ComboBox.style.display = "none";
						divID_TableData.style.height = "180px";
						divID_TableMeta.style.display = "";
						divID_TableData.style.display = "";
						tableID_ClickNext.style.display = "";
						labelID_SelectSource.innerText = parent.nrc_SelectSource;
						if(parent.htcID_SAL.mode == "EPO")
						{
							tableID_LegacySupport.style.display = "none";
							tableID_MoveToPrevBranch.style.display = "none";
						}
						labelID_ClickNext.innerHTML = parent.nrc_ToContinueClickNext;
						m_szView = szView;
						break;
					case "LIST_BOX_EDIT":
						fnAdjustMargins();
						divID_ComboBox.style.display = "none";
						divID_TableMeta.style.display = "";
						divID_TableData.style.display = "";
						labelID_SelectSource.innerText = parent.nrc_SelectSource;
						m_szView = szView;
						break;
					case "LIST_BOX":
						divID_ComboBox.style.display = "none";
						divID_TableMeta.style.display = "";
						divID_TableData.style.display = "";
						labelID_SelectSource.innerText = parent.nrc_SelectSource;
						m_szView = szView;
						break;
					case "COMBO_BOX":
						divID_TableMeta.style.display = "none";
						divID_TableData.style.display = "none";
						divID_ComboBox.style.display = "";
						m_szView = szView;
						fnLoadComboBox();
						break;
				}
			}
			
			function fnLoadComboBox()
			{
				var bOK = false;
				var dwError = 0;
				var arraySites = new Array();
				var arraySourceSites = new Array();
				var dwIndex = 0;
				
				dwError = parent.htcID_SAL.fnGetSites(arraySites, false);
				bOK = (dwError == 0);
				
				if(bOK)
					bOK = (arraySites.length > 0);
				
				if(bOK)
				{
					for(i=0; i<arraySites.length; i++)
					{
						if(arraySites[i].szType == "0" || arraySites[i].szType == "1")
							continue;
						
						arraySourceSites[dwIndex++] = arraySites[i].szName;
					}
				}
				
				if(bOK)
					comboboxID_SourceSites.fnAddOptions(arraySourceSites);
			}
			
			function fnLoadValues()
			{
				var bOK = false;
				var dwError = 0;
				var arraySites = new Array();
				var arraySourceSites = new Array();
				var dwIndex = 0;
				
				m_bFoundHttpSite = false;
				var objReturnValue = parent.fnShowDowndloadSiteList();
				bOK = (objReturnValue.dwError == 0);

				if(bOK)
				{
					dwError = parent.htcID_SAL.fnGetSites_DCF(arraySites, objReturnValue.szXmlList);
					bOK = (dwError == 0);
				}
				
				if(bOK)
				{
					fnEmpty();
					bOK = (arraySites.length > 0);
				}
				
				if(bOK)
				{
					for(i=0; i<arraySites.length; i++)
					{
						if((m_szView == "LIST_BOX_EDIT" || m_szView == "LIST_BOX_PULL_NOW" || m_szView == "LIST_BOX") && (arraySites[i].szType == "0" || arraySites[i].szType == "1"))
							continue;
						else if(m_szView == "REPLICATION_SITES_LIST_BOX" && (arraySites[i].szType == "0" || arraySites[i].szType == "2" || arraySites[i].szType == "3"))
							continue;

						fnAddSite(arraySites[i].szName, parent.nrc_arraySiteType[Math.abs(arraySites[i].szType)], arraySites[i].szSiteType, arraySites[i].szServer);
					}
				}
			}
			
			function fnOnCheckBoxClick()
			{
				fnFireModify();
			}			
			
			function fnGetLength()
			{
				return tbodyID.rows.length;
			}

			function fnAddSite(szSiteName, szSiteType, szSiteConfig, szSiteServer)
			{
				var objTR = tbodyID.insertRow();
				
				objTD = objTR.insertCell()
				
				switch(m_szView)
				{
					case "REPLICATION_SITES_LIST_BOX":
						objInput = document.createElement("<INPUT type='checkbox' name='radioName_Sites' >");
						break;
					case "LIST_BOX":
					default:
						if(!m_bFoundHttpSite && szSiteConfig == "HttpSite" && szSiteName.toLowerCase() == "naihttp")
						{
							objInput = document.createElement("<INPUT type='radio' name='radioName_Sites' checked >");
							m_bFoundHttpSite = true;
						}
						else if(!m_bFoundHttpSite && szSiteType == parent.nrc_arraySiteType[2])
							objInput = document.createElement("<INPUT type='radio' name='radioName_Sites' checked >");
						else
							objInput = document.createElement("<INPUT type='radio' name='radioName_Sites' >");
						break;
				}
				
				objInput.onclick = fnOnCheckBoxClick;
				objTD.noWrap = "true";
				objTD.className = 'TaskTableTextLeft';
				objTD.width = "6%";
				objTD.appendChild(objInput);
				
				objTD = objTR.insertCell()
				objTD.noWrap = "true";
				objTD.className = 'TaskTable TaskTableText';
				objTD.width = "23%";
				objTD.innerText = szSiteName;
				objTD.title = szSiteName;
				
				objTD = objTR.insertCell()
				objTD.className = 'ruleColumnText';
				objTD.innerHTML = "&#160;"

				objTD = objTR.insertCell()
				objTD.noWrap = "true";
				objTD.className = 'TaskTable TaskTableText';
				objTD.width = "24%";
				objTD.innerText = szSiteType;
				objTD.title = szSiteType;
				
				objTD = objTR.insertCell()
				objTD.className = 'ruleColumnText';
				objTD.innerHTML = "&#160;"

				objTD = objTR.insertCell()
				objTD.noWrap = "true";
				objTD.className = 'TaskTable TaskTableText';
				objTD.width = "24%";
				objTD.innerText = szSiteConfig;
				objTD.title = szSiteConfig;
				
				objTD = objTR.insertCell()
				objTD.className = 'ruleColumnText';
				objTD.innerHTML = "&#160;"

				objTD = objTR.insertCell()
				objTD.noWrap = "true";
				objTD.className = 'TaskTable TaskTableTextCapRight';
				objTD.width = "23%";
				objTD.innerText = szSiteServer;
				objTD.title = szSiteServer;
			}
			
			function fnIsSelected(dwIndex)
			{
				objRow = tbodyID.rows[dwIndex];
				objCell = objRow.cells[0];
				objInput = objCell.firstChild;
				return objInput.checked;
			}
			
			function fnGetSiteNameByIndex(dwIndex)
			{
				objRow = tbodyID.rows[dwIndex];
				objCell = objRow.cells[1];
				return objCell.innerText;
			}
			
			function fnGetSourceSite()
			{
				var szSelectedSite = "";
				
				switch(m_szView)
				{
					case "LIST_BOX_EDIT":
					case "LIST_BOX_PULL_NOW":
					case "LIST_BOX":
						for(i=0; i < tbodyID.rows.length; i++)
						{
							objRow = tbodyID.rows[i];
							objCell = objRow.cells[0];
							objInput = objCell.firstChild;
							if(objInput.checked)
							{
								szSelectedSite = fnGetSiteNameByIndex(i);
								break;
							}
						}
						break;
					case "COMBO_BOX":
						szSelectedSite = comboboxID_SourceSites.selected_text;
						break;
				}
				
				return szSelectedSite;
			}
			
			function fnPutSourceSite(szSourceSite)
			{
				switch(m_szView)
				{
					case "LIST_BOX_EDIT":
					case "LIST_BOX_PULL_NOW":
					case "LIST_BOX_EDIT":
						for(i=0; i < tbodyID.rows.length; i++)
						{
							objRow = tbodyID.rows[i];
							objCell = objRow.cells[0];
							objInput = objCell.firstChild;
							if(fnGetSiteNameByIndex(i) == szSourceSite)
							{
								objInput.checked = true;
								break;
							}
						}
						break;
					case "COMBO_BOX":
						comboboxID_SourceSites.selected_text = szSourceSite;
						break;
				}
			}

			function fnGetReplicationSites()
			{
				var szReplicationSites = "";
				
				for(var i = 0; i < tbodyID.rows.length; i++)
				{
					objRow = tbodyID.rows[i];
					objCell = objRow.cells[0];
					objInput = objCell.firstChild;
					if(objInput.checked)
					{
						szReplicationSites += fnGetSiteNameByIndex(i);
						szReplicationSites += "|";
					}
				}
				
				szReplicationSites = szReplicationSites.substring(0, szReplicationSites.length-1);
				
				return szReplicationSites;
			}
			
			function fnOnSelectionChanged()
			{
			}
			
			function fnEmpty()
			{
				dwLength = tbodyID.rows.length;
				for(i=0; i < dwLength; i++)
				{
					tbodyID.deleteRow(0);
				}
			}
			
			function fnFireModify()
			{
				eventID_OnModify.fire();
			}

			function fnGetLegacySupport()
			{
				return checkboxID_CopyOption.checked;
			}			
			
			function fnGetLegacySupport_BOOL()
			{
				return checkboxID_CopyOption.bChecked;
			}

			function fnPutLegacySupport(szLegacySupport)
			{
				checkboxID_CopyOption.checked = szLegacySupport;
			}
			
			function fnGetMoveToPrevBranch()
			{
				return checkboxID_MoveOption.checked;
			}
			
			function fnGetMoveToPrevBranch_BOOL()
			{
				return checkboxID_MoveOption.bChecked;
			}
			
			function fnPutMoveToPrevBranch(szMoveToPrevBranch)
			{
				checkboxID_MoveOption.checked = szMoveToPrevBranch;
			}
			
			function fnPutShowDescription(bShowDescription)
			{
				if(bShowDescription)
					checkboxID_CopyOption.fnLoadDescription(parent.nrc_LegacySupport, parent.nrc_LegacySupportDesc);
			}
			
			function fnPutShowMoveDescription(bShowMoveDescription)
			{
				if(bShowMoveDescription)
					checkboxID_MoveOption.fnLoadDescription(parent.nrc_MoveToPrevious, parent.nrc_MoveToPreviousDesc);
			}
			
			function fnOnSelectAllClick(bState)
			{
				fnToggleAll(true);
			}
			
			function fnOnDeSelectAllClick()
			{
				fnToggleAll(false);
			}
			
			function fnToggleAll(bState)
			{
				for(var i = 0; i < tbodyID.rows.length; i++)
				{
					objRow = tbodyID.rows[i];
					objCell = objRow.cells[0];
					objInput = objCell.firstChild;
					objInput.checked = bState;
				}
			}
		</SCRIPT>
	</HEAD>
	<BODY>
		<DIV style="PADDING-RIGHT: 15px; WIDTH: 100%" id="divID_TableMeta">
			<TABLE width="100%">
				<TR>
					<TD>
						<LABEL class="clsLabelComment" id="labelID_SelectSource"></LABEL>
					</TD>
				</TR>
			</TABLE>
			<DIV style="width:100%;overflow-x:hidden;overflow-y:scroll" class="clsHideScrollBar">
				<TABLE width="100%" style="table-layout:fixed" cellspacing="0" cellpadding="0" border="0">
					<TR bgcolor="#999966">
						<TD nowrap width="6%" class="TaskTableHdCapLeft"><INPUT type="radio" style="visibility:hidden" /></TD>
						<TH nowrap width="23%" class="TaskTable TaskTableHd" id="buttonID_Name"></TH>
						<TD class="ruleColumnResize" id="tdID_Resize1">&#160;</TD>
						<TH nowrap width="24%" class="TaskTable TaskTableHd" id="buttonID_Type"></TH>
						<TD class="ruleColumnResize" id="tdID_Resize2">&#160;</TD>
						<TH nowrap width="24%" class="TaskTable TaskTableHd" id="buttonID_Configuration"></TH>
						<TD class="ruleColumnResize" id="tdID_Resize3">&#160;</TD>
						<TH nowrap width="23%" class="TaskTable TaskTableHdCapRight" id="buttonID_Server"></TH>
					</TR>
				</TABLE>
			</DIV>
			<DIV id="divID_TableData" style="width:100%;height:185px;overflow-x:hidden;overflow-y:scroll;border-bottom:1px black solid;background-color:white">
				<TABLE id="tbodyID" style="table-layout:fixed" cellspacing="0" cellpadding="0" border="0"></TABLE>
			</DIV>
		</DIV>
		<DIV id="divID_ComboBox" style="display:none">
			<TABLE>
				<TR>
					<TD>
						<SOURCE_SITES:COMBOBOX id="comboboxID_SourceSites" onselectionchanged="fnOnSelectionChanged()" OnModify="fnFireModify()" />
					</TD>
				</TR>
			</TABLE>
		</DIV>
		<TABLE id="tableID_LegacySupport">
			<TR>
				<TD>
					<COPY_OPTION:CHECKBOX id="checkboxID_CopyOption" OnModify="fnFireModify()" />
				</TD>
			</TR>
		</TABLE>
		<TABLE id="tableID_MoveToPrevBranch">
			<TR>
				<TD>
					<MOVE_OPTION:CHECKBOX id="checkboxID_MoveOption" onmodify="fnFireModify()" />
				</TD>
			</TR>
		</TABLE>
		<TABLE id="tableID_SelectDeselect" width="100%" cellpadding="8" style="DISPLAY: none;">
			<TR align="center">
				<TD>
					<INPUT class="clsBtn" type="button" id="inputbtnID_SelectAll" onclick="fnOnSelectAllClick()">
					&nbsp;&nbsp;
					<INPUT class="clsBtn" type="button" id="inputbtnID_DeSelectAll" onclick="fnOnDeSelectAllClick()">
				</TD>
			</TR>
		</TABLE>
		<TABLE id="tableID_ClickNext" cellpadding="8" style="DISPLAY: none;">
			<TR class="clsTR">
				<TD class="clsTD">
					<LABEL class="clsLabelComment" id="labelID_ClickNext"></LABEL>
				</TD>
			</TR>
		</TABLE>
	</BODY>
</HTML>
