﻿// Exception Highlighting option dialog code
var M_astrExceptionHLSetting;  // measure x ExceptionHL option x range
var M_bHasExistingSelections;  // flag to indicate existing selections.

var EH_SELECT = 0;
var EH_TO = 1;
var EH_FROM = 2;
var EH_CELLCOLOR = 3;
var EH_TEXTCOLOR = 4;

var EH_OPTIONS_COUNT = 5;  // number of EH settings.
var EH_RANGE_COUNT = 5;  // number of possible ranges

var M_strExceptionHLOptions =
"<table class='OptionTable' border='0' width='100%' cellPadding='3' cellSpacing='0'>"
+ "<tr><td>"
+ "<table cellPadding='3' cellSpacing='0'>"
+ "<tr>"
+ "<td class=OptionHeader nowrap align=left>"
+ resHighlightValues
+ "</td>"
+ "</tr>"
+ "<tr height='3'>"
+ "</tr>"
+ "</table>"
+ "</td></tr>"
+ "<tr><td>"
+ "<table cellspacing='3' cellpadding='0'>"
+ "<tr><td class=OptionItem nowrap>"
+ "<table border='0' cellspacing='0' cellpadding='0'>"
+ "<tr><td width=10>&nbsp;&nbsp;</td>"
+ "<td class='OptionItem' nowrap><Label for='ehMeasure' "
+ " onclick=\"javascript:switchExceptionHighlightingSet();\""
+ ">" + resMeasure + "</Label>&nbsp;&nbsp;</td>"
+ "<td><select class=Default id='ehMeasure' title='" + resMeasure + "' name='ehMeasure' "
+ "onkeyup='switchExceptionHighlightingSet()' "
+ "onkeypress='javascript:SubmitExceptionHighlighting(event);' "
+ "onchange='switchExceptionHighlightingSet()'>"
+ "</select></td>"
+ "</tr></table>"
+ "</td></tr>"
+ "<tr><td height=3></td></tr>"
+ "<tr><td>"
+ "<table border=0 cellspacing=0 cellpadding=0>"
+ "<tr>"
+ "<td width=10>&nbsp;</td>"
+ "<td id='Select' height=28 align='center' valign='bottom' class='OptionItem' nowrap>" + resSelect + "</td>"
+ "<td width=10>&nbsp;</td>"
+ "<td id='Clear' height=28 align='center' valign='bottom' class='OptionItem' nowrap>" + resClear + "&nbsp;&nbsp;</td>"
+ "<td id='From' align=left valign=bottom class='OptionItem' nowrap>" + resFrom + "</td>"
+ "<td width=20></td>"
+ "<td id='To' align='left' valign='bottom' class='OptionItem' nowrap>" + resTo + "</td>"
+ "<td width=10></td>"
+ "<td id='CellColor' align='left' valign='bottom' class='OptionItem' nowrap>" + resCellColor + "</td>"
+ "<td width=20></td>"
+ "<td id='textColor' align='left' valign='bottom' class='OptionItem' nowrap>" + resTextColor + "</td>"
+ "<td width=20></td>"
+ "<td id='Preview' align='left' valign='bottom' class='OptionItem' nowrap>" + resPreview + "</td>"
+ "</tr>"
+ "<tr>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Select' align='right'>"
+ "<label for='ehSelect0' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resSelect + "</label>"
+ "<input type=checkbox title='" + resSelect + "' id='ehSelect0' name='ehSelect0'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " onclick='enableExceptionHLRange(0);'></td>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Clear' valign=middle>"
+ "<div id='ehClear0_enabled' style='display:none;' name='ehClear0_enabled'>"
+ "<a href=\"javascript:clearCurrentExceptionHLRange(0);\">"
+ "<img src='../bmp/eh_clear_enabled.gif' Title='" + resClear + "' Alt='" + resClear + "' border=0>"
+ "</a>"
+ "</div>"
+ "<div id='ehClear0_disabled' style='display:block;' name='ehClear0_disabled'>"
+ "<img src='../bmp/eh_clear_disabled.gif' title='" + resClear + "' alt='" + resClear + "' border=0>"
+ "</div>"
+ "</td>"
+ "<td headers='From'><label for='ehFrom0' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resFrom
+ "</label><input class=VariableTextInput type=text title='" + resFrom + "' size=12 name='ehFrom0' id='ehFrom0' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 0, " + EH_FROM + ")'>"
+ "</td>"
+ "<td width=10></td>"
+ "<td headers='To'><label for='ehTo0' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTo
+ "</label><input class=VariableTextInput type=text title='" + resTo + "' size=12 name='ehTo0' ID='ehTo0' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 0, " + EH_TO + ")'>"
+ "</td>"
+ "<td width=20></td>"
+ "<td nowrap headers='CellColor'><label for='ehCellColor0' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resCellColor
+ "</label><input class=VariableTextInput type=text title='" + resCellColor + "' name='ehCellColor0'"
+ " id='ehCellColor0'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" "
+ " size=3 readonly style='background-Color:#FF0000;'>"
+ "<input type=button name='ehCellColorButton0' id='ehCellColorButton0' value='...' style='WIDTH:22px;HEIGHT:22px;' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehCellColor0\");' onClick='javascript:displayColorPicker(0, " + EH_CELLCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td nowrap headers='TextColor'><Label for='ehTextColor0' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTextColor
+ "</label><input class=VariableTextInput type=text title='" + resTextColor + "' name='ehTextColor0'"
+ " id='ehTextColor0'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " size='3' readonly style='background-Color:#000000;'>"
+ "<input type='button' name='ehTextColorButton0' id='ehTextColorButton0' value='...' style='WIDTH:22px;HEIGHT:22px' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehTextColor0\");' onClick='javascript:displayColorPicker(0, " + EH_TEXTCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td headers='Preview'><label for='ehPreview0' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resPreview
+ "</label><input class=VariableTextInput type=text title='" + resPreview + "' name='ehPreview0' id='ehPreview0'"
+ " onkeypress='javascript:SubmitExceptionHighlighting(event);'"
+ " size=16 readonly value='#FFFF00;#000000' style='color:#000000;background-Color:#FFFF00;'></td>"
+ "<td width=10></td>"
+ "</tr>"
+ "<tr>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Select' align='right'>"
+ "<label for='ehSelect1' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resSelect + "</label>"
+ "<input type=checkbox title='" + resSelect + "' id='ehSelect1' name='ehSelect1'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " onclick='enableExceptionHLRange(1);'></td>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Clear' valign=middle>"
+ "<div id='ehClear1_enabled' style='display:none;' name='ehClear1_enabled'>"
+ "<a href=\"javascript:clearCurrentExceptionHLRange(1);\">"
+ "<img src='../bmp/eh_clear_enabled.gif' Title='" + resClear + "' Alt='" + resClear + "' border=0>"
+ "</a>"
+ "</div>"
+ "<div id='ehClear1_disabled' style='display:block;' name='ehClear1_disabled'>"
+ "<img src='../bmp/eh_clear_disabled.gif' title='" + resClear + "' alt='" + resClear + "' border=0>"
+ "</div>"
+ "</td>"
+ "<td headers='From'><label for='ehFrom1' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resFrom
+ "</label><input class=VariableTextInput type=text title='" + resFrom + "' size=12 name='ehFrom1' id='ehFrom1' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 1, " + EH_FROM + ")'>"
+ "</td>"
+ "<td width=10></td>"
+ "<td headers='To'><label for='ehTo1' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTo
+ "</label><input class=VariableTextInput type=text title='" + resTo + "' size=12 name='ehTo1' ID='ehTo1' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 1, " + EH_TO + ")'>"
+ "</td>"
+ "<td width=20></td>"
+ "<td nowrap headers='CellColor'><label for='ehCellColor1' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resCellColor
+ "</label><input class=VariableTextInput type=text title='" + resCellColor + "' name='ehCellColor1'"
+ " id='ehCellColor1'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" "
+ " size=3 readonly style='background-Color:#FF0000;'>"
+ "<input type=button name='ehCellColorButton1' id='ehCellColorButton1' value='...' style='WIDTH:22px;HEIGHT:22px;' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehCellColor1\");' onClick='javascript:displayColorPicker(1, " + EH_CELLCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td nowrap headers='TextColor'><Label for='ehTextColor1' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTextColor
+ "</label><input class=VariableTextInput type=text title='" + resTextColor + "' name='ehTextColor1'"
+ " id='ehTextColor1'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " size='3' readonly style='background-Color:#000000;'>"
+ "<input type='button' name='ehTextColorButton1' id='ehTextColorButton1' value='...' style='WIDTH:22px;HEIGHT:22px' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehTextColor1\");' onClick='javascript:displayColorPicker(1, " + EH_TEXTCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td headers='Preview'><label for='ehPreview1' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resPreview
+ "</label><input class=VariableTextInput type=text title='" + resPreview + "' name='ehPreview1' id='ehPreview1'"
+ " onkeypress='javascript:SubmitExceptionHighlighting(event);'"
+ " size=16 readonly value='#FFFF00;#000000' style='color:#000000;background-Color:#FFFF00;'></td>"
+ "<td width=10></td>"
+ "</tr>"
+ "<tr>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Select' align='right'>"
+ "<label for='ehSelect2' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resSelect + "</label>"
+ "<input type=checkbox title='" + resSelect + "' id='ehSelect2' name='ehSelect2'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " onclick='enableExceptionHLRange(2);'></td>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Clear' valign=middle>"
+ "<div id='ehClear2_enabled' style='display:none;' name='ehClear2_enabled'>"
+ "<a href=\"javascript:clearCurrentExceptionHLRange(2);\">"
+ "<img src='../bmp/eh_clear_enabled.gif' Title='" + resClear + "' Alt='" + resClear + "' border=0>"
+ "</a>"
+ "</div>"
+ "<div id='ehClear2_disabled' style='display:block;' name='ehClear2_disabled'>"
+ "<img src='../bmp/eh_clear_disabled.gif' title='" + resClear + "' alt='" + resClear + "' border=0>"
+ "</div>"
+ "</td>"
+ "<td headers='From'><label for='ehFrom2' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resFrom
+ "</label><input class=VariableTextInput type=text title='" + resFrom + "' size=12 name='ehFrom2' id='ehFrom2' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 2, " + EH_FROM + ")'>"
+ "</td>"
+ "<td width=10></td>"
+ "<td headers='To'><label for='ehTo2' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTo
+ "</label><input class=VariableTextInput type=text title='" + resTo + "' size=12 name='ehTo2' ID='ehTo2' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 2, " + EH_TO + ")'>"
+ "</td>"
+ "<td width=20></td>"
+ "<td nowrap headers='CellColor'><label for='ehCellColor2' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resCellColor
+ "</label><input class=VariableTextInput type=text title='" + resCellColor + "' name='ehCellColor2'"
+ " id='ehCellColor2'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" "
+ " size=3 readonly style='background-Color:#FF0000;'>"
+ "<input type=button name='ehCellColorButton2' id='ehCellColorButton2' value='...' style='WIDTH:22px;HEIGHT:22px;' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehCellColor2\");' onClick='javascript:displayColorPicker(2, " + EH_CELLCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td nowrap headers='TextColor'><Label for='ehTextColor2' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTextColor
+ "</label><input class=VariableTextInput type=text title='" + resTextColor + "' name='ehTextColor2'"
+ " id='ehTextColor2'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " size='3' readonly style='background-Color:#000000;'>"
+ "<input type='button' name='ehTextColorButton2' id='ehTextColorButton2' value='...' style='WIDTH:22px;HEIGHT:22px' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehTextColor2\");' onClick='javascript:displayColorPicker(2, " + EH_TEXTCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td headers='Preview'><label for='ehPreview2' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resPreview
+ "</label><input class=VariableTextInput type=text title='" + resPreview + "' name='ehPreview2' id='ehPreview2'"
+ " onkeypress='javascript:SubmitExceptionHighlighting(event);'"
+ " size=16 readonly value='#FFFF00;#000000' style='color:#000000;background-Color:#FFFF00;'></td>"
+ "<td width=10></td>"
+ "</tr>"
+ "<tr>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Select' align='right'>"
+ "<label for='ehSelect3' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resSelect + "</label>"
+ "<input type=checkbox title='" + resSelect + "' id='ehSelect3' name='ehSelect3'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " onclick='enableExceptionHLRange(3);'></td>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Clear' valign=middle>"
+ "<div id='ehClear3_enabled' style='display:none;' name='ehClear3_enabled'>"
+ "<a href=\"javascript:clearCurrentExceptionHLRange(3);\">"
+ "<img src='../bmp/eh_clear_enabled.gif' Title='" + resClear + "' Alt='" + resClear + "' border=0>"
+ "</a>"
+ "</div>"
+ "<div id='ehClear3_disabled' style='display:block;' name='ehClear3_disabled'>"
+ "<img src='../bmp/eh_clear_disabled.gif' title='" + resClear + "' alt='" + resClear + "' border=0>"
+ "</div>"
+ "</td>"
+ "<td headers='From'><label for='ehFrom3' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resFrom
+ "</label><input class=VariableTextInput type=text title='" + resFrom + "' size=12 name='ehFrom3' id='ehFrom3' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 3, " + EH_FROM + ")'>"
+ "</td>"
+ "<td width=10></td>"
+ "<td headers='To'><label for='ehTo3' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTo
+ "</label><input class=VariableTextInput type=text title='" + resTo + "' size=12 name='ehTo3' ID='ehTo3' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 3, " + EH_TO + ")'>"
+ "</td>"
+ "<td width=20></td>"
+ "<td nowrap headers='CellColor'><label for='ehCellColor3' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resCellColor
+ "</label><input class=VariableTextInput type=text title='" + resCellColor + "' name='ehCellColor3'"
+ " id='ehCellColor3'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" "
+ " size=3 readonly style='background-Color:#FF0000;'>"
+ "<input type=button name='ehCellColorButton3' id='ehCellColorButton3' value='...' style='WIDTH:22px;HEIGHT:22px;' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehCellColor3\");' onClick='javascript:displayColorPicker(3, " + EH_CELLCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td nowrap headers='TextColor'><Label for='ehTextColor3' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTextColor
+ "</label><input class=VariableTextInput type=text title='" + resTextColor + "' name='ehTextColor3'"
+ " id='ehTextColor3'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " size='3' readonly style='background-Color:#000000;'>"
+ "<input type='button' name='ehTextColorButton3' id='ehTextColorButton3' value='...' style='WIDTH:22px;HEIGHT:22px' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehTextColor3\");' onClick='javascript:displayColorPicker(3, " + EH_TEXTCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td headers='Preview'><label for='ehPreview3' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resPreview
+ "</label><input class=VariableTextInput type=text title='" + resPreview + "' name='ehPreview3' id='ehPreview3'"
+ " onkeypress='javascript:SubmitExceptionHighlighting(event);'"
+ " size=16 readonly value='#FFFF00;#000000' style='color:#000000;background-Color:#FFFF00;'></td>"
+ "<td width=10></td>"
+ "</tr>"
+ "<tr>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Select' align='right'>"
+ "<label for='ehSelect4' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resSelect + "</label>"
+ "<input type=checkbox title='" + resSelect + "' id='ehSelect4' name='ehSelect4'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " onclick='enableExceptionHLRange(4);'></td>"
+ "<td width=10>&nbsp;</td>"
+ "<td height=30 headers='Clear' valign=middle>"
+ "<div id='ehClear4_enabled' style='display:none;' name='ehClear4_enabled'>"
+ "<a href=\"javascript:clearCurrentExceptionHLRange(4);\">"
+ "<img src='../bmp/eh_clear_enabled.gif' Title='" + resClear + "' Alt='" + resClear + "' border=0>"
+ "</a>"
+ "</div>"
+ "<div id='ehClear4_disabled' style='display:block;' name='ehClear4_disabled'>"
+ "<img src='../bmp/eh_clear_disabled.gif' title='" + resClear + "' alt='" + resClear + "' border=0>"
+ "</div>"
+ "</td>"
+ "<td headers='From'><label for='ehFrom4' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resFrom
+ "</label><input class=VariableTextInput type=text title='" + resFrom + "' size=12 name='ehFrom4' id='ehFrom4' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 4, " + EH_FROM + ")'>"
+ "</td>"
+ "<td width=10></td>"
+ "<td headers='To'><label for='ehTo4' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTo
+ "</label><input class=VariableTextInput type=text title='" + resTo + "' size=12 name='ehTo4' ID='ehTo4' readonly"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" onchange='SaveExceptionHLRange(this, 4, " + EH_TO + ")'>"
+ "</td>"
+ "<td width=20></td>"
+ "<td nowrap headers='CellColor'><label for='ehCellColor4' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resCellColor
+ "</label><input class=VariableTextInput type=text title='" + resCellColor + "' name='ehCellColor4'"
+ " id='ehCellColor4'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\" "
+ " size=3 readonly style='background-Color:#FF0000;'>"
+ "<input type=button name='ehCellColorButton4' id='ehCellColorButton4' value='...' style='WIDTH:22px;HEIGHT:22px;' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehCellColor4\");' onClick='javascript:displayColorPicker(4, " + EH_CELLCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td nowrap headers='TextColor'><Label for='ehTextColor4' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resTextColor
+ "</label><input class=VariableTextInput type=text title='" + resTextColor + "' name='ehTextColor4'"
+ " id='ehTextColor4'"
+ " onkeypress=\"javascript:SubmitExceptionHighlighting(event);\""
+ " size='3' readonly style='background-Color:#000000;'>"
+ "<input type='button' name='ehTextColorButton4' id='ehTextColorButton4' value='...' style='WIDTH:22px;HEIGHT:22px' disabled"
+ " onBlur='javascript:removeColorPicker(\"ehTextColor4\");' onClick='javascript:displayColorPicker(4, " + EH_TEXTCOLOR + ");'></td>"
+ "<td width=20></td>"
+ "<td headers='Preview'><label for='ehPreview4' style='width:1px;height:1px;font-size:0;overflow:hidden;visibility:hidden;'>" + resPreview
+ "</label><input class=VariableTextInput type=text title='" + resPreview + "' name='ehPreview4' id='ehPreview4'"
+ " onkeypress='javascript:SubmitExceptionHighlighting(event);'"
+ " size=16 readonly value='#FFFF00;#000000' style='color:#000000;background-Color:#FFFF00;'></td>"
+ "<td width=10></td>"
+ "</tr>"
+ "<tr>"
+ "<td width=10>&nbsp;</td>"
+ "<td align='right' valign='middle'>"
+ "<a href=\"javascript:SelectAllExceptionHLRanges();\">"
+ "<img src='../bmp/eh_select_all.gif' border=0 alt='" + resSelectMeasureExceptions + "' title='" + resSelectMeasureExceptions + "'>"
+ "</a>"
+ "</td>"
+ "<td width=10>&nbsp;</td>"
+ "<td align='left' valign='middle'>"
+ "<a href=\"javascript:ClearAllExceptionHLRanges();\">"
+ "<img src='../bmp/eh_clear_all.gif' border=0 alt='" + resClearMeasureExceptions + "' title='" + resClearMeasureExceptions + "'>"
+ "</a>"
+ "</td>"
+ "<td colspan=9 class='OptionItem' nowrap>" + resSelectOrClearMeasureExceptions + "</td>"
+ "</tr>"
+ "</table>"
+ "</td>"
+ "<td width='10'></td>"
+ "</tr>"
+ "</table>"
+ "</td></tr>"
+ "<tr><td><table><tr>"
+ "<td nowrap>"
+ "<input type=button name=ehGo value='" + resOK + "'"
+ " onclick=\"javascript:OnExceptionHighlightingOptions();\">&nbsp;"
+ "<input type=button name=Cancel value='" + resCancel + "'"
+ " onclick=\"javascript:OnCancelOptions();\">&nbsp;"
+ "<input type=button name=ehClearAll value='" + resClearAll + "'"
+ " onclick=\"javascript:OnClearExceptionHighlighting();\">&nbsp;"
+ "<input name=DialogHelpButton type=button value=\"" + resHelp
+ "\" onclick=\"javascript:DisplayDialogHelp('ExceptionHighlighting.htm', '');\">"
+ "&nbsp;</td>"
+ "</tr></table></td></tr>"
+ "</table>"

