﻿var req;

function Initialize()
{
try
{
	req=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
	try
	{
		req=new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(oc)
	{
		req=null;
	}
}

if(!req&&typeof XMLHttpRequest!="undefined")
{req=new XMLHttpRequest();}
}

function SendQuery(key)
{
Initialize();
var url="http://" + window.location.hostname + "/naseptavace/main_keywords.aspx?k=" + key;
if(req!=null)
{
req.onreadystatechange = Process;
req.open("GET", url, true);
req.send(null);
}
}

function SendQueryEmailVkladani(key)
{
Initialize();
var url="http://" + window.location.hostname + "/naseptavace/vkladani_email.aspx?email=" + key;
if(req!=null)
{
req.onreadystatechange = ProcessEmailVkladani;
req.open("GET", url, true);
req.send(null);
}
}

function Process()
{
if (req.readyState == 4) 
{
    // only if "OK"
    if (req.status == 200) 
    {
        if(req.responseText.indexOf("null")==-1)
        {
        ShowDiv("autocomplete");
        document.getElementById("autocomplete").innerHTML =req.responseText;
        }
        else
        {HideDiv("autocomplete");}
    }
    else
    {document.getElementById("autocomplete").innerHTML="There was a problem retrieving data:<br>"+req.statusText;}
    }
}


function ProcessEmailVkladani()
{
if (req.readyState == 4) 
{
    // only if "OK"
    if (req.status == 200) 
    {
        if(req.responseText.indexOf("null")==-1)
        {ShowDiv("ctl00_obsah__login_box");
         ShowDiv("_emailInfo");
        }
        else
        {HideDiv("ctl00_obsah__login_box");
         HideDiv("_emailInfo");
        }
    }
    else
    {document.getElementById('ctl00_obsah__login_box').innerHTML="There was a problem retrieving data:<br>"+req.statusText;
    }
}
}

function ShowDiv(divid) 
{
if (document.layers) document.layers[divid].visibility="show";
else document.getElementById(divid).style.visibility="visible";
}

function HideDiv(divid) 
{
if (document.layers) document.layers[divid].visibility="hide";
else document.getElementById(divid).style.visibility="hidden";
}

function BodyLoad()
{
HideDiv("autocomplete");
document.getElementById('keyword').focus();

}
