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')) {
      window.sidebar.addPanel(addTitle,addUrl,'');
      return false;
  }
}

function SetAsHomepage() {
  if (document.all && !window.opera) {
    this.style.behavior='url(#default#homepage)'; 
    this.setHomePage(document.location.href); 
    return false;
  } 
  else {
    window.alert('Váš prohlížeč nepodporuje automatické nastavení této funkce.');
    return false;
  }
}

if (!document.getElementById && document.all) document.getElementById = document.all;

function SetDivBackground(id,image) {
  document.getElementById(id).style.background = 'url('+image+')';
}

function SetDivBackgroundPosition(id,position) {
  document.getElementById(id).style.backgroundPosition = position;
}

function to_clip(copytext) {
  //Inspirace: http://www.krikkit.net/howto_javascript_copy_clipboard.html
  if (window.clipboardData) {
    window.clipboardData.setData("Text", copytext);
  }
  else if (window.netscape) {
    try {
      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
    }
    catch (e) {
      alert(e);
      alert("Nemáte povoleno kopírování do schránky. Do adresního řádku napište prosím 'about:config' nastavte 'signed.applets.codebase_principal_support' na 'true'");
      return false;
    }
    var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
    if (!clip)
      return;
    var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
    if (!trans)
      return;
    trans.addDataFlavor('text/unicode');
    var str = new Object();
    var  len = new Object();
    var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
    str.data=copytext;
    trans.setTransferData("text/unicode",str,copytext.length*2);
    var clipid=Components.interfaces.nsIClipboard;
    if (!clip) return
      false;
    clip.setData(trans,null,clipid.kGlobalClipboard);
  }
  return true;
}

function from_clip() {
  //Inspirace: http://www.xulplanet.com/tutorials/xultu/clipboard.html
  var pastetext;
  if (window.clipboardData) {
    pastetext = window.clipboardData.getData("Text")
  }
  else if (window.netscape) {
    try {
      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
    }
    catch (e) {
      alert(e);
      alert("Nemáte povoleno kopírování do schránky. Do adresního řádku napište prosím 'about:config' nastavte 'signed.applets.codebase_principal_support' na 'true'");
      return false;
    }
    var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
    if (!clip)
      return false;
    var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
    if (!trans)
      return false;
    trans.addDataFlavor("text/unicode");

    clip.getData(trans,clip.kGlobalClipboard);

    var str = new Object();
    var strLength = new Object();

    trans.getTransferData("text/unicode",str,strLength);
 
    if (str)
      str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
    if (str)
      pastetext = str.data.substring(0,strLength.value / 2);
  }
  return pastetext;
}
  function ajax(stranka, kam) {
    var httpRequest;
   
    if(typeof window.ActiveXObject != 'undefined') {
      httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else {  
      httpRequest = new XMLHttpRequest();
    }
    httpRequest.open("GET", stranka, true);
    httpRequest.onreadystatechange= function () { processRequest(httpRequest, kam) };
    httpRequest.send(null);
  }

  function processRequest(httpRequest, kam) {
    if (httpRequest.readyState == 4) {
      if(httpRequest.status == 200) {
        if (typeof kam == 'string') {
          document.getElementById(kam).innerHTML = httpRequest.responseText;
        }
        if (typeof kam == 'function') {
          kam(httpRequest.responseText);
        }
      }
      else {
        //alert("Chyba pri nacitani stanky " + httpRequest.status +" : "+ httpRequest.statusText);
      }
    }
    else {
      if (typeof kam == 'string' && kam != '') {
        document.getElementById(kam).innerHTML = '.';
      }
    }
  } 
  function clearOrigInputValue(id,origValue) {
    if ( document.getElementById(id).value == origValue)
		  document.getElementById(id).value = "";
	}


function testRequired( item, message) {
	if (document.getElementById(item).value == '') {
		alert( message);
		document.getElementById( item).focus();
		return false;
  }
  return true;
}