//-------------------------------------------------------------------
function ReadExistingSelections()
{
   var objEhSelect = document.aspnetForm.ehSelect;
   
   M_bHasExistingSelections = false;
   if (objEhSelect) {
      if (objEhSelect.value != "") {
         if (objEhSelect.value.indexOf("1") > -1) M_bHasExistingSelections = true;
      }
   }
}

//-------------------------------------------------------------------
function LoadExceptionHLSettings(i_objCalcHiddenField, i_nOptionIndex)
{
   var aszRange;
   var aszMeasure;
   var nMeasure;
   var nOpt;
   var nRange;

   if (i_objCalcHiddenField) {
      if (i_objCalcHiddenField.value != "") {
         aszMeasure = i_objCalcHiddenField.value.split(";");
         if (aszMeasure) {
            for (nMeasure = 0; nMeasure < aszMeasure.length; nMeasure++) {
            if (M_astrExceptionHLSetting[nMeasure] != null){
               aszRange = aszMeasure[nMeasure].split(",");
               for (nRange = 0; nRange < aszRange.length; nRange++) {
                  if (aszRange[nRange] != "") {
                     M_astrExceptionHLSetting[nMeasure][i_nOptionIndex][nRange] = aszRange[nRange];
                  }
               }
               }
            }
         }
      }
   }
}
   
