
function openWindow(string,mywidth,myheight)
{
	window.adminView = open(string,'adminView','width=' + mywidth + ',height=' + myheight + ',left=55,top=220,status=no,scrollbars=yes,toolbar=no,titlebar=no,location=no,menubar=no,alwaysRaised=yes');
}


// -------------------------------------------------------------------
//	Rozbalene/zabalenie polozky v organizačnej štruktúre
// -------------------------------------------------------------------
function expand(i) 
{   
	// Pozn.: Vstupny parameter: i - ID rozbalovaneho/zabalovaneho prvku

	if (document.getElementById(i + "div").style.display == "block")
	{
		// zabalenie
		document.getElementById(i + "div").style.display = "none";
		// zmena obrazku na "plus" - stav po zmene = zabaleny
		document.getElementById(i).src='../ImgAdmin/p.gif';			
		// zmaze udaj o rozbaleni polozky z cookie
		registerCookieEI(i,"delete");
	}
	else
	{
		// rozbalenie
		document.getElementById(i + "div").style.display = "block";
		// zmena obrazku na "minus" - stav po zmene = rozbaleny
		document.getElementById(i).src='../ImgAdmin/m.gif';
		// zapise udaj o rozbaleni polozky do cookie
		registerCookieEI(i, "not delete");
	}		
}



// -------------------------------------------------------------------
//	Nastavenie cookie EI: zapamatanie rozbalenych prvkov 
// (je ich viac - su ale v 1 COOKIE)
// -------------------------------------------------------------------
function registerCookieEI(arg, del) 
{             
     var today = new Date()   
     var expires = new Date()
     var name = "EI"  

     var val = getCookie(name);
     var newVal = "";


     if (del != "delete")
     {    
		if(val != null)
		{
			// vymazem staru hodnotu
	        var cookieValues = val.split("&");
		    for (counter=0; counter<cookieValues.length; counter++)
			{
				if (cookieValues[counter] != arg)
				{
					newVal += cookieValues[counter] + "&";
				}
			}

			// odsekni posledne & (ak tam je)
			if (newVal.substring(newVal.length - 1, newVal.length) == "&")
			{
				newVal = newVal.substring(0, newVal.length - 1)
			}

			// pridam novu hodnotu
			newVal = newVal+"&"+ escape(arg);
		}
		else
		{
			// pridam 1. hodnotu (stara tam iste nie je)
			newVal = escape(arg);
		}
     }
     else
     {
		// vymazem z cookie danu hodnotu
		if(val != null)
		{
	        var cookieValues = val.split("&");
		    for (counter=0; counter<cookieValues.length; counter++)
			{
				if (cookieValues[counter] != arg)
				{
					newVal += cookieValues[counter] + "&";
				}
			}

			// odsekni posledne & (ak tam je)
			if (newVal.substring(newVal.length - 1, newVal.length) == "&")
			{
				newVal = newVal.substring(0, newVal.length - 1)
			}
		}
     }

	 // session cookie - v pripade, ze je prazdna vymaz cookie
	 if (newVal != "")
	 {
		expires = null;
     }
     else
     {
          expires.setTime(today.getTime())     
     }
     
     // poslem cookie
     setCookie(name, newVal, expires);
}


// -------------------------------------------------------------------
//	Pomocna funkcia na zapis cookie so zvolenymi parametrami
// -------------------------------------------------------------------
function setCookie(name, value, expire) 
{   
     document.cookie = name + "=" + escape(value)   
     + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}



// -------------------------------------------------------------------
//	Ziskam VALUE z COOKIE zadaneho mena
// -------------------------------------------------------------------
function getCookie(Name) 
{   
   var search = Name + "="   
   if (document.cookie.length > 0) 
   { 
      // if there are any cookies      
      offset = document.cookie.indexOf(search)       
      if (offset != -1) 
      { 
		// if cookie exists          
		offset += search.length          
        // set index of beginning of value         
        end = document.cookie.indexOf(";", offset)          
        // set index of end of cookie value         
        if (end == -1)
        {
			end = document.cookie.length         
		}
        return unescape(document.cookie.substring(offset, end))      
      }    
   }   
   return null;
}
