//
// Script         dictionary
// Copyright      2007 OEM Scripts
// Autor          Denny Schlesinger
// OEM Scripts    http://oemscripts.com
//
// $Id:$
//

// global variables
// none so far

// function debugConsole()       // For debugging only
// function GetXmlHttpObject()   // Check for javaScript
// function showButton()         // If javaScript, show button
// function onDictionary()       // Call translator


function debugConsole() {
    debugWindow = window.open("","debugWin","toolbar=yes,scrollbar=yes,width=300,height=400");
}

function GetXmlHttpObject() {
    var xmlHttp;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    return xmlHttp;
} // function GetXmlHttpObject()

//////////////////////////////////////////////////


function showButton() {

    document.getElementById("dictionaryButton").style.visibility='visible';

} // function showButton()


function onDictionary() {

    var word =  document.getElementById("sp-q").value;

    xmlHttp=GetXmlHttpObject();
    xmlHttp.onreadystatechange=function() {
        // We are going to write some code here
        if(xmlHttp.readyState==4) {
            // Get the data from the server's response
            document.getElementById("content").innerHTML=xmlHttp.responseText;
        }
    }
    
    var url="/translate.php";
//    var url="/~denny/bahiaredonda.com/dictionary/dictionary.php";
    url=url+"?word="+word;
    url=url+"&language=english";    
    url=url+"&words_action=Translate";
    url=url+"&words_source=Ajax";
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    var blank = "";
//    document.getElementById("content").innerHTML=blank;
} // function onDictionary()



//////////////////////////////////////////////////
