﻿<html>
<head>
<title>Server Management - Activation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--base href="$$BASE_URL$$"-->
<link href="css/trend-style-new.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="javascripts/localization.js"></script>
<script language="JavaScript" src="javascripts/trend-ui-new.js"></script>
<script language="JavaScript" src="javascripts/OLH_Mapping.js"></script>
<script language="JavaScript" src="javascripts/prototype.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
var vStep = 1;
var fCheck = "true";
function jsInitPage() {
	// init page
	jsUIDisplay();
	// set max length
	$("UserID").maxLength = INT_SM_LMAX_USERNAME + INT_LMAX_DOMAIN + 1;
	$("UserPW").maxLength = INT_LMAX_PASSWORD;
	$("SpecifyID").maxLength = INT_SM_LMAX_USERNAME;
	$("SpecifyPW").maxLength = INT_LMAX_PASSWORD;
	$("CreateID").maxLength = INT_SM_LMAX_USERNAME;
	$("CreatePW").maxLength = INT_LMAX_PASSWORD;
	$("CreateCPW").maxLength = INT_LMAX_PASSWORD;
}
function jsSubmit(vAction) {
    var vUserPW,vCreatePW,vSpecifyPW,vSetting;
    if(vAction == "NEXT"){
        if(vStep == 1){
            if(document.getElementById("rdoCreate").checked == true) vStep++;
            else if(vStep == 4)
            {
                if(setTrim($("UserID").value) == "")
                {
                    alert(STR_USERID_EMPTY);
                    jsFocus($("UserID"));
                    return false; 
                }
            }
            vStep++;
            jsUIDisplay();
        }
        else if(vStep == 2 || vStep == 3){
	        var vRdoAccount = (document.getElementById("rdoSpecify").checked)?document.getElementById("rdoSpecify").value:document.getElementById("rdoCreate").value;
	        if(vRdoAccount == "createnew")
	        {
	            if(setTrim($("CreateID").value) == "")
                {
                    alert(STR_USERID_EMPTY);
                    jsFocus($("CreateID"));
                    return false; 
                }
                else if(!checkADUserName($("CreateID").value, STR_ACTIVATE_ADUSER)){
                    jsFocus($("CreateID"));
                    return false; 
                } 
	            else if(document.getElementById("CreatePW").value != document.getElementById("CreateCPW").value)
	            {
	                alert(STR_PASSWORD_CONFIRM_FAIL);
	                jsFocus($("CreatePW"));
	                return false; 
	            }
	        }
	        else if(vRdoAccount == "existing")
	        {
                if(setTrim($("SpecifyID").value) == "")
                {
                    alert(STR_USERID_EMPTY);
                    jsFocus($("SpecifyID"));
                    return false; 
                }
                if(!checkADUserName($("SpecifyID").value, STR_ACTIVATE_ADUSER)){
                    jsFocus($("SpecifyID"));
                    return false; 
                } 
            }
    	    
            vCreatePW = encryptString(document.fmMain.CreatePW.value);
            vSpecifyPW = encryptString(document.fmMain.SpecifyPW.value);

	        vSetting = "Page=summary/activate_progress.htm&Locale=&CurPage="
	    			    + "&UserID="
	    			    + "&UserPW="
	    			    + "&rdoAccount=" + encodeURIComponent(vRdoAccount)
	    			    + "&SpecifyID=" + encodeURIComponent(document.getElementById("SpecifyID").value)
	    			    + "&SpecifyPW=" + encodeURIComponent(vSpecifyPW)
	    			    + "&CreateID=" + encodeURIComponent(document.getElementById("CreateID").value)
	    			    + "&CreatePW=" + encodeURIComponent(vCreatePW)
	    			    + "&CHECKED=" + encodeURIComponent(fCheck);

	        jsProgress(vSetting);
        }
        else if(vStep == 4){
            if(setTrim($("UserID").value) == "")
            {
                alert(STR_USERID_EMPTY);
                jsFocus($("UserID"));
                return false; 
            }
            if(!checkADUserNamewithDomain($("UserID").value, STR_ACTIVATE_ADUSER)){
                    jsFocus($("UserID"));
                    return false; 
            }
            else {
                var tmpString = $("UserID").value.split("\\");
                if(tmpString.length > 1){
                    if(!checkNumberRange(tmpString[0].length,INT_LMAX_DOMAIN,0,STR_DOMAIN_EXCEED) || !checkNumberRange(tmpString[1].length,INT_SM_LMAX_USERNAME,0,STR_USERID_EXCEED))
                        return false;
                }
                else{
                    if(!checkNumberRange(tmpString[0].length,INT_SM_LMAX_USERNAME,0,STR_USERID_EXCEED))
                        return false;
                }  
            }
            var vRdoAccount = (document.getElementById("rdoSpecify").checked)?document.getElementById("rdoSpecify").value:document.getElementById("rdoCreate").value;
            vUserPW = encryptString(document.fmMain.UserPW.value);
            vCreatePW = encryptString(document.fmMain.CreatePW.value);
            vSpecifyPW = encryptString(document.fmMain.SpecifyPW.value);
            fCheck = "false";

	        vSetting = "Page=summary/activate_progress.htm&Locale=&CurPage="
	    			    + "&UserID=" + encodeURIComponent(document.getElementById("UserID").value)
	    			    + "&UserPW=" + encodeURIComponent(vUserPW)
	    			    + "&rdoAccount=" + encodeURIComponent(vRdoAccount)
	    			    + "&SpecifyID=" + encodeURIComponent(document.getElementById("SpecifyID").value)
	    			    + "&SpecifyPW=" + encodeURIComponent(vSpecifyPW)
	    			    + "&CreateID=" + encodeURIComponent(document.getElementById("CreateID").value)
	    			    + "&CreatePW=" + encodeURIComponent(vCreatePW)
	    			    + "&CHECKED=" + encodeURIComponent(fCheck);
	    	
	        jsProgress(vSetting);
        }
        
   }
   if(vAction == "BACK"){
        if(vStep==4){
            var vRdoAccount = (document.getElementById("rdoSpecify").checked)?document.getElementById("rdoSpecify").value:document.getElementById("rdoCreate").value;
	        if(vRdoAccount == "existing"){vStep = vStep - 2;}
	        else{vStep--;}
	    }
        else if(vStep == 3){vStep = vStep - 2;}
        else{vStep--;}
        jsUIDisplay();
   } 
}
function jsUIDisplay(){
   document.getElementById("btnBack").style.display = (vStep>1)?"":"none"; 
    for(i=1;i<5;i++){
        document.getElementById("ActStep" + i).style.display = (i == vStep)? "":"none";
   }
   if(vStep == 2) vStep++;
}
function jsProgress(vSetting){
    if(vStep == 4){
        $("Activate_Content").style.display="none";
        $("Progress_Content").style.display="";
    } 
	vURL = "cgiDispatcher.exe";
	var PostArgument = vSetting;
	var cacheBuster = "&tick=" + new Date() * 1;
    PostArgument += cacheBuster; 
    var myAjax = new Ajax.Request(vURL, {method:'post', postBody:PostArgument , onComplete:jsActivateDone}); 
}

