//switches visibility of table based on dropdown menu
function switchGroup(groupSwitch){
    if(groupSwitch){
        mylength = groupSwitch.options.length;
        for(i=0;i<mylength;i++){
            document.getElementById(groupSwitch.options[i].value).style.display = 'none';
        }
        document.getElementById(groupSwitch.options[groupSwitch.selectedIndex].value).style.display = 'block';
    }
}

// Form validation script to check dates
function validateForm(theForm)
{
    if (theForm.EVENT_START_DAY.value == "ANY" && theForm.EVENT_START_MONTH.value == "ANY" && theForm.EVENT_START_YEAR.value == "ANY")
    {
        //then we're ok
    }else{
        //then one of the fields has changed, and we need to initialize the other fields
        changed = false;
        if(theForm.EVENT_START_DAY.value == "ANY"){
            theForm.EVENT_START_DAY.value = 1;
            changed = true;
        }
        if(theForm.EVENT_START_MONTH.value == "ANY"){
            theForm.EVENT_START_MONTH.value = 1;
            changed = true;
        }
        if(theForm.EVENT_START_YEAR.value == "ANY"){
            theForm.EVENT_START_YEAR.value = 2003;
            changed = true;
        }
        if(changed == true){
            //2alert("Changed Start Date to :"+theForm.EVENT_START_DAY.value+" / " + theForm.EVENT_START_MONTH.value + " / " + theForm.EVENT_START_YEAR.value );
        }
    }
    if (theForm.EVENT_END_DAY.value == "ANY" && theForm.EVENT_END_MONTH.value == "ANY" && theForm.EVENT_END_YEAR.value == "ANY")
    {
        //then we're ok
    }else{
        //then one of the fields has changed, and we need to initialize the other fields
        if(theForm.EVENT_END_DAY.value == "ANY"){
            theForm.EVENT_END_DAY.value = 31;
            changed = true;
        }
        if(theForm.EVENT_END_MONTH.value == "ANY"){
            theForm.EVENT_END_MONTH.value = 12;
            changed = true;
        }
        if(theForm.EVENT_END_YEAR.value == "ANY"){
            theForm.EVENT_END_YEAR.value = 2008;
            changed = true;
        }
        if(changed == true){
            //alert("Changed End Date to :"+theForm.EVENT_END_DAY.value+" / " + theForm.EVENT_END_MONTH.value + " / " + theForm.EVENT_END_YEAR.value );
        }
    }
    
    return true;
    
}

function toggleSelectAll(combo_name, string_select, string_unselect)
{
    
    var select_all_link = document.getElementById('select_all_link');
    var combo = document.getElementById(combo_name);//get the select

    var to_select = true;
    var select_link_new_caption;//the new "Select All" link caption will be here
    
    if (select_all_link.unselectAll == true)//this is a new attribute that is dynamically added
    {
        //we now want to select all options
        to_select = false;
        select_all_link.unselectAll = false;
        select_link_new_caption = string_select;
    }
    else
    {
        //we now want to unselect all options
        select_all_link.unselectAll = true;
        select_link_new_caption = string_unselect;
    }

    select_all_link.innerText = select_link_new_caption;//change the caption of the select all link
    SelectAll(combo, to_select);
}

//select is true for selecting all, false for unselecting all
function SelectAll(combo,select)
{
    for (var i=0;i<combo.options.length;i++)
    {
        combo.options[i].selected=select;
    }
}



// Global objects to keep track of DynamicOptionList objects created on the page
var dynamicOptionListCount=0;
var dynamicOptionListObjects = new Array();

// Init call to setup lists after page load. One call to this function sets up all lists.
function initDynamicOptionLists() {
    // init each DynamicOptionList object
    for (var i=0; i<dynamicOptionListObjects.length; i++) {
        var dol = dynamicOptionListObjects[i];

        // Find the form associated with this list
        if (dol.formName!=null) { 
            dol.form = document.forms[dol.formName];
        }
        else if (dol.formIndex!=null) {
            dol.form = document.forms[dol.formIndex];
        }
        else {
            // Form wasn't set manually, so go find it!
            // Search for the first form element name in the lists
            var name = dol.fieldNames[0][0];
            for (var f=0; f<document.forms.length; f++) {
                if (typeof(document.forms[f][name])!="undefined") {
                    dol.form = document.forms[f];
                    break;
                }
            }
            if (dol.form==null) {
                alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted"); return;
            }
        }

        // Form is found, now set the onchange attributes of each dependent select box
        for (var j=0; j<dol.fieldNames.length; j++) {
            // For each set of field names...
            for (var k=0; k<dol.fieldNames[j].length-1; k++) {
                // For each field in the set...
                var selObj = dol.form[dol.fieldNames[j][k]];
                if (typeof(selObj)=="undefined") { alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted"); return; }
                // Map the HTML options in the first select into the options we created
                if (k==0) {
                    if (selObj.options!=null) {
                        for (l=0; l<selObj.options.length; l++) {
                            var sopt = selObj.options[l];
                            var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);
                            if (m!=null) {
                                var reselectForNN6 = sopt.selected;
                                var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);
                                m2.selected = sopt.selected; // For some reason I need to do this to make NN4 happy
                                m2.defaultSelected = sopt.defaultSelected;
                                m2.DOLOption = m;
                                selObj.options[l] = m2;
                                selObj.options[l].selected = reselectForNN6; // Reselect this option for NN6 to be happy. Yuck.
                            }
                        }
                    }
                }
                if (selObj.onchange==null) {
                    // We only modify the onChange attribute if it's empty! Otherwise do it yourself in your source!
                    selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");
                }
            }
        }
    }
    // Set the preselectd options on page load 
    resetDynamicOptionLists();
}

// This function populates lists with the preselected values. 
// It's pulled out into a separate function so it can be hooked into a 'reset' button on a form
// Optionally passed a form object which should be the only form reset
function resetDynamicOptionLists(theform) {
    // reset each DynamicOptionList object
    for (var i=0; i<dynamicOptionListObjects.length; i++) {
        var dol = dynamicOptionListObjects[i];
        if (typeof(theform)=="undefined" || theform==null || theform==dol.form) {
            for (var j=0; j<dol.fieldNames.length; j++) {
                dol.change(dol.form[dol.fieldNames[j][0]],true); // Second argument says to use preselected values rather than default values
            }
        }
    }
}

// An object to represent an Option() but just for data-holding
function DOLOption(text,value,defaultSelected,selected) {
    this.text = text;
    this.value = value;
    this.defaultSelected = defaultSelected;
    this.selected = selected;
    this.options = new Array(); // To hold sub-options
    return this;
}

// DynamicOptionList CONSTRUCTOR
function DynamicOptionList() {
    this.form = null;// The form this list belongs to
    this.options = new Array();// Holds the options of dependent lists
    this.longestString = new Array();// Longest string that is currently a potential option (for Netscape)
    this.numberOfOptions = new Array();// The total number of options that might be displayed, to build dummy options (for Netscape)
    this.currentNode = null;// The current node that has been selected with forValue() or forText()
    this.currentField = null;// The current field that is selected to be used for setValue()
    this.currentNodeDepth = 0;// How far down the tree the currentNode is
    this.fieldNames = new Array();// Lists of dependent fields which use this object
    this.formIndex = null;// The index of the form to associate with this list
    this.formName = null;// The name of the form to associate with this list
    this.fieldListIndexes = new Object();// Hold the field lists index where fields exist
    this.fieldIndexes = new Object();// Hold the index within the list where fields exist
    this.selectFirstOption = true;// Whether or not to select the first option by default if no options are default or preselected, otherwise set the selectedIndex = -1
    this.numberOfOptions = new Array();// Store the max number of options for a given option list
    this.longestString = new Array();// Store the longest possible string 
    this.values = new Object(); // Will hold the preselected values for fields, by field name
    
    // Method mappings
    this.forValue = DOL_forValue;
    this.forText = DOL_forText;
    this.forField = DOL_forField;
    this.forX = DOL_forX;
    this.addOptions = DOL_addOptions;
    this.addOptionsTextValue = DOL_addOptionsTextValue;
    this.setDefaultOptions = DOL_setDefaultOptions;
    this.setValues = DOL_setValues;
    this.setValue = DOL_setValues;
    this.setFormIndex = DOL_setFormIndex;
    this.setFormName = DOL_setFormName;
    this.printOptions = DOL_printOptions;
    this.addDependentFields = DOL_addDependentFields;
    this.change = DOL_change;
    this.child = DOL_child;
    this.selectChildOptions = DOL_selectChildOptions;
    this.populateChild = DOL_populateChild;
    this.change = DOL_change;
    this.addNewOptionToList = DOL_addNewOptionToList;
    this.findMatchingOptionInArray = DOL_findMatchingOptionInArray;

    // Optionally pass in the dependent field names
    if (arguments.length > 0) {
        // Process arguments and add dependency groups
        for (var i=0; i<arguments.length; i++) {
            this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
            this.fieldIndexes[arguments[i].toString()] = i;
        }
        this.fieldNames[this.fieldNames.length] = arguments;
    }
    
    // Add this object to the global array of dynamicoptionlist objects
    this.index = window.dynamicOptionListCount++;
    window["dynamicOptionListObjects"][this.index] = this;
}

// Given an array of Option objects, search for an existing option that matches value, text, or both
function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired) {
    if (a==null || typeof(a)=="undefined") { return null; }
    var value_match = null; // Whether or not a value has been matched
    var text_match = null; // Whether or not a text has been matched
    for (var i=0; i<a.length; i++) {
        var opt = a[i];
        // If both value and text match, return it right away
        if (opt.value==value && opt.text==text) { return opt; }
        if (!exactMatchRequired) {
            // If value matches, store it until we complete scanning the list
            if (value_match==null && value!=null && opt.value==value) {
                value_match = opt;
            }
            // If text matches, store it for later
            if (text_match==null && text!=null && opt.text==text) {
                text_match = opt;
            }
        }
    }
    return (value_match!=null)?value_match:text_match;
}

// Util function used by forValue and forText
function DOL_forX(s,type) {
    if (this.currentNode==null) { this.currentNodeDepth=0; }
    var useNode = (this.currentNode==null)?this:this.currentNode;
    var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false);
    if (o==null) {
        o = new DOLOption(null,null,false,false);
        o[type] = s;
        useNode.options[useNode.options.length] = o;
    }
    this.currentNode = o;
    this.currentNodeDepth++;
    return this;
}

// Set the portion of the list structure that is to be used by a later operation like addOptions
function DOL_forValue(s) { return this.forX(s,"value"); }

// Set the portion of the list structure that is to be used by a later operation like addOptions
function DOL_forText(s) { return this.forX(s,"text"); }

// Set the field to be used for setValue() calls
function DOL_forField(f) { this.currentField = f; return this; }

// Create and add an option to a list, avoiding duplicates
function DOL_addNewOptionToList(a, text, value, defaultSelected) {
    var o = new DOLOption(text,value,defaultSelected,false);
    // Add the option to the array
    if (a==null) { a = new Array(); }
    for (var i=0; i<a.length; i++) {
        if (a[i].text==o.text && a[i].value==o.value) {
            if (o.selected) { 
                a[i].selected=true;
            }
            if (o.defaultSelected) {
                a[i].defaultSelected = true;
            }
            return a;
        }
    }
    a[a.length] = o;
}

// Add sub-options to the currently-selected node, with the same text and value for each option
function DOL_addOptions() {
    if (this.currentNode==null) { this.currentNode = this; }
    if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
    for (var i=0; i<arguments.length; i++) {
        var text = arguments[i];
        this.addNewOptionToList(this.currentNode.options,text,text,false);
        if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
            this.numberOfOptions[this.currentNodeDepth]=0;
        }
        if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
            this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
        }
        if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
            this.longestString[this.currentNodeDepth] = text;
        }
    }
    this.currentNode = null;
    this.currentNodeDepth = 0;
}

// Add sub-options to the currently-selected node, specifying separate text and values for each option
function DOL_addOptionsTextValue() {
    if (this.currentNode==null) { this.currentNode = this; }
    if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
    for (var i=0; i<arguments.length; i++) {
        var text = arguments[i++];
        var value = arguments[i];
        this.addNewOptionToList(this.currentNode.options,text,value,false);
        if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
            this.numberOfOptions[this.currentNodeDepth]=0;
        }
        if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
            this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
        }
        if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
            this.longestString[this.currentNodeDepth] = text;
        }
    }
    this.currentNode = null;
    this.currentNodeDepth = 0;
}

// Find the first dependent list of a select box
// If it's the last list in a chain, return null because there are no children
function DOL_child(obj) {
    var listIndex = this.fieldListIndexes[obj.name];
    var index = this.fieldIndexes[obj.name];
    if (index < (this.fieldNames[listIndex].length-1)) {
        return this.form[this.fieldNames[listIndex][index+1]];
    }
    return null;
}

// Set the options which should be selected by default for a certain value in the parent
function DOL_setDefaultOptions() {
    if (this.currentNode==null) { this.currentNode = this; }
    for (var i=0; i<arguments.length; i++) {
        var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false);
        if (o!=null) {
            o.defaultSelected = true;
        }
    }
    this.currentNode = null;
}

// Set the options which should be selected when the page loads. This is different than the default value and ONLY applies when the page LOADS
function DOL_setValues() {
    if (this.currentField==null) { 
        alert("Can't call setValues() without using forField() first!");
        return;
    }
    if (typeof(this.values[this.currentField])=="undefined") {
        this.values[this.currentField] = new Object();
    }
    for (var i=0; i<arguments.length; i++) {
        this.values[this.currentField][arguments[i]] = true;
    }
    this.currentField = null;
}

// Manually set the form for the object using an index
function DOL_setFormIndex(i) {
    this.formIndex = i;
}

// Manually set the form for the object using a form name
function DOL_setFormName(n) {
    this.formName = n;
}

// Print blank <option> objects for Netscape4, since it refuses to grow or shrink select boxes for new options
function DOL_printOptions(name) {
    // Only need to write out "dummy" options for Netscape4
    if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) <= 4)){
        var index = this.fieldIndexes[name];
        var ret = "";
        if (typeof(this.numberOfOptions[index])!="undefined") {
            for (var i=0; i<this.numberOfOptions[index]; i++) { 
                ret += "<OPTION>";
            }
        }
        ret += "<OPTION>";
        if (typeof(this.longestString[index])!="undefined") {
            for (var i=0; i<this.longestString[index].length; i++) {
                ret += "_";
            }
        }
        document.writeln(ret);
    }
}

// Add a list of field names which use this option-mapping object.
// A single mapping object may be used by multiple sets of fields
function DOL_addDependentFields() {
    for (var i=0; i<arguments.length; i++) {
        this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
        this.fieldIndexes[arguments[i].toString()] = i;
    }
    this.fieldNames[this.fieldNames.length] = arguments;
}

// Called when a parent select box is changed. It populates its direct child, then calls change on the child object to continue the population.
function DOL_change(obj, usePreselected) {
    if (usePreselected==null || typeof(usePreselected)=="undefined") { usePreselected = false; }
    var changedListIndex = this.fieldListIndexes[obj.name];
    var changedIndex = this.fieldIndexes[obj.name];
    var child = this.child(obj);
    if (child == null) { return; } // No child, no need to continue
    if (obj.type == "select-one") {
        // Treat single-select differently so we don't have to scan the entire select list, which could potentially speed things up
        if (child.options!=null) {
            child.options.length=0; // Erase all the options from the child so we can re-populate
        }
        if (obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0) {
            var o = obj.options[obj.selectedIndex];
            this.populateChild(o.DOLOption,child,usePreselected);
            this.selectChildOptions(child,usePreselected);
        }
    }
    else if (obj.type == "select-multiple") {
        // For each selected value in the parent, find the options to fill in for this list
        // Loop through the child list and keep track of options that are currently selected
        var currentlySelectedOptions = new Array();
        if (!usePreselected) {
            for (var i=0; i<child.options.length; i++) {
                var co = child.options[i];
                if (co.selected) {
                    this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected);
                }
            }
        }
        child.options.length=0;
        if (obj.options!=null) {
            var obj_o = obj.options;
            // For each selected option in the parent...
            for (var i=0; i<obj_o.length; i++) {
                if (obj_o[i].selected) {
                    // if option is selected, add its children to the list
                    this.populateChild(obj_o[i].DOLOption,child,usePreselected);
                }
            }
            // Now go through and re-select any options which were selected before
            var atLeastOneSelected = false;
            if (!usePreselected) {
                for (var i=0; i<child.options.length; i++) {
                    var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true);
                    if (m!=null) {
                        child.options[i].selected = true;
                        atLeastOneSelected = true;
                    }
                }
            }
            if (!atLeastOneSelected) {	
                this.selectChildOptions(child,usePreselected);
            }
        }
    }
    // Change all the way down the chain
    this.change(child,usePreselected);
}
function DOL_populateChild(dolOption,childSelectObj,usePreselected) {
    // If this opton has sub-options, populate the child list with them
    if (dolOption!=null && dolOption.options!=null) {
        for (var j=0; j<dolOption.options.length; j++) {
            var srcOpt = dolOption.options[j];
            if (childSelectObj.options==null) { childSelectObj.options = new Array(); }
            // Put option into select list
            var duplicate = false;
            var preSelectedExists = false;
            for (var k=0; k<childSelectObj.options.length; k++) {
                var csi = childSelectObj.options[k];
                if (csi.text==srcOpt.text && csi.value==srcOpt.value) {
                    duplicate = true;
                    break;
                }
            }
            if (!duplicate) {
                var newopt = new Option(srcOpt.text, srcOpt.value, false, false);
                newopt.selected = false; // Again, we have to do these two statements for NN4 to work
                newopt.defaultSelected = false;
                newopt.DOLOption = srcOpt;
                childSelectObj.options[childSelectObj.options.length] = newopt;
            }
        }
    }
}

// Once a child select is populated, go back over it to select options which should be selected
function DOL_selectChildOptions(obj,usePreselected) {
    // Look to see if any options are preselected=true. If so, then set then selected if usePreselected=true, otherwise set defaults
    var values = this.values[obj.name];
    var preselectedExists = false;
    if (usePreselected && values!=null && typeof(values)!="undefined") {
        for (var i=0; i<obj.options.length; i++) {
            var v = obj.options[i].value;
            if (v!=null && values[v]!=null && typeof(values[v])!="undefined") {
                preselectedExists = true;
                break;
            }
        }
    }
    // Go back over all the options to do the selection
    var atLeastOneSelected = false;
    for (var i=0; i<obj.options.length; i++) {
        var o = obj.options[i];
        if (preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined") {
            o.selected = true;
            atLeastOneSelected = true;
        }
        else if (!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected) {
            o.selected = true;
            atLeastOneSelected = true;
        }
        else {
            o.selected = false;
        }
    }
    // If nothing else was selected, select the first one by default
    if (this.selectFirstOption && !atLeastOneSelected && obj.options.length>0) {
        if(obj.name=="CN[]"){
            for (var i=0; i<obj.options.length; i++) {
                obj.options[i].selected = true;
            }
        }else{
            obj.options[0].selected = true;
        }
    }
    else if (!atLeastOneSelected &&  obj.type=="select-one") {
        obj.selectedIndex = -1;
    }
}

function ChangeCurrentProfile(selectedProfile)
{
    document.forms.Input.PROFILE.value = selectedProfile;
    
    var currentURL = document.location.href;
    if (currentURL.indexOf("index.asp") >= 0)
        document.location = 'index.asp?PROFILE=' + selectedProfile;
}

function ChangeCurrentConfigProfile(selectedProfile,referral)
{
    document.forms.Input.PROFILE.value = selectedProfile;
    
    var currentURL = document.location.href;
    if (currentURL.indexOf("eventsentry_config.asp") >= 0)
        document.location = 'eventsentry_config.asp?PROFILE=' + selectedProfile + '&EditProfile=Edit+Selected+Profile&refer=' + referral;
}

function ChangeCurrentComputer(selectedComputer, selectedProfile)
{
    Element.show("Loading");
    document.forms.Input.PROFILE.value = selectedProfile;
    
    var currentURL = document.location.href;
    document.location = 'eventsentry_computer_overview.asp?PROFILE=' + selectedProfile + '&COMPUTER=' + selectedComputer;
}

function HeaderLoadPage(myPage)
{
    myProfile = document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value;
    
    myURL = myPage;
    if (myPage.indexOf("?") >= 0) {
        myURL = myPage + '&';
    }
    else {
        myURL = myPage + '?';
    }
    
    myURL = myURL + 'PROFILE=' + myProfile;
    
    document.location = myURL;
}

// Opens up the event details in its own window
function SED(EventNumber, EventID, EventLog, EventSource, EventComputer, EventTime)
{
    Url = 'eventsentry_db_detail.asp?PROFILE=' + document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value;
    Url = Url + '&eventnumber=' + EventNumber + '&eventid=' + EventID + '&eventlog=' + EventLog + '&eventsource=' + EventSource + '&eventcomputer=' + EventComputer + '&eventtime=' + EventTime;
    EventWindow = window.open(Url, 'EventDetails','width=600,height=675,scrollbars=1,menubar=0'); 
}

// Opens up Nessus details in its own window
function SND(myComputer, myPort, myID, myTime)
{
    Url = 'eventsentry_nessus_detail.asp?PROFILE=' + document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value;
    Url = Url + '&COMPUTER=' + myComputer + '&PORT=' + myPort + '&ID=' + myID + '&RECORDDATE=' + myTime;
    EventWindow = window.open(Url, 'NessusDetails','width=600,height=675,scrollbars=1,menubar=0'); 
}

function ManageLocations()
{
    Url = 'eventsentry_location_mapping.asp?PROFILE=' + document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value;
    LocationWindow = window.open(Url, 'LocationMapping', 'width=500,height=355');
}

function SaveSearch(QString,page)
{
    Url = 'eventsentry_reports_standard.asp?QSTRING=' + QString + '&page='+page+'&PROFILE=' +document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value;
    Window = window.open(Url, 'SaveSearch', 'width=450,height=400');
} 

function UpdateSearch(QString, reportname, comment)
{
    Url = 'eventsentry_reports_standard.asp?QSTRING=' + QString + '&PROFILE=' +document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value + '&searchname=' + reportname + '&comment=' + comment;
    Window = window.open(Url, 'SaveSearch', 'width=450,height=400');
} 

function UpdateCurrent(QString, reportname, comment)
{
    Url = 'eventsentry_reports_standard.asp?QSTRING=' + QString + '&PROFILE=' +document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value + '&searchname=' + reportname + '&comment=' + comment + '&UpdateCurrent=1';
    Window = window.open(Url, 'SaveSearch', 'width=450,height=400');
} 

function ProcessLookup(Process)
{
    URL = 'http://www.fileresearchcenter.com/search.html?searchitem=' + Process + '&search=Search+Now';
    FRCWindow = window.open(URL, 'ProcessLookup', 'width=800,scrollbars=1,resizeable=1,location=1,menubar=1,toolbar=1,');
}

function timeChange()
{
    myForm = document.forms.Input;
    
        
    if (myForm.EVENT_START_HOUR.selectedIndex != 0)
    {	
        if (myForm.EVENT_START_MIN.selectedIndex == 0)
            myForm.EVENT_START_MIN.selectedIndex = 1;
        if (myForm.EVENT_START_SEC.selectedIndex == 0)
            myForm.EVENT_START_SEC.selectedIndex = 1;

        if (myForm.EVENT_END_HOUR.selectedIndex == 0)
            myForm.EVENT_END_HOUR.selectedIndex = myForm.EVENT_START_HOUR.selectedIndex + 1; 

        if (myForm.EVENT_END_MIN.selectedIndex == 0)
            myForm.EVENT_END_MIN.selectedIndex = 1;
        if (myForm.EVENT_END_SEC.selectedIndex == 0)
            myForm.EVENT_END_SEC.selectedIndex = 1;
    }	
}

function dateChange()
{
    myForm = document.forms.Input;
    
    if (myForm.EVENT_END_DAY.selectedIndex == 0)
        myForm.EVENT_END_DAY.selectedIndex = myForm.EVENT_START_DAY.selectedIndex ;

    if (myForm.EVENT_END_MONTH.selectedIndex == 0)
        myForm.EVENT_END_MONTH.selectedIndex = myForm.EVENT_START_MONTH.selectedIndex ;
    
    if (myForm.EVENT_END_YEAR.selectedIndex == 0)
        myForm.EVENT_END_YEAR.selectedIndex = myForm.EVENT_START_YEAR.selectedIndex ;
}

function CustomExecute(searchname, id)
{
    Url = 'eventsentry_db.asp?PROFILE=' + document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value + '&REPORTTYPE=Custom&NAME=' + searchname + '&ID=' + id;
    location.href = Url
} 

function EditSearchCustom(id, searchName)
{
    Url = 'eventsentry_reports_custom.asp?ID=' + id + '&SEARCHNAME=' + searchName + '&PROFILE=' +document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value;
    location.href = Url;
}

function LabelSelectElement(myTag)
{
    if (myTag.selectedIndex > 0 ) {
        myTag.className = "FormSelected";
    }
    else {
        myTag.className = "Form";
    }
}

function LabelInputElement(myTag)
{
    if (myTag.value == "" ) {
        myTag.className = "Form";
    }
    else {
        myTag.className = "FormSelected";
    }
}

function ShowMotionChart(myDate,myComputer,myLocation)
{
    myURL = 'eventsentry_environment_motion.asp?PROFILE=' + document.forms.PROFILES.PROFILE[document.forms.PROFILES.PROFILE.selectedIndex].value + '&DETAILEDMOTION=CONFIRMED&searchbutton=Enter&MyDate=' + myDate + '&COMPUTERNAME=' + myComputer + '&LOCATION=' + myLocation ;
    Window = window.open(myURL, 'Charts', 'height=440,width=900,scrollbars=0,resizeable=0,location=0,menubar=0,toolbar=0,');	
}

function PrintThis(QString)
{
    myURL = 'eventsentry_db.asp?' + QString +'&RESULTTYPE=PRINT';
    Window = window.open(myURL, 'PrintPreview', 'height=720,width=540,scrollbars=0,resizeable=0,location=0,menubar=0,toolbar=0,');
}

function resetForm()
{
    var myForm = document.forms.Input
    myForm.reset()
    for (var i = 0; i < myForm.elements.length; i++) 
    {
        var el = myForm.elements[i];
        if (el.id == "mySelect" || el.id == "calendar" || el.id == "sysinfo" || el.id == "Computer" || el.id == "ID" || el.id == "Source" || el.id == "Category" || el.id == "Username" || el.id == "Group" || el.id == "Filter" || el.id == "Type" || el.id == "Domain" || el.id == "domain" || el.id == "Filename" || el.id == "Filepath" || el.id == "LogonID" || el.id == "DurationType" || el.id == "Document" || el.id == "Printer" || el.id == "PagesType" || el.id == "SizeType"|| el.id == "computer" || el.id == "counter" || el.id == "instance" || el.id == "Action" || el.id == "OldFileSizeType" || el.id == "NewFileSizeType" || el.id == "Service" || el.id == "StartupOld" || el.id == "StartupNew" || el.id == "applications" || el.id == "Publisher" || el.id == "Status" || el.id == "Port" || el.id == "Plugin" || el.id == "CVSS" || el.id == "CVSSType" || el.id == "Facility" || el.id == "Client" || el.id == "TargetAccount" || el.id == "TargetDomain" || el.id == "CallerDomain" || el.id == "TargetAccount" || el.id == "CallerUser" || el.id == "Details" || el.id == "AccountGroup" || el.id == "MemberAccountID" || el.id == "MemberName" || el.id == "SourceComputer" || el.id == "GroupType" || el.id == "GroupScope" || el.id == "ComputerType" || el.id == "Caller" || el.id == "TargetAccountID" || el.id == "EVENT_END_YEAR" || el.id == "EVENT_START_YEAR" || el.id == "EVENT_START_HOUR" || el.id == "EVENT_END_HOUR" || el.id == "Protocol" || el.id == "Authentication_Type" || el.id == "Failure_Reason" || el.id == "Logon_Type" || el.id == "Logon_Process" || el.id == "TrustType" || el.id == "TrustDirection" || el.id == "SIDFiltering" || el.id == "Policy" || el.id == "Operation" || el.id == "LogonRightShort" || el.id == "LogonRightLong" || el.id == "ResultsCondition" || el.id == "Results" || el.id == "ViewTimeCondition" || el.id == "ViewTime" || el.id == "LoadTimeCondition" || el.id == "LoadTime" || el.id == "Report" || el.id == "Package" || el.id == "Event_Log" || el.id == "Event_Source" || el.id == "Filtername" || el.id == "Recipients" || el.id == "TerminalServer" || el.id == "ServerCore" || el.id == "VM" || el.id == "Bit64" || el.id == "HyperV" || el.id == "CallerAccountID" || el.id == "CallerAccountSID" || el.id == "OperationType" || el.id == "TargetDomainID" || el.id == "OrderBy2" || el.id == "DurationScale" || el.id == "SizeScale" || el.id == "ValueCondition" || el.id == "user" || el.id == "StatusOld" || el.id == "StatusNew" || el.id == "TargetUser" || el.id == "CallerUser" || el.id == "SuccessFailure"  || el.id == "FilenamePathInput" || el.id == "Email" || el.id == "Files_Condition" || el.id == "Folder_Conditions" || el.id == "Logcial_Conditions" || el.id == "Physical_Conditions" || el.id == "Logical_Type" || el.id == "Physical_Type")
        {
            el.className="Form";
            el.selectedIndex = 0;
        }
        else if (el.className == "checkbox")
        {
            el.className="Form";
            el.checked = false;
        }
        else if (el.id == "OrderBy")
        {
            el.className="FormSelected";
            el.selectedIndex = 1;
        }	
        else if (el.id == "myText" || el.id == "PID" || el.id == "CPID" || el.id == "Duration" || el.id == "Size" || el.id == "Pages" || el.id == "OldFileSize" || el.id == "NewFileSize" || el.id == "EVENT_MESSAGE" || el.id == "TargetAccountSID" || el.id == "CallerAccountSID" || el.id == "CallerLogonID" || el.id == "ComputerProductType" || el.id == "TrustAttributes" || el.id == "KerberosChanges" || el.id == "EventNumber" || el.id == "Event_ID" || el.id == "VMDescription" || el.id == "ChangeDetails" || el.id == "CallerFilename" || el.id == "LogonID" || el.id == "AccessMask"  || el.id == "Files" || el.id == "Folders" || el.id == "Logical" || el.id == "Physical" || el.id == "Values" || el.id == "FilePath" || el.id == "Filename" || el.id == "ComputerText" || el.id == "CategoryText" || el.id == "SourceText" || el.id == "IDText" )
        {
            el.className="Form";
            el.value = "";
        }
    }
}

//=================================
// Begin Sorting
//=================================
var FastInit = {
    done : false,
    onload : function() {
        if (FastInit.done) return;
        FastInit.done = true;
        FastInit.actions.each(function(func) {
            func();
        })
    },
    actions : $A([]),
    addOnLoad : function() {
        for(var x = 0; x < arguments.length; x++) {
            var func = arguments[x];
            if(!func || typeof func != 'function') continue;
            FastInit.actions.push(func);
        }
    }
}

if (/WebKit|khtml/i.test(navigator.userAgent)) {
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            delete _timer;
            FastInit.onload();
        }
    }, 10);
}
if (document.addEventListener) {
    document.addEventListener('DOMContentLoaded', FastInit.onload, false);
    FastInit.legacy = false;
}



var SortableTable = {
    init : function(elm, o){
        var table = $(elm);
        if(table.tagName != "TABLE") return;
        if(!table.id) table.id = "sortable-table-" + SortableTable._count++;
        Object.extend(SortableTable.options, o || {} );
        var doscroll = (SortableTable.options.tableScroll == 'on' || (SortableTable.options.tableScroll == 'class' && table.hasClassName(SortableTable.options.tableScrollClass)));
        var sortFirst;
        var cells = SortableTable.getHeaderCells(table);
        cells.each(function(c){
            c = $(c);
            if(!doscroll) {
                Event.observe(c, 'click', SortableTable._sort.bindAsEventListener(c));
                c.addClassName(SortableTable.options.columnClass);
            }
            if(c.hasClassName(SortableTable.options.sortFirstAscendingClass) || c.hasClassName(SortableTable.options.sortFirstDecendingClass)) sortFirst = c;
        });

        if(sortFirst) {
            if(sortFirst.hasClassName(SortableTable.options.sortFirstAscendingClass)) {
                SortableTable.sort(table, sortFirst, 1);
            } else {
                okSortableTable.sort(table, sortFirst, -1);
            }
        } else { // just add row stripe classes
            var rows = SortableTable.getBodyRows(table);
            rows.each(function(r,i) {
                SortableTable.addRowClass(r,i);
            });
        }
        if(doscroll) SortableTable.initScroll(table);
    },
    initScroll : function(elm){
        var table = $(elm);
        if(table.tagName != "TABLE") return;
        table.addClassName(SortableTable.options.tableScrollClass);
        
        var w = table.getDimensions().width;
        
        table.setStyle({
            'border-spacing': '0',
            'table-layout': 'fixed',
            width: w + 'px'
        });
        
        var cells = SortableTable.getHeaderCells(table);
        cells.each(function(c,i){
            c = $(c);
            var cw = c.getDimensions().width;
            c.setStyle({width: cw + 'px'});
            $A(table.tBodies[0].rows).each(function(r){
                $(r.cells[i]).setStyle({width: cw + 'px'});
            })
        })	
        
        // Fixed Head
        var head = (table.tHead && table.tHead.rows.length > 0) ? table.tHead : table.rows[0];
        var hclone = head.cloneNode(true);
        
        var hdiv = $(document.createElement('div'));
        hdiv.id = table.id + '-head';
        table.parentNode.insertBefore(hdiv, table);
        hdiv.setStyle({
            overflow: 'hidden'
        });
        var htbl = $(document.createElement('table'));
        htbl.setStyle({
            'border-spacing': '0',
            'table-layout': 'fixed',
            width: w + 'px'
        });
        hdiv.appendChild(htbl);
        hdiv.addClassName('scroll-table-head');
        
        table.removeChild(head);
        htbl.appendChild(hclone);
        
        cells = SortableTable.getHeaderCells(htbl);
        cells.each(function(c){
            c = $(c);
            Event.observe(c, 'click', SortableTable._sortScroll.bindAsEventListener(c));
            c.addClassName(SortableTable.options.columnClass);
        });	

        // Table Body
        var cdiv = $(document.createElement('div'));
        cdiv.id = table.id + '-body';
        table.parentNode.insertBefore(cdiv, table);
        cdiv.setStyle({
            overflow: 'auto'
        });
        cdiv.appendChild(table);
        cdiv.addClassName('scroll-table-body');
        
        hdiv.scrollLeft = 0;
        cdiv.scrollLeft = 0;

        Event.observe(cdiv, 'scroll', SortableTable._scroll.bindAsEventListener(table), false);
        if(table.offsetHeight - cdiv.offsetHeight > 0){
            cdiv.setStyle({width:(cdiv.getDimensions().width + 16) + 'px'})
        }
    },
    _scroll: function(){
        $(this.id + '-head').scrollLeft  = $(this.id + '-body').scrollLeft;
    },
    _sort : function(e) {
        SortableTable.sort(null, this);
    },
    _sortScroll : function(e) {	
        var hdiv = $(this).up('div.scroll-table-head');
        var id = hdiv.id.match(/^(.*)-head$/);
        SortableTable.sort($(id[1]), this);
    },
    sort : function(table, index, order) {
        var cell;
        if(typeof index == 'number') {
            if(!table || (table.tagName && table.tagName != "TABLE")) return;
            index = Math.min(table.rows[0].cells.length, index);
            index = Math.max(1, index);
            index -= 1;
            cell = (table.tHead && table.tHead.rows.length > 0) ? $(table.tHead.rows[table.tHead.rows.length-1].cells[index]) : $(table.rows[0].cells[index]);
        } else {
            cell = $(index);
            table = table ? $(table) : table = cell.up('table');
            index = SortableTable.getCellIndex(cell)
        }
        var op = SortableTable.options;
        
        if(cell.hasClassName(op.nosortClass)) return;	
        order = order ? order : (cell.hasClassName(op.descendingClass) ? 1 : -1);

        var hcells = SortableTable.getHeaderCells(null, cell);
        $A(hcells).each(function(c,i){
            c = $(c);
            if(i == index) {
                if(order == 1) {
                    c.removeClassName(op.descendingClass);
                    c.addClassName(op.ascendingClass);
                } else {
                    c.removeClassName(op.ascendingClass);
                    c.addClassName(op.descendingClass);
                }
            } else {
                c.removeClassName(op.ascendingClass);
                c.removeClassName(op.descendingClass);
            }
        });

        var rows = SortableTable.getBodyRows(table);
        var datatype = SortableTable.getDataType(cell,index,table);
        rows.sort(function(a,b) {
            return order * SortableTable.types[datatype](SortableTable.getCellText(a.cells[index]),SortableTable.getCellText(b.cells[index]));
        });

        rows.each(function(r,i) {
            table.tBodies[0].appendChild(r);
            SortableTable.addRowClass(r,i);
        });
    },
    types : {
        number : function(a,b) {
            // This will grab the first thing that looks like a number from a string, so you can use it to order a column of various srings containing numbers.
            var calc = function(v) {
                v = parseFloat(v.replace(/^.*?([-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?).*$/,"$1"));
                return isNaN(v) ? 0 : v;
            }
            return SortableTable.compare(calc(a),calc(b));
        },
        text : function(a,b) {
            return SortableTable.compare(a ? a.toLowerCase() : '', b ? b.toLowerCase() : '');
        },
        casesensitivetext : function(a,b) {
            return SortableTable.compare(a,b);
        },
        datasize : function(a,b) {
            var calc = function(v) {
                var r = v.match(/([-+]?[\d]*\.?[\d]+([eE][-+]?[\d]+)?)\s?([k|m|g|t]?b)?/i);
                var b = r[1] ? Number(r[1]).valueOf() : 0;
                var m = r[3] ? r[3].substr(0,1).toLowerCase() : '';
                
                switch(m) {
                    case  'k':
                        return b * 1024;
                        break;
                    case  'm':
                        return b * 1024 * 1024;
                        break;
                    case  'g':
                        return b * 1024 * 1024 * 1024;
                        break;
                    case  't':
                        return b * 1024 * 1024 * 1024 * 1024;
                        break;
                }
                return b;
            }
            
            return SortableTable.compare(calc(a),calc(b));
        },
        'date-au' : function(a,b) {
            var calc = function(v) {
                var r = v.match(/^(\d{2})\/(\d{2})\/(\d{4})\s?(?:(\d{1,2})\:(\d{2})(?:\:(\d{2}))?\s?([a|p]?m?))?/i);
                var yr_num = r[3];
                var mo_num = parseInt(r[2])-1;
                var day_num = r[1];
                var hr_num = r[4] ? r[4] : 0;
                if(r[7] && r[7].toLowerCase().indexOf('p') != -1) {
                    hr_num = parseInt(r[4]) + 12;
                }
                var min_num = r[5] ? r[5] : 0;
                var sec_num = r[6] ? r[6] : 0;
                return new Date(yr_num, mo_num, day_num, hr_num, min_num, sec_num, 0).valueOf();
            }
            return SortableTable.compare(a ? calc(a) : 0, b ? calc(b) : 0);
        },
        'date-us' : function(a,b) {
            var calc = function(v) {
                v=v.substring(v.length,4);
                v=v.replace(/^\s+|\s+$/g, '');
                return new Date(v).valueOf();
            }
            return SortableTable.compare(a ? calc(a) : 0, b ? calc(b) : 0);
        },
        'date-eu' : function(a,b) {
            var calc = function(v) {
                var r = v.match(/^(\d{2})-(\d{2})-(\d{4})/);
                var yr_num = r[3];
                var mo_num = parseInt(r[2])-1;
                var day_num = r[1];
                return new Date(yr_num, mo_num, day_num).valueOf();
            }
            return SortableTable.compare(a ? calc(a) : 0, b ? calc(b) : 0);
        },
        'date-iso' : function(a,b) {
            // http://delete.me.uk/2005/03/iso8601.html ROCK!
            var calc = function(v) {
                var d = v.match(/([\d]{4})(-([\d]{2})(-([\d]{2})(T([\d]{2}):([\d]{2})(:([\d]{2})(\.([\d]+))?)?(Z|(([-+])([\d]{2}):([\d]{2})))?)?)?)?/);
            
                var offset = 0;
                var date = new Date(d[1], 0, 1);
            
                if (d[3]) { date.setMonth(d[3] - 1) ;}
                if (d[5]) { date.setDate(d[5]); }
                if (d[7]) { date.setHours(d[7]); }
                if (d[8]) { date.setMinutes(d[8]); }
                if (d[10]) { date.setSeconds(d[10]); }
                if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
                if (d[14]) {
                    offset = (Number(d[16]) * 60) + Number(d[17]);
                    offset *= ((d[15] == '-') ? 1 : -1);
                }
                offset -= date.getTimezoneOffset();
                if(offset != 0) {
                    var time = (Number(date) + (offset * 60 * 1000));
                    date.setTime(Number(time));
                }
                return date.valueOf();
            }
            return SortableTable.compare(a ? calc(a) : 0, b ? calc(b) : 0);

        },
        date : function(a,b) { // must be standard javascript date format
            if(a && b) {
                return SortableTable.compare(new Date(a),new Date(b));
            } else {
                return SortableTable.compare(a ? 1 : 0, b ? 1 : 0);
            }
            return SortableTable.compare(a ? new Date(a).valueOf() : 0, b ? new Date(b).valueOf() : 0);
        },
        time : function(a,b) {
            var d = new Date();
            var ds = d.getMonth() + "/" + d.getDate() + "/" + d.getFullYear() + " "
            return SortableTable.compare(new Date(ds + a),new Date(ds + b));
        },
        currency : function(a,b) {
            a = parseFloat(a.replace(/[^-\d\.]/g,''));
            b = parseFloat(b.replace(/[^-\d\.]/g,''));
            return SortableTable.compare(a,b);
        }
    },
    compare : function(a,b) {
        return a < b ? -1 : a == b ? 0 : 1;
    },
    detectors : $A([
        {re: /[\d]{4}-[\d]{2}-[\d]{2}(?:T[\d]{2}\:[\d]{2}(?:\:[\d]{2}(?:\.[\d]+)?)?(Z|([-+][\d]{2}:[\d]{2})?)?)?/, type : "date-iso"}, // 2005-03-26T19:51:34Z
        {re: /^sun|mon|tue|wed|thu|fri|sat\,\s\d{1,2}\sjan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec\s\d{4}(?:\s\d{2}\:\d{2}(?:\:\d{2})?(?:\sGMT(?:[+-]\d{4})?)?)?/i, type : "date"}, //Mon, 18 Dec 1995 17:28:35 GMT 
        {re: /^\d{2}-\d{2}-\d{4}/i, type : "date-eu"},
        {re: /^\d{2}\/\d{2}\/\d{4}\s?(?:\d{1,2}\:\d{2}(?:\:\d{2})?\s?[a|p]?m?)?/i, type : "date-au"},
        {re: /^\d{1,2}\:\d{2}(?:\:\d{2})?(?:\s[a|p]m)?$/i, type : "time"},
        {re: /^[$£¥€¤]/, type : "currency"}, // dollar,pound,yen,euro,generic currency symbol
        {re: /^[-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?\s?[k|m|g|t]b$/i, type : "datasize"},
        {re: /^[-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?/, type : "number"},
        {re: /^[A-Z]+$/, type : "casesensitivetext"},
        {re: /.*/, type : "text"}
    ]),
    addSortType : function(name, sortfunc) {
        SortableTable.types[name] = sortfunc;
    },
    addDetector : function(rexp, name) {
        SortableTable.detectors.unshift({re:rexp,type:name});
    },
    getBodyRows : function(table) {
        table = $(table);
        return (table.hasClassName(SortableTable.options.tableScrollClass) || table.tHead && table.tHead.rows.length > 0) ? 
                    $A(table.tBodies[0].rows) : $A(table.rows).without(table.rows[0]);
    },
    addRowClass : function(r,i) {
        r = $(r)
        r.removeClassName(SortableTable.options.rowEvenClass);
        r.removeClassName(SortableTable.options.rowOddClass);
        r.addClassName(((i+1)%2 == 0 ? SortableTable.options.rowEvenClass : SortableTable.options.rowOddClass));
    },
    getHeaderCells : function(table, cell) {
        if(!table) table = $(cell).up('table');
        return $A((table.tHead && table.tHead.rows.length > 0) ? table.tHead.rows[table.tHead.rows.length-1].cells : table.rows[0].cells);
    },
    getCellIndex : function(cell) {
        return $A(cell.parentNode.cells).indexOf(cell);
    },
    getCellText : function(cell) {
        if(!cell) return "";
        return cell.textContent ? cell.textContent : cell.innerText;
    },
    getDataType : function(cell,index,table) {
        cell = $(cell);
        var t = cell.classNames().detect(function(n){ // first look for a data type classname on the heading row cell
            return (SortableTable.types[n]) ? true : false;
        });
        if(!t) {
            var i = index ? index : SortableTable.getCellIndex(cell);
            var tbl = table ? table : cell.up('table')
            cell = tbl.tBodies[0].rows[0].cells[i]; // grab same index cell from second row to try and match data type
            t = SortableTable.detectors.detect(function(d){return d.re.test(SortableTable.getCellText(cell));})['type'];
        }
        return t;
    },
    setup : function(o) {
        Object.extend(SortableTable.options, o || {} )
         //in case the user added more types/detectors in the setup options, we read them out and then erase them
         // this is so setup can be called multiple times to inject new types/detectors
        Object.extend(SortableTable.types, SortableTable.options.types || {})
        SortableTable.options.types = {};
        if(SortableTable.options.detectors) {
            SortableTable.detectors = $A(SortableTable.options.detectors).concat(SortableTable.detectors);
            SortableTable.options.detectors = [];
        }
    },
    options : {
        autoLoad : true,
        tableSelector : ['table.sortable'],
        columnClass : 'sortcol',
        descendingClass : 'sortdesc',
        ascendingClass : 'sortasc',
        nosortClass : 'nosort',
        sortFirstAscendingClass : 'sortfirstasc',
        sortFirstDecendingClass : 'sortfirstdesc',
        rowEvenClass : 'roweven',
        rowOddClass : 'rowodd',
        tableScroll : 'class',   // off | on | class;
        tableScrollClass : 'scroll'
    },
    _count : 0,
    load : function() {
        if(SortableTable.options.autoLoad) {
            $A(SortableTable.options.tableSelector).each(function(s){
                $$(s).each(function(t) {
                    SortableTable.init(t, {tableScroll : SortableTable.options.tableScroll});
                });
            });
        }
    }
}


//=================================
// End Sorting
//=================================



function Toggle(myelement)
{
    if (document.all)
    {
        if (myelement == "Computer")
        {
            if (document.getElementById("ComputerList").currentStyle.display == "inline" )
            {
                if (document.forms.Input.COMPUTER.options[document.forms.Input.COMPUTER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.COMPUTERTEXT.value = document.forms.Input.COMPUTER.options[document.forms.Input.COMPUTER.selectedIndex].value;
                }		
                document.forms.Input.COMPUTER.selectedIndex = 0;
                document.getElementById("ComputerList").style.display="none";
                document.getElementById("ComputerField").style.display="inline";
            }
            else
            {
                document.getElementById("ComputerList").style.display="inline";
                document.forms.Input.COMPUTERTEXT.value = "";
                document.getElementById("ComputerField").style.display="none";			
            }
        }
        else if (myelement == "Client")
        {
            if (document.getElementById("ClientList").currentStyle.display == "inline" )
            {
                if (document.forms.Input.CLIENT.options[document.forms.Input.CLIENT.selectedIndex].value != "ANY")
                {
                    document.forms.Input.CLIENTTEXT.value = document.forms.Input.CLIENT.options[document.forms.Input.CLIENT.selectedIndex].value;
                }		
                document.forms.Input.CLIENT.selectedIndex = 0;
                document.getElementById("ClientList").style.display="none";
                document.getElementById("ClientField").style.display="inline";
            }
            else
            {
                document.getElementById("ClientList").style.display="inline";
                document.forms.Input.CLIENTTEXT.value = "";
                document.getElementById("ClientField").style.display="none";			
            }
        }
        else if (myelement == "Caller")
        {
            if (document.getElementById("CallerList").currentStyle.display == "inline" )
            {
                if (document.forms.Input.CALLER.options[document.forms.Input.CALLER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.CALLERTEXT.value = document.forms.Input.CALLER.options[document.forms.Input.CALLER.selectedIndex].value;
                }		
                document.forms.Input.CALLER.selectedIndex = 0;
                document.getElementById("CallerList").style.display="none";
                document.getElementById("CallerField").style.display="inline";
            }
            else
            {
                document.getElementById("CallerList").style.display="inline";
                document.forms.Input.CALLERTEXT.value = "";
                document.getElementById("CallerField").style.display="none";			
            }
        }
        else if (myelement == "Sender")
        {
            if (document.getElementById("SenderList").currentStyle.display == "inline" )
            {
                if (document.forms.Input.SENDER.options[document.forms.Input.SENDER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.SENDERTEXT.value = document.forms.Input.SENDER.options[document.forms.Input.SENDER.selectedIndex].value;
                }		
                document.forms.Input.SENDER.selectedIndex = 0;
                document.getElementById("SenderList").style.display="none";
                document.getElementById("SenderField").style.display="inline";
            }
            else
            {
                document.getElementById("SenderList").style.display="inline";
                document.forms.Input.SENDERTEXT.value = "";
                document.getElementById("SenderField").style.display="none";			
            }
        }
        else if (myelement == "Receiver")
        {
            if (document.getElementById("ReceiverList").currentStyle.display == "inline" )
            {
                if (document.forms.Input.RECEIVER.options[document.forms.Input.RECEIVER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.RECEIVERTEXT.value = document.forms.Input.RECEIVER.options[document.forms.Input.RECEIVER.selectedIndex].value;
                }		
                document.forms.Input.RECEIVER.selectedIndex = 0;
                document.getElementById("ReceiverList").style.display="none";
                document.getElementById("ReceiverField").style.display="inline";
            }
            else
            {
                document.getElementById("ReceiverList").style.display="inline";
                document.forms.Input.RECEIVERTEXT.value = "";
                document.getElementById("ReceiverField").style.display="none";			
            }
        }
        else if (myelement == "SourceComputer")
        {
            if (document.getElementById("SourceComputerList").currentStyle.display == "inline" )
            {
                if (document.forms.Input.SOURCECOMPUTER.options[document.forms.Input.SOURCECOMPUTER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.SOURCECOMPUTERTEXT.value = document.forms.Input.SOURCECOMPUTER.options[document.forms.Input.SOURCECOMPUTER.selectedIndex].value;
                }		
                document.forms.Input.SOURCECOMPUTER.selectedIndex = 0;
                document.getElementById("SourceComputerList").style.display="none";
                document.getElementById("SourceComputerField").style.display="inline";
            }
            else
            {
                document.getElementById("SourceComputerList").style.display="inline";
                document.forms.Input.SOURCECOMPUTERTEXT.value = "";
                document.getElementById("SourceComputerField").style.display="none";			
            }
        }
        else if (myelement == "ID")
        {
            if (document.getElementById("IDList").currentStyle.display == "inline")
            {
                if (document.forms.Input.EVENT_ID.options[document.forms.Input.EVENT_ID.selectedIndex].value != "ANY")
                {
                    document.forms.Input.IDTEXT.value = document.forms.Input.EVENT_ID.options[document.forms.Input.EVENT_ID.selectedIndex].value;
                }
                document.forms.Input.EVENT_ID.selectedIndex = 0;
                document.getElementById("IDList").style.display="none";
                document.getElementById("IDField").style.display="inline";
            }
            else
            {
                document.getElementById("IDList").style.display="inline";
                document.forms.Input.IDTEXT.value = "";
                document.getElementById("IDField").style.display="none";			
            }
        }		
        else if (myelement == "Application")
        {
            if (document.getElementById("ApplicationList").currentStyle.display == "inline")
            {
                if (document.forms.Input.APPLICATION.options[document.forms.Input.APPLICATION.selectedIndex].value != "ANY")
                {
                    document.forms.Input.APPLICATIONTEXT.value = document.forms.Input.APPLICATION.options[document.forms.Input.APPLICATION.selectedIndex].value;
                }
                document.forms.Input.APPLICATION.selectedIndex = 0;
                document.getElementById("ApplicationList").style.display="none";
                document.getElementById("ApplicationField").style.display="inline";
            }
            else
            {
                document.getElementById("ApplicationList").style.display="inline";
                document.forms.Input.APPLICATIONTEXT.value = "";
                document.getElementById("ApplicationField").style.display="none";			
            }
        }

        else if (myelement == "Publisher")
        {
            if (document.getElementById("PublisherList").currentStyle.display == "inline")
            {
                if (document.forms.Input.PUBLISHER.options[document.forms.Input.PUBLISHER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.PUBLISHERTEXT.value = document.forms.Input.PUBLISHER.options[document.forms.Input.PUBLISHER.selectedIndex].value;
                }
                document.forms.Input.PUBLISHER.selectedIndex = 0;
                document.getElementById("PublisherList").style.display="none";
                document.getElementById("PublisherField").style.display="inline";
                
            }
            else
            {
                document.getElementById("PublisherList").style.display="inline";
                document.forms.Input.PUBLISHERTEXT.value = "";
                document.getElementById("PublisherField").style.display="none";			
            }			
        }	
        else if (myelement == "Service")
        {
            if (document.getElementById("ServiceList").currentStyle.display == "inline")
            {
                if (document.forms.Input.SERVICE.options[document.forms.Input.SERVICE.selectedIndex].value != "ANY")
                {
                    document.forms.Input.SERVICETEXT.value = document.forms.Input.SERVICE.options[document.forms.Input.SERVICE.selectedIndex].value;
                }
                document.forms.Input.SERVICE.selectedIndex = 0;
                document.getElementById("ServiceList").style.display="none";
                document.getElementById("ServiceField").style.display="inline";
                
            }
            else
            {
                document.getElementById("ServiceList").style.display="inline";
                document.forms.Input.SERVICETEXT.value = "";
                document.getElementById("ServiceField").style.display="none";			
            }			
        }	
        else if (myelement == "Counter")
        {
            if (document.getElementById("CounterList").currentStyle.display == "inline")
            {
                if (document.forms.Input.COUNTERNAME.options[document.forms.Input.COUNTERNAME.selectedIndex].value != "ANY")
                {
                    document.forms.Input.COUNTERNAMETEXT.value = document.forms.Input.COUNTERNAME.options[document.forms.Input.COUNTERNAME.selectedIndex].value;
                }
                document.forms.Input.COUNTERNAME.selectedIndex = 0;
                document.getElementById("CounterList").style.display="none";
                document.getElementById("CounterField").style.display="inline";
                
            }
            else
            {
                document.getElementById("CounterList").style.display="inline";
                document.forms.Input.COUNTERNAMETEXT.value = "";
                document.getElementById("CounterField").style.display="none";			
            }			
        }
        else if (myelement == "Instance")
        {
            if (document.getElementById("InstanceList").currentStyle.display == "inline")
            {
                if (document.forms.Input.INSTANCE.options[document.forms.Input.INSTANCE.selectedIndex].value != "ANY")
                {
                    document.forms.Input.INSTANCETEXT.value = document.forms.Input.INSTANCE.options[document.forms.Input.INSTANCE.selectedIndex].value;
                }
                document.forms.Input.INSTANCE.selectedIndex = 0;
                document.getElementById("InstanceList").style.display="none";
                document.getElementById("InstanceField").style.display="inline";
                
            }
            else
            {
                document.getElementById("InstanceList").style.display="inline";
                document.forms.Input.INSTANCETEXT.value = "";
                document.getElementById("InstanceField").style.display="none";			
            }			
        }
        else if (myelement == "Document")
        {
            if (document.getElementById("DocumentList").currentStyle.display == "inline")
            {
                if (document.forms.Input.DOCUMENT.options[document.forms.Input.DOCUMENT.selectedIndex].value != "ANY")
                {
                    document.forms.Input.DOCUMENTTEXT.value = document.forms.Input.DOCUMENT.options[document.forms.Input.DOCUMENT.selectedIndex].value;
                }
                document.forms.Input.DOCUMENT.selectedIndex = 0;
                document.getElementById("DocumentList").style.display="none";
                document.getElementById("DocumentField").style.display="inline";
                
            }
            else
            {
                document.getElementById("DocumentList").style.display="inline";
                document.forms.Input.DOCUMENTTEXT.value = "";
                document.getElementById("DocumentField").style.display="none";			
            }			
        }
        else if (myelement == "Filename")
        {
            if (document.getElementById("FilenameList").currentStyle.display == "inline")
            {
                if (document.forms.Input.FILENAME.options[document.forms.Input.FILENAME.selectedIndex].value != "ANY")
                {
                    document.forms.Input.FILENAMETEXT.value = document.forms.Input.FILENAME.options[document.forms.Input.FILENAME.selectedIndex].value;
                }
                document.forms.Input.FILENAME.selectedIndex = 0;
                document.getElementById("FilenameList").style.display="none";
                document.getElementById("FilenameField").style.display="inline";
                
            }
            else
            {
                document.getElementById("FilenameList").style.display="inline";
                document.forms.Input.FILENAMETEXT.value = "";
                document.getElementById("FilenameField").style.display="none";			
            }			
        }
        else if (myelement == "FilenamePath")
        {
            if (document.getElementById("FilenamePathList").currentStyle.display == "inline")
            {
                if (document.forms.Input.FILENAME_PATH.options[document.forms.Input.FILENAME_PATH.selectedIndex].value != "ANY")
                {
                    document.forms.Input.FILENAME_PATHTEXT.value = document.forms.Input.FILENAME_PATH.options[document.forms.Input.FILENAME_PATH.selectedIndex].value;
                }
                document.forms.Input.FILENAME_PATH.selectedIndex = 0;
                document.getElementById("FilenamePathList").style.display="none";
                document.getElementById("FilenamePathField").style.display="inline";
                
            }
            else
            {
                document.getElementById("FilenamePathList").style.display="inline";
                document.forms.Input.FILENAME_PATHTEXT.value = "";
                document.getElementById("FilenamePathField").style.display="none";			
            }			
        }		
        else if (myelement == "Source")
        {
            if (document.getElementById("SourceList").currentStyle.display == "inline")
            {
                if (document.forms.Input.EVENT_SOURCE.options[document.forms.Input.EVENT_SOURCE.selectedIndex].value != "ANY")
                {
                    document.forms.Input.EVENT_SOURCETEXT.value = document.forms.Input.EVENT_SOURCE.options[document.forms.Input.EVENT_SOURCE.selectedIndex].value;
                }
                document.forms.Input.EVENT_SOURCE.selectedIndex = 0;
                document.getElementById("SourceList").style.display="none";
                document.getElementById("SourceField").style.display="inline";
                
            }
            else
            {
                document.getElementById("SourceList").style.display="inline";
                document.forms.Input.EVENT_SOURCETEXT.value = "";
                document.getElementById("SourceField").style.display="none";			
            }			
        }		
        else if (myelement == "Category")
        {
            if (document.getElementById("CategoryList").currentStyle.display == "inline")
            {
                if (document.forms.Input.EVENT_CATEGORY.options[document.forms.Input.EVENT_CATEGORY.selectedIndex].value != "ANY")
                {
                    document.forms.Input.EVENT_CATEGORYTEXT.value = document.forms.Input.EVENT_CATEGORY.options[document.forms.Input.EVENT_CATEGORY.selectedIndex].value;
                }
                document.forms.Input.EVENT_CATEGORY.selectedIndex = 0;
                document.getElementById("CategoryList").style.display="none";
                document.getElementById("CategoryField").style.display="inline";
                
            }
            else
            {
                document.getElementById("CategoryList").style.display="inline";
                document.forms.Input.EVENT_CATEGORYTEXT.value = "";
                document.getElementById("CategoryField").style.display="none";			
            }			
        }			
    }
    else
    {
        if (myelement == "Computer")
        {
            if (document.defaultView.getComputedStyle(document.getElementById("ComputerList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.COMPUTER.options[document.forms.Input.COMPUTER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.COMPUTERTEXT.value = document.forms.Input.COMPUTER.options[document.forms.Input.COMPUTER.selectedIndex].value;
                }		
                document.forms.Input.COMPUTER.selectedIndex = 0;
                document.getElementById("ComputerList").style.display="none";
                document.getElementById("ComputerField").style.display="inline";
            }
            else
            {
                document.getElementById("ComputerList").style.display="inline";
                document.forms.Input.COMPUTERTEXT.value = "";
                document.getElementById("ComputerField").style.display="none";			
            }		
        }
        else if (myelement == "Client")
        {
            if (document.defaultView.getComputedStyle(document.getElementById("ClientList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.CLIENT.options[document.forms.Input.CLIENT.selectedIndex].value != "ANY")
                {
                    document.forms.Input.CLIENTTEXT.value = document.forms.Input.CLIENT.options[document.forms.Input.CLIENT.selectedIndex].value;
                }		
                document.forms.Input.CLIENT.selectedIndex = 0;
                document.getElementById("ClientList").style.display="none";
                document.getElementById("ClientField").style.display="inline";
            }
            else
            {
                document.getElementById("ClientList").style.display="inline";
                document.forms.Input.CLIENTTEXT.value = "";
                document.getElementById("ClientField").style.display="none";			
            }		
        }
        else if (myelement == "Caller")
        {
            if (document.defaultView.getComputedStyle(document.getElementById("CallerList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.CALLER.options[document.forms.Input.CALLER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.CALLERTEXT.value = document.forms.Input.CALLER.options[document.forms.Input.CALLER.selectedIndex].value;
                }		
                document.forms.Input.CALLER.selectedIndex = 0;
                document.getElementById("CallerList").style.display="none";
                document.getElementById("CallerField").style.display="inline";
            }
            else
            {
                document.getElementById("CallerList").style.display="inline";
                document.forms.Input.CALLERTEXT.value = "";
                document.getElementById("CallerField").style.display="none";
            }		
        }
        else if (myelement == "Sender")
        {
            if (document.defaultView.getComputedStyle(document.getElementById("SenderList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.SENDER.options[document.forms.Input.SENDER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.SENDERTEXT.value = document.forms.Input.SENDER.options[document.forms.Input.SENDER.selectedIndex].value;
                }		
                document.forms.Input.SENDER.selectedIndex = 0;
                document.getElementById("SenderList").style.display="none";
                document.getElementById("SenderField").style.display="inline";
            }
            else
            {
                document.getElementById("SenderList").style.display="inline";
                document.forms.Input.SENDERTEXT.value = "";
                document.getElementById("SenderField").style.display="none";			
            }		
        }
        else if (myelement == "Receiver")
        {
            if (document.defaultView.getComputedStyle(document.getElementById("ReceiverList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.RECEIVER.options[document.forms.Input.RECEIVER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.RECEIVERTEXT.value = document.forms.Input.RECEIVER.options[document.forms.Input.RECEIVER.selectedIndex].value;
                }		
                document.forms.Input.RECEIVER.selectedIndex = 0;
                document.getElementById("ReceiverList").style.display="none";
                document.getElementById("ReceiverField").style.display="inline";
            }
            else
            {
                document.getElementById("ReceiverList").style.display="inline";
                document.forms.Input.RECEIVERTEXT.value = "";
                document.getElementById("ReceiverField").style.display="none";			
            }		
        }
        else if (myelement == "SourceComputer")
        {
            if (document.defaultView.getComputedStyle(document.getElementById("SourceComputerList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.SOURCECOMPUTER.options[document.forms.Input.SOURCECOMPUTER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.SOURCECOMPUTERTEXT.value = document.forms.Input.SOURCECOMPUTER.options[document.forms.Input.SOURCECOMPUTER.selectedIndex].value;
                }		
                document.forms.Input.SOURCECOMPUTER.selectedIndex = 0;
                document.getElementById("SourceComputerList").style.display="none";
                document.getElementById("SourceComputerField").style.display="inline";
            }
            else
            {
                document.getElementById("SourceComputerList").style.display="inline";
                document.forms.Input.SOURCECOMPUTERTEXT.value = "";
                document.getElementById("SourceComputerField").style.display="none";
            }		
        }
        else if (myelement == "ID") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("IDList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.EVENT_ID.options[document.forms.Input.EVENT_ID.selectedIndex].value != "ANY")
                {
                    document.forms.Input.IDTEXT.value = document.forms.Input.EVENT_ID.options[document.forms.Input.EVENT_ID.selectedIndex].value;
                }
                document.forms.Input.EVENT_ID.selectedIndex = 0;
                document.getElementById("IDList").style.display="none";
                document.getElementById("IDField").style.display="inline";
            }
            else
            {
                document.getElementById("IDList").style.display="inline";
                document.forms.Input.IDTEXT.value = "";
                document.getElementById("IDField").style.display="none";			
            }
        }		
        else if (myelement == "Application") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("ApplicationList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.APPLICATION.options[document.forms.Input.APPLICATION.selectedIndex].value != "ANY")
                {
                    document.forms.Input.APPLICATIONTEXT.value = document.forms.Input.APPLICATION.options[document.forms.Input.APPLICATION.selectedIndex].value;
                }
                document.forms.Input.APPLICATION.selectedIndex = 0;
                document.getElementById("ApplicationList").style.display="none";
                document.getElementById("ApplicationField").style.display="inline";
            }
            else
            {
                document.getElementById("ApplicationList").style.display="inline";
                document.forms.Input.APPLICATIONTEXT.value = "";
                document.getElementById("ApplicationField").style.display="none";			
            }
        }
        else if (myelement == "Publisher") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("PublisherList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.PUBLISHER.options[document.forms.Input.PUBLISHER.selectedIndex].value != "ANY")
                {
                    document.forms.Input.PUBLISHERTEXT.value = document.forms.Input.PUBLISHER.options[document.forms.Input.PUBLISHER.selectedIndex].value;
                }
                document.forms.Input.PUBLISHER.selectedIndex = 0;
                document.getElementById("PublisherList").style.display="none";
                document.getElementById("PublisherField").style.display="inline";
                
            }
            else
            {
                document.getElementById("PublisherList").style.display="inline";
                document.forms.Input.PUBLISHERTEXT.value = "";
                document.getElementById("PublisherField").style.display="none";			
            }
        }
        else if (myelement == "Service") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("ServiceList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.SERVICE.options[document.forms.Input.SERVICE.selectedIndex].value != "ANY")
                {
                    document.forms.Input.SERVICETEXT.value = document.forms.Input.SERVICE.options[document.forms.Input.SERVICE.selectedIndex].value;
                }
                document.forms.Input.SERVICE.selectedIndex = 0;
                document.getElementById("ServiceList").style.display="none";
                document.getElementById("ServiceField").style.display="inline";
                
            }
            else
            {
                document.getElementById("ServiceList").style.display="inline";
                document.forms.Input.SERVICETEXT.value = "";
                document.getElementById("ServiceField").style.display="none";			
            }			
        }
        else if (myelement == "Counter") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("CounterList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.COUNTERNAME.options[document.forms.Input.COUNTERNAME.selectedIndex].value != "ANY")
                {
                    document.forms.Input.COUNTERNAMETEXT.value = document.forms.Input.COUNTERNAME.options[document.forms.Input.COUNTERNAME.selectedIndex].value;
                }
                document.forms.Input.COUNTERNAME.selectedIndex = 0;
                document.getElementById("CounterList").style.display="none";
                document.getElementById("CounterField").style.display="inline";
                
            }
            else
            {
                document.getElementById("CounterList").style.display="inline";
                document.forms.Input.COUNTERNAMETEXT.value = "";
                document.getElementById("CounterField").style.display="none";			
            }
        }
        else if (myelement == "Instance") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("InstanceList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.INSTANCE.options[document.forms.Input.INSTANCE.selectedIndex].value != "ANY")
                {
                    document.forms.Input.INSTANCETEXT.value = document.forms.Input.INSTANCE.options[document.forms.Input.INSTANCE.selectedIndex].value;
                }
                document.forms.Input.INSTANCE.selectedIndex = 0;
                document.getElementById("InstanceList").style.display="none";
                document.getElementById("InstanceField").style.display="inline";
                
            }
            else
            {
                document.getElementById("InstanceList").style.display="inline";
                document.forms.Input.INSTANCETEXT.value = "";
                document.getElementById("InstanceField").style.display="none";			
            }
        }		
        else if (myelement == "Document") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("DocumentList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.DOCUMENT.options[document.forms.Input.DOCUMENT.selectedIndex].value != "ANY")
                {
                    document.forms.Input.DOCUMENTTEXT.value = document.forms.Input.DOCUMENT.options[document.forms.Input.DOCUMENT.selectedIndex].value;
                }
                document.forms.Input.DOCUMENT.selectedIndex = 0;
                document.getElementById("DocumentList").style.display="none";
                document.getElementById("DocumentField").style.display="inline";
                
            }
            else
            {
                document.getElementById("DocumentList").style.display="inline";
                document.forms.Input.DOCUMENTTEXT.value = "";
                document.getElementById("DocumentField").style.display="none";			
            }
        }		
        else if (myelement == "Filename") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("FilenameList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.FILENAME.options[document.forms.Input.FILENAME.selectedIndex].value != "ANY")
                {
                    document.forms.Input.FILENAMETEXT.value = document.forms.Input.FILENAME.options[document.forms.Input.FILENAME.selectedIndex].value;
                }
                document.forms.Input.FILENAME.selectedIndex = 0;
                document.getElementById("FilenameList").style.display="none";
                document.getElementById("FilenameField").style.display="inline";
                
            }
            else
            {
                document.getElementById("FilenameList").style.display="inline";
                document.forms.Input.FILENAMETEXT.value = "";
                document.getElementById("FilenameField").style.display="none";			
            }
        }		
        else if (myelement == "FilenamePath") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("FilenamePathList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.FILENAME_PATH.options[document.forms.Input.FILENAME_PATH.selectedIndex].value != "ANY")
                {
                    document.forms.Input.FILENAME_PATHTEXT.value = document.forms.Input.FILENAME_PATH.options[document.forms.Input.FILENAME_PATH.selectedIndex].value;
                }
                document.forms.Input.FILENAME_PATH.selectedIndex = 0;
                document.getElementById("FilenamePathList").style.display="none";
                document.getElementById("FilenamePathField").style.display="inline";
                
            }
            else
            {
                document.getElementById("FilenamePathList").style.display="inline";
                document.forms.Input.FILENAME_PATH.value = "";
                document.getElementById("FilenamePathField").style.display="none";			
            }
        }	
        else if (myelement == "Source") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("SourceList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.EVENT_SOURCE.options[document.forms.Input.EVENT_SOURCE.selectedIndex].value != "ANY")
                {
                    document.forms.Input.EVENT_SOURCETEXT.value = document.forms.Input.EVENT_SOURCE.options[document.forms.Input.EVENT_SOURCE.selectedIndex].value;
                }
                document.forms.Input.EVENT_SOURCE.selectedIndex = 0;
                document.getElementById("SourceList").style.display="none";
                document.getElementById("SourceField").style.display="inline";
            }
            else
            {
                document.getElementById("SourceList").style.display="inline";
                document.forms.Input.EVENT_SOURCETEXT.value = "";
                document.getElementById("SourceField").style.display="none";			
            }
        }											
        else if (myelement == "Category") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("CategoryList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.EVENT_CATEGORY.options[document.forms.Input.EVENT_CATEGORY.selectedIndex].value != "ANY")
                {
                    document.forms.Input.EVENT_CATEGORYTEXT.value = document.forms.Input.EVENT_CATEGORY.options[document.forms.Input.EVENT_CATEGORY.selectedIndex].value;
                }
                document.forms.Input.EVENT_CATEGORY.selectedIndex = 0;
                document.getElementById("CategoryList").style.display="none";
                document.getElementById("CategoryField").style.display="inline";
            }
            else
            {
                document.getElementById("CategoryList").style.display="inline";
                document.forms.Input.EVENT_CATEGORYTEXT.value = "";
                document.getElementById("CategoryField").style.display="none";			
            }
        }
        else if (myelement == "Facility") 
        {
            if (document.defaultView.getComputedStyle(document.getElementById("FacilityList"), null).getPropertyValue("display") == "inline")
            {
                if (document.forms.Input.FACILITY.options[document.forms.Input.FACILITY.selectedIndex].value != "ANY")
                {
                    document.forms.Input.FACILITYTEXT.value = document.forms.Input.FACILITY.options[document.forms.Input.FACILITY.selectedIndex].value;
                }
                document.forms.Input.FACILITY.selectedIndex = 0;
                document.getElementById("FacilityList").style.display="none";
                document.getElementById("FacilityField").style.display="inline";
            }
            else
            {
                document.getElementById("FacilityList").style.display="inline";
                document.forms.Input.FACILITYTEXT.value = "";
                document.getElementById("FacilityField").style.display="none";			
            }
        }																
    }
}

////addEvent(window, "load", sortables_init);
//
//var SORT_COLUMN_INDEX;
//
//function sortables_init() {
//    // Find all tables with class sortable and make them sortable
//    if (!document.getElementsByTagName) return;
//    tbls = document.getElementsByTagName("table");
//    for (ti=0;ti<tbls.length;ti++) {
//        thisTbl = tbls[ti];
//        if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
//            //initTable(thisTbl.id);
//            ts_makeSortable(thisTbl);
//        }
//    }
//    
//}
//
//function ts_makeSortable(table) {
//    if (table.rows && table.rows.length > 0) {
//        var firstRow = table.rows[0];
//    }
//    if (!firstRow) return;
//    
//    // We have a first row: assume it's the header, and make its contents clickable links
//    for (var i=0;i<firstRow.cells.length;i++) {
//        var cell = firstRow.cells[i];
//        var txt = ts_getInnerText(cell);
//		var hide = cell.className.replace('Header','');
//        
//        if (hide.length > 0) {
//        	var hidelink = "<a href=\"#\" class=\"hidecol\" onclick=\"javascript:hide_column('"+hide.replace(' ','')+"');new Ajax.Request('eventsentry_action.asp',{asynchronous:true,method: 'post', parameters: '&HideColumn=1&class=" + hide.replace(' ','') + "'}) ; return false;\">X</a>";
//        	//var hidelink = "<a href=\"#\" class=\"hidecol\" onclick=\"javascript:new Ajax.Request('eventsentry_action.asp',{asynchronous:true,method: 'post', parameters: '&HideColumn=1&class=" + hide.replace(' ','') + "'}) ; return false;\">X</a>";
//        	//var hidelink = "<a href=\"#\" class=\"hidecol\" onclick=\"javascript:hide_column('"+hide.replace(' ','')+"');\">X</a>";
//        }else{
//        	hidelink='';	
//        }
//        	
//        //alert(hide);
//        
//        cell.innerHTML =  hidelink + '<a href="#" class="sortheader" '+ 
//        'onclick="ts_resortTable(this, '+i+');return false;">' + 
//        txt+'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a>';
//    }
//    
//}
//
//function ts_getInnerText(el) {
//	if (typeof el == "string") return el;
//	if (typeof el == "undefined") { return el };
//	if (el.innerText) return el.innerText;	//Not needed but it is faster
//	var str = "";
//	
//	var cs = el.childNodes;
//	var l = cs.length;
//	for (var i = 0; i < l; i++) {
//		switch (cs[i].nodeType) {
//			case 1: //ELEMENT_NODE
//				str += ts_getInnerText(cs[i]);
//				break;
//			case 3:	//TEXT_NODE
//				str += cs[i].nodeValue;
//				break;
//		}
//	}
//	return str;
//}
//
//function ts_resortTable(lnk,clid) {
//    // get the span
//    var span;
//    for (var ci=0;ci<lnk.childNodes.length;ci++) {
//        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
//    }
//    var spantext = ts_getInnerText(span);
//    var td = lnk.parentNode;
//    var column = clid || td.cellIndex;
//    var table = getParent(td,'TABLE');
//    
//    // Work out a type for the column
//    if (table.rows.length <= 1) return;
//    var itm = ts_getInnerText(table.rows[1].cells[column]);
//    sortfn = ts_sort_caseinsensitive;
//    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
//    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
//    if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
//    if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
//    SORT_COLUMN_INDEX = column;
//    var firstRow = new Array();
//    var newRows = new Array();
//    for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
//    for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }
//
//    newRows.sort(sortfn);
//
//    if (span.getAttribute("sortdir") == 'down') {
//        ARROW = '&nbsp;&nbsp;&uarr;';
//        newRows.reverse();
//        span.setAttribute('sortdir','up');
//    } else {
//        ARROW = '&nbsp;&nbsp;&darr;';
//        span.setAttribute('sortdir','down');
//    }
//    
//    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
//    // don't do sortbottom rows
//    for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);}
//    // do sortbottom rows only
//    for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);}
//    
//    // Delete any other arrows there may be showing
//    var allspans = document.getElementsByTagName("span");
//    for (var ci=0;ci<allspans.length;ci++) {
//        if (allspans[ci].className == 'sortarrow') {
//            if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
//                allspans[ci].innerHTML = '&nbsp;&nbsp;&nbsp;';
//            }
//        }
//    }
//    span.innerHTML = ARROW;
//}
//
//function getParent(el, pTagName) {
//	if (el == null) return null;
//	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
//		return el;
//	else
//		return getParent(el.parentNode, pTagName);
//}
//function ts_sort_date(a,b) {
//    // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
//    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
//    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
//    if (aa.length == 10) {
//        dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
//    } else {
//        yr = aa.substr(6,2);
//        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
//        dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
//    }
//    if (bb.length == 10) {
//        dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
//    } else {
//        yr = bb.substr(6,2);
//        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
//        dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
//    }
//    if (dt1==dt2) return 0;
//    if (dt1<dt2) return -1;
//    return 1;
//}
//
//function ts_sort_currency(a,b) { 
//    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
//    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
//    return parseFloat(aa) - parseFloat(bb);
//}
//
//function ts_sort_numeric(a,b) { 
//    aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
//    if (isNaN(aa)) aa = 0;
//    bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); 
//    if (isNaN(bb)) bb = 0;
//    return aa-bb;
//}
//
//function ts_sort_caseinsensitive(a,b) {
//    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
//    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
//    if (aa==bb) return 0;
//    if (aa<bb) return -1;
//    return 1;
//}
//
//function ts_sort_default(a,b) {
//    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
//    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
//    if (aa==bb) return 0;
//    if (aa<bb) return -1;
//    return 1;
//}
//
//
//function addEvent(elm, evType, fn, useCapture)
//// addEvent and removeEvent
//// cross-browser event handling for IE5+,  NS6 and Mozilla
//// By Scott Andrew
//{
//  if (elm.addEventListener){
//    elm.addEventListener(evType, fn, useCapture);
//    return true;
//  } else if (elm.attachEvent){
//    var r = elm.attachEvent("on"+evType, fn);
//    return r;
//  } else {
//    alert("Handler could not be removed");
//  }
//} 


//
function striper(parentElementTag, parentElementClass, childElementTag, styleClasses)
{
    var i=0,currentParent,currentChild;
    // capability and sanity check
    if ((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses)) {
        // turn the comma separate list of classes into an array
        var styles = styleClasses.split(',');
        // get an array of all parent tags
        var parentItems = document.getElementsByTagName(parentElementTag);
        // loop through all parent elements
        while (currentParent = parentItems[i++]) {
            // if parentElementClass was null, or if the current parent's class matches the specified class
            if ((parentElementClass == null)||(currentParent.className == parentElementClass)) {
                var j=0,k=0;
                // get all child elements in the current parent element
                var childItems = currentParent.getElementsByTagName(childElementTag);
                // loop through all child elements
                while (currentChild = childItems[j++]) {
                    // based on the current element and the number of styles in the array, work out which class to apply
                    k = (j+(styles.length-1)) % styles.length;
                    // add the class to the child element - if any other classes were already present, they're kept intact
                    currentChild.className = currentChild.className+" "+styles[k];
                }
            }
        }
    }
}

function stripe() {
     striper('tbody','striped','tr','odd,even');
}

function highlight(item) 
{
    if (item.className.indexOf('highlighted') != -1) {
        item.style.color ='#000';
        item.style.background ='';
        if (item.className.indexOf('odd') > -1 ) {
            item.style.background ='#F2F2F2';
        }
        item.className = item.className.replace('highlighted','');	
    } else {
        item.className = item.className.replace('hover','');	
        item.className = 'highlighted ' + item.className;
        item.style.background ='#0085DD';
        item.style.color ='#FFF';
    }	
}

function highlightOver(item)
{
    if (item.className.indexOf('highlighted') == -1) 
        item.className = 'hover ' + item.className;
    else 
        item.className=item.className.replace('hover ','');
}
 
function highlightOut(item)
{
    if (item.className.indexOf('highlighted') == -1) {
        item.className=item.className.replace('hover ','');
    }
} 

function getGroupOrder() {

    sections = document.getElementsByClassName('index');
    var alerttext = '';
    sections.each(function(section) {
        var sectionID = section.id;
        var order = Sortable.serialize(sectionID);
        alert(order);
        alerttext += Sortable.sequence(section);
    });
    
    return alerttext;
}

function loadXML(dname) 
{
    var xmlDoc;
    // code for IE
    if (window.ActiveXObject)
      {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument)
      {
      xmlDoc=document.implementation.createDocument("","",null);
      }
    else
      {
      alert('Your browser cannot handle this script');
      }
    xmlDoc.async=false;
    xmlDoc.load(dname);
    return(xmlDoc);
}

function IEtruncate () 
{
    //If IE give option to toggle truncated data
    if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null) {
        var selectbox = document.getElementsByTagName('select');
        var selectboxLen = selectbox.length;
        for ( i=0;i<selectboxLen;i++ ) {
            if ($('truncateToggle').checked){
								
                selectbox[i].style.width = '';
								selectbox[i].style.maxWidth = '100%';

            } else {
                if (selectbox[i].id == "mySelect"  || selectbox[i].id == "sysinfo" || selectbox[i].id == "Computer" || selectbox[i].id == "ID" || selectbox[i].id == "Source" || selectbox[i].id == "Category" || selectbox[i].id == "Username" || selectbox[i].id == "Group" || selectbox[i].id == "Filter" || selectbox[i].id == "Type" || selectbox[i].id == "Domain" || selectbox[i].id == "domain" || selectbox[i].id == "Filename" || selectbox[i].id == "Filepath" || selectbox[i].id == "LogonID" || selectbox[i].id == "Document" || selectbox[i].id == "Printer" || selectbox[i].id == "computer" || selectbox[i].id == "counter" || selectbox[i].id == "instance" || selectbox[i].id == "Action"  || selectbox[i].id == "Service" || selectbox[i].id == "StartupOld" || selectbox[i].id == "StartupNew" || selectbox[i].id == "applications" || selectbox[i].id == "Publisher" || selectbox[i].id == "Status" || selectbox[i].id == "Port" || selectbox[i].id == "Plugin" || selectbox[i].id == "CVSS"  || selectbox[i].id == "Facility" || selectbox[i].id == "Client" || selectbox[i].id == "TargetAccount" || selectbox[i].id == "TargetDomain" || selectbox[i].id == "CallerDomain" || selectbox[i].id == "TargetAccount" || selectbox[i].id == "CallerUser" || selectbox[i].id == "Details" || selectbox[i].id == "AccountGroup" || selectbox[i].id == "MemberAccountID" || selectbox[i].id == "MemberName" || selectbox[i].id == "SourceComputer" || selectbox[i].id == "GroupType" || selectbox[i].id == "GroupScope" || selectbox[i].id == "ComputerType" || selectbox[i].id == "Caller" || selectbox[i].id == "TargetAccountID" || selectbox[i].id == "Protocol" || selectbox[i].id == "Authentication_Type" || selectbox[i].id == "Failure_Reason" || selectbox[i].id == "Logon_Type" || selectbox[i].id == "Logon_Process" || selectbox[i].id == "TrustType" || selectbox[i].id == "TrustDirection" || selectbox[i].id == "SIDFiltering" || selectbox[i].id == "Policy" || selectbox[i].id == "Operation" || selectbox[i].id == "LogonRightShort" || selectbox[i].id == "LogonRightLong"  || selectbox[i].id == "Results"  || selectbox[i].id == "ViewTime"  || selectbox[i].id == "LoadTime" || selectbox[i].id == "Report" || selectbox[i].id == "Package" || selectbox[i].id == "Event_Log" || selectbox[i].id == "Event_Source" || selectbox[i].id == "Filtername" || selectbox[i].id == "Recipients" || selectbox[i].id == "TerminalServer" || selectbox[i].id == "ServerCore" || selectbox[i].id == "VM" || selectbox[i].id == "Bit64" || selectbox[i].id == "HyperV" || selectbox[i].id == "CallerAccountID" || selectbox[i].id == "CallerAccountSID" || selectbox[i].id == "OperationType" || selectbox[i].id == "TargetDomainID" || selectbox[i].id == "LogonPrivileges" || selectbox[i].id == "Subcategory" || selectbox[i].id == "SubcategoryGUID"  || selectbox[i].id == "KerberosChanges" || selectbox[i].id == "user")
                {
                    //if (selectbox[i].id == 'mySelect' || selectbox[i].id == 'counter' || selectbox[i].id == 'instance' || selectbox[i].id == 'computer' || selectbox[i].id == 'Computer' || selectbox[i].id == 'Source' || selectbox[i].id == 'Category' || selectbox[i].id == 'Username' ) {
                    selectbox[i].style.width = '125px';
                }	
            }
        }
        $('truncate').style.display = "inline";
    }	
}

function hide_column(cName) {
    $$('.'+cName).invoke('toggle');
}

function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function copy(text2copy) {
  if (window.clipboardData) {
    window.clipboardData.setData("Text",text2copy);
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="charts/clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}
 
function MEL(eventid,eventsource,eventmessage,usercomment,ischecked)
{
    if (ischecked == true)
    {
        var Url = 'http://www.myeventlog.com/eventrecord_submit.html?EVENT_ID=' + eventid + '&EVENT_SOURCE=' + eventsource + '&EVENT_MESSAGE=' + eventmessage + '&COMMENT=' + usercomment;
        var SubmissionWindow = window.open(Url, 'EventSubmission','width=540,height=450,scrollbars=yes');
    }		
}	

function clickBox(id)
{
    if ($(id).checked == false)
        { $(id).checked = true } 
    else 
        { $(id).checked = false }
}

function Preselect(myID, myValue)
{
    $(myID).value = myValue;
    $(myID).addClassName('FormSelected');
}


var onImage = "images/exclamationOn.gif";
var offImage = "images/exclamationOff.gif";

if (document.images)
{
    //preload checkbox images, this must exist in the HEAD tag 
    pic1 = new Image(18,18);
    pic1.src = onImage;
  
    pic2 = new Image(18,18);
    pic2.src = offImage;
}
function ImageCheckBox(checkbox)
{
    img = checkbox.childNodes[0];
    formfield = checkbox.childNodes[1];
        
    if(formfield.value == "false") {
        img.src = onImage;
        formfield.value = "true";
    }
    else {
        img.src = offImage;
        formfield.value = "false";
    }
}
function ImageCheckBoxInit(checkbox,initialValue)
{
    img = checkbox.childNodes[0];
    formfield = checkbox.childNodes[1];
    
    if(initialValue)
    {
        img.src = onImage;
        formfield.value = "true";
    }
    else {
        img.src = offImage;
        formfield.value = "false";
    }
}


function InputOK()
{
    var listSelected = 0;
    var itemSelected = -1;
    var listLength = document.forms.Input.DISTINCT.length;
    
    for (var i = 0; i < listLength; i++)
    {
        if (document.forms.Input.DISTINCT.options[i].selected == true)
        {
            itemSelected = i;
            listSelected += 1;
        }
    }
    
    if (listSelected == 1 && document.forms.Input.DISTINCT.options[itemSelected].text == 'Duration')
    {
        alert('You cannot only group by the DURATION field. Please select an additional field by holding the CTRL button on your keyboard while selecting another field.');
        return false;
    }
    
    return true;
}

function $RF(el, radioGroup) {
    if($(el).type && $(el).type.toLowerCase() == 'radio') {
        var radioGroup = $(el).name;
        var el = $(el).form;
    } else if ($(el).tagName.toLowerCase() != 'form') {
        return false;
    }
 
    var checked = $(el).getInputs('radio', radioGroup).find(
        function(re) {return re.checked;}
    );
    return (checked) ? $F(checked) : null;
}







// Macromedia rollover scripts
var MM_findObj;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/**
 * SWFObject v1.4.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null) {this.addParam("wmode", "transparent");}
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){
var _25=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);_25=new deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){
try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}return _25;};
deconcept.PlayerVersion=function(_29){
this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;
this.minor=parseInt(_29[1])||0;
this.rev=parseInt(_29[2])||0;};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};
deconcept.util={getRequestParameter:function(_2b){
var q=document.location.search||document.location.hash;
if(q){var _2d=q.indexOf(_2b+"=");
var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;
if(q.length>1&&_2d>-1){return q.substring(q.indexOf("=",_2d)+1,_2e);}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){
var _2f=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2f.length;i++){
for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=null;}}}};
if(typeof window.onunload=="function"){
var oldunload=window.onunload;
window.onunload=function(){
	deconcept.SWFObjectUtil.cleanupSWFs();
	//oldunload();
};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}
if(Array.prototype.push==null){
Array.prototype.push=function(_32){
this[this.length]=_32;
return this.length;};}

var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for backwards compatibility
var SWFObject = deconcept.SWFObject;