//-------------------------------------------------------------------
function SaveExceptionHLRange(i_objText, i_nRange, i_nOption)
{
   var nMeasure = document.getElementById("ehMeasure").selectedIndex;
   M_astrExceptionHLSetting[nMeasure][i_nOption][i_nRange] = i_objText.value;
}

//--------------------------------------------------------------
function enableExceptionHLRange(i_nRange)
{
   var nMeasure = document.getElementById("ehMeasure").selectedIndex;

   if (document.getElementById("ehSelect" + i_nRange).checked){
      M_astrExceptionHLSetting[nMeasure][EH_SELECT][i_nRange] = "1";
      if (M_astrExceptionHLSetting[nMeasure][EH_TO][i_nRange] == "") {
         M_astrExceptionHLSetting[nMeasure][EH_TO][i_nRange] = "max";
      }
      if (M_astrExceptionHLSetting[nMeasure][EH_FROM][i_nRange] == "") {
         M_astrExceptionHLSetting[nMeasure][EH_FROM][i_nRange] = "min";
      }
   }
   else {
      M_astrExceptionHLSetting[nMeasure][EH_SELECT][i_nRange] = "";
   }
   SetRange(i_nRange);
}

//--------------------------------------------------------------
function clearCurrentExceptionHLRange(i_nRange)
{
   var nOption;
   var nMeasure = document.getElementById("ehMeasure").selectedIndex;

   for (nOption = 0; nOption < EH_OPTIONS_COUNT; nOption++) {
      M_astrExceptionHLSetting[nMeasure][nOption][i_nRange] = "";
      if (nOption == EH_CELLCOLOR) {
         M_astrExceptionHLSetting[nMeasure][nOption][i_nRange] = G_defaultCellColor[i_nRange];
      }
      else if (nOption == EH_TEXTCOLOR) {
         M_astrExceptionHLSetting[nMeasure][nOption][i_nRange] = G_defaultTextColor;
      }
   }
   SetRange(i_nRange);
}