// originalRequest = "0:Activation succeeds message" or "1:Activation fails message".
function jsActivateDone(originalRequest){
  	var response = originalRequest.responseText;
   	var vResultSignal = response.substring(0,response.indexOf(":"));
  	if(vStep == 3){
  	    if(vResultSignal == "0"){
  	        var vRdoAccount = (document.getElementById("rdoSpecify").checked)?document.getElementById("rdoSpecify").value:document.getElementById("rdoCreate").value;
  	        var vCreatePW = encryptString(document.fmMain.CreatePW.value);
            var vSpecifyPW = encryptString(document.fmMain.SpecifyPW.value);
            var fCheck = "false";

            var vSetting = "Page=summary/activate_progress.htm&Locale=&CurPage="
    			        + "&UserID="
    			        + "&UserPW="
    			        + "&rdoAccount=" + encodeURIComponent(vRdoAccount)
    			        + "&SpecifyID=" + encodeURIComponent(document.getElementById("SpecifyID").value)
    			        + "&SpecifyPW=" + encodeURIComponent(vSpecifyPW)
    			        + "&CreateID=" + encodeURIComponent(document.getElementById("CreateID").value)
    			        + "&CreatePW=" + encodeURIComponent(vCreatePW)
	    			    + "&CHECKED=" + encodeURIComponent(fCheck);
        	vStep = 4;
        	jsProgress(vSetting);
  	    }
  	    else if(vResultSignal == "1") { // require more permission.
  	        vStep = 4;
  	        jsUIDisplay();
  	    }else if(vResultSignal == "2") {
  	        vStep = 3;
  	        alert(STR_ACTIVATE_ACCOUNT_PASSWORD_INCORRECT);
  	    }else if(vResultSignal == "3") { // select new account but account is existing
  	        alert(STR_ACTIVATE_ACCOUNT_EXIST);
  	    }
  	}
  	else{
        Element.hide("ProgressBar_Running");
        Element.show("ProgressBar_Success");
        Element.show("btnComplete"); 
        if(vResultSignal == "0")
            $("ActivateResult").innerText = STR_ACTIVATE_E2K7_RESULT_SUCCESS;
        else if(vResultSignal == "2")
        		$("ActivateResult").innerText = STR_ACTIVATE_RESULT_FAIL + " " + response.substring(response.indexOf(":")+1);
        else
            $("ActivateResult").innerText = STR_ACTIVATE_RESULT_FAIL;
            
    }
}
function encryptString(str)     
{
	var ret = "";
	try{
		ret = document.SendEncrypt.Encryptdata(str);
	}catch(e){
	}
	return ret;
}
//-->
</script>
</head>

