<html>
<head>
<title>Scheduled_Scan</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/TmCube_Common.js"></script>
<script language="JavaScript" src="javascripts/OLH_Mapping.js"></script>
<script language="JavaScript" src="javascripts/prototype.js"></script>

<script language="JavaScript" src="cgiDispatcher.exe?Page=administration/SystemDateTime.htm">
<!-- //src="cgiDispatcher.exe?Page=administration/SystemDateTime.htm" return 4 values: vSvrDate, vSvrDateFormat, vSvrTime, vSvrTimeFormat, vSvrTwoDigitYearMax. //-->
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
CANCEL_EVENT = true;
var vNowDate;
var behavior="$$SCAN_TASK_BEHAVIOR_VALUE4$$";
var sGIDs = "$$DB_SELECTION_DATA_VALUE$$";
var sPartGIDs = "$$DB_PARTSELECTED_DATA_VALUE$$";
var site_url_keyword = "";
/**
 * Get component object by prefix.
 * Then get the object with the eval funtion.
 * @param prefix The prefix Strip from compnent inner control's id.
 * @return The component object which is generated by ui conversion (Menu : CUBE Component/Convert to CCGI PAGE).
 */
function TmCube_getComponentByPrefix(prefix)
{
    return eval("TmCube_" + prefix);
}
/**
 * Get element with prefix and original id.
 * @param prefix Prefix of a component instance. may be it's name or type.
 * @return The element.
 */
 function TmCube_getElement(prefix, id)
 {
     return document.getElementById(prefix + "__" + id);
 }
 
function jsSubmit() {
	// add some checking
	if(document.fmMain.ScanTaskName.value == "") {
		alert(STR_ALR_EMPTY_SCAN_TASK_NAME);
		return;
	}
	//check the range of txtLastNDayNumberPart	
	if (!checkNumberRange(document.getElementById("txtLastNDayNumberPart").value, INT_NMAX_LAST_N_DAY_NUMBER_PART, INT_NMIN_LAST_N_DAY_NUMBER_PART,  STR_ON_DEMAND_SCAN_LAST_N_DAY_NUMBER_PART_INVALID,false))
	{
		jsFocus(document.getElementById("txtLastNDayNumberPart"));
		return false;
	}	
	if(!jsSaveFromToDate()) return false;
	//check the range of txtLastNDayNumberPart	
if (!checkNumberRange(document.getElementById("txtLastNDayNumberPart").value, INT_NMAX_LAST_N_DAY_NUMBER_PART, INT_NMIN_LAST_N_DAY_NUMBER_PART,  STR_ON_DEMAND_SCAN_LAST_N_DAY_NUMBER_PART_INVALID,false))
	{
		jsFocus(document.getElementById("txtLastNDayNumberPart"));
		return false;
	}	
	// cancel event capture
	CANCEL_EVENT = true;
	document.fmMain.TaskButton.disabled			= true;
	//document.fmMain.DbSelectionData.value 		= getTreeEntityValue(document.fmMain.chkEntity);
	document.fmMain.DbSelectionData.value    	=  TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE1$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE1$$";
	document.fmMain.Behavior.value	 			= "$$SCAN_TASK_BEHAVIOR_VALUE1$$";
	document.fmMain.ScheduleScanRedirect.value	= "scan/Scheduledscan_List.htm";
	document.fmMain.DbSelectionSelectAll.value = (document.getElementById("rdoSelectAllDB").checked)?"SelectAll":"";
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}
function jsRefresh() {
	// cancel event capture
	CANCEL_EVENT = true;
	document.fmMain.TaskButton.disabled			= true;
	// refresh database-selection list
	document.fmMain.DbSelectionData.value    	=  TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE2$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE2$$";
	document.fmMain.Behavior.value 				= "$$SCAN_TASK_BEHAVIOR_VALUE2$$";
	document.fmMain.FormAction.value	 		= "Refresh";
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}

function jsCancel() {
	// cancel event capture
	CANCEL_EVENT = true;
	//document.fmMain.TaskButton.disabled			= true;
	document.fmMain.TaskButtonCancel.diabled    = true;
	//document.fmMain.DbSelectionData.value    	=  TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE3$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE3$$";
	document.fmMain.Behavior.value 				= behavior;
	document.fmMain.FormAction.value			= "Cancel";
	document.fmMain.ScheduleScanRedirect.value	= "scan/Scheduledscan_List.htm";
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}

function jsVirusScan() {
	// add some checking
	if(document.fmMain.ScanTaskName.value == "") {
		alert(STR_EMPTY_SCAN_TASK_NAME);
		return;
	}
	
	//if(!jsSaveFromToDate()) return false;
	
	// cancel event capture
	CANCEL_EVENT = true;
	document.fmMain.TaskButton.disabled			= true;
	document.fmMain.TaskButtonCancel.disabled	= true;
	document.fmMain.DbSelectionData.value    	=  TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE4$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE4$$";
	document.fmMain.Behavior.value 				= behavior;
	document.fmMain.FormAction.value			= "VSCONFIG";
	document.fmMain.DbSelectionSelectAll.value = (document.getElementById("rdoSelectAllDB").checked)?"SelectAll":"";
	var strTaskName = document.getElementById("txtTaskName").value;
	var strPagelink = "scan\\Virusscanning.htm&Subject=$$SCAN_SUBJECT_ID1$$&Behavior=$$SCAN_TASK_BEHAVIOR_VALUE8$$";
	if(strTaskName=="")
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink;
	else
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink+"&TaskName="+strTaskName;
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}
function jsAttachBlock() {
	// add some checking
	if(document.fmMain.ScanTaskName.value == ""){
		alert(STR_EMPTY_SCAN_TASK_NAME);
		return;
	}
	
	//if(!jsSaveFromToDate()) return false;
	
	// cancel event capture
	CANCEL_EVENT = true;
	document.fmMain.TaskButton.disabled			= true;
	document.fmMain.TaskButtonCancel.disabled	= true;
	document.fmMain.DbSelectionData.value    	=  TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE5$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE5$$";
	document.fmMain.Behavior.value 				= "$$SCAN_TASK_BEHAVIOR_VALUE5$$";
	document.fmMain.FormAction.value			= "ABCONFIG";
	document.fmMain.DbSelectionSelectAll.value = (document.getElementById("rdoSelectAllDB").checked)?"SelectAll":"";	
	var strTaskName = document.getElementById("txtTaskName").value;
	var strPagelink = "scan\\Attachmentblocking.htm&Subject=$$SCAN_SUBJECT_ID2$$&Behavior=$$SCAN_TASK_BEHAVIOR_VALUE9$$";
	if(strTaskName=="")
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink;
	else
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink+"&TaskName="+strTaskName;
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}
function jsContentFilter() {
	// add some checking
	if(document.fmMain.ScanTaskName.value == "") {
		alert(STR_EMPTY_SCAN_TASK_NAME);
		return;
	}
	
	//if(!jsSaveFromToDate()) return false;
	
	// cancel event capture
	CANCEL_EVENT = true;
	document.fmMain.TaskButton.disabled			= true;
	document.fmMain.TaskButtonCancel.disabled	= true;
	document.fmMain.DbSelectionData.value    	=  TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE6$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE6$$";
	document.fmMain.Behavior.value 				= "$$SCAN_TASK_BEHAVIOR_VALUE6$$";
	document.fmMain.FormAction.value			= "CFCONFIG";
	var strTaskName = document.getElementById("txtTaskName").value;
	var strPagelink = "scan/Contentfiltering_List.htm&Subject=$$SCAN_SUBJECT_ID3$$&Behavior=$$SCAN_TASK_BEHAVIOR_VALUE10$$";
	if(strTaskName=="")
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink;
	else
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink+"&TaskName="+strTaskName;
	document.fmMain.DbSelectionSelectAll.value = (document.getElementById("rdoSelectAllDB").checked)?"SelectAll":"";	
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}
function jsWebReputation(){
		if(document.fmMain.ScanTaskName.value == "") {
		alert(STR_EMPTY_SCAN_TASK_NAME);
		return;
	}
    CANCEL_EVENT = true;
	document.fmMain.TaskButton.disabled			= true;
	document.fmMain.TaskButtonCancel.disabled	= true;
	document.fmMain.DbSelectionData.value    =  TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE7$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE7$$";
	document.fmMain.Behavior.value 				= "$$SCAN_TASK_BEHAVIOR_VALUE7$$";
	document.fmMain.FormAction.value			= "WTPCONFIG";
	var strTaskName = document.getElementById("txtTaskName").value;
	var strPagelink = "scan/WebThreatProtection.htm&Subject=$$SCAN_SUBJECT_ID4$$&Behavior=$$SCAN_TASK_BEHAVIOR_VALUE11$$";
	if(strTaskName=="")
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink;
	else
	   document.fmMain.ScheduleScanRedirect.value	= strPagelink+"&TaskName="+strTaskName;
	document.fmMain.DbSelectionSelectAll.value = (document.getElementById("rdoSelectAllDB").checked)?"SelectAll":"";	
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}
function jsDataLossPrevention() {
	// add some checking
	if(document.fmMain.ScanTaskName.value == ""||document.fmMain.ScanTaskName.value.length>64) {
		alert(STR_EMPTY_SCAN_TASK_NAME);
		return;
	}
	CANCEL_EVENT = true;
	document.fmMain.TaskButton.disabled			= true;
	document.fmMain.DbSelectionData.value 		= TmCube_Tree_getResult("Tree");
	document.fmMain.TaskId.value 				= "$$SCAN_TASK_ID_VALUE8$$";
	document.fmMain.AddTaskButton.value 		= "$$ADD_TASK_BUTTON_VALUE8$$";
	document.fmMain.Behavior.value 				= "$$SCAN_TASK_BEHAVIOR_VALUE12$$";
	document.fmMain.FormAction.value			= "DLPCONFIG";
	document.fmMain.ScheduleScanRedirect.value	= "scan/DLP_Rule_List.htm&Subject=$$SCAN_SUBJECT_ID5$$&Behavior=$$SCAN_TASK_BEHAVIOR_VALUE12$$";
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
}
function jsSaveFromToDate(){
    var vFromDate = (document.fmMain.txtDateFrom_display.disabled)?"":document.fmMain.txtDateFrom_display.value;
	    document.fmMain.txtDateFrom.value = (vFromDate=="")?"":setDateTimeFormatToProgramStandard(vFromDate,vSvrDateFormat,vSvrTwoDigitYearMax);
	var vEndDate = (document.fmMain.txtDateTo_display.disabled)?"":document.fmMain.txtDateTo_display.value;
	    document.fmMain.txtDateTo.value = (vEndDate=="")?"":setDateTimeFormatToProgramStandard(vEndDate,vSvrDateFormat,vSvrTwoDigitYearMax);
	
	if(vFromDate != ""){
        if (!checkDateTimeFormat(document.fmMain.txtDateFrom.value,STR_WARN_DATE,vSvrDateFormat)) {
	        jsFocus(document.fmMain.txtDateFrom_display);
	        return false;
        }
	}
	if(vEndDate !=""){
	    if (!checkDateTimeFormat(document.fmMain.txtDateTo.value,STR_WARN_DATE,vSvrDateFormat)) {
		    jsFocus(document.fmMain.txtDateTo_display);
		    return false;
	    }
	}
	jsCombineDateTime();
	if(vFromDate != "" && vEndDate !=""){
	    if (new Date(document.fmMain.txtDateFrom.value) > new Date(document.fmMain.txtDateTo.value)) {
		    alert(STR_ERR_DATETIME_PERIOD);
		    document.fmMain.txtDateFrom.value = document.fmMain.txtDateFrom.value.substr(0,10);
		    document.fmMain.txtDateTo.value = document.fmMain.txtDateTo.value.substr(0,10);
		    document.fmMain.txtDateFrom_display.focus();
		    document.fmMain.txtDateFrom_display.select();
		    return false;
	    }
	}
	return true;
}