//-------------------------------------------------------------------
function InitializeExceptionHLData()
{
   var nMeasureCount = M_astrMeasures.length;
   var nMeasure;
   var nOpt;
   var nRange;

   M_astrExceptionHLSetting = new Array(nMeasureCount);
   for (nMeasure = 0; nMeasure < nMeasureCount; nMeasure++) {
      M_astrExceptionHLSetting[nMeasure] = new Array(EH_OPTIONS_COUNT);
      for (nOpt = 0; nOpt < EH_OPTIONS_COUNT; nOpt++) {
         M_astrExceptionHLSetting[nMeasure][nOpt] = new Array(EH_RANGE_COUNT);
         for (nRange = 0; nRange < EH_RANGE_COUNT; nRange++) {
            M_astrExceptionHLSetting[nMeasure][nOpt][nRange] = "";
            if (nOpt == EH_CELLCOLOR) {
               M_astrExceptionHLSetting[nMeasure][nOpt][nRange] = G_defaultCellColor[nRange];
            }
            else if (nOpt == EH_TEXTCOLOR) {
               M_astrExceptionHLSetting[nMeasure][nOpt][nRange] = G_defaultTextColor;
            }
         }
      }
   }
   LoadExceptionHLSettings(document.aspnetForm.ehSelect, EH_SELECT);
   LoadExceptionHLSettings(document.aspnetForm.ehTo, EH_TO);
   LoadExceptionHLSettings(document.aspnetForm.ehFrom, EH_FROM);
   LoadExceptionHLSettings(document.aspnetForm.ehCellColor, EH_CELLCOLOR);
   LoadExceptionHLSettings(document.aspnetForm.ehTextColor, EH_TEXTCOLOR);
}

