
	var Opera = false;
	if (window.opera) Opera = true;

	var IE = false;
	if ((document.all) && (!Opera)) IE = true;

	var MOZILLA = false;
	if ((!Opera) && (!IE)) MOZILLA = true;

	var BrowserVersion = parseInt(navigator.appVersion);
	var XmlRequestFunction = null;

  function GetFullMSIEVersion()
    {
      var strHttpString = window.navigator.userAgent;
      var intIEVerIndex = strHttpString.indexOf("MSIE ");
      if (intIEVerIndex > 0)
        return strHttpString.substring(intIEVerIndex+5, strHttpString.indexOf(';',intIEVerIndex));
      else
        return 0;
    }

        var Tload = new Array(10);
	var TCounts = 0;

        function onLoad()
        {

		// alert(document.location.href);

		var i=0;
		for (i=0; i<TCounts; i++)
		{
			eval(Tload[i] + '()');
		}

		if ((IE) && (parseInt(GetFullMSIEVersion()) < 7))
		{
			document.body.childNodes[0].style.background="";
		}
        }

	window.onload = onLoad;
	document.onkeypress = keyDown;

function TickInit(Fnc, t)
{
        ptick = window.setInterval(Fnc, t);
	return ptick;
}

function TickDone(ptick)
{
	if (ptick == null) return;
        window.clearInterval(ptick);
}


function keyDown(e)
{
        var evt = (e) ? e : ((event) ? event : null);
        var t = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);

        var keycode = null;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        
        if ((keycode == 13) && (t.type == "text"))  
        {

                page = 1;

                Search(t.id.substr(t.id.length - 2, 2));
                return false;
        }
        else
        {
		// alert(t.type);
		if ((t.type != "text") 
			&& (t.type != "textarea") 
			&& (t.type != "file") 
			&& (t.type != "select-one")
		) AccessKeyPress(keycode);
        }
}

var DietologieSearch = null;
var DietologieScrollp = null;

function qsearch(s)
{
	var v = document.getElementById('searchBoxCZ');
	v.value = "";
        var page = 1;
	DietologieScrollp = TickInit(DietologieScroll, 20);
	DietologieSearch = s;
	Search('CZ')
}


function DietologieScroll()
{
	window.scrollBy(0, -50);
    	var y = window.pageYOffset;
	if (IE) y = document.documentElement.scrollTop;
	if (y < 200) TickDone(DietologieScrollp);
}


function rsearch(s)
{
	var os = "";
	for (var i=0; i<s.length; i++)
	{
		if (s.substr(i, 1) == "_") { os += " "; continue; }
		os += s.substr(i, 1) + s.substr(i, 1);
	}
	var v = document.getElementById('searchBoxCZ');
	v.value = "";
        var page = 1;
	DietologieScrollp = TickInit(DietologieScroll, 20);
	DietologieSearch = os;
	Search('CZ')
}


function Search(a)
{
	var v = document.getElementById('searchBox' + a);
	if (v != null)
	{

		var keyword = v.value;
		if (keyword == "") keyword = DietologieSearch;

		la = a;

		// TickDone();
		var okno = document.getElementById("okno000");
		okno.style.display = "block";
    		
		// sch.innerHTML = "";

		FromDate = new Date();

		XmlRequestFunction = "fSearch();";

		var s = 'http://www.dietologie.cz/search.asmx/GetSearchResults?ver='+a+'&KeyWords='+encodeURI(keyword)+'&Page='+page+'&PerPage='+rpage;
    		GetXmlFromWebService(s);


		var Hledam = document.getElementById('Hledam');
		Hledam.style.display = 'block';

	}
}



var oHttp = null;
var xmlDoc = null;

function XmlLoaded() 
{

	eval(XmlRequestFunction);

}

function GetXmlFromWebService(WebServiceLink)
{
    oHttp = null;
    if (window.XMLHttpRequest)
    {
        oHttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        oHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (oHttp != null)
    {
        oHttp.onreadystatechange = XmlLoaded;
        oHttp.open("GET", WebServiceLink, true);
        oHttp.send(null);
    }
    else
    {
        alert('Problem in HTTP request');
        return;
    }
}


function GetPosForElement(elmCurr, struct)
{
var intX = 0;
var intY = 0;
do
{
intX += elmCurr.offsetLeft;
intY += elmCurr.offsetTop;
}
while (elmCurr = elmCurr.offsetParent);
struct.x = intX;
struct.y = intY;
}



function www_kraj_info()
{
	var www_kraj_info = document.getElementById("www_kraj_info");
	www_kraj_info.style.display = "block";
}

function fncCookieWrite(strId, strValue)
{
    var dtmDateTime = new Date();
    dtmDateTime.setTime(dtmDateTime.getTime() + (365 * 24 * 3600 * 1000));
    var strCookie = strId + '=' + strValue;
    strCookie += '; expires=' + dtmDateTime.toGMTString();
    strCookie += '; path=/';
    // strCookie += '; domain=/';
    // strCookie += '; secure=';
    document.cookie = strCookie;
}

function fncCookieRead(strId)
{
    var strFind = strId + '=';
    var strCookie = document.cookie;
    var i = 0;
    while (i < strCookie.length)
    {
        if (strCookie.substr(i, strFind.length) == strFind)
        {
            var intEidx = strCookie.indexOf (";", i);
            if (intEidx == -1) intEidx = strCookie.length;
            return unescape(strCookie.substring(i + strFind.length, intEidx));
        }
        else
        i ++;
    }
    return null;
}