function jsInitPage() {
	// Init Page
	if($$ID_PR_CONTENT_FILTERING_HIDE$$) {
		document.getElementById("prContentFilter").style.display="none";
	} else {
		document.getElementById("prContentFilter").style.display="";
	}
    if( document.getElementById("chkContentFilterDoc").checked||document.getElementById("chkContentFilterWeb").checked)
       document.getElementById("chkContentFilter").checked="true";
	if( document.getElementById("chkWebReputationDoc").checked||document.getElementById("chkWebReputationWeb").checked)
       document.getElementById("chkWTP").checked="true";
	//when editing a added task, the "Cancel" button should not be hided.
	//when editing a already existing task, the "Cancel" buttong should be hided.
	if ($$ID_CANCEL_BUTTON_HIDE$$)
	{
		document.getElementById("TaskButtonCancel").style.display="none";
	}
	if($$ID_PR_DLP_HIDE$$) 
	{
		document.getElementById("prDLPFilter").style.display="none";
		document.getElementById("prDLPForDoc").style.display="none";
		document.getElementById("prDLPForWeb").style.display="none";
	}
	else 
	{
		document.getElementById("prDLPFilter").style.display="";
	}
	if( document.getElementById("chkDLPDoc").checked || document.getElementById("chkDLPWeb").checked)
       document.getElementById("chkDLPFilter").checked="true";
	
	setDateTimeValue(document.fmMain.optWeek,STR_TIME_WEEK);
	setDateTimeValue(document.fmMain.optDays,STR_TIME_DAYS);
	setDateTimeValue(document.fmMain.optStartHour,STR_TIME_HOUR);
	setDateTimeValue(document.fmMain.optStartMins,STR_TIME_MINS);
	document.fmMain.optSchedule[$$OPT_SCHEDULED_FREQ$$].checked = true;
	document.fmMain.optWeek.options[$$OPT_SCHEDULED_WEEK_OFFSET_VALUE$$].selected = true;
	document.fmMain.optDays.options[($$OPT_SCHEDULED_MONTH_OFFSET_VALUE$$-1)].selected = true;
	document.fmMain.optStartHour.options[$$OPT_SCHEDULED_START_HOUR_IDX$$].selected = true;
	document.fmMain.optStartMins.options[$$OPT_SCHEDULED_START_MINS_IDX$$].selected = true;
	
	// set max length
	document.fmMain.ScanTaskName.maxLength		= INT_LMAX_TASKNAME;
	
	document.fmMain.TaskButton.value = (document.fmMain.Behavior.value == "Add")?STR_ADD_SCAN_TASK:STR_SAVE_SCAN_TASK;	
	document.getElementById("labTitleAction").innerHTML = (behavior == "Add")?STR_ADD_SCAN_TASK:STR_EDIT_SCAN_TASK;
	
	// Init Tree
	TmCube_Tree.onload();
	
	document.fmMain.txtScanTask.focus();
	document.fmMain.txtScanTask.select();
	
	if('$$VAR_INPUT_VALID1$$' != 'UI_SUCCESS')
		window.alert(jsInputValidToL10NText('$$VAR_INPUT_VALID2$$'));
	// release event capture
	CANCEL_EVENT = false;
	
	var iniDbSelectionSelectAll = document.fmMain.DbSelectionSelectAll.value;
    document.getElementById("rdoSelectAllDB").checked = (iniDbSelectionSelectAll == "SelectAll")?true:false;
    document.getElementById("rdoSelectSpecificDB").checked = ( iniDbSelectionSelectAll == "SelectAll")?false:true;
    
	setOptionValue(document.fmMain.optHourFrom,		STR_TIME_HOUR,	false);
	setOptionValue(document.fmMain.optMinFrom,		STR_TIME_MIN,	false);
	setOptionValue(document.fmMain.optHourTo,		STR_TIME_HOUR,	false);
	setOptionValue(document.fmMain.optMinTo,		STR_TIME_MIN,	false);
	
	var vEndTime,vEndDate,vFromDate,vFromHour,vEndHour;
	if(document.fmMain.txtDateFrom.value=="")
	{
	    vEndTime = new Date();
	    vEndDate = new Date(vEndTime);	
	    vFromDate = new Date(vEndTime);
	    vFromDate.setDate(vFromDate.getDate()-1);
	    vFromHour = 0;
	    vEndHour = 0;
	}
	else
	{
	    //Server MUST return "mm/dd/yy hh:mm:ss" format
	    var vtempFromDate = document.fmMain.txtDateFrom.value;
	    var vtempEndDate = document.fmMain.txtDateTo.value;
	    var vtempYear = (vtempFromDate.substr(6,2) > vSvrTwoDigitYearMax.substr(2,2))?"19":"20";
	    vFromDate = vtempFromDate.substr(0,6) + vtempYear + vtempFromDate.substr(6,2);
	    vEndDate = vtempEndDate.substr(0,6) + vtempYear + vtempEndDate.substr(6,2);
	    vFromHour = (vtempFromDate.substr(9,1) == 0)?vtempFromDate.substr(10,1):vtempFromDate.substr(9,2);
	    vEndHour = (vtempEndDate.substr(9,1) == 0)?vtempEndDate.substr(10,1):vtempEndDate.substr(9,2);
	}
	document.fmMain.txtDateFrom_display.value		= setDateTimeFormatToServerSetting(setDateTimeFormat(vFromDate).substr(0,10),vSvrDateFormat);
	document.fmMain.txtDateTo_display.value		= setDateTimeFormatToServerSetting(setDateTimeFormat(vEndDate).substr(0,10),vSvrDateFormat);
	vNowDate = document.fmMain.txtDateTo_display.value;
	document.getElementById("FromDateString").innerHTML = vSvrDateFormat.toLowerCase();
	document.getElementById("ToDateString").innerHTML = vSvrDateFormat.toLowerCase();
	document.fmMain.optHourFrom.options[vFromHour].selected = true;
	document.fmMain.optHourTo.options[vEndHour].selected = true;
	
	
	//jsServerRoleDependency("scan/Scheduledscan.htm");
	
	// Added for SMEX 8.5 CPU usage control feature.
	setOptionValueEx( document.fmMain.optScheduleScanMaxCpuUsage, STR_CPU_USAGE_DISPLAY, STR_CPU_USAGE_VALUE );
	document.fmMain.optScheduleScanMaxCpuUsage.selectedIndex = $$OPT_SCHEDULE_SCAN_MAX_CPU_USAGE$$ / 5 - 1;
	
	var timePeriodType ="$$TIME_PERIOD_TYPE$$";
    if(timePeriodType=="LastNDays")
    {
        document.getElementById("radioLastNDays").checked = true;
    }
    else
    {
        document.getElementById("radioFromToDate").checked = true;
    }
    
    var lastNDayUnitPart = $$LAST_N_DAY_UNIT_PART$$;
    document.fmMain.selectLastNDayUnitPart.selectedIndex = lastNDayUnitPart;
	jsUIDependency();	
}

function jsUIDependency(){
    //Set Schedule
    document.getElementById("SPWeek").style.display = (document.fmMain.optSchedule[1].checked)?"":"none" 
    document.getElementById("SPDays").style.display = (document.fmMain.optSchedule[2].checked)?"":"none" 
    
    //Select Database
    var fSelectAllDB = document.getElementById("rdoSelectAllDB").checked;
	var compObj = TmCube_getComponentByPrefix("Tree");
    if (fSelectAllDB)
    {
        TmCube_Tree_enableTree(compObj.name, false);
    
    }
    else
    {
        TmCube_Tree_enableTree(compObj.name, true);
        
    }
    //Incremental function  
	    //Incremental function  
	if (document.getElementById("chkModifyTime").checked)
	{
    	document.getElementById("radioLastNDays").disabled = false;    
    	document.getElementById("radioFromToDate").disabled = false;    
		if(document.getElementById("radioFromToDate").checked)
		{
			document.getElementById("txtDateFrom_display").disabled = false;
    		document.getElementById("txtDateFrom_display_img").disabled = false;
    		document.getElementById("txtDateFrom_display_img").style.cursor = "hand";
    		document.getElementById("optHourFrom").disabled = false;
    		document.getElementById("optMinFrom").disabled = false;    

    		document.getElementById("txtDateTo_display").disabled = false;
    		document.getElementById("txtDateTo_display_img").disabled = false;
   	 		document.getElementById("txtDateTo_display_img").style.cursor = "hand";
    		document.getElementById("optHourTo").disabled = false;
    		document.getElementById("optMinTo").disabled = false;		
 
    		document.getElementById("txtLastNDayNumberPart").disabled = true;
    		document.getElementById("selectLastNDayUnitPart").disabled = true; 

		}
		else
		{
			document.getElementById("txtDateFrom_display").disabled = true;
    		document.getElementById("txtDateFrom_display_img").disabled = true;
    		document.getElementById("txtDateFrom_display_img").style.cursor = "default";
    		document.getElementById("optHourFrom").disabled = true;
    		document.getElementById("optMinFrom").disabled = true;    

    		document.getElementById("txtDateTo_display").disabled = true;
    		document.getElementById("txtDateTo_display_img").disabled = true;
   	 		document.getElementById("txtDateTo_display_img").style.cursor = "default";
    		document.getElementById("optHourTo").disabled = true;
    		document.getElementById("optMinTo").disabled = true;		
 
    		document.getElementById("txtLastNDayNumberPart").disabled = false;
    		document.getElementById("selectLastNDayUnitPart").disabled = false; 
		}
		
	}
	else
	{
		document.getElementById("txtDateFrom_display").disabled = true;
    	document.getElementById("txtDateFrom_display_img").disabled = true;
    	document.getElementById("txtDateFrom_display_img").style.cursor = "default";
    	document.getElementById("optHourFrom").disabled = true;
    	document.getElementById("optMinFrom").disabled = true;    

    	document.getElementById("txtDateTo_display").disabled = true;
    	document.getElementById("txtDateTo_display_img").disabled = true;
   	 	document.getElementById("txtDateTo_display_img").style.cursor = "default";
    	document.getElementById("optHourTo").disabled = true;
    	document.getElementById("optMinTo").disabled = true;

        
    	document.getElementById("radioLastNDays").disabled = true;    
    	document.getElementById("radioFromToDate").disabled = true;    
    	document.getElementById("txtLastNDayNumberPart").disabled = true;
    	document.getElementById("selectLastNDayUnitPart").disabled = true; 
	} 
 
}
function jsCombineDateTime() {
	if (document.fmMain.txtDateFrom.value != "") {
		document.fmMain.txtDateFrom.value = setDateTimeFormat(document.fmMain.txtDateFrom.value).substr(0,10)
			+ " " + document.fmMain.optHourFrom.value
			+ ":" + document.fmMain.optMinFrom.value;
	}
	if (document.fmMain.txtDateTo.value !="") {
		document.fmMain.txtDateTo.value = setDateTimeFormat(document.fmMain.txtDateTo.value).substr(0,10)
			+ " " + document.fmMain.optHourTo.value
			+ ":" + document.fmMain.optMinTo.value;
	}
}



//Component: Tree
var XmlPath = "scan/XmlTree.htm";//jimmy
var TmCube_Tree = new Object();
TmCube_Tree.apData = "Scan/XmlTree.htm";
TmCube_Tree.idOnly = "true";
TmCube_Tree.name = "Tree";
TmCube_Tree.onload = window.TmCube_Tree_onload;
//Global variable definition
var TmCube_ERR_LOADXML_FAILED = "Xml document loading failed";

var TmCube_ERR_TREENODE_EMPTY = "Tree node is empty";
var TmCube_ERR_TREENODE_NOTVALID = "Tree node is not valid";
var TmCube_ERR_TREENODE_IDMISSED = "Tree node ID is missed";
var TmCube_ERR_TREENODE_NOTEXT = "Tree node has no text label";
var TmCube_ERR_TREENODE_NOBRANCH = "Tree node is not branch type";
var TmCube_ERR_CANNOTUSETUNNEL  = "Can not using tunnel in Non-CCGI environment.";
var TmCube_ERR_TREEPANEL_NOTFOUND = "Tree panel has been removed";
var TmCube_ERR_TREENODE_NOTFOUND ="Tree node can't be found";
var TmCube_ERR_TREE_NOTFOUND = "Tree can not be found";

var TmCube_Tree_BRANCHOPENED = "treeimages/openedFolder_cui.gif";
var TmCube_Tree_BRANCHCLOSED = "treeimages/closedFolder_cui.gif";
var TmCube_Tree_NOTBRANCH = "treeimages/ph9x9_cui.gif";
var TmCube_Tree_COLLAPSEDICON = "treeimages/collapsed_cui.gif";
var TmCube_Tree_EXPANDEDICON = "treeimages/expanded_cui.gif";
var TmCube_Tree_CHECKEDICON = "treeimages/checked_cui.gif";
var TmCube_Tree_NOTALLICON = "treeimages/notAllChecked_cui.gif";
var TmCube_Tree_UNCHECKEDICON = "treeimages/unChecked_cui.gif";
var TmCube_Tree_ARCHIVE = "treeimages/archive_cui.gif";
var TmCube_Tree_HOSTICON = "treeimages/host_cui.gif";
var TmCube_Tree_GROUPICON = "treeimages/group_cui.gif";
var TmCube_Tree_SITEICON = "treeimages/site_cui.gif";
var TmCube_Tree_WEBICON = "treeimages/web_cui.gif";