//---------------------------------------------------------------
// sets the Range UI from the M_astrExceptionHLSetting array
function SetRange(i_nIndex)
{
   var nMeasure = document.getElementById("ehMeasure").selectedIndex;

   document.getElementById("ehSelect" + i_nIndex).checked = M_astrExceptionHLSetting[nMeasure][EH_SELECT][i_nIndex] == "1";
   document.getElementById("ehFrom" + i_nIndex).value = M_astrExceptionHLSetting[nMeasure][EH_FROM][i_nIndex];
   document.getElementById("ehTo" + i_nIndex).value = M_astrExceptionHLSetting[nMeasure][EH_TO][i_nIndex];
   document.getElementById("ehCellColor" + i_nIndex).style.backgroundColor = M_astrExceptionHLSetting[nMeasure][EH_CELLCOLOR][i_nIndex];
   document.getElementById("ehTextColor" + i_nIndex).style.backgroundColor = M_astrExceptionHLSetting[nMeasure][EH_TEXTCOLOR][i_nIndex];
   document.getElementById("ehPreview" + i_nIndex).style.backgroundColor = M_astrExceptionHLSetting[nMeasure][EH_CELLCOLOR][i_nIndex];
   document.getElementById("ehPreview" + i_nIndex).style.color = M_astrExceptionHLSetting[nMeasure][EH_TEXTCOLOR][i_nIndex];
   document.getElementById("ehPreview" + i_nIndex).value = M_astrExceptionHLSetting[nMeasure][EH_CELLCOLOR][i_nIndex] +
                                                            ";" + M_astrExceptionHLSetting[nMeasure][EH_TEXTCOLOR][i_nIndex];
   
   if (M_astrExceptionHLSetting[nMeasure][EH_SELECT][i_nIndex] == "1") {
      document.getElementById("ehClear" + i_nIndex + "_enabled").style.display = 'block';
      document.getElementById("ehClear" + i_nIndex + "_disabled").style.display = 'none';
      document.getElementById("ehCellColorButton" + i_nIndex).disabled=false;
      document.getElementById("ehTextColorButton" + i_nIndex).disabled=false;
      document.getElementById("ehFrom" + i_nIndex).readOnly=false;
      document.getElementById("ehTo" + i_nIndex).readOnly=false;
      
   }
   else {
      document.getElementById("ehClear" + i_nIndex + "_enabled").style.display = 'none';
      document.getElementById("ehClear" + i_nIndex + "_disabled").style.display = 'block';
      document.getElementById("ehFrom" + i_nIndex).readOnly=true;
      document.getElementById("ehTo" + i_nIndex).readOnly=true;
      document.getElementById("ehCellColorButton" + i_nIndex).disabled=true;
      document.getElementById("ehTextColorButton" + i_nIndex).disabled=true;
   }
}

