/* getElementById */

function e(a)
{
  return document.getElementById(a);
}

function oe(a)
{
  return window.opener.document.getElementById(a);
}

/* windows */

function openWindow(link, jmeno, w, h)
{
  window.open(link, jmeno, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h).focus();
}

function closePopupAndReloadParent()
{
  window.opener.window.location.reload();
  window.close();
}

function resizeWindow(w, h)
{
  window.resizeTo(w, h);
}

/* checkbox */

function changeCheckbox(id)
{
  var ch = e(id);
  if (ch)
    ch.checked = !ch.checked;
}

/* AJAX */

function createAjax()
{
  if (window.ActiveXObject)
    hr = new ActiveXObject("Microsoft.XMLHTTP");
  else
    hr = new XMLHttpRequest();
  
  return hr;
}

/* URL */

function urlencode(str) 
{
	str = escape(str);
	str = str.replace('+', '%2B');
	str = str.replace('%20', '+');
	str = str.replace('*', '%2A');
	str = str.replace('/', '%2F');
	str = str.replace('@', '%40');
	
	return str;
}

function urldecode(str) 
{
	str = str.replace('+', ' ');
	str = unescape(str);

	return str;
}

/* cookie */

function createCookie(name,value,days) 
{
	if (days) 
  {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}


function addFavorite(linkObj, addUrl, addTitle) 
{ 
  if (document.all && !window.opera) 
  {
    window.external.AddFavorite(addUrl,addTitle); 
    return false; 
  } 
  else if (window.opera && window.print) 
  {
    linkObj.title = addTitle; 
    return true; 
  } 
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) 
  {
    //if (window.confirm(question)) 
    //{
      //window.sidebar.addPanel(addTitle,addUrl,''); 
      return false; 
    //} 
  } 
  //window.alert(text); 
  return false; 
}