var TmCube_Tree_SELECTEDBGCOLOR = "#0b256b"; 
var TmCube_Tree_SELECTEDFONTCOLOR = "white";


//Function definition
/**
 * Enable tree or disable tree.
 * @param compName component name
 * @param flag true or false. If true the tree 
 */
function TmCube_Tree_enableTree(compName, flag)
{
	var compObj = TmCube_getComponentByPrefix(compName);
	if (compObj.disabled == flag)
	{
		compObj.disabled = !flag;
		var treepanel = TmCube_getElement(compObj.name, 'treepanel');
		TmCube_Tree_setNodeStatus(compObj, treepanel, flag);
		document.getElementById("site_path_keyword").disabled = !flag;
		document.getElementById("site_path_search_btn").disabled = !flag;
	}
}

/**
 *
 */
function TmCube_Tree_setDisable(compObj)
{
	var treepanel = TmCube_getElement(compObj.name, 'treepanel');
	if (treepanel)
	{
		treepanel.style.backgroundColor = "#808080";
	}
}

/**
 *
 */
function TmCube_Tree_setNodeStatus(compObj, node, flag)
{
	var children = node.childNodes;
	if (children && children.length > 0)
	{
		for (var i=0; i<children.length; i++)
		{
			TmCube_Tree_setNodeStatus(compObj, children[i], flag);
		}
	}
	/*if (/^iconbutton$|^iconlabel$/.test(node.className) && /^img$/i.test(node.tagName))
	{
		node.className = flag ? "iconbutton" : "iconlabel";
	}*/
	if (/^a$/i.test(node.tagName) && /_itemText$/.test(node.getAttribute("id")))
	{
		node.disabled = !flag;
		if (node.disabled)
		{
			node.style.color="gray";
		}
		else
		{
			node.style.color="black";
		}
	}
}
/**
 * Clear current tree, and re-get tree data from aphost by tunnel and re-draw it.
 * API function.
 * @param compName component name.
 * @param tunnelData the tunnel data
 * @return none  
 */
function TmCube_Tree_refreshTreeByTunnel(compName, tunnelData)
{
	var compObj = TmCube_getComponentByPrefix(compName);
	if (compObj)
	{
		TmCube_Tree_clearTree(compObj);
		compObj.apData = tunnelData;
		//var url = TmCube_Tree_getApTunnelURL(compObj.apData);
		var url = TmCube_Tree_getXMLURL(compObj.apData);
		TmCube_Tree_readXmlDoc(compObj, url);
	}
	else
	{
		throw TmCube_ERR_TREE_NOTFOUND;
	}
}

/**
 * Clear current tree, and re-get tree data from aphost by url and re-draw it.
 * API function.
 * @param compName component name.
 * @param url new url, can be normal url or ccgi url.
 * @return none  
 */
function TmCube_Tree_refreshTreeByURL(compName, url)
{
	var compObj = TmCube_getComponentByPrefix(compName);
	if (compObj && url)
	{
		TmCube_Tree_clearTree(compObj);
		compObj.xmlDocURL = TmCube_getNormalURL(url);
		TmCube_Tree_readXmlDoc(compObj, compObj.xmlDocURL);
	}
}

/**
 * Clear the tree, remove the xml doc content and html elements of tree view.
 * API function. Make sure the compObj is available.
 * @param compObj the component object
 * @return none.
 */
function TmCube_Tree_clearTree(compObj)
{
	compObj.xmlDoc = null;
	compObj.xmlDocURL = null;
	compObj.apData = null;
	compObj.selectedItem = "";

	var panel = TmCube_getElement(compObj.name, "treepanel");
	var children = panel.childNodes;
	for (var i=children.length-1; i>=0; i--)
	{
		panel.removeChild(children[i]);
	}
}

/**
 * Initial Tree control, 1) initial UI 2) Read the xml document.  Internal function.
 * @param compObj component object.
 * @return none.
 */
function TmCube_Tree_init(compObj)
{
   
	TmCube_Tree_initialUI(compObj);
	if (compObj.apData)
	{
		//var url = TmCube_Tree_getApTunnelURL(compObj.apData);
		var url = TmCube_Tree_getXMLURL();
		TmCube_Tree_readXmlDoc(compObj, url);
	}
	else	if (compObj.xmlDocURL)
	{
		compObj.xmlDocURL = TmCube_getNormalURL(compObj.xmlDocURL);
		TmCube_Tree_readXmlDoc(compObj, compObj.xmlDocURL);
	}
	else
	{
		var panel = TmCube_getElement(compObj.name, "treepanel");
		panel.innerHTML = "[Empty Tree]";
	}
}

/**
 * Generate result value and set the value to the treeresult element.
 * The function must be called before user submit the tree control
 * The function will return the selected item while compObj.needCheckStatus is false,
 * and return the xml doc while compObj.needCheckedStatus is true.
 * @param compName component name
 * @return The result value;
 * @throw TmCube_ERR_TREENODE_NOTEXT. If no text label found.
 */
function TmCube_Tree_getResult(compName)
{
	var result = "[Failure]";
	if (compName)
	{
		var compObj = TmCube_getComponentByPrefix(compName);
		var resultNode = TmCube_getElement(compObj.name, "treeresult");
		if (compObj && !compObj.needCheckStatus)
		{
			result = TmCube_Tree_getSelectedItem(compObj, resultNode);
		}
		else if (compObj)
		{
			if (/^true$/i.test(compObj.idOnly))
			{
				result = TmCube_Tree_saveIds(compObj, resultNode);
			}
			else
			{
				result = TmCube_Tree_saveXml(compObj, resultNode);
			}
		}
	}
	return result;
}

/**
 * Get tree current selected item. 
 * Also write to the result node.(hidden element of the tree)
 * Internal function. The function requires compObj available and  compObj.needCheckStatus is true.
 * @param compObj component object.
 * @param resultNode To which the result shouled be written
 * @return full path of the selected item according to tree.
 */
function TmCube_Tree_getSelectedItem(compObj, resultNode)
{
	var result = "";
	if (compObj.selectedItem)
	{
		var folderArray = new Array();
		var i=0;
		var item = compObj.selectedItem;
		var textNode = document.getElementById(item + "_itemText");
		while(textNode)
		{
			if (textNode)
			{
				folderArray[i++] = textNode.innerText;
			}
			else
			{
				throw TmCube_ERR_TREENODE_NOTEXT;
			}
			item = TmCube_Tree_getParentId(item);
			if (!item) break;
			textNode = document.getElementById(item + "_itemText");
		}
		var str = "";
		while(--i >= 0)
		{
			str += "/" + folderArray[i];
		}
		result = str;
	}
	else
	{
		result = "[No selection]";
	}
	if (resultNode)
	{
		resultNode.value = result;
	}
	return result;
}

/**
 * Save tree checked status to source xml doc. and then return the xml of xml doc. The value]
 *  also write to the result node.(hidden element of the tree)
 * Internal function. The function requires compObj available and  compObj.needCheckStatus is true.
 * @param compObj component object.
 * @param resultNode To which the result shouled be written
 * @return The xml doc string.
 */
function TmCube_Tree_saveXml(compObj, resultNode)
{
	var allNodes = compObj.xmlDoc.getElementsByTagName("*");
	for (var i=0; i<allNodes.length; i++)
	{
		if (/^branch$|^leaf$/.test(allNodes[i].tagName))
		{
			var id = allNodes[i].getAttribute("id");
			if (id)
			{
				var checkedNode = document.getElementById(compObj.name + "__" + id + "_checkedImg");
				if (checkedNode)
				{
					var checkedImg = checkedNode.getAttribute("src");
					if (checkedImg)
					{
						if (checkedImg.indexOf(TmCube_Tree_CHECKEDICON) != -1)
						{
							allNodes[i].setAttribute("checked", "true");
						}
						else if (checkedImg.indexOf(TmCube_Tree_NOTALLICON) != -1)
						{
							allNodes[i].setAttribute("checked", "part");
						}
						else
						{
							allNodes[i].setAttribute("checked", "false");
						}
					}
					else //need be removed
					{
						throw "No src";
					}
				}
				else //need be removed
				{
					throw "chechedNode not found";
				}
			}
			else //need be removed.
			{
				throw "No id found";
			}
		}
	}
	if (resultNode)
	{
		resultNode.value = compObj.xmlDoc.xml; //only for IE
	}
	return compObj.xmlDoc.xml;
}

/**
 * Generate a result string to record all the selected branch and leaf.
 * the result string will be saved to result node and be returned.
 * Internal function.
 * @param compObj component object.
 * @param resultNode To which the result shouled be written
 * @return the string of the result string.
 */
function TmCube_Tree_saveIds(compObj, resultNode)
{

	var root = compObj.xmlDoc.documentElement;
	var result = new Array();
	var virtualservers = root.childNodes;
	if (virtualservers.length == 0)
	{
		return;
	}
	var hosts = virtualservers[0].childNodes;
	for (var i=1; i<hosts.length; i++)//in order to ignore the root id:R{000000000xxxxxx}
	{
	    var host = hosts[i];
		var id = host.getAttribute("id");
		var checkedNode = document.getElementById(compObj.name + "__" + id + "_checkedImg");
		if (checkedNode)
		{
			var checkedImg = checkedNode.getAttribute("src");
			if (checkedImg)
			{
				if (checkedImg.indexOf(TmCube_Tree_CHECKEDICON) != -1) //checked status is checked
				{
					result[result.length] = id;
				}
				else if (checkedImg.indexOf(TmCube_Tree_NOTALLICON) != -1) //checked status is part
				{
				//jimmy_huang, when the node is part selected, the id also need be saved, but with 'P' padded.
				    result[result.length] = id+"P";
					if (/^branch$/.test(host.tagName)) //branch node
					{
						TmCube_Tree_traversalNode(compObj, host, result);
					}
					else
					{
						throw "Element 'leaf' should not be partly checked";
					}
				}
				// else {} //checked status is unchecked
			}
			else //need be removed
			{
				throw "No src";
			}
		}
	}
	//TmCube_Tree_traversalNode(compObj, root, result)
	var resultString = result.join(";");
	if (resultNode)
	{
		resultNode.value = resultString;  //only for IE
	}
	return resultString;
}

/**
 * Go through the tree and record the id of which checkedStatus is checked.
 * Internal function. throw exceptions. all parameters should be checked.
 * @param compObj component object
 * @param node the root node of the tree
 * @param result the result array 
 * @return none.
 */
function TmCube_Tree_traversalNode(compObj, node, result)
{
	var children = node.childNodes;
	for (var i=0; i<children.length; i++)
	{
		var child = children[i];
		if (1 == child.nodeType && /^branch$|^leaf$/.test(child.tagName))
		{
			var id = child.getAttribute("id");
			var checkedNode = document.getElementById(compObj.name + "__" + id + "_checkedImg");
			if (checkedNode)
			{
				var checkedImg = checkedNode.getAttribute("src");
				if (checkedImg)
				{
					if (checkedImg.indexOf(TmCube_Tree_CHECKEDICON) != -1) //checked status is checked
					{
						result[result.length] = id;
					}
					else if (checkedImg.indexOf(TmCube_Tree_NOTALLICON) != -1) //checked status is part
					{
					//jimmy_huang, when the node is part selected, the id also need be saved, but with 'P' padded.
					    result[result.length] = id+"P";
						if (/^branch$/.test(child.tagName)) //branch node
						{
							TmCube_Tree_traversalNode(compObj, child, result);
						}
						else
						{
							throw "Element 'leaf' should not be partly checked";
						}
					}
					// else {} //checked status is unchecked
				}
				else //need be removed
				{
					throw "No src";
				}
			}
		}
	}
}

/**
 * Initial Tree control view rectangle, set basic attributes. Internal function.
 * @param compObj component object.
 * @return none.
 */
function TmCube_Tree_initialUI(compObj)
{
	compObj.idOnly = /^true$/i.test(compObj.idOnly);
	var panel = TmCube_getElement(compObj.name, "treepanel");
	var children = panel.childNodes;
	for (var i=children.length-1; i>=0; i--)
	{//do not move "Please wait" before the XML was successfully loaded.
		//panel.removeChild(children[i]);
	}
	if (compObj.disabled)
	{
		compObj.disabled = true;
	}
	else
	{
		compObj.disabled = false;
	}
}

/**
 * Load tree xml document. Internal function. The function will invoke TmCube_Tree_xmlDocLoaded()
 * after xml document successfully loaded.
 * @param compObj component object.
 * @param url XML document url, can be a ccgi url
 * @return none.
 */