//-----------------------------------------------------------
function switchExceptionHighlightingSet()
{
   ValidateRanges();
   SetAllCurrentRanges();
}

//---------------------------------------------------------------
function InitializeExceptionHLUI()
{
   var nMeasure;
   
   // add the measures
   document.aspnetForm.ehMeasure.options.length = 0;
   for (nMeasure = 0; nMeasure < M_astrMeasures.length; nMeasure++) {
      SelectControlAddOption(document.aspnetForm.ehMeasure, nMeasure, M_astrMeasures[nMeasure]);
   }
   SetAllCurrentRanges();
}

//-------------------------------------------------------------------
function ShowExceptionHighlightingOptions()
{
	zeroScrollPosition();
	
   DisplayOption(M_strExceptionHLOptions);
   InitializeExceptionHLData();
   InitializeExceptionHLUI();
   document.aspnetForm.ehMeasure.focus();
   // Resize scroll bars
   onLayoutResize();         
}

//-----------------------------------------------------------------------------
function SetAllCurrentRanges()
{
   for (nRange = 0; nRange < EH_RANGE_COUNT; nRange++) {
      SetRange(nRange);
   }
}

//-----------------------------------------------------------------------------
function OnClearExceptionHighlighting()
{
   var nMeasureCount = M_astrMeasures.length;
   var nMeasure;
   var nOpt;
   var nRange;

   for (nMeasure = 0; nMeasure < nMeasureCount; nMeasure++) {
      for (nOpt = 0; nOpt < EH_OPTIONS_COUNT; nOpt++) {
         for (nRange = 0; nRange < EH_RANGE_COUNT; nRange++) {
            M_astrExceptionHLSetting[nMeasure][nOpt][nRange] = "";
            if (nOpt == EH_CELLCOLOR) {
               M_astrExceptionHLSetting[nMeasure][nOpt][nRange] = G_defaultCellColor[nRange];
            }
            else if (nOpt == EH_TEXTCOLOR) {
               M_astrExceptionHLSetting[nMeasure][nOpt][nRange] = G_defaultTextColor;
            }
         }
      }
   }
   SetAllCurrentRanges();
   document.aspnetForm.ehMeasure.focus();
}

