// © 1995-2009 Healthwise, Incorporated. Healthwise, Healthwise for every health decision,
// and the Healthwise logo are trademarks of Healthwise, Incorporated.

if (!window.org) var org = { healthwise: {} };
else if (!window.org.healthwise) org["healthwise"] = {};

if (org.healthwise.sx == undefined) {
    org.healthwise["sx"] = {};
}

// provided state for consumer symptom topics
org.healthwise.sx.getCurrentState = function() {
    var data = {
        state: [
  	]
    };
    return data;
}

org.healthwise.sx.showAdditionalInformation = function(link) {
    alert('calling obsolete function : showAdditionalInformation');
}

// link.documentHref
// link.sectionHref
// link.documenttype
// link.rank
// link.source [question-context|redirection|search|disposition]
// link.className [additional|quickdefine]
// link.linkType [hometreatment|relatedinformation|undefined]
org.healthwise.sx.displayLink = function(link) {
    link.documentHref = link.documentHref.replace(/'/g, "");
    link.sectionHref = link.sectionHref.replace(/'/g, "");
    if (link.sectionHref == 'null')
        link.sectionHref = '';

    if (link.documenttype == 'null')
        link.documenttype = '';

    link.documenttype = org.healthwise.sx.mapDocType(link.documenttype);
    var path = org.healthwise.sx.getRelativeURLToDocument(link);
    link.source = link.source.toLowerCase();
    link.className = link.className.toLowerCase();

    //org.healthwise.sx.debugDisplayLink(link);

    if (link.className == 'additional') {
        if (link.source == 'search' || link.source == 'redirection')
            window.location = path;
        else if (link.source == 'disposition' && parseInt(link.rank) <= 2)
            window.location = path;
        else
            popoffwindow(path, '');
    }
    else {
        window.location = path;
    }
}

org.healthwise.sx.debugDisplayLink = function(link) {
    alert(link.documentHref + '\r\n' +
        link.sectionHref + '\r\n' +
        link.documenttype + '\r\n' +
        link.rank + '\r\n' +
        link.source + '\r\n' +
        link.className);
}

org.healthwise.sx.flash = {
    layout: "consumer",
    stylesheet: "../../../inc/custom/custom.css"
};

org.healthwise.sx.mapDocType = function(docTypeIn) {
    if (docTypeIn == 'MM-DOC')
        return 'mm-doc';
    else if (docTypeIn == 'FRAME-TOPIC')
        return 'frame';
    else
        return docTypeIn.toLowerCase();
}

// assumes this is being called from a symptom topic swf
org.healthwise.sx.getRelativeURLToDocument = function(link) {
    var pathToRoot = '../../../';
    if (link.documenttype == 'frame')
        return pathToRoot + 'frame' + '/' + link.documentHref.substring(0, 5) + '/' + link.documentHref + '/frame.htm';
    else if ((link.documenttype == 'mm-doc') || ('multimedia' == link.documenttype))
        return pathToRoot + 'mm-doc' + '/' + link.documentHref.substring(0, 5) + '/' + link.documentHref + '.htm';
    else if (link.documentHref == 'search')
        return '../../../default.htm';
    else if (link.documenttype == 'symptom') {
        var tempURL = '../' + link.documentHref + '/';
        if (link.linkType == 'hometreatment')
            tempURL = tempURL + 'hometrt.htm';
        else if (link.linkType == 'relatedinformation')
            tempURL = tempURL + 'relinfo.htm';
        else
            tempURL = tempURL + 'cys.htm';

        return tempURL;
    }
    else if (link.documenttype == 'special')
        return pathToRoot + 'topic/special/' + link.documentHref.substring(0, 5) + '/sec' + link.sequence + '.htm';
    else if (link.documenttype == 'definition')
        return pathToRoot + 'glossary' + '/' + link.documentHref.substring(0, 5) + '/' + link.documentHref + '/def.htm';
    else
        alert('Linking from Symptom Topic to unsupported target document type: ' + link.documenttype);
}