<%@ Page language="c#" Inherits="WebApp.Wpdcc.selectWebService" Codebehind="selectWebService.aspx.cs" %>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD id="tt" runat="server">
		<title>WEB服务选择</title>
		
		<link href="../Css/Admin_STYLE.CSS" type="text/css" rel="stylesheet">
		
		<style type="text/css">.style1 { COLOR: #ffffff }
	.style2 { FONT-SIZE: 12px }
	.style3 { FONT-SIZE: 12px; COLOR: #ffffff }
		</style>
	</HEAD>
	<body topmargin="0" leftmargin="0">
		<form id="myform" method="post" runat="server">
		
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
			<FONT face="宋体">
				<div align="center">
					<FONT face="宋体">
						<TABLE width="400" border="1" align="left" cellPadding="0" cellSpacing="0" bordercolor="#6375d6"
							id="Table2" style="WIDTH: 400px;BORDER-COLLAPSE: collapse">
							<TR>
								<td height="21" colspan="3" bgcolor="#6375d6">
									<div align="center" style="color:White">
                                        选择WEB服务器：<asp:DropDownList ID="ddlServer" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlServer_SelectedIndexChanged">
                                    </asp:DropDownList></div>
								<TD colspan="3" bgcolor="#6375d6" style="WIDTH:200px"><div align="center" class="style1">
										<div align="center" class="style2">&nbsp;</div>
									</div>
								</TD>
							</TR>
							<TR>
								<TD width="46" valign="top" bgcolor="#6375d6"><img src="Images/ceng.gif" width="50" height="1"></TD>
								<TD width="6" class="bgcolor">
								<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
        <ContentTemplate> 
                                    <asp:ListBox ID="d_b1" runat="server" SelectionMode="Multiple" Height="232px" Width="168px"></asp:ListBox>
                                    </ContentTemplate>  
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="ddlServer" EventName="SelectedIndexChanged" />
                                    </Triggers>
                                  
                                </asp:UpdatePanel>
                                    </TD>
								<TD width="148" align="center" bgcolor="#6375d6">
									<P><FONT face="宋体"> <INPUT onclick="Add()" type="button" value=" → " name="b1">
											<BR>
											<BR>
											<INPUT onclick="Del()" type="button" value=" ← " name="b1"> </FONT>
									</P>
									<P><FONT face="宋体"> <INPUT style="WIDTH: 32px; HEIGHT: 22px" onclick="AddAll()" type="button" value=">>" name="b1">
										</FONT>
									</P>
									<P><FONT face="宋体"> <INPUT style="WIDTH: 32px; HEIGHT: 22px" onclick="DelAll()" type="button" value="<<" name="b1">
											<img src="Images/ceng.gif" width="50" height="8"></FONT></P>
								</TD>
								<TD width="96" class="bgcolor" style="WIDTH: 95px"><FONT face="宋体">
										<asp:listbox id="d_b2" runat="server" SelectionMode="Multiple" Height="232px" Width="168px"></asp:listbox>
									</FONT>
								</TD>
								<TD width="150" bgcolor="#6375d6">
									<INPUT onclick="Up()" type="button" value="↑" name="b3">
									<BR>
									<BR>
									<INPUT onclick="Down()" type="button" value="↓" name="b4"> <img src="Images/ceng.gif" width="50" height="1">
								</TD>
							</TR>
							<tr>
								<td colspan="5" align="center" ><INPUT type="button" value="确定" onclick="checkform();">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="取消" name="btnClose" onclick="javascript:window.close();">
								</td>
							</tr>
						</TABLE>
					</FONT>
				</div>
			</FONT><INPUT id="d_name" type="hidden" name="d_button" runat="server"><INPUT id="d_value" type="hidden" name="d_button" runat="server">
		</form>
	</body>
</HTML>
<SCRIPT language="javascript">
			// 加入已选
			function Add() {
				var selectFrom=document.myform.d_b1;
				var selectTo=document.myform.d_b2;
				if (selectFrom.selectedIndex<0) {
					alert("请选择WEB服务！");
					return;
				}

				for(var loop=0;loop<selectFrom.options.length;loop++)
				{
				if(selectFrom.options[loop].selected==true)
					{                        
						var optionName = selectFrom.options[loop].text ;
						var optionValue = selectFrom.options[loop].value ;                        
						var flag = false;
							for(var i=0;i<selectTo.options.length;i++)
							{
								if(optionValue == selectTo.options[i].value)
									{
											flag = true;
											break;
									}
							}
			                        
						if (flag == true)
						{
							alert("“"+selectFrom.options[loop].text+"”已被选择!");
						}
							else 
							{
							selectTo.add(new Option(optionName,optionValue));
							}  
					} 
				}                       
				
			}
			function AddAll() 
			{
			var selectFrom=document.myform.d_b1;
				var selectTo=document.myform.d_b2;
				

				for(var loop=0;loop<selectFrom.options.length;loop++)
				{
			                           
						var optionName = selectFrom.options[loop].text ;
						var optionValue = selectFrom.options[loop].value ;                        
						var flag = false;
							for(var i=0;i<selectTo.options.length;i++)
							{
								if(optionValue == selectTo.options[i].value)
									{
											flag = true;
											break;
									}
							}
			                        
						if (flag == false)
						{
			              
							selectTo.add(new Option(optionName,optionValue));
							}  
			           
				}            
			}

			// 从已选中删除
			function Del() {
				var selectTo=document.myform.d_b2;
				var nIndex = selectTo.selectedIndex;
				var nLen = selectTo.length;
				if (nLen<1) return;
				if (nIndex<0) {
					alert("请选择已选WEB服务！");
					return;
				}
				
				for(var loop=0;loop<selectTo.options.length;loop++)
				{
					if(selectTo.options[loop].selected){                        
               			selectTo.options[loop] = null; loop--;
					}
			     }
			}
			function DelAll() {
				var selectTo=document.myform.d_b2;
				var nLen = selectTo.length;
				if (nLen<1) return;
				for(var loop=nLen;loop>=0;loop--)
				{ 
               		selectTo.options[loop] = null;
               	}			  
			}

			// 排序：向上移动
			function Up() {
				var sel=document.myform.d_b2;
				var nIndex = sel.selectedIndex;
				var nLen = sel.length;
				if ((nLen<1)||(nIndex==0)) return;
				if (nIndex<0) {
					alert("请选择一个要移动的已选WEB服务！");
					return;
				}
				var sValue=sel.options[nIndex].value;
				var sHTML=sel.options[nIndex].innerHTML;
				sel.options[nIndex].value=sel.options[nIndex-1].value;
				sel.options[nIndex].innerHTML=sel.options[nIndex-1].innerHTML;
				sel.options[nIndex-1].value=sValue;
				sel.options[nIndex-1].innerHTML=sHTML;
				sel.selectedIndex=nIndex-1;
			}

			// 排序：向下移动
			function Down() {
				var sel=document.myform.d_b2;
				var nIndex = sel.selectedIndex;
				var nLen = sel.length;
				if ((nLen<1)||(nIndex==nLen-1)) return;
				if (nIndex<0) {
					alert("请选择一个要移动的已选按钮！");
					return;
				}
				var sValue=sel.options[nIndex].value;
				var sHTML=sel.options[nIndex].innerHTML;
				sel.options[nIndex].value=sel.options[nIndex+1].value;
				sel.options[nIndex].innerHTML=sel.options[nIndex+1].innerHTML;
				sel.options[nIndex+1].value=sValue;
				sel.options[nIndex+1].innerHTML=sHTML;
				sel.selectedIndex=nIndex+1;
			}

			// 提交处理
			function checkform() {
			    //parent.window.dialogArguments.DelAll();
			    parent.DelAll();
				var selectFrom=document.myform.d_b2;
			   for(var loop=0;loop<selectFrom.options.length;loop++)
				{ 
					var optionName = selectFrom.options[loop].text ;
					var optionValue = selectFrom.options[loop].value ;                        
					//parent.window.dialogArguments.checkform(optionName,optionValue);
					parent.checkform(optionName,optionValue);
				}            	
				//window.close();
				parent.$.fancybox.close();
			}
		</SCRIPT>