function include(js)
{
	document.write('<script type="text/javascript" src="'+js+'"> </script>'); 
}

function isIE()
{
   /* window.opera identifikuje prohlizec Opera ikdyz je
      nastaven tak, aby se identifikoval jako Explorer */
  if(window.opera) return false;
  return (navigator.appName == 'Microsoft Internet Explorer');
}

function isOpera()
{
  /* window.opera identifikuje prohlizec Opera ikdyz je
     nastaven tak, aby se identifikoval jako Explorer  */
   return window.opera;
}


function openWin(url,width,height,pkey)
{
        if (!pkey) pkey = 'openWin';
        if (!width) width=620;
        if (!height) height=480;
        var w = window.open(url,pkey,"width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,scrollbars=yes,resizable=yes");
	if (!w) return w;
	w.focus();
	return w;
}

function otevri (odkaz) {
       	return window.open(odkaz,"odkaz","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no");
}

function target_blank (odkaz) {
       	var w = window.open(odkaz,"t_blank","copyhistory=yes");
	if (!w) return w;
	w.focus();
	return w;
}

function openClose(id)
{
	var obj = $(id);
	if (!obj) {
		alert('Chyba JS: '+id+' not found.');
		return false;
	}
	if (obj.style.display=='block')
		obj.style.display ='none';
	else
		obj.style.display = 'block';
	return true;
}

function toggleEditor(id) {
	if (!tinyMCE.getInstanceById(id))
		tinyMCE.execCommand('mceAddControl', false, id);
	else
		tinyMCE.execCommand('mceRemoveControl', false, id);
}


function showAjaxHtml(event)
{
	var a = Event.element(event);
	var d = new Element('div', { 'class': 'ajaxhtml' });
	var img = new Element('img', {'src' : 'http://www.pierot.biz/app/img/close.gif','alt' :'[x]','class':'close' });
	var cekani = '<span>Nahrávám text, prosím čekejte ...</span>';
	d.update(cekani).insert({'top':img});
	img.observe("click", function() {
		d.style.visibility="hidden";
		d.style.display="none";
		d.remove();
	});
	a.insert({ 'before' : d} );
	
	var data = a.href.split('?')
	var getdata = new Object();
	if (data.length == 2) {
	        data = data[1];
		data = data.split('&');
		for(var i = 0; i < data.length; i++)
		{
			var x = data[i].split('=');
			getdata[x[0]] = x[1];
		}
	}
	getdata['ajax'] = 'true';

	var cajax = new cdiAjax;
	cajax.onSuccess = function(data)
	{
		d.update(data).insert({'top':img});
	};
	cajax.onError = function() { alert('error'); }
	cajax.send("GET","http://www.pierot.biz/hinc/ajax/html.php",getdata,'html');

	Event.stop(event);
	return false;
}

function parseURL(url) {
        var rx=/^((?:ht|f|nn)tps?)\:\/\/(?:([^\:\@]*)(?:\:([^\@]*))?\@)?([^\/]*)([^\?\#]*)(?:\?([^\#]*))?(?:\#(.*))?$/,
            rg=[null,'scheme','user','pass','host','path','query','fragment'],
            r=url.match(rx),i,q,ret={};
        if (r==null) return ret;

        for (i=1; i<rg.length; i++) 
                if (r[i]!=undefined)
                        ret[rg[i]]=r[i];        

        if (ret.path=='') ret.path='/';
        if (r[6]!=undefined) {
                var q=r[6];
                ret.query=Array();
                q=q.split('&');
                for (var i=0; i<q.length; i++) {
                        q[i]=q[i].split('=',2);
                        ret.query[i] = Array(unescape(q[i][0]),unescape(q[i][1]));
                }
        }
        return ret;
}