<body onload="jsInitPage();">
<form id="fmMain" name="fmMain" action="$$FORM_ACTION$$" method="POST">
<!--Hidden Field--><!--/Hidden Field-->

<!--Page Title-->
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr><td class="content-title">Server Management</td>
	<td valign="bottom" align="right">
		<a href="javascript:jsMapOnlineHelp('summary\activate_2k3.htm');" class="moretestblue">
		<img src="images/question.gif" class="vAlignMid"> Help</a></td></tr>
<tr><td colspan="2" height="4"></td></tr>
<tr><td colspan="2" height="1" background="images/dot.gif"></td></tr>
<tr><td colspan="2" height="10"></td></tr>
</table>
<!--/Page Title-->

<table width="98%" border="0" cellpadding="0" cellspacing="0" id="Activate_Content">
<!--Page Description--><!--/Page Description-->
<!--Page Content-->
<!--Activate Step 1-->
<tr id="ActStep1"><td><table border="0" cellpadding="0" cellspacing="0" width="100%">
		<tr><td class="data1" colspan="2">To activate the Server Management feature successfully, specify an existing account or create a new account. The activation program/wizard assigns this account to the predefined “SMEX Admin Group” with permissions to log on to the Web management console and manage PortalProtect servers.</td></tr>
		<tr><td colspan="2" height="10"></td></tr>
		<tr><td class="data1" width="20"><input type="radio" class="text" id="rdoSpecify" name="rdoAccount" value="existing" checked  /></td>
		       <td width="520"  class="data1">Specify an existing account from Active Directory</td></tr>
		<tr><td></td>
		       <td  class="data1">Activation uses your existing domain account and adds it to the "SMEX Admin Group" in the Active Directory.</td></tr>
		<tr><td class="data1"><input type="radio" class="text" id="rdoCreate" name="rdoAccount" value="createnew" /></td>
		       <td class="data1">Create a new account</td></tr>
		<tr><td></td>
		       <td  class="data1">Activation will create a new user account and add it to the "SMEX Admin Group" in the Active Directory.</td></tr>
		</table></td></tr>