function TmCube_Tree_readXmlDoc(compObj, url)
{
	var browserType = TmCube_getBrowserType();
	if ("IE" == browserType)
	{
		compObj.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		//compObj.xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
		compObj.xmlDoc.async = false;
		var loadResult = compObj.xmlDoc.load(url);
		if (loadResult)
		{
			TmCube_Tree_xmlDocLoaded(compObj.name);
		}	
	}
	else if ("NS" == browserType)
	{
		var xmlhttp = new XMLHttpRequest();
        xmlhttp.open('GET', url);
        xmlhttp.setRequestHeader('Content-Type', 'text/xml');
		xmlhttp.onload=function(){
		    compObj.xmlDoc = xmlhttp.responseXML;
	        TmCube_Tree_xmlDocLoaded(compObj.name);
		}
        xmlhttp.send();
	}
}
 
/**
 * Event handler after document loaded. Internal function, 1) Draw the UI; 2)attach 
 * event handler to the UI elements.
 * @param compName component name.
 * @return none.
 */
function TmCube_Tree_xmlDocLoaded(compName)
{
	var panel = document.getElementById("Tree__treepanel");
	var children = panel.childNodes;
	panel.removeChild(children[0]);//remvoe "Please wait"
	var compObj = TmCube_getComponentByPrefix(compName);
	if (compObj.xmlDoc)
	{
		TmCube_Tree_drawTree(compObj);
		if (compObj.disabled)
		{
			compObj.disabled = false;
			TmCube_Tree_enableTree(compObj.name, false);
		}
		//TmCube_Tree_dumpTree(compObj);
	}
	else
	{
		throw TmCube_ERR_LOADXML_FAILED;
	}
}


/**
 * Draw UI of Tree control. Internal function. The funciotn required that
 * xml doc has been successfully loaded (compObj.xmlDoc != null)
 * @compObj component object
 * @return none;
 */
function TmCube_Tree_drawTree(compObj)
{
	var xmlDoc = compObj.xmlDoc;
	var panel = TmCube_getElement(compObj.name, "treepanel");
	if (!panel)
		throw TmCube_ERR_TREEPANEL_NOTFOUND;
	if (xmlDoc && xmlDoc.documentElement)
	{
		compObj.needCheckStatus = /^true$/i.test(xmlDoc.documentElement.getAttribute("needCheckStatus"));
		var children = xmlDoc.documentElement.childNodes;
		for (var i=0; i<children.length; i++)
		{
			if (1 == children[i].nodeType && "branch" == children[i].tagName)
			{
				TmCube_Tree_drawBranch(compObj, children[i], panel);
			}
		}
	}
	if (TmCube_getBrowserType() == "IE")
	{
		panel.innerHTML = panel.innerHTML;
	}
}

/**
 * Draw branch include its sub items. Internal function. Error handled by TmCube_Tree_validateNode call.
 * @param compObj component object.
 * @param node branch node needs to to be drawn
 * @param pane the parent div, which will contains the branch node and its sub items.
 * @return none.
 */
function TmCube_Tree_drawBranch(compObj, node, panel)
{
	TmCube_Tree_validateNode(node);
	TmCube_Tree_drawBranchItem(compObj, node, panel);
	TmCube_Tree_drawBranchSubItems(compObj, node, panel);
	{//auto load the subtree in order to show the select-state of sub directory
	    var id = compObj.name + "__" +  node.getAttribute("id");


        if (id.indexOf("R{")==-1 && compObj.needCheckStatus)
        {
	        var checked = document.getElementById(id + "_checkedImg");

	        var status = TmCube_Tree_resolveStatusImage(node.getAttribute("status")) || TmCube_Tree_COLLAPSEDICON;
	        var contentUrl = node.getAttribute("targetid");//jimmy,use targetid

	        if (status && checked &&contentUrl && checked.getAttribute("src").indexOf(TmCube_Tree_NOTALLICON) != -1 && id.indexOf("R{")==-1)
	        {
	       
                var statusIcon = document.getElementById(id + "_statusImg");
                TmCube_Tree_renderSubTree(statusIcon, id, contentUrl);
             
        	
	        }

        }
	}
	//After tree drawn, reset checked status for current branch node.
	if (compObj.needCheckStatus)
	{
		TmCube_Tree_adjustBranchChecked(compObj.name + "__" + node.getAttribute("id"));
	}
}

/**
 * Draw leaf node of tree control. Internal funciton. Error handled by TmCube_Tree_validateNode call.
 * @param compObj component object.
 * @param node leaf node needs to to be drawn
 * @param pane the parent div, which will contains the leaf node.
 * @return none.
 */
function TmCube_Tree_drawLeaf(compObj, node, panel)
{
	TmCube_Tree_validateNode(node);
	
	//Draw leaf item
	var id = compObj.name + "__" + node.getAttribute("id");
	var status = TmCube_Tree_NOTBRANCH;
	var checked = null;
	if (compObj.needCheckStatus)
	{
		checked = TmCube_Tree_resolveCheckedImage(node.getAttribute("checked")) || TmCube_Tree_UNCHECKEDICON;
	}
	var type = TmCube_Tree_resolveTypeImage(node.getAttribute("type")) || TmCube_Tree_ARCHIVE;
	var text = TmCube_Tree_getLabelText(node);
	var extend = TmCube_Tree_getExtendText(node);
	TmCube_Tree_drawItem(id, panel, status, checked, type, text, extend);
}

/**
 * Draw branch item. Internal function. The function required that node has been fully checked.
 * @param compObj component object.
 * @param node leaf node needs to to be drawn
 * @param pane the parent div, which will contains the branch node. 
 * @return none.
 */
function TmCube_Tree_drawBranchItem(compObj, node, panel)
{
  // debugger;
	var id = compObj.name + "__" +  node.getAttribute("id");
	var status = TmCube_Tree_resolveStatusImage(node.getAttribute("status")) || TmCube_Tree_COLLAPSEDICON;
	var contentUrl = node.getAttribute("targetid");//jimmy,use targetid
	if (contentUrl)
	{

		status = TmCube_Tree_COLLAPSEDICON;
	}
	else if (node.getAttribute("xmlDocURL"))
	{
		contentUrl = TmCube_getNormalURL(node.getAttribute("xmlDocURL"));
		status = TmCube_Tree_COLLAPSEDICON;
	}
	var checked = null;
	if (compObj.needCheckStatus)
	{
		//debugger;
        var gid= node.getAttribute("id");
        var parentId = compObj.name + "__" + node.parentNode.getAttribute("id");
        if (gid.indexOf("R{0000")!=-1)
        {
           checked =  TmCube_Tree_NOTALLICON; 
        }
        else if (parentId && gid.indexOf("R{0000")==-1)
        {
	        var parentNodeCheckedImgId = parentId+"_checkedImg";
	        var parentNodeCheckedImg = document.getElementById(parentNodeCheckedImgId);
	        var img = parentNodeCheckedImg.getAttribute("src");
	        if (parentNodeCheckedImg.getAttribute("src").indexOf(TmCube_Tree_CHECKEDICON)!=-1)
	        {
	            checked = TmCube_Tree_CHECKEDICON
	        }
	        else if (parentNodeCheckedImg.getAttribute("src").indexOf(TmCube_Tree_NOTALLICON)!=-1)
	        {
		        if (sGIDs.indexOf(gid)!=-1)
	            {

	                checked = TmCube_Tree_CHECKEDICON;
	            }
	            else if (sPartGIDs.indexOf(gid)!=-1)
	            {
	                checked = TmCube_Tree_NOTALLICON;
	            }	
	            else
	            {
	                checked = TmCube_Tree_UNCHECKEDICON;
	            }	    		
	        }
            else
            {
                checked = TmCube_Tree_UNCHECKEDICON;
            }		
        }

	}
	var type = TmCube_Tree_resolveTypeImage(node.getAttribute("type"), status) || TmCube_Tree_BRANCHOPENED;
	var text =  TmCube_Tree_getLabelText(node);
	var extend = TmCube_Tree_getExtendText(node);
	TmCube_Tree_drawItem(id, panel, status, checked, type, text, extend, contentUrl);
}

/**
 * Draw branch sub items. Internal function. It requires that the node has been fully checked.
 * @param compObj component object.
 * @param node leaf node needs to to be drawn
 * @param pane the parent div, which will contains the sub items. 
 * @return none.
 */
function TmCube_Tree_drawBranchSubItems(compObj, node, panel)
{
	var subpanel = document.createElement("div");
	subpanel.setAttribute("id", compObj.name + "__" + node.getAttribute("id") +"_subpanel");
	subpanel.setAttribute("class", "subitems");
	if (node.getAttribute("apData") || node.getAttribute("xmlDocURL"))
	{
		subpanel.style.display = "none";
		subpanel.innerHTML = "Please wait...";
	}
	else if ("expanded" ==node.getAttribute("status"))
	{
		subpanel.style.display = "block";
	}
	else
	{
		subpanel.style.display = "none";
	}
	panel.appendChild(subpanel);
	var children = node.childNodes;
	for (var i=0; i<children.length; i++)
	{
		if (1 == children[i].nodeType && "branch" == children[i].tagName)
		{
			TmCube_Tree_drawBranch(compObj, children[i], subpanel);
		}
		else if (1 == children[i].nodeType && "leaf" == children[i].tagName)
		{
			TmCube_Tree_drawLeaf(compObj, children[i], subpanel);
		}
	}
}

/**
 * Validate the branch or leaf node, If it is ok, do nothing. If testing failed, throw exceptions
 * @param node branch or leaf node.
 * @throw TmCube_ERR_TREENODE_EMPTY  If the node is empty.
 * @throw TmCube_ERR_TREENODE_NOTVALID If tree node is not valid (not a leaf or branch)
 * @throw TmCube_ERR_TREENODE_IDMISSED If tree node misses attribute id
 * @throw TmCube_ERR_TREENODE_NOTEXT If tree node has no text description.
 * @return none.
 */
function TmCube_Tree_validateNode(node)
{
	if (node)
	{
		if (1 == node.nodeType && /leaf|branch/.test(node.tagName))
		{
			if (node.getAttribute("id"))
			{
				if (!TmCube_Tree_getLabelText(node))
				{
					throw TmCube_ERR_TREENODE_NOTEXT;
				}
			}
			else
			{
				throw TmCube_ERR_TREENODE_IDMISSED;
			}
		}
		else
		{
			throw TmCube_ERR_TREENODE_NOTVALID;
		}
	}
	else
	{
		throw TmCube_ERR_TREENODE_EMPTY;
	}
}

/**
 * Retrieve branch or leaf label text (content BranchText or LeafText)
 * Internal function, the node must be Branch or Leaf node.
 * @param node a Branch or Leaf node.
 * @return Null if can not find text label.
 * @throw TmCube_ERR_TREENODE_NOTVALID if node isn't Branch or Leaf
 */
function TmCube_Tree_getLabelText(node)
{
	if (!/^leaf$|^branch$/.test(node.tagName))
	{
		throw TmCube_ERR_TREENODE_NOTVALID;
	}
	var textTagName = node.tagName + "Text";
	var textElems = node.getElementsByTagName(textTagName);
	if (textElems && textElems.length > 0)
	{
		var textElem = textElems[0];
		if (textElem && textElem.parentNode == node)
		{
			if (textElem.firstChild && 3 == textElem.firstChild.nodeType && textElem.firstChild.nodeValue)
			{
				return TmCube_trimString(textElem.firstChild.nodeValue);
			}
		}
	}
	return null;
}

/**
 * Retrieve branch or leaf label text (content BranchText or LeafText)
 * Internal function, the node must be Branch or Leaf node.
 * @param node a Branch or Leaf node.
 * @return Null if can not find text label.
 * @throw TmCube_ERR_TREENODE_NOTVALID if node isn't Branch or Leaf
 */
function TmCube_Tree_getExtendText(node)
{
	if (!/^leaf$|^branch$/.test(node.tagName))
	{
		throw TmCube_ERR_TREENODE_NOTVALID;
	}
	var textTagName = node.tagName + "Extend";
	var textElems = node.getElementsByTagName(textTagName);
	if (textElems && textElems.length > 0)
	{
		var textElem = textElems[0];
		if (textElem && textElem.parentNode == node)
		{
			if (textElem.firstChild && 3 == textElem.firstChild.nodeType && textElem.firstChild.nodeValue)
			{
				return TmCube_trimString(textElem.firstChild.nodeValue);
			}
		}
	}
	return null;
}

/**
 * Get appropriate type icon according to type. Internal function.
 * The function need be enhanced to support more type icon.
 * @param type icon type
 * @param status static icon which need be considered while type is empty.
 * @return type image file url.
 */