//-----------------------------------------------------------------------------
function ClearAllExceptionHLRanges()
{
   for (nRange = 0; nRange < EH_RANGE_COUNT; nRange++) {
      clearCurrentExceptionHLRange(nRange);
   }
}

//-----------------------------------------------------------------------------
function SelectAllExceptionHLRanges()
{
   for (nRange = 0; nRange < EH_RANGE_COUNT; nRange++) {
      document.getElementById("ehSelect" + nRange).checked = true;
      enableExceptionHLRange(nRange);
   }
}

//--------------------------------------------------------------
function WriteExceptionHighlightingSetting(i_objHiddenField, i_nOptionIndex)
{
   var szSubValue = "";
   var szValue = "";
   var nRange;
   var nMeasure;
   
   for (nMeasure = 0; nMeasure < M_astrMeasures.length; nMeasure++){
      szSubValue = '';
      for (nRange = 0; nRange < EH_RANGE_COUNT; nRange++) {
         if (i_nOptionIndex == EH_SELECT){
            if (M_astrExceptionHLSetting[nMeasure][i_nOptionIndex][nRange] == "1") szSubValue += "1,";
            else szSubValue += ",";
         }
         if ((i_nOptionIndex == EH_FROM) || (i_nOptionIndex == EH_TO)){
            szTemp = M_astrExceptionHLSetting[nMeasure][i_nOptionIndex][nRange];
            if (szTemp != '') szSubValue += szTemp.toLowerCase() + ",";
            else szSubValue +=",";
         }
         if ((i_nOptionIndex == EH_CELLCOLOR) || (i_nOptionIndex == EH_TEXTCOLOR)) {
            szSubValue += M_astrExceptionHLSetting[nMeasure][i_nOptionIndex][nRange] + ",";
         }
      }
      szValue += szSubValue.substring(0,szSubValue.length-1) + ";";
   }
   szValue = szValue.substring(0, szValue.length-1);
   i_objHiddenField.value = szValue;
}