<!--Activate Step 2-->
<tr id="ActStep2" style="display:none"><td><table border="0" cellpadding="0" cellspacing="0" width="100%">
		<tr><td class="data1" colspan="2">If the “SMEX Admin Group” exists in Active Directory and the existing account you specify is a member of this group, no special privileges are required to activate PortalProtect Server Management. If this is not the case, specify an account that has Domain Administrator privileges in the next step.</td></tr>
		<tr><td colspan="2" height="10"></td></tr>
		<tr><td colspan="2" height="20" class="data1">When typing the account, do not use the "domain\account" format.</td></tr>
		<tr><td colspan="2" height="10"></td></tr>
		<tr><td class="data1" width="65"><b>User name:</b></td>
		       <td width="475"><input type="text" class="text" id="SpecifyID" name="SpecifyID" size="25" /></td></tr>
		<tr><td class="data1"><b>Password:</b></td>
		       <td><input type="password" class="text" id="SpecifyPW" name="SpecifyPW" size="25" /></td></tr>
		</table></td></tr>
<!--Activate Step 3-->
<tr id="ActStep3" style="display:none"><td><table border="0" cellpadding="0" cellspacing="0" width="100%">
		<tr><td class="data1" colspan="2">To create a new account in Active Directory, specify an account with Domain Administrator privileges in the next step.</td></tr>
		<tr><td colspan="2" height="10"></td></tr>
		<tr><td colspan="2" height="20" class="data1">When typing the account, do not use the "domain\account" format.</td></tr>
		<tr><td colspan="2" height="10"></td></tr>
		<tr><td class="data1" width="80"><b>User name:</b></td>
		       <td width="460"><input type="text" class="text" id="CreateID" name="CreateID" size="25" /></td></tr>
		<tr><td class="data1"><b>Password:</b></td>
		       <td><input type="password" class="text" id="CreatePW" name="CreatePW" size="25" /></td></tr>
		<tr><td class="data1"><b>Confirm Password:</b></td>
		       <td><input type="password" class="text" id="CreateCPW" name="CreateCPW" size="25" /></td></tr>
		</table></td></tr>
<!--Activate Step 4-->
<tr id="ActStep4" style="display:none"><td><table border="0" cellpadding="0" cellspacing="0" width="100%">
		<tr><td class="data1" colspan="2">Specify an account with Domain Administrator privileges.</td></tr>
		<tr><td colspan="2" height="10"></td></tr>
		<tr><td class="data1" width="65"><b>User name:</b></td>
		       <td width="475"><input type="text" class="text" id="UserID" name="UserID" size="25" /></td></tr>
		<tr><td class="data1"><b>Password:</b></td>
		       <td><input type="password" class="text" id="UserPW" name="UserPW" size="25" /></td></tr>
		</table></td></tr>
<tr><td height="20"></td></tr>
<tr><td><input type="button" id="btnBack" name="btnBack" value="< Back" class="text" onclick="jsSubmit('BACK')" style="display:none" />
               <input type="button" id="btnNext" name="btnNext" value="Next >" class="text" onclick="jsSubmit('NEXT')" />
               <input type="button" id="btnCancel" name="btnCancel" value="Cancel" onclick="window.close();" class="text" />
               </td></tr>
</table>

<!--Page Progress-->
<table width="98%" border="0" cellpadding="0" cellspacing="0" id="Progress_Content" style="display:none">
<tr><td><b>Please wait while the Server Management activates. Activation takes only a few minutes.</b></td></tr>
<tr><td height="10"></td></tr>
<tr id="ProgressBar_Running"><td><table width="418" height="25" border="0" cellpadding="0" cellspacing="0">
		<tr><td id="td1"><img src="images/icon_progress.gif"></td></tr>
		</table></td></tr>