function TmCube_Tree_resolveTypeImage(type, status)
{
	if (type)
	{
		switch (type)
		{
		case "host":
			return TmCube_Tree_HOSTICON;
		case "group":
			return TmCube_Tree_GROUPICON;
		case "site":
			return TmCube_Tree_SITEICON;
		case "web":
			return TmCube_Tree_WEBICON;
		}
		return type;
	}
	if (status)
	{
		return ((TmCube_Tree_EXPANDEDICON == status) ? TmCube_Tree_BRANCHOPENED : TmCube_Tree_BRANCHCLOSED);
	}
	return TmCube_Tree_ARCHIVE;
}

/**
 * Get appropriate checked icon. Internal function.
 * @param checked come from attribute of branch or leaf. May be "true", "part", "false"
 * @return checked image file url.
 */
function TmCube_Tree_resolveCheckedImage(checked)
{
	switch (checked)
	{
	case "true" :
		return TmCube_Tree_CHECKEDICON;
	case "part" :
		return TmCube_Tree_NOTALLICON;
	case "false" :
	default :
		return TmCube_Tree_UNCHECKEDICON;
	}
}

/**
 * Get appropriate status icon. Internal function.
 * @param status come from attribute of branch or leaf. May be "collapsed", "expanded"or null
 * @return status image file url.
 */
function TmCube_Tree_resolveStatusImage(status)
{
	switch (status)
	{
	case "collapsed" :
		return TmCube_Tree_COLLAPSEDICON;
	case "expanded" :
		return TmCube_Tree_EXPANDEDICON;
	default :
		return null;
	}
}

/**
 * Context regardless drawing action. The caller must supply all needed
 * information. Internal function. 
 * @param id the id of the item
 * @param panel the parent pane (div)
 * @param status status icon
 * @param checked checked icon
 * @param type type icon
 * @param text text description of the item
 * @param extend extend description of the item
 * @param contentUrl url from which to generate the sub tree.
 * @return none.
 */
function TmCube_Tree_drawItem(id, panel, status, checked, type, text, extend, contentUrl)
{
    //alert(contentUrl);//jimmy
	var line = document.createElement("div");
	line.setAttribute("id", id);
	line.setAttribute("class", "line");
	panel.appendChild(line);
	line.style.whiteSpace = "nowrap";
	if (status)
	{
		var statusIcon = document.createElement("img");
		line.appendChild(statusIcon);
		statusIcon.setAttribute("src", (status));
		statusIcon.setAttribute("id", id + "_statusImg");
		if (status != TmCube_Tree_NOTBRANCH)
		{
			if (contentUrl)
			{
				statusIcon.setAttribute("onclick", "TmCube_Tree_renderSubTree(this, '" + id + "', '" + contentUrl + "')");

				statusIcon.setAttribute("class", "iconbutton");
			}
			else
			{
				statusIcon.setAttribute("onclick", "TmCube_Tree_toggleBranch(this, '" + id + "')");
				statusIcon.setAttribute("class", "iconbutton");
			}
		}
		TmCube_Tree_appendGap(line);
	}
	if (checked)
	{
		var checkedIcon = document.createElement("img");
		line.appendChild(checkedIcon);
		checkedIcon.setAttribute("src", (checked));
		checkedIcon.setAttribute("onclick", "TmCube_Tree_toggleChecked(this, '" + id + "')");
		checkedIcon.setAttribute("class", "iconbutton");
		checkedIcon.setAttribute("id", id + "_checkedImg");
		TmCube_Tree_appendGap(line);
	}
	if (type)
	{
		var typeIcon = document.createElement("img");
		line.appendChild(typeIcon);
		typeIcon.setAttribute("src", (type));
		typeIcon.setAttribute("id", id + "_typeImg");
		TmCube_Tree_appendGap(line);
	}
	if (text)
	{
		var nodeLabel = document.createElement("a");
		line.appendChild(nodeLabel);
		nodeLabel.setAttribute("id", id + "_itemText");
		nodeLabel.setAttribute("onclick", "TmCube_Tree_selectItem(this, '" + id + "')");
		nodeLabel.style.cursor = "hand";
		nodeLabel.style.padding = "2px 1px";
		if(type.indexOf("site") != -1 && site_url_keyword != "" && text.indexOf(site_url_keyword) != -1){
			TmCube_Tree_highlight_keyword(nodeLabel, text, site_url_keyword);
		}
		else{
			var textNode = document.createTextNode(text);
			nodeLabel.appendChild(textNode);
		}
		TmCube_Tree_appendGap(line);
	}
	if (extend)
	{
		var extendNode = document.createTextNode(extend);
		line.appendChild(extendNode);
		TmCube_Tree_appendGap(line);
	}

}

/**
 * Draw sub tree
 * Internal funciton.
 * @param elem the element for which the sub tree should be attached
 * @param id the id of item node (div)
 * @param contentUrl url from which to read the sub tree definition.
 * @return none.
 */
function TmCube_Tree_renderSubTree(elem, id, contentUrl)
{

    var url = TmCube_Tree_getXMLURL(contentUrl);
	var compObj = TmCube_getComponent(elem);
	if (!compObj || compObj.disabled)
	{
		return;
	}
	var browserType = TmCube_getBrowserType();
	var subpanel = document.getElementById(id + "_subpanel");
	if (subpanel)
	{
		subpanel.style.display = "block";
	}
	else
	{
		subpanel.style.display = "none";
	}
	if ("IE" == browserType)
	{
		compObj.tempDoc = new ActiveXObject("Microsoft.XMLDOM");
		compObj.tempDoc.async = false;
		var loadResult = compObj.tempDoc.load(url);
		if (loadResult)
		{
			TmCube_Tree_subTreeLoaded(compObj.name, id);
		}
		else
		{
			if (subpanel)
			{
				subpanel.style.display = "none";
			}
		}
	}
	else if ("NS" == browserType)
	{
		var xmlhttp = new XMLHttpRequest();
        xmlhttp.open('GET', url);
        xmlhttp.setRequestHeader('Content-Type', 'text/xml');
		xmlhttp.onload=function(){
		    compObj.tempDoc = xmlhttp.responseXML;
	        TmCube_Tree_subTreeLoaded(compObj.name,id);
		}
        xmlhttp.send();
	}
}


/**
 * Event handler after extended document loaded. Internal function. 
 * event handler to the UI elements.
 * @param compName component name.
 * @param id id of the node for which the extended doc should be appended.
 * @throw TmCube_ERR_LOADXML_FAILED if tempDoc
 * @return none.
 */
function TmCube_Tree_subTreeLoaded(compName, id)
{
	var compObj = TmCube_getComponentByPrefix(compName);
	if (compObj.tempDoc)
	{
		TmCube_Tree_mergeTree(compObj, id);
		TmCube_Tree_drawSubTree(compObj, id);
		var elem = document.getElementById(id + "_statusImg");
		TmCube_Tree_toggleBranch(elem, id);
		//TmCube_Tree_dumpTree(compObj);
		delete compObj.tempDoc;
		elem.setAttribute("onclick", "TmCube_Tree_toggleBranch(this, '" + id + "')");
		if (TmCube_getBrowserType() == "IE")
		{
			elem.parentNode.innerHTML = elem.parentNode.innerHTML;
		}
	}
	else
	{
		throw TmCube_ERR_LOADXML_FAILED;
	}
}

/**
 *  Merge extended xml to original xml.
 * Internal function
 * @param compObj component object
 * @param id for which the extended xml should be add.
 * @throw TmCube_ERR_TREENODE_IDMISSED if 
 */
function TmCube_Tree_mergeTree(compObj, id)
{
	if (compObj.xmlDoc && compObj.tempDoc && compObj.tempDoc.documentElement)
	{
		var root = compObj.tempDoc.documentElement;
		var children = root.childNodes;
		var nodeId;
        var index = id.indexOf("__");
        if (index != -1)
        {
            nodeId = id.slice(index + 2);
        }
		else
		{
			throw TmCube_ERR_TREENODE_IDMISSED;
		}

		var parentNode =  TmCube_Tree_getElementById(compObj.xmlDoc, "branch", nodeId);
		if (!parentNode)
		{
			throw TmCube_ERR_TREENODE_NOTFOUND;
		}
		for (var i=0; i<children.length; i++)
		{
			if (1 == children[i].nodeType)
			{
				var tempNode = children[i].cloneNode(true);
				parentNode.appendChild(tempNode);
			}
		}
	}
	else
	{
		throw TmCube_ERR_TREENODE_NOTVALID;
	}
}

/**
 * Draw extented branch.
 * Internal function
 * @param compObj component object
 * @param id id of div node contains the branch or leaf item
 */
function TmCube_Tree_drawSubTree(compObj, id)
{
	var nodeId;
	var index = id.indexOf("__");
	if (index != -1)
	{
		nodeId = id.slice(index + 2);
	}
	else
	{
		throw TmCube_ERR_TREENODE_IDMISSED;
	}
	var node = TmCube_Tree_getElementById(compObj.xmlDoc, "branch", nodeId);
	if (node)
	{
		var subpanel = document.getElementById(id + "_subpanel");
		if (!subpanel)
		{
			throw TmCube_ERR_TREEPANEL_NOTFOUND;
		}
		subpanel.innerHTML = "";
		var children = node.childNodes;
		for (var i=0; i<children.length; i++)
		{
			if (1 == children[i].nodeType && "branch" == children[i].tagName)
			{
				var cid = children[i].getAttribute("id");
				if(TmCube_Tree_getLabelText(children[i]).indexOf(site_url_keyword) != -1 ||
				   children[i].getAttribute("type") != "site" || sGIDs.indexOf(cid) != -1 ||
				   TmCube_Tree_checked_status(id) == TmCube_Tree_CHECKEDICON){
					TmCube_Tree_drawBranch(compObj, children[i], subpanel);
				}
			}
			else if (1 == children[i].nodeType && "leaf" == children[i].tagName)
			{
				TmCube_Tree_drawLeaf(compObj, children[i], subpanel);
			}
		}
		if (TmCube_getBrowserType() == "IE")
		{
			subpanel.innerHTML = subpanel.innerHTML;
		}
		if (subpanel.innerHTML == "")
		{
			subpanel.style.display = "none";
		}
	}
	else //Node not found
	{
		throw TmCube_ERR_TREENODE_NOTFOUND;
	}
}

/**
 * Get xml node by specfying id
 * Internal function
 * @param doc xml document dom
 * @param tagName tag name
 * @param id specified id 
 * @return the found element, or null if not find.
 */
function TmCube_Tree_getElementById(doc, tagName, id)
{
	var node = null;
	if (TmCube_getBrowserType() == "IE")
	{
	  node = doc.selectSingleNode("//" + tagName + "[@id=\"" + id + "\"]"); 
	}
	else if (TmCube_getBrowserType() == "NS")
	{
	  var nodes = doc.getElementsByTagName(tagName); 
	  if (nodes && nodes.length>0 )
	  {
	  	for (var i=0; i<nodes.length; i++)
		{
		  if (nodes[i].getAttribute("id") == id)
		  {
		  	node = nodes[i];
			break;
		  }
		}
	  }
	}
	return node;	
}

/**
 * Toggle collapsed and expanded status of branch. Event handler function. It's
 * hook at status image if the item is branch type.
 * @param thisNode this image node which hooks the function.
 * @param id the id of item node (div)
 * @return none.
 */
function TmCube_Tree_toggleBranch(thisNode, id)
{
	var currentImg = thisNode.getAttribute("src");
	var compObj = TmCube_getComponent(thisNode);
	if (!compObj || compObj.disabled)
	{
		return;
	}
	if (-1 != currentImg.indexOf(TmCube_Tree_COLLAPSEDICON))
	{
		var subPanel = document.getElementById(id + "_subpanel");
		if (TmCube_trimString(subPanel.innerHTML))
		{
			subPanel.style.display = "block";
		}
		thisNode.setAttribute("src", (TmCube_Tree_EXPANDEDICON));
		var typeImg = document.getElementById(id + "_typeImg");
		if (-1 != typeImg.getAttribute("src").indexOf(TmCube_Tree_BRANCHCLOSED))
		{
			typeImg.setAttribute("src", (TmCube_Tree_BRANCHOPENED));
		}
	}
	else
	{
		var subPanel = document.getElementById(id + "_subpanel");
		if (TmCube_trimString(subPanel.innerHTML))
		{
			subPanel.style.display = "none";
		}
		thisNode.setAttribute("src", (TmCube_Tree_COLLAPSEDICON));
		var typeImg = document.getElementById(id + "_typeImg");
		if (-1 != typeImg.getAttribute("src").indexOf(TmCube_Tree_BRANCHOPENED))
		{
			typeImg.setAttribute("src", (TmCube_Tree_BRANCHCLOSED));
		}
	}
}

