﻿function SubmitForm(url,posttrue,params,values)
{var forma=document.createElement("FORM");forma.method=posttrue?"POST":"GET";forma.action=url;document.body.appendChild(forma);for(var i=0;i<params.length;i++)
{if(params[i]=="")continue;if(values[i]=="")continue;var input=document.createElement("INPUT");input.type="hidden";input.name=params[i];input.value=values[i];forma.appendChild(input);}
forma.submit();document.body.removeChild(forma);forma=null;input=null;}

function Search(){var q="";if($("#ctl00_pageBody_zSEARCH1").val()!=null)
q=$("#ctl00_pageBody_zSEARCH1").val();else if($("#ctl00_pageBody_zSEARCH2").val()!=null)
q=$("#ctl00_pageBody_zSEARCH2").val();var p=new Array(1);p[0]="q";var v=new Array(1);v[0]=q;SubmitForm("/",false,p,v);}

function Redirect(u)
{
    window.location.href = u;
}

function GetLinks(i)
{
    if ($("#Links" + i.toString()).css("display") == "block")
    {
        $("div.Links").hide(300);
        return;
    }
    $.ajax({
        url:"/SiteTools/Links.aspx",
        data:"i=" + i.toString(),
        cache:true,
        success:function(html)
        {
            $("div.Links").hide(300);
            $("#Links" + i.toString()).html(html);
            $("#Links" + i.toString()).show(100);}
        }
    );
 }

function ErrorLink(i,o,id)
{
    if ($(o).html().indexOf("removeok") != -1) return;
    $.ajax({url:"/SiteTools/Links.aspx", data:"q=" + i + "&e=t"});
    $(o).html('<img class=\"img\" src=\"/SiteData/Design/removeok.gif\" />');
}

function GenioKeyPress(e)
{
    if(e.keyCode==13)
    {
        Search();
        return false;
    } else return true;
}

function stopRKey(evt){var evt=(evt)?evt:((event)?event:null);var node=(evt.target)?evt.target:((evt.srcElement)?evt.srcElement:null);if((evt.keyCode==13)&&(node.type=="text"))
return false;}

function GetLinksSpecial(q)
{
    $.ajax({
        url:"/SiteTools/Links.aspx",
        data:"q=" + q,
        cache:true,
        success:function(html)
        {
            $("div.Links").hide(300);
            $("#Links").html(html);
            $("#Links").show(100);}
        }
    );
 } 

function hore()
{
    var targetOffset = $('body').offset().top;
    $('html,body').animate({scrollTop: targetOffset}, 800);
}

var IsClick = false;
function TextBox_OnClick(o)
{
    o.value = "";
    o.style.color = "black";
    IsClick = true;

}

$(document).ready(function()
{
	$("a.Title1").each(function()
	{
	    $(this).click(function(){ GetLinks($(this).attr("id").replace("link", "")); });
	});

    if (document.getElementById("Pomocnik"))
        setTimeout(function() { $("#Pomocnik").show(500); setTimeout(function() { $("#Pomocnik").hide(500); }, 6000); }, 1000);                

    if (document.getElementById("ctl00_pageBody_pnl_mini") != null)
        $("body").addClass("bodybg1");    

    if (document.getElementById("Zoznam"))
        if (document.getElementById("Zakon"))
            setTimeout(function() { $("#Zakon").show(500); setTimeout(function() { $("#Zakon").hide(500); }, 6000); }, 1000);

    $("#menu1").createDialog({
        opacity: 0.85,
        bg: '#303030',
        addr: '/SiteData/Ajax/informacie.html',
        opacity: 0.9
    });

	$(function(){
        if (document.getElementById("ctl00_pageBody_pnl_mini") != null)
            setAutoComplete("ctl00_pageBody_zSEARCH2", "results", "/SiteTools/Pomocnik.aspx?q=");
          else
            setAutoComplete("ctl00_pageBody_zSEARCH1", "results", "/SiteTools/Pomocnik.aspx?q=");
    });

    $(window).scroll(function()
    {
        if ($("#hore").css("display") != "block")
            $("#hore").css("display", "block");
    });
});     