//--------------------------------------------------------------
function SubmitExceptionHighlightingOptions()
{
   var nMeasure;
   var szValue = "";
   
   WriteExceptionHighlightingSetting(document.aspnetForm.ehSelect, EH_SELECT);
   WriteExceptionHighlightingSetting(document.aspnetForm.ehFrom, EH_FROM);
   WriteExceptionHighlightingSetting(document.aspnetForm.ehTo, EH_TO);
   WriteExceptionHighlightingSetting(document.aspnetForm.ehCellColor, EH_CELLCOLOR);
   WriteExceptionHighlightingSetting(document.aspnetForm.ehTextColor, EH_TEXTCOLOR);
   
   // write the measures
   for (nMeasure = 0; nMeasure < M_astrMeasures.length; nMeasure++){
      szValue += nMeasure.toString() + ",";
   }
   szValue = szValue.substring(0, szValue.length-1);
   document.aspnetForm.ehMeasures.value = szValue;
   executeWait(document.aspnetForm);
}

//-----------------------------------------------------------------------------
function ValidateRanges()
{
   var bValid;
   var cChar;
   var nMeasure;
   var objMeasure = document.getElementById("ehMeasure");
   var fromObj;
   var nRange;

   for (nMeasure = 0; nMeasure < M_astrMeasures.length; nMeasure++) {
      for (nRange = 0; nRange < EH_RANGE_COUNT; nRange++) {
         if (M_astrExceptionHLSetting[nMeasure][EH_SELECT][nRange] == "1") {
            szFrom = M_astrExceptionHLSetting[nMeasure][EH_FROM][nRange];
            szTo = M_astrExceptionHLSetting[nMeasure][EH_TO][nRange];
            if (szFrom.toLowerCase() != 'min') {
               bValid = true;
               cChar = szFrom.charAt(0);
               if (cChar == '0' && szFrom.length > 1) {
                  cChar = szFrom.charAt(1);
                  if (cChar < '0' || cChar > '9') {
                     bValid = GPattern.test(szFrom);
                  }
                  else {
                     bValid = false;
                  }
               }
               else if (!GPattern.test(szFrom)) {
                  bValid = false;
               }
               if (!bValid) {
                  alert(resRange + " " + (nRange+1).toString() + " " + resInvalidRange 
                     + " " + resInvalidRangeFromValue);
                  objMeasure.options.selectedIndex= nMeasure;
                  fromObj = document.getElementById("ehFrom" + nRange.toString());
                  if (fromObj) {
                     fromObj.focus();
                  }
                  return false;
               }
            }            
            if (szTo.toLowerCase() != 'max') {
               bValid = true;
               cChar = szTo.charAt(0);
               if (cChar == '0' && szTo.length > 1) {
                  cChar = szTo.charAt(1);
                  if (cChar < '0' || cChar > '9') {
                     bValid = GPattern.test(szTo);
                  }
                  else {
                     bValid = false;
                  }
               }
               else if (!GPattern.test(szTo)) {
                  bValid = false;
               }
               if(!bValid) {
                  alert(resRange + " " + (nRange+1).toString() + " " + resInvalidRange 
                     + " " + resInvalidRangeToValue);
                  objMeasure.options.selectedIndex= nMeasure;
                  fromObj = document.getElementById("ehTo" + nRange.toString());
                  if (fromObj) {
                     fromObj.focus();
                  }
                  return false;
               }
            }
            if (szFrom != 'min' && szTo != 'max') {
               if(parseFloat(szFrom) > parseFloat(szTo)) {
                  alert(resRange + " " + (nRange+1).toString() + " " + resInvalidRange + " " + resInvalidRangeBound);
                  fromObj = document.getElementById("ehFrom" + nRange.toString());
                  if (fromObj) {
                     fromObj.focus();
                  }
                  return false;
               }
            }
         }
      }
   }
   return true;
}

//-----------------------------------------------------------------------------
function OnExceptionHighlightingOptions()
{
   if (!ValidateRanges()) return;
   SubmitExceptionHighlightingOptions();
}

//-----------------------------------------------------------------------------
function SubmitExceptionHighlighting(e)
{
   var key = GetKeyCode(e);
   if ( key ==13) {
      document.aspnetForm.ehGo.focus(); // this forces the onchange event for range values
      OnExceptionHighlightingOptions();
      ResetSubmit(e);
   }
}