/**
 * Toggle checked status of item. Event handler function.
 * The function will be called while user click checked icon.
 * @param thisNode this image node which hooks the function.
 * @param id the id of item node (div)
 * @return none.
 */
function TmCube_Tree_toggleChecked(thisNode, id)
{
	var currentImg = thisNode.getAttribute("src");
	var compObj = TmCube_getComponent(thisNode);
	if (!compObj || compObj.disabled)
	{
		return;
	}
	if (-1 != currentImg.indexOf(TmCube_Tree_CHECKEDICON))
	{
		thisNode.setAttribute("src", (TmCube_Tree_UNCHECKEDICON));
		TmCube_Tree_notifyChildNodes(id, TmCube_Tree_UNCHECKEDICON);
		TmCube_Tree_notifyParentNode(id);
	}
	else if (-1 != currentImg.indexOf(TmCube_Tree_UNCHECKEDICON))
	{
		thisNode.setAttribute("src", (TmCube_Tree_CHECKEDICON));
		TmCube_Tree_notifyChildNodes(id, TmCube_Tree_CHECKEDICON);
		if(id.indexOf("}V")!=-1 || id.indexOf("R{")!=-1){
			TmCube_Tree_adjustBranchChecked(id);
		}
		TmCube_Tree_notifyParentNode(id);
	}
	else
	{
		status = TmCube_Tree_CHECKEDICON;
		if(id.indexOf("}V")!=-1 || id.indexOf("R{")!=-1){
			if(TmCube_Tree_all_site_checked(id)){
				status = TmCube_Tree_UNCHECKEDICON;
			}
		}
		thisNode.setAttribute("src", (status));
		TmCube_Tree_notifyChildNodes(id, status);
		if(id.indexOf("}V")!=-1 || id.indexOf("R{")!=-1){
			TmCube_Tree_adjustBranchChecked(id);
		}
		TmCube_Tree_notifyParentNode(id);
	}
}

/**
 * Notify parent node to adjust the checed status. Internal function
 * @param id id of current item 
 * @return none.
 */
function TmCube_Tree_notifyParentNode(id)
{

	var  parentId = TmCube_Tree_getParentId(id);
	if (parentId)
	{
		var checkedNode = document.getElementById(parentId + "_checkedImg");
		var subPanelNode = document.getElementById(parentId + "_subpanel");
		if (checkedNode && subPanelNode)
		{
			var img = TmCube_Tree_calcChildrenChecked(subPanelNode);
			if (img && -1 == checkedNode.getAttribute("src").indexOf(img))
			{
				checkedNode.setAttribute("src", (img));
				TmCube_Tree_notifyParentNode(parentId);
			}
		}
		else
		{
			//Need error handling ?
		}
	}
}

/**
 * Notify child nodes to adjust the checked status. Internal function
 * @param id id of current item 
 * @param chechedImg The image of current item. It also can be use to determine current checked status.
 * @return none.
 */
function TmCube_Tree_notifyChildNodes(id, checkedImg)
{
	var subPanelNode = document.getElementById(id + "_subpanel");
	if (subPanelNode)
	{
		var children = subPanelNode.childNodes;
		for (var i=0; i<children.length; i++)
		{
			if (1 == children[i].nodeType && /^div$/i.test(children[i].tagName))
			{
				var childId = children[i].getAttribute("id");
				var childImg = document.getElementById(childId + "_checkedImg");
				if (childImg)
				{
					childImg.setAttribute("src", (checkedImg));
					/*Because the child's sub panel also contains in the div, so this calling is not very efficient.
					  Need to be tuned in futrue.*/
					TmCube_Tree_notifyChildNodes(childId, checkedImg);
					if(childId.indexOf("}V")!=-1){
						TmCube_Tree_adjustBranchChecked(childId);
					}
				}
			}
		}
	}
}

/**
 * Select current node and change its checked status. Event handler function.
 * The fucntion will perform while user click the tree item.
 * @param thisNode this image node which hooks the function.
 * @param id the id of item node (div)
 * @return none.
 */
function TmCube_Tree_selectItem(thisNode, id)
{
	var compObj = TmCube_getComponent(thisNode);
	if (!compObj || compObj.disabled)
	{
		return;
	}
	if (compObj.selectedItem && id != compObj.selectedItem)
	{
		var selected = document.getElementById(compObj.selectedItem + "_itemText");
		selected.style.backgroundColor  = ""; 
		selected.style.color = ""; 
	}
	if (!compObj.selectedItem || id != compObj.selectedItem)
	{
		compObj.selectedItem = id;
		var selected = document.getElementById(compObj.selectedItem + "_itemText");
		selected.style.backgroundColor = TmCube_Tree_SELECTEDBGCOLOR;
		selected.style.color = TmCube_Tree_SELECTEDFONTCOLOR;
		if (compObj.selectionChanged)
		{
			compObj.selectionChanged(compObj.name);
		}
	}
	var checkedImg = document.getElementById(compObj.selectedItem + "_checkedImg");
	if (checkedImg)
	{
		TmCube_Tree_toggleChecked(checkedImg, id);
	}
}

/**
 * Select current node and expand or collapse the branch
 * The fucntion will perform while user double click the tree item.
 * @param thisNode this image node which hooks the function.
 * @param id the id of item node (div)
 * @return none.
 */
function TmCube_Tree_selectAndToggleBranch(thisNode, id)
{
	var compObj = TmCube_getComponent(thisNode);
	TmCube_Tree_selectItem(thisNode, id);
	if (compObj.selectedItem && id != compObj.selectedItem)
	{
		var selected = document.getElementById(compObj.selectedItem + "_itemText");
		selected.style.backgroundColor  = ""; 
		selected.style.color = ""; 
	}
	if (!compObj.selectedItem || id != compObj.selectedItem)
	{
		compObj.selectedItem = id;
		var selected = document.getElementById(compObj.selectedItem + "_itemText");
		selected.style.backgroundColor = TmCube_Tree_SELECTEDBGCOLOR;
		selected.style.color = TmCube_Tree_SELECTEDFONTCOLOR;
	}
	var subPanel = document.getElementById(id + "_subpanel");
	if (subPanel)
	{
		var statusImg = document.getElementById(id + "_statusImg");
		if (statusImg)
		{
			TmCube_Tree_toggleBranch(statusImg, id);
		}
	}
}

/**
 * Calculate checked status from its sub item.  Internal function
 * @paran subPanel panel to contains sub items.
 * @return The checked image appropriate to current branch.
 */
function TmCube_Tree_calcChildrenChecked(subPanel)
{
	var lastStatus = TmCube_Tree_calcChildrenChecked_view(subPanel);
    var subp_id = subPanel.getAttribute("id");
	if( lastStatus == null ){
        var id = subp_id.slice(0,subp_id.indexOf("_subpanel")).substring(6);
	    var xmlroot = TmCube_Tree_get_root();
	    var node = TmCube_Tree_get_node_by_id(xmlroot, id);
        if(node.childNodes.length>1)
	       lastStatus = TmCube_Tree_UNCHECKEDICON;
	}
	if(lastStatus == TmCube_Tree_CHECKEDICON && subp_id.indexOf("}V") != -1){
		if(!TmCube_Tree_all_sub_showed(subPanel)){
			lastStatus = TmCube_Tree_NOTALLICON;
		}
	}
	return lastStatus;
}

/**
 * Reset branch checked status. internal function.
 * This function must be called after sub items has been drawn, and current
 * tree nees checked status.
 * @param node the branch node
 * @return none.
 * @throw TmCube_ERR_TREENODE_NOBRANCH if node is not a branch
 */
function TmCube_Tree_adjustBranchChecked(id)
{
	var checkedNode = document.getElementById(id + "_checkedImg");
	var subPanelNode = document.getElementById(id + "_subpanel");
	if (checkedNode && subPanelNode )
	{
		var img = TmCube_Tree_calcChildrenChecked(subPanelNode);
		if (img)
		{
			checkedNode.setAttribute("src", (img));
		}
	}
	else
	{
		throw TmCube_ERR_TREENODE_NOBRANCH;
	}
}

/**
 * Get parent branch node id. Internal function
 * @param id id of current item
 * @return parent branch id. Null indicates current id has no parent branch.
 */
function TmCube_Tree_getParentId(id)
{
	var node = document.getElementById(id);
	var prefix = id.slice(0, id.indexOf("__"));

	if (node.parentNode && 	1 == node.parentNode.nodeType && /^div$/i.test(node.parentNode.tagName))
	{
		var parentId = node.parentNode.getAttribute("id");
		if (parentId && parentId.slice(0, parentId.indexOf("__")) == prefix && /_subpanel$/.test(parentId) )
		{
			return parentId.slice(0, parentId.indexOf("_subpanel"));
		}
	}
	return null;
}

/**
 * Add a white space to the html node. Internal function.
 * @param node the node will be appended a space.
 * @return none.
 */ 
function TmCube_Tree_appendGap(node)
{
	node.appendChild(document.createTextNode(" "));
}

/**
 * Convert data to ap tunnel url. Internal function.
 * @param data tunnel data
 * @return CCGI url that environment  relatived.
 * @throw TmCube_ERR_CANNOTUSETUNNEL if current environment is non-CCGI.
 */
function TmCube_Tree_getApTunnelURL(data)
{
    if (!TmCube_Href)
    {
	    TmCube_Href = new TmCube_HrefObject(window.location);
    }
	if (TmCube_Href.type == ".") 
	{
		throw TmCube_ERR_CANNOTUSETUNNEL;
	}
	return TmCube_Href.href.slice(0, TmCube_Href.startPos) + TmCube_Href.getParamList() + data;
}

/**
*targetid:like as {xxxx}s,1,0;{xxxx}d,1,0
*return the url that represent the XML of the virtual server, site, or directory.
**/
function TmCube_Tree_getXMLURL(targetid)
{
	var id=targetid;
	var loca=window.location.toString();
	var index = loca.lastIndexOf("?");
	if (id==undefined)
	{
		id="";
	}
	var url=loca.substr(0,index)+"?Page="+XmlPath+"&TargetID="+id;//+"&PreDbSel="+sGIDs;//use PreDbSel to present the DbSelection of last time(for both manual scan and schedule scan)
	return url;
}

/**
 * Call back function on loading time.
 * While loading failed, show error message to explain the cause.
 * No parameters and no return value
 */
function TmCube_Tree_onload()
{
	try
	{
		TmCube_Tree_init(this);
	}
	catch (exp)
	{
		alert(exp);
	}
}


function TmCube_Tree_all_site_checked(id){
	var id = id.substring(6);
	var xmlroot = TmCube_Tree_get_root();
	var node = TmCube_Tree_get_node_by_id(xmlroot, id);
	var ret = true;
	if(node){
		TmCube_Tree_iter_node(node,
							 function(node){
			if(node.getAttribute("type") == "site"){
				var img_id = "Tree__"+node.getAttribute("id")+"_checkedImg";
				var image = document.getElementById(img_id);
				if(image){
					var status = image.getAttribute("src");
					if(status && status != TmCube_Tree_CHECKEDICON){
						ret = false;
						return true;
					}
				}
			}
			return false;
		},
							 function(node){
			if(node.getAttribute("type") == "site")
				return false;
			else
				return true;
		})
		return ret;
	}
	else{
		return false;
	}
}

function TmCube_Tree_get_root() {
	var compObj = TmCube_getComponentByPrefix("Tree");
	xmlDoc = compObj.xmlDoc;
	if (xmlDoc && xmlDoc.documentElement){
		return xmlDoc.documentElement;
	}
	else{
		return null;
	}
}

function TmCube_Tree_calcChildrenChecked_view(subPanel)
{
	var children = subPanel.childNodes;
	var lastStatus = null;
	for (var i=0; i<children.length; i++)
	{
		if (1 == children[i].nodeType && /^div$/i.test(children[i].tagName))
		{
			var id = children[i].getAttribute("id");
			var checkedImg = document.getElementById(id + "_checkedImg");
			if (checkedImg)
			{
				var imgSrc = checkedImg.getAttribute("src");
				if (imgSrc)
				{
					if (-1 != imgSrc.indexOf(TmCube_Tree_NOTALLICON))
					{
						return TmCube_Tree_NOTALLICON;
					}
					if (!lastStatus)
					{
						lastStatus =  (-1 != imgSrc.indexOf(TmCube_Tree_CHECKEDICON))? TmCube_Tree_CHECKEDICON : TmCube_Tree_UNCHECKEDICON;
					}
					else if (-1 == imgSrc.indexOf(lastStatus))
					{
						return TmCube_Tree_NOTALLICON;
					}
				}
			}
		}
	}
	return lastStatus;
}

function TmCube_Tree_all_sub_showed(subpanel){
	var subp_id = subpanel.getAttribute("id");
	var pos = subp_id.indexOf("_subpanel");
	var parentid = subp_id;
	if(pos != -1){
		parentid = subp_id.substring(6,pos);
	}
	else{
		parentid = subp_id.substring(6);
	}
	var xmlroot = TmCube_Tree_get_root();
	if (xmlroot)
	{
		var node = TmCube_Tree_get_node_by_id(xmlroot, parentid);
		if(node && node.childNodes.length-1 > subpanel.childNodes.length/2){
			return false;
		}
	}
	return true;
}

function TmCube_Tree_get_node_by_id(node, id){
	var ret = null;
	TmCube_Tree_iter_node(node,
						 function(node){
		if(node.getAttribute("id") == id){
			ret = node;
			return true;
		}
	})
	return ret;
}

function TmCube_Tree_filter_sites() {
	site_url_keyword = document.getElementById('site_path_keyword').value;
	var compObj = TmCube_getComponentByPrefix("Tree");
	var xmlroot = TmCube_Tree_get_root();
	if (xmlroot)
	{
	//expanding
		TmCube_Tree_expanding_virtualserver(compObj,xmlroot);
	//filter site
		TmCube_Tree_filter_nodes(compObj, xmlroot, site_url_keyword);
	}
}

function TmCube_Tree_expanding_virtualserver(compObj, root){
	TmCube_Tree_iter_node(root,
						 function(node){
							var id = node.getAttribute("id");
							var st_id = compObj.name + "__" + id + "_statusImg";
							var st_img = document.getElementById(st_id);
							if(st_img){
								if(st_img.getAttribute("src")==TmCube_Tree_COLLAPSEDICON){
									st_img.onclick();
								}
							}
							return false;
						 },
						 function(node){
							if(node.getAttribute("type") == "host")
								return false;
							else{
								return true;
							}
						 });
}

function TmCube_Tree_iter_node(node, func, check){
	//alert(new XMLSerializer().serializeToString(node))
	var children = node.childNodes;
	for (var i=0; i<children.length; i++)
	{
		if (1 == children[i].nodeType && "branch" == children[i].tagName)
		{
			var ret = func(children[i]);
			if(ret){
				return ret;
			}
			if(check == null || check(children[i])){
				ret = TmCube_Tree_iter_node(children[i], func, check);
				if(ret){
					return ret;
				}
			}
		}
	}
	return false;
}

function TmCube_Tree_checked_status(id){
	var img_id = id+"_checkedImg";
	image = document.getElementById(img_id);
	if(image){
	    image_src = image.getAttribute("src");
		if(image_src){
			return image_src;
		}
	}
	return TmCube_Tree_UNCHECKEDICON;
}

function TmCube_Tree_filter_nodes(compObj, node, filter_str){
	TmCube_Tree_iter_node(node,
						 function(node){
		if(node.getAttribute("type") == "site"){
			var text = TmCube_Tree_getLabelText(node);
			if(text.indexOf(filter_str) == -1 && TmCube_Tree_checked_status(compObj.name+"__"+node.getAttribute("id")) == TmCube_Tree_UNCHECKEDICON){
				var id = compObj.name+"__"+node.getAttribute("id");
				var removed_div = document.getElementById(id);
				if(removed_div != null){
					removed_div.parentNode.removeChild(removed_div);
				}
				var sub_id = compObj.name + "__"+node.getAttribute("id") + "_subpanel";
				var removed_sub_div = document.getElementById(sub_id);
				if(removed_sub_div != null){
					removed_sub_div.parentNode.removeChild(removed_sub_div);
				}
			}
			else{
				var id = compObj.name + "__"+node.getAttribute("id");
				var add_div = document.getElementById(id);
				if(add_div == null){
					parent_subpanel_id = compObj.name + "__" + node.parentNode.getAttribute("id") + "_subpanel";
					subpanel = document.getElementById(parent_subpanel_id);
					TmCube_Tree_drawBranch(compObj, node, subpanel);
					if (subpanel.style.display = "none")
		            {
		            	subpanel.style.display = "block";
		            }
				}
				else{
					//exist
					var textId = compObj.name+"__"+node.getAttribute("id")+"_itemText";
					var textEle = document.getElementById(textId);
					textEle.innerHTML = ""
					if(text != "" && text.indexOf(filter_str) != -1){
						TmCube_Tree_highlight_keyword(textEle, text, filter_str);
					}
					else{
						var textNode = document.createTextNode(text);
						textEle.appendChild(textNode);
					}
				}
			}
			return false;
		}
	},
						 function(node){
		if(node.getAttribute("type") == "site") return false;
		else return true;
	});
}

function TmCube_Tree_highlight_keyword(docNode, text, keyword){
	var pos = text.indexOf(keyword);
	var highlight_font = document.createElement("font");
	highlight_font.style.backgroundColor = "yellow";
	var keword_node = document.createTextNode(keyword);
	highlight_font.appendChild(keword_node);
	docNode.appendChild(document.createTextNode(text.substring(0,pos)));
	docNode.appendChild(highlight_font);
	docNode.appendChild(document.createTextNode(text.substring(pos+site_url_keyword.length)))
}

// For WTP check
function jsWTPCheck(srcObj)
{
	var chkCF = document.getElementById("chkWTP");
    var chkCFDoc = document.getElementById("chkWebReputationDoc");
    var chkCFWeb = document.getElementById("chkWebReputationWeb");
    
    if (srcObj.id == "chkWTP")
    {
        chkCFDoc.checked = srcObj.checked;
        chkCFWeb.checked = srcObj.checked;
    }
    else
    {
        chkCF.checked = chkCFWeb.checked || chkCFDoc.checked;
    }
}
function jsCFCheck(srcObj)
{
    
    var chkCF = document.getElementById("chkContentFilter");
    var chkCFDoc = document.getElementById("chkContentFilterDoc");
    var chkCFWeb = document.getElementById("chkContentFilterWeb");
    
    if (srcObj.id == "chkContentFilter")
    {
        chkCFDoc.checked = srcObj.checked;
        chkCFWeb.checked = srcObj.checked;
    }
    else
    {
        chkCF.checked = chkCFWeb.checked || chkCFDoc.checked;
    }
}
function jsDLPCheck(srcObj)
{
    
    var chkDLP = document.getElementById("chkDLPFilter");
    var chkDLPDoc = document.getElementById("chkDLPDoc");
    var chkDLPWeb = document.getElementById("chkDLPWeb");
    
    if (srcObj.id == "chkDLPFilter")
    {
        chkDLPDoc.checked = srcObj.checked;
        chkDLPWeb.checked = srcObj.checked;
    }
    else
    {
        chkDLP.checked = chkDLPWeb.checked || chkDLPDoc.checked;
    }
}
//-->
</script>
<style id="CompCSS" type="text/css">
.tabbedPane
{
 position : relative;
 padding : 10px;
 border : 1px solid #666666;
}


/* Compnent : Tree */

div.line
{
	height : 18px;
	FONT-SIZE: 10px;
	FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif";
	word-wrap: normal;
	white-space : nowrap;
}

div.subitems
{
    margin-left: 16px;
	FONT-SIZE: 10px;
	FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif";
}

div.root
{
	overflow : auto;
	border : 1px solid;
	padding:2px;
}

.iconbutton
{
	cursor : hand;
}


</style>
</head>
<body onLoad="jsInitPage();" onclick="checkPageStatus(event);">
<form id="fmMain" name="fmMain" action="$$FORM_ACTION$$" method=post>
<!--Hidden Field-->
<input type="hidden" id="FormAction" name="FormAction" value=""/>
<input type="hidden" id="ScheduleScanRedirect" name="ScheduleScanRedirect" value=""/>
<input type="hidden" id="AddTaskButton" name="AddTaskButton" value=""/>
<input type="hidden" id="DbSelectionData" name="DbSelectionData" value=""/>
<input type="hidden" id="DbSelectionSelectAll" name="DbSelectionSelectAll" value="$$DB_SELECTION_SELECT_ALL$$"/>
<input type="hidden" id="TaskId" name="TaskId" value="$$SCAN_TASK_ID_VALUE$$"/>
<input type="hidden" id="Behavior" name="Behavior" value=""/>
<input type="hidden" id="txtDateFrom" name="txtDateFrom" value="$$LOWER_DELIVERY_TIME_LIMIT$$" />
<input type="hidden" id="txtDateTo" name="txtDateTo" value="$$UPPER_DELIVERY_TIME_LIMIT$$" />
<input type="hidden" id="txtTaskName" name="txtTaskName" value="$$SS_TASK_NAME$$" />
<!--/Hidden Field-->

<!--Page Title-->
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr><td class="content-title">Scheduled Scan : <font id="labTitleAction"></font>&nbsp;Scan Task</td>
	<td align="right" valign="bottom">		
		<a href="javascript:jsMapOnlineHelp('scan\Scheduledscan.htm');" class="moretestblue">
		<img src="images/question.gif" border="0" 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" cellspacing="0" cellpadding="0">
<!--Page Description--><!--/Page Description-->
<!--Page Content-->
<tr><td><table border="0" cellpadding="0" cellspacing="0" style="padding-top:2;padding-bottom:2;">
		<!--||Global Setting||-->
		<tr><td width="120"><b>Scan task name:</b></td>
			<td><input type=text class="text" id="txtScanTask" name="ScanTaskName" style="width:150" value="$$SCAN_TASK_NAME_VALUE$$"/></td></tr>
		</table></td></tr>
<tr height="10"><td></td></tr>
<tr><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
		<!--||Scheduling||-->
		<tr><td class="tableheadergreyS" colspan="2">Schedule</td></tr>
		<tr><td colspan="2" height="3"></td></tr>
		<tr><td colspan="2">
		    <table border="0" cellpadding="0" cellspacing="0">
		        <tr>
		            <td class="data1" width="85" valign="top">Scan every:</td>
		            <td width="120"><table border="0" cellpadding="0" cellspacing="0" width="100%">
		                <tr><td width="20"><input type=radio id="optSchedule" name="$$OPT_SCHEDULED_FREQ1$$" onClick="jsUIDependency();" value="$$OPT_SCHEDULED_FREQ_VALUE1$$" $$OPT_SCHEDULED_FREQ_VALUE1_CHECKED$$></td>
		                    <td class="data1" nowrap>Daily</td></tr>
		                <tr><td width="20"><input type=radio id="optSchedule" name="$$OPT_SCHEDULED_FREQ2$$" onClick="jsUIDependency();" value="$$OPT_SCHEDULED_FREQ_VALUE2$$" $$OPT_SCHEDULED_FREQ_VALUE2_CHECKED$$></td>
		                    <td class="data1" nowrap>Weekly, every</td></tr>
		                <tr><td width="20"><input type=radio id="optSchedule" name="$$OPT_SCHEDULED_FREQ3$$" onClick="jsUIDependency();" value="$$OPT_SCHEDULED_FREQ_VALUE3$$" $$OPT_SCHEDULED_FREQ_VALUE3_CHECKED$$></td>
		                    <td class="data1" nowrap>Monthly, on date</td></tr>
		                </table>
		            </td>
		            <td class="data1" width="1" style="background-image: url(images/dot_cui_verticle.gif);background-repeat: repeat-y;background-position: center;"></td>
		            <td class="data1">
		                <span id="SPWeek" style="display:none;width:95;"><select class="text" id="optWeek" name="$$OPT_SCHEDULED_WEEK_OFFSET$$"></select></span>
		                <span id="SPDays" style="display:none;width:45;"><select class="text" id="optDays" name="$$OPT_SCHEDULED_MONTH_OFFSET$$"></select></span>
		            </td>
		            <td id="TDTime" class="data1">at
		                <select class="text" id="optStartHour" name="$$OPT_SCHEDULED_START_HOUR$$"></select>&nbsp;:&nbsp;
		                <select class="text" id="optStartMins" name="$$OPT_SCHEDULED_START_MINS$$"></select>
		                (hh:mm)
		            </td>
		        </tr>
		    </table> 
		    </td></tr>
		<!--||Database selection||-->
		<tr><td class="tableheadergreyM">Database selection</td>
		    <td class="tableheadergreyM" align="right"><a href="javascript:jsRefresh();" class="moretestblue"><img src="images/icon_refresh.gif" class="vAlignMid"/> Refresh</a></td>
		    </tr>
			<input type="hidden" name="RefreshButton">
		<tr><td colspan="2" height="3"></td></tr>
		<tr><td colspan="2" class="data1">
		    <table width="100%" border="0" cellpadding="0" cellspacing="0">
               <tr id="trDBSelect_All"><td width="20" height="20"><input type="radio" id="rdoSelectAllDB" name="rdoSelectDB" onClick="jsUIDependency();" value="SelectAll" /></td>
                    <td>All databases
                        <img src="images/info_mark.gif" style="cursor:pointer;position:relative" onMouseOut="hideToolTip('ifmToolTip');" 
						onmouseover="showToolTip('ifmToolTip',this,250,80,TIP_SELECTALL_DB_TITEL,TIP_SELECTALL_DB_CONTENT);">
						</td></tr>
		        <tr id="trDBSelect_Spec"><td><input type="radio" id="rdoSelectSpecificDB" name="rdoSelectDB" onClick="jsUIDependency();" value="SelectSpc" checked /></td>
                    <td>Specific databases:</td></tr>
				<tr style="height:30px"><td/><td>Site URL keyword: <input type="text" class="button" name="site_path_keyword" id="site_path_keyword"><input type="button" class="button" style="margin-left:10px" value="Search" onClick = "TmCube_Tree_filter_sites();" id = "site_path_search_btn"></td></tr>
                <tr><td></td>
                     <td align="left" width="220px" valign="top">
          <table width="216px" border="0" cellpadding="0" cellspacing="1">
            <tr>
              <td>
                <div id="Tree__treepanel" style="width:350; height:318;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;height:252px">Please
                  wait...</div>
                <input id="Tree__treeresult" name="Tree__treeresult" type="hidden"/></td>
            </tr>
          </table></td>
                </tr>
                </table>
		    </td></tr>
		<tr><td colspan="2" height="10"></td></tr> 
		<tr><td class="tableheadergreyM" colspan="2">Select scan type</td></tr>
		<tr><td class="data1" colspan="2">
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr><td width="20"><input type=checkbox id="chkVirusScan" name="$$OPT_MANUAL_SCAN_TYPE_VS$$" $$ID_PR_VIRUS_SCAN_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_VS_VALUE_CHECKED$$></td>
					<td class="data1"><a href="javascript:jsVirusScan();">Security risk scan</a></td></tr>
				
				<tr><td width="20"><input type=checkbox id="chkAttachBlock" name="$$OPT_MANUAL_SCAN_TYPE_AB$$" $$ID_PR_ATTACHMENT_BLOCKING_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_AB_VALUE_CHECKED$$></td>
					<td class="data1"><a href="javascript:jsAttachBlock();">File blocking</a></td></tr>
				
				<tr id="prContentFilter" style="display:none">
					<td width="20"><input type=checkbox id="chkContentFilter" onclick="jsCFCheck(this);" name="chkContentFilter" $$ID_PR_CONTENT_FILTER_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_CF_VALUE_CHECKED$$></td>
					<td class="data1"><a href="javascript:jsContentFilter();">Content filtering</a></td></tr>
                     <tr>
                    <td width="20"></td> 
                <td class="data1"><input type=checkbox onclick="jsCFCheck(this);" id="chkContentFilterDoc" name="$$OPT_MANUAL_SCAN_TYPE_CF_DOC$$" $$ID_PR_CONTENT_FILTER_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_CF_DOC_VALUE_CHECKED$$>Content filtering for document</td></tr>
                <tr><td width="20"></td> 
                <td class="data1"><input type=checkbox onclick="jsCFCheck(this);" id="chkContentFilterWeb" name="$$OPT_MANUAL_SCAN_TYPE_CF_WEB$$" $$ID_PR_CONTENT_FILTER_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_CF_WEB_VALUE_CHECKED$$>Content filtering for Web content</td></tr>
				<tr id="prDLPFilter" style="display:none">
					<td width="20"><input type=checkbox id="chkDLPFilter" onclick="jsDLPCheck(this);" name="chkDLPFilter" $$ID_PR_DLP_FILTER_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_DLP_VALUE_CHECKED$$></td>
				<td class="data1"><a href="javascript:jsDataLossPrevention();">Data loss prevention</a></td></tr>
				<tr id="prDLPForDoc">
					<td width="20"></td> 
					<td class="data1"><input type=checkbox onClick="jsDLPCheck(this);" id="chkDLPDoc" name="$$OPT_MANUAL_SCAN_TYPE_DLP_DOC$$" $$ID_PR_DLP_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_DLP_DOC_VALUE_CHECKED$$>Data loss prevention for document</td></tr>
				<tr id="prDLPForWeb"><td width="20"></td>
					<td class="data1"><input type=checkbox onClick="jsDLPCheck(this);" id="chkDLPWeb" name="$$OPT_MANUAL_SCAN_TYPE_DLP_WEB$$" $$ID_PR_DLP_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_DLP_WEB_VALUE_CHECKED$$>Data loss prevention for Web content</td></tr>
                <tr ><td width="20"><input type=checkbox onclick="jsWTPCheck(this);" id="chkWTP" name="chkWTP" $$ID_PR_WEB_REPUTATION_DISABLE$$></td>
					<td class="data1"><a id="chkWTP_link" href="javascript:jsWebReputation();">Web Reputation</a></td></tr>
				<td width="20"></td> 
                <td class="data1"><input type=checkbox onclick="jsWTPCheck(this);" id="chkWebReputationDoc" name="$$OPT_MANUAL_SCAN_TYPE_WTP_DOC$$" $$ID_PR_WEB_REPUTATION_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_WTP_DOC_VALUE_CHECKED$$>Web reputation for document</td></tr>
                <tr><td width="20"></td> 
                <td class="data1"><input type=checkbox onclick="jsWTPCheck(this);" id="chkWebReputationWeb" name="$$OPT_MANUAL_SCAN_TYPE_WTP_WEB$$" $$ID_PR_WEB_REPUTATION_DISABLE$$ $$OPT_MANUAL_SCAN_TYPE_WTP_WEB_VALUE_CHECKED$$>Web reputation for Web content</td></tr>	
					
				</table></td></tr>
		<!--||Increment Function||-->
		<tr id="IncremFunc_Title" ><td class="tableheadergreyM" colspan="2">Incremental Scan Options</td></tr>
		<tr id="IncremFunc_Setting"><td class="data1" colspan="2"><table border="0" cellpadding="0" cellspacing="0">
		       <tr style="display:none">
		         <td colspan="9" height="20" class="data1">If all checkboxes are clear, ProtalProtect scans all files.</td>
		       </tr> 
		        <tr>
		               <td width="20" class="data1"><input type="checkbox" id="chkModifyTime" name="optBackgroundScanSpecificDeliveryTime" onClick="jsUIDependency()" $$OPT_BACKGROUND_SCAN_SPECIFIC_DELIVERY_TIME_VALUE_CHECKED$$ /></td>
		               <td class="data1" colspan="8">Scan files modified:</td>
		               
		       </tr>
         	   <tr>
                  <td class=data1 colSpan=1></td> 
                  <td style="display:none" class=data1 ><input id="radioLastNDays" onClick="jsUIDependency()" type="radio" 
                  value="LastNDays" name="radioTimePeriodType">Last</td>
                  <td class="data1">&nbsp;Last</td>
		       	  <td class="data1"> <input type="text" class="text"
                  id="txtLastNDayNumberPart" size=5 
                  value=$$LAST_N_DAY_NUMBER_PART$$ name="txtLastNDaysNumberPart"> 
                  <SELECT class="text" id="selectLastNDayUnitPart" 
                  name="selectLastNDayUnitPart"> <OPTION 
                    value=hours>hours</OPTION> <OPTION value=days 
                    selected>days</OPTION> <OPTION 
                  value=weeks>weeks</OPTION></SELECT> 
                  </td>
               </tr>             
		       <tr style="display:none">
		       		  <td class=data1 colSpan=1></td><td class=data1><input id="radioFromToDate" onClick="jsUIDependency()" type="radio" 
                       CHECKED value="FromToDate" name="radioTimePeriodType">From</td>
		       		  <td class="data1"><input type="text" class="text" id="txtDateFrom_display" name="txtDateFrom_display" style="width:75">		                             <img id="txtDateFrom_display_img" src="images/icon_calendar.gif" style="position:relative;vertical-align:top" onClick="getCalendar(window.ifmCalendar,document.fmMain.txtDateFrom_display,vSvrDateFormat,vSvrTwoDigitYearMax);">
		              </td>
		              <td class="data1"><select class="text" id="optHourFrom" name="optHourFrom"></select></td>
		              <td class="data1" ><select class="text" id="optMinFrom" name="optMinFrom"></select></td>
		              <td class="data1">to</td>
		              <!--td class="data1"><input type="radio" class="text" id="rdoDateTo_Now" name="rdoDateTo" onclick="jsUIDependency()" checked /></td>
		              <td class="data1">Now</td>
		              <td class="data1"><input type="radio" class="text" id="rdoDateTo_Date" name="rdoDateTo" onclick="jsUIDependency()"></td-->
		              <td class="data1"><input type=text class="text" id="txtDateTo_display" name="txtDateTo_display" style="width:75">		                      <img id="txtDateTo_display_img" src="images/icon_calendar.gif" style="position:relative;vertical-align:top" onClick="getCalendar(window.ifmCalendar,document.fmMain.txtDateTo_display,vSvrDateFormat,vSvrTwoDigitYearMax);">
		              </td>
		              <td class="data1"><select class="text" id="optHourTo" name="optHourTo"></select></td>
		              <td class="data1" ><select class="text" id="optMinTo" name="optMinTo"></select></td> 
		       </tr>
		       <tr style="display:none">
		              <td></td>
		              <td></td>
		              <td class="data1"><span id="FromDateString">mm/dd/yyyy</span></td>
		              <td class="data1">hh</td>
		              <td class="data1">mm</td>
		              <td></td>
		              <td class="data1"><span id="ToDateString">mm/dd/yyyy</span></td>
		              <td class="data1">hh</td>
		              <td class="data1" >mm</td>
		        </tr>
		        <tr style="display:none">
		                <td class="data1"><input type="checkbox" id="chkWithATT" name="optBackgroundScanMsgWithAttachment" onClick="jsUIDependency()" $$OPT_BACKGROUND_SCAN_MSG_WITH_ATTACHMENT_VALUE_CHECKED$$ /></td>
		                <td class="data1" colspan="8">Scan messages with attachments</td></tr>
		        <tr style="display:none">
		                <td class="data1"><input type="checkbox" id="chkWithoutSTA" name="optBackgroundScanUnscannedMsg" onClick="jsUIDependency()" $$OPT_BACKGROUND_SCAN_UNSCANNED_MSG_VALUE_CHECKED$$ /></td>
		                <td class="data1" colspan="8">Scan messages that have not been scanned</td></tr></table>
		        </td></tr>
		        <tr style="display:none"><td colspan="2" height="10"></td></tr> 
		        <tr style="display:none"><td class="tableheadergreyM" colspan="2">CPU Usage
		            <img src="images/info_mark.gif" style="cursor:pointer;position:relative" onMouseOut="hideToolTip('ifmToolTip');" 
						onmouseover="showToolTip('ifmToolTip',this,250,80,TIP_CPUUSAGE_TITEL,TIP_CPUUSAGE_CONTENT);"></td></tr>
		        <tr style="display:none"><td colspan="2" height="3"></td></tr> 
		        <tr style="display:none"><td class="data1" colspan="2"><table border="0" cellpadding="0" cellspacing="0">
		            <tr><td class="data1" width="20"><input id="optScheduleScanEnableCpuUsage" name="optScheduleScanEnableCpuUsage" type="checkbox" $$OPT_SCHEDULE_SCAN_ENABLE_CPU_USAGE$$>
		                </td>
		                <td class="data1">Enable CPU usage limitation</td>
		            </tr>
		            <tr><td></td><td class="data1">Scheduled scan will consume a maximum CPU usage of:&nbsp;
                    <select id="optScheduleScanMaxCpuUsage" name="optScheduleScanMaxCpuUsage" class="text"></select>
                    </td></tr>
		            </table>
                </td></tr>
              <tr ><td colspan="2" height="5"></td></tr> 
		</table></td></tr>
<!--/Page Content-->
<!--Page Button-->
<tr><td height="10"></td></tr>
<tr><td>
<table>
<tr><td><input type="button"  id="TaskButton" class="button" name="TaskButton" onClick="jsSubmit();"></td><td><input name="TaskButtonCancel" type="button" class="button"  id="TaskButtonCancel" onClick="jsCancel();" value="Cancel" ></td></tr>
</table>
</td></tr>

<!--/Page Button-->
</table>
</form>

<iframe id="ifmToolTip" name="ifmToolTip" src="html/ToolTip.htm" frameborder="0" style="z-index:10000;position:absolute;width:0;height:0;scrolling:no"/>
</body>
</html>
