/**
 * Contains general JavaScript functions that are used by the DTS web application
 *
 * Copyright (c) 2002 Comprendium, Inc. All Rights Reserved.
 *
 * This file is part of the DTS project.
 */

function mOver(cell)
{
    if (! cell.contains(event.fromElement)) {
        cell.style.cursor = 'hand';
        cell.bgColor = '#c3ccd0';
    }
}

function mOut(cell)
{
    if (! cell.contains(event.toElement)) {
        cell.style.cursor = 'default';
        cell.bgColor = '#ffffff';
    }
}

function mClick(src) {
    if (event.srcElement.tagName=='TD') {
        src.children.tags('A')[0].click();
    }
}

/**
 * Opens a new browser window displaying the page specified by "path".
 */
function showPage(path, name) {

    var features='tool-bar=no,location=no,directories=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,alwayRaised=1,hotkeys=0';

    if ((navigator.appVersion.substring(0,1) > 3) && (screen.height > 700)) {
      features+= ',width=800';
      features+= ',height=600';
    }
    else {
      features+= ',fullscreen=no';
    }

    return window.open(path, name, features);
}

/**
 * Pops up a confirmation window
 */
function askConfirmation(message) {

    if (confirm(message)) {
        return true;
    }
    else {
        return false;
    }
}


/**
 * Pops up a confirmation window
 */
function askConfirmationHostRestartShutdown(message,url,whattodo) {
   if(confirm(message)) {
        goDoAminHostAction(whattodo,url);
      return true;
    }
    else {
        return false;
    }
}


/**
 * Shows the instances that should be displayed.
 *
 * @param   type   the type of components that should be listed
 */
function showDTSInstances(request, type) {
    var  url = request + "/admin/hosts.do?selectedCompType=" + type;

    window.open(url, "_self");
}

/**
 * Generates HTML code that displays the translation
 *
 * @param	translation	the translation
 */
function writeTranslation(translation) {
    if ((frames.RESULT == null) || (frames.RESULT.document == null)) {
        alert("Error: Could not find result frame");
    }
    else {
        frames.RESULT.document.open();
        frames.RESULT.document.writeln("<html>");
        frames.RESULT.document.writeln("<head>");	
        frames.RESULT.document.writeln("<style type='text/css'>");
        frames.RESULT.document.writeln("body {margin:1px;padding:1px;font-size:12px;font-family:Arial;color:black;}");
        frames.RESULT.document.writeln("span.unknown {color:#ff0000;}");
        frames.RESULT.document.writeln("span.alternative {color:#008000;}");
        frames.RESULT.document.writeln("span.compound {color:#000080;}");
        frames.RESULT.document.writeln("span.memory {color:#800080;}");
        frames.RESULT.document.writeln("span.memory2 {color:#c0c0c0;}");
        frames.RESULT.document.writeln("span.memory3 {color:#808080;}");
        frames.RESULT.document.writeln("span.memory4 {color:#808000;}");
        frames.RESULT.document.writeln("span.term {color:#a52a2a;}");
        frames.RESULT.document.writeln("span.name {color:#8b8b8b;}");
        frames.RESULT.document.writeln("</style>");
        frames.RESULT.document.writeln("<body>");
        frames.RESULT.document.write(translation);
        frames.RESULT.document.writeln("</body>");
        frames.RESULT.document.writeln("</head>");
        frames.RESULT.document.writeln("</html>");
        frames.RESULT.document.close();
    }
}