
<!-- To allow Internet Explorer to change the color of the row where the mouse is over by changing the label from hover to hilite -->
var rows = document.getElementsByTagName('tr');
for (var i = 0; i < rows.length; i++) {
     rows[i].onmouseover = function() {
         this.className += ' hilite';
     }
     rows[i].onmouseout = function() {
         this.className = this.className.replace('hilite', '');
    }
}

var finished = true;

var timeout = "";
function reset_timer()
{
    if (timeout != "") {
        clearTimeout(timeout);
        if (timeout2 != "") {
            clearTimeout(timeout2);
        }
    }
    timeout = setTimeout('get_results(false)', 1000); 
}

var timeout2 = "";
function reset_timer2()
{
    if (timeout2 != "") {
        clearTimeout(timeout2);
    }
    timeout2 = setTimeout('redirect()', 5000); 
}

function is_punct(char)
{
    if (char == ' ' || char == ';' || char == ',') return(true);
    return(false);
}

function loadpage(page_request, containerid)
{
    if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http")==-1))
    {
        containerid.innerHTML = page_request.responseText;
        finished = true;
    }
}

function open_url(url, containerid)
{
    var page_request = false;

    if (typeof XMLHttpRequest == "undefined") // if IE
    {
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP.6.0");
        } 
        catch (e){
            try {
                page_request = new ActiveXObject("Msxml2.XMLHTTP.3.0");
            } 
            catch (e){
                try {
                    page_request = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e){
                    try{
                        page_request = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch (e){
                        return false;
                    }
                }
            }
        }
    }
    else { // if Mozilla, Safari etc
        page_request = new XMLHttpRequest();
    }

    page_request.onreadystatechange = function() { loadpage(page_request, containerid); }

    page_request.open('GET', url, true);
    page_request.send(null);
}

function redirect()
{
    location.href = 'http://www.lookfordiagnosis.com/results.php' +
                    '?lang=' + document.symptoms.lang.value +
                    '&symptoms=' + document.symptoms.symptoms.value + 
                    '&mode=' + 'F' + //document.symptoms.mode.value + 
                    '&parent=' + document.symptoms.parent.value;
}

function get_results(check)
{
    var length = document.symptoms.symptoms.value.length;

    if (length == 0) return;

    if (check == true) 
    {
        var last_char = document.symptoms.symptoms.value.charAt(length-1);

        if (!is_punct(last_char)) // if the last char is not a punctuation sign
        {
            reset_timer();
            return;
        }
    }

    if (finished == false) return;
    finished = false;

    open_url('http://www.lookfordiagnosis.com/results.php' +
             '?lang=' + document.symptoms.lang.value +
             '&symptoms=' + document.symptoms.symptoms.value + 
             '&mode=' + 'F' + //document.symptoms.mode.value + 
             '&parent=' + document.symptoms.parent.value +
             '&ajax=1', document.getElementById("results"));
}

function get_health_topic()
{
    if (finished == false) return;
    finished = false;

    open_url('http://www.lookfordiagnosis.com/health_topics.php' +
             '?lang=' + document.filter.lang.value +
             '&filter=' + document.filter.filter.value + 
             '&ajax=1', document.getElementById("results_bold"));
}

function wopen(url, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  "_blank",
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');
 win.resizeTo(w, h);
 }