
var MyCookie = {
        Write:function(name,value,days) {
                var D = new Date();
                D.setTime(D.getTime()+86400000*days)
                document.cookie = escape(name)+"="+escape(value)+
                        ((days == null)?"":(";expires="+D.toGMTString()))
                return (this.Read(name) == value);
        },
        Read:function(name) {
                var EN=escape(name)
                var F=' '+document.cookie+';', S=F.indexOf(' '+EN);
                return S==-1 ? null : unescape(        F.substring(EN=S+EN.length+2,F.indexOf(';',EN))        );
        }
}

// Parametry
var iHeight = 400;  // sirka okna
var iWidth = 300;   // vyska okna
var iXoff=20;       // offset zleva
var iX2off=20;      // offset zprava
var iYoff=20;       // -"- shora
var iY2off=80;      // -"- zdola

function Otevri_okno()
{
msg = window.open('cena_benzinu.html', 'nove_okno', 'toolbar=no, menubar=no, location=yes, directories=no, scrollbars=yes, resizable=no, status=no, width=350, height=350, top=100, left=100')
//Pozor, definice proměnné msg musí být napsána na jednom řádku!
}


function Reposition() {
var x,y;

     var pos = MyCookie.Read("newspos");
     pos = pos== null ? "" : pos;
     switch(pos) {
            case "ldn":
                  x=iXoff; y=parseInt(screen.height)-iY2off-iHeight;
                  break;
            case "rdn":
                  x=parseInt(screen.width)-iX2off-iWidth; y=parseInt(screen.height)-iY2off-iHeight;
                  break;
            case "rup":
                  x=parseInt(screen.width)-iX2off-iWidth; y=iYoff;
                  break;
            case "lup":
            case "":
                  x=iXoff; y=iYoff;
                  break;
     }
     self.moveTo(x,y);
}

function Position(thePos) {
     MyCookie.Write("newspos",thePos,365);
     Reposition();
}

function DisableNewswin() {
         MyCookie.Write('newsdisabled','yes',365);
         window.close();
}

function EnableNewswin() {
         MyCookie.Write('newsdisabled','',365)
         OpenNewswin(true);
}

function OpenNewswin(fForceOpen) {

       if(MyCookie.Read("newsdisabled")!="yes") {
          if( (MyCookie.Read("newstoday")!="yes") || (fForceOpen) ) {
                    window.open( "cena_benzinu.html", "PopupNews", "location=no,status=no,toolbar=no,menubar=no,width="+iWidth+",height="+iHeight)
                    MyCookie.Write('newstoday','yes',1);
          }
       }
}






var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj)
{  if(document.getElementById)
  { var el = document.getElementById(obj);
	  var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		var ar1 = document.getElementById("masterdiv1").getElementsByTagName("span"); //DynamicDrive.com change
		var ar2 = document.getElementById("masterdiv2").getElementsByTagName("span"); //DynamicDrive.com change
		var ar3 = document.getElementById("masterdiv3").getElementsByTagName("span"); //DynamicDrive.com change		
		
		if(el.style.display != "block")
		{  for (var i=0; i<ar.length; i++)
		   {  if (ar[i].className=="submenu") //DynamicDrive.com change
            ar[i].style.display = "none";
       } 
			 for (var i=0; i<ar1.length; i++)
		   {  if (ar1[i].className=="submenu") //DynamicDrive.com change
            ar1[i].style.display = "none";
       }
			 for (var i=0; i<ar2.length; i++)
		   {  if (ar2[i].className=="submenu") //DynamicDrive.com change
            ar2[i].style.display = "none";
       }
			 for (var i=0; i<ar3.length; i++)
		   {  if (ar3[i].className=="submenu") //DynamicDrive.com change
            ar3[i].style.display = "none";
       }
		   el.style.display = "block";
		}
		else
		{  el.style.display = "none";
		}
		
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
