/* (c) 2007. Kladionice Zderic  Sva prava pridržana / All rights reserved. */

function Slika_MouseOver(controlID, image)
{
	var d = gID(controlID);
	if (d != null) d.src = image;
}

function Slika_MouseOut(controlID, image)
{
	var d = gID(controlID);
	if (d != null) d.src = image;
}

function UcitajSlike()
{ 
	var d=document; 
	if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=UcitajSlike.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function Menu_Click(name, ind, count)
{
	for (var i=1; i<=count; i++)
	{
		var d = gID(name+i);
		if (d != null)
		{
			if (i==ind)
			{
				if (d.style.display == "inline")
				{
					d.style.display = "none";
					Cookie_Set(name, -i, "inline");
				}
				else
				{
					d.style.display = "inline";
					Cookie_Set(name, i, "inline");
				}			
			}
			else
			{
				d.style.display = "none";
			}			
		}
	}
}

function Cookie_Set(name, rbr, stanje)
{
	if (stanje == "inline")
		document.cookie = name + "=" + rbr + ";";
}

function Menu_Set(name, count)
{
    if (document.cookie.length>0)
    {
        var sind = document.cookie.indexOf(name+"=");
        if (sind != -1)
        {
            sind = sind + name.length + 1;
            eind = document.cookie.indexOf(";",sind);
            if (eind==-1)
                eind = document.cookie.length;

            var rbr = document.cookie.substring(sind,eind);
            Menu_Click(name, rbr, count);
        }    
    }
}

function Menu_Inic(name, count)
{
    setTimeout('Menu_Set("'+name+'", '+count+')',500);
}

function OpenPopUpWindow(urlslike, nazivprozora, sirina, visina)
{
	var popupprozor = window.open(urlslike, nazivprozora, "width=" + sirina + ", height=" + visina + ", toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes, modal=yes, top=1, left=200");
	
	popupprozor.focus();
}

function OpenStatsWindow(url, nazivprozora, sirina, visina)
{
	var popupprozor = window.open(url, nazivprozora, "width=" + sirina + ", height=" + visina + ", toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes, modal=no, top=1, left=1");
	popupprozor.focus();
}

function T(id, menu)
{
	if (id != null)
	{
		if (menu != null)
		{
			if (menu == true)
				OpenStatsWindow('../Statistika.aspx?clientmatchid='+id, 'Zderic', 800, 500);
			else	
				OpenStatsWindow('../Statistika.aspx?clientmatchid='+id+'&treemenu=false', 'Zderic', 800, 500);
		}
		else
			OpenStatsWindow('../Statistika.aspx?clientmatchid='+id+'&treemenu=false', 'Zderic', 800, 500);
		
	}
	else
		OpenStatsWindow('Statistika.aspx', 'Zderic', 800, 500);
}

function ChkBrowser()
{
	if (navigator.appName.indexOf("Microsoft") != -1)
		return 1;
	else if (navigator.appName.indexOf("Netscape") != -1)
		return 2;
	else
		return 3;
}

function ChkIEVer()
{
	var agt = navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);

	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
	var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6")!=-1) );

	if (is_ie5)
		return 5;
	else if (is_ie5_5)
		return 55;
	else if (is_ie6)
		return 6;
	else
		return 0;
}

function gID(id, doc)
{
	var iedom;
	var nsdom;

	if (doc != null)
	{
		iedom = doc.getElementById;
		nsdom = doc.layers;
	}
	else
	{
		iedom = document.getElementById;
		nsdom = document.layers;
	}
	
	if ((id != null) && (id.length>0))
	{
		if (iedom != null)
		{
			if (doc != null)
				return doc.getElementById(id);
			else			
				return document.getElementById(id);
		}
		else if (nsdom != null)
		{
			if (doc != null)
				return doc.layers[id];
			else
				return document.layers[id];
		}
		else
		{
			if (doc != null)
				return doc.all[id];
			else
				return document.all[id];
		}
	}
	
	return null;
}


function YScroll()
{
    var yscroll = 0;
    if( typeof( window.pageYOffset ) == 'number' )
    {
        //Netscape
        yscroll = window.pageYOffset;
    } 
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
    {
        //DOM
        yscroll = document.body.scrollTop;
    } 
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
    {
        //IE6
        yscroll = document.documentElement.scrollTop;
    }
    return yscroll;
}


function WindowHeight()
{
    var height = 0;
    if(typeof(window.innerWidth) == 'number')
    {
        //non-IE
        height = window.innerHeight;
    }
    else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
        //IE 6+
        height = document.documentElement.clientHeight;
    }
    else if(document.body && (document.body.clientWidth || document.body.clientHeight))
    {
        //IE 4
        height = document.body.clientHeight;
    }
    return height;
}


function FrameResize()
{
	var top = 215;
	var visina = 1200;
	var sv = 0;

    sv = YScroll();
    if (sv>600) sv = 600;
    visina = WindowHeight() + sv - top;
    if (visina<100) visina = 100;
    
	var pframetag = gID("PonudaFrame");
	if (pframetag != null)
	{
	    if (pframetag.style.height)
		    pframetag.style.height = visina;
		else   
		    pframetag.height = visina;
	}
	var lpframetag = gID("LotoPonudaFrame");
	if (lpframetag != null)
	{
        if (lpframetag.style.height)
		    lpframetag.style.height = visina;
		else    
		    lpframetag.height = visina;
	}
	var rlframetag = gID("RezultatiUzivoFrame");
	if (rlframetag != null)
	{
	    if (rlframetag.style.height)
		    rlframetag.style.height = visina;
		else   
		    rlframetag.height = visina;
	}
	var rframetag = gID("RezultatiFrame");
	if (rframetag != null)
	{
	    if (rframetag.style.height)
		    rframetag.style.height = visina;
		else   
		    rframetag.height = visina;
	}

}

function Scroller()
{
	setInterval("FrameResize()", 500);
}

function PrintListic()
{
    window.print();
}

function PrintBefore()
{
    var df = gID("pp_listic_print");
    if (df != null) df.style.display = "none";
}

function PrintAfter()
{
    var df = gID("pp_listic_print");
    if (df != null) df.style.display = "block";
}

var defpage = "Glavna.aspx";
var content = (location.search) ? location.search.substring(1, location.search.length) : defpage;

function setFrame() {
    parent.GlavniFrame.location.href = content;
}