<tr id="ProgressBar_Success" style="display:none"><td><table width="418" height="25" border="0" cellpadding="0" cellspacing="0" background="images/icon_progress_bg.gif" style="padding-left:7">
		<tr><td id="td2"><img id="imgEM0" src="images/icon_progress_em.gif"
			><img id="imgEM1" src="images/icon_progress_em.gif"
			><img id="imgEM2" src="images/icon_progress_em.gif"
			><img id="imgEM3" src="images/icon_progress_em.gif"
			><img id="imgEM4" src="images/icon_progress_em.gif"
			><img id="imgEM5" src="images/icon_progress_em.gif"
			><img id="imgEM6" src="images/icon_progress_em.gif"
			><img id="imgEM7" src="images/icon_progress_em.gif"
			><img id="imgEM8" src="images/icon_progress_em.gif"
			><img id="imgEM9" src="images/icon_progress_em.gif"
			><img id="imgEM10" src="images/icon_progress_em.gif"
			><img id="imgEM11" src="images/icon_progress_em.gif"
			><img id="imgEM12" src="images/icon_progress_em.gif"
			><img id="imgEM13" src="images/icon_progress_em.gif"
			><img id="imgEM14" src="images/icon_progress_em.gif"
			><img id="imgEM15" src="images/icon_progress_em.gif"
			><img id="imgEM16" src="images/icon_progress_em.gif"
			><img id="imgEM17" src="images/icon_progress_em.gif"
			><img id="imgEM18" src="images/icon_progress_em.gif"
			><img id="imgEM19" src="images/icon_progress_em.gif"
			><img id="imgEM20" src="images/icon_progress_em.gif"
			><img id="imgEM21" src="images/icon_progress_em.gif"
			><img id="imgEM22" src="images/icon_progress_em.gif"
			><img id="imgEM23" src="images/icon_progress_em.gif"
			><img id="imgEM24" src="images/icon_progress_em.gif"
			><img id="imgEM25" src="images/icon_progress_em.gif"
			><img id="imgEM26" src="images/icon_progress_em.gif"
			><img id="imgEM27" src="images/icon_progress_em.gif"
			><img id="imgEM28" src="images/icon_progress_em.gif"
			><img id="imgEM29" src="images/icon_progress_em.gif"
			><img id="imgEM30" src="images/icon_progress_em.gif"
			><img id="imgEM31" src="images/icon_progress_em.gif"
			><img id="imgEM32" src="images/icon_progress_em.gif"
			><img id="imgEM33" src="images/icon_progress_em.gif"
			><img id="imgEM34" src="images/icon_progress_em.gif"
			><img id="imgEM35" src="images/icon_progress_em.gif"
			><img id="imgEM36" src="images/icon_progress_em.gif"
			><img id="imgEM37" src="images/icon_progress_em.gif"
			><img id="imgEM38" src="images/icon_progress_em.gif"
			><img id="imgEM39" src="images/icon_progress_em.gif"
			><img id="imgEM40" src="images/icon_progress_em.gif"
			><img id="imgEM41" src="images/icon_progress_em.gif"
			><img id="imgEM42" src="images/icon_progress_em.gif"
			><img id="imgEM43" src="images/icon_progress_em.gif"
			><img id="imgEM44" src="images/icon_progress_em.gif"
			><img id="imgEM45" src="images/icon_progress_em.gif"
			><img id="imgEM46" src="images/icon_progress_em.gif"
			><img id="imgEM47" src="images/icon_progress_em.gif"
			><img id="imgEM48" src="images/icon_progress_em.gif"
			><img id="imgEM49" src="images/icon_progress_em.gif"
			></td></tr>
		</table></td></tr>
<tr><td height="10"></td></tr>
<tr><td><strong id="ActivateResult"></strong></td></tr>		
<tr><td height="20"></td></tr>
<tr><td><input type="button" id="btnComplete" name="btnComplete" value="Complete" class="text" onclick="window.close();" style="display:none" />
               </td></tr>
</table>

</form>
<applet code="EncryptEx.class" name="SendEncrypt" width=0 height=0 id="SendEncrypt"></applet>
</body>
</html>