
function initFocus(f) {
    f.termClinical.onfocus = function(x) { this.style.backgroundColor = '#ff9'; }
    f.termClinical.onblur = function(x) { this.style.backgroundColor = 'white'; }
    f.termClinical.style.backgroundColor = 'white';
}

function obj() 
{
    this.therapy = '';
    this.diagnosis = '';
    this.etiology = '';
    this.prognosis = '';
}               

function clinical(f)
{
    if( f.termClinical.value == '' ) {
      alert("Please enter a search phrase")
      return false;
    }
    
    var i, strategy = '', precision = '';
    
    // sensitive
    sensitive = new obj;

    sensitive['therapy'] =
      "(clinical[Title/Abstract] AND trial[Title/Abstract]) OR clinical trials[MeSH Terms] OR " +
      "clinical trial[Publication Type] OR random*[Title/Abstract] OR random allocation[MeSH Terms] " +
      "OR therapeutic use[MeSH Subheading]";
    
    sensitive['diagnosis'] =
      "sensitiv*[Title/Abstract] OR sensitivity and specificity[MeSH Terms] OR diagnos*[Title/Abstract] OR " +
      "diagnosis[MeSH:noexp] OR diagnostic *[MeSH:noexp] OR diagnosis,differential[MeSH:noexp] OR " +
      "diagnosis[Subheading:noexp]";		
    
    sensitive['etiology'] =
      "risk* [Title/Abstract] OR risk* [MeSH:noexp] OR risk *[MeSH:noexp] OR cohort studies[MeSH Terms] OR " +
      "group*[Text Word]";
    
    sensitive['prognosis'] =
      "incidence[MeSH:noexp] OR mortality[MeSH Terms] OR follow up studies[MeSH:noexp] OR prognos*[Text Word] " +
      "OR predict*[Text Word] OR course*[Text Word]";
    
    sensitive['clinical prediction guides'] =
      "predict*[tiab] OR predictive value of tests[mh] OR scor*[tiab] OR observ*[tiab] OR observer variation[mh]";

    // specific
    specific = new obj;

    specific['therapy'] = "randomized controlled trial[Publication Type] OR " +
      "(randomized[Title/Abstract] AND controlled[Title/Abstract] AND trial[Title/Abstract])";

    specific['diagnosis'] = "specificity[Title/Abstract]";

    specific['etiology'] =  "(relative[Title/Abstract] AND risk*[Title/Abstract]) OR " +
      "(relative risk[Text Word]) OR risks[Text Word] OR cohort studies[MeSH:noexp] OR " +
      "(cohort[Title/Abstract] AND stud*[Title/Abstract])";
    
    specific['prognosis'] = "prognos*[Title/Abstract] OR " +
      "(first[Title/Abstract] AND episode[Title/Abstract]) OR cohort[Title/Abstract]";
    
    specific['clinical prediction guides'] = "validation[tiab] OR validate[tiab]";

    for( i = 0; i < f.strategy.length; i++ ) {
        if( f.strategy[i].checked ) { strategy = f.strategy[i].value; break; }
    }
    
    for( i = 0; i < f.precision.length; i++ ) {
        if( f.precision[i].checked ) { precision = f.precision[i].value; break; }
    }
    
    if( strategy == '' || precision == '' ) 
      return false;
    
    var cond = sensitive[strategy];
    if( precision == "specificity" ) {     
        cond = specific[strategy];
    }
    
    f.term.value = "(" + f.termClinical.value + ") AND (" +  cond + ")";
    
    return true;
}

function systematic(f) {
    if( f.termClinical.value == '' ) {
      alert("Please enter a search phrase")
      return false;
    }
    
    f.term.value = "(" + f.termClinical.value + ") AND systematic[sb]";
    return true;
}

function medgenquery (f)
{
    if( f.termClinical.value == '' ) {
      alert("Please enter a search phrase")
      return false;
    }
    
    qtext = new obj();

    qtext.diagnosis = "Diagnosis AND genetics";
    qtext.differential = "Differential Diagnosis[MeSH] OR Differential Diagnosis[Text Word] AND genetics";
    qtext.clinical = "Natural History OR Mortality OR Phenotype OR Prevalence OR Penetrance AND genetics";
    qtext.therapy = "therapy[Subheading] OR treatment[Text Word] OR treatment outcome OR investigational therapies AND genetics";
    qtext.genetic = "Genetic Counseling OR Inheritance pattern AND genetics";
    qtext.molecular = "Medical Genetics OR genotype OR genetics[Subheading] AND genetics";
    qtext.gentest = "DNA Mutational Analysis OR Laboratory techniques and procedures OR Genetic Markers OR " +
      "diagnosis OR testing OR test OR screening OR mutagenicity tests OR genetic techniques OR " +
      "molecular diagnostic techniques AND genetics";

    allflag = f.category[0].checked;

    result = ""
    for (i = 1; i < f.category.length; i++) {
        if (allflag || f.category[i].checked) {
            if (result != "") {
                result += " OR ";
            }
            result += "(" + qtext[f.category[i].value] + ")"
        }
    }

    if (result != "") {
        f.term.value = "(" + f.termClinical.value + ") AND (" + result + ")";
    } else {
        f.term.value = f.termClinical.value;
    }
    return true;
}
