<!--
//potvrzení vymazání
function confDel(itm) {
	
	return window.confirm("Are you sure to delete this " + itm + "?");

}

//vrací řetězec bez počátečních netiskutelných znaků
function trim(str) {
	var len;
	if (!str)
		return "";
	len = str.length;

	//odstranění netisknutelných znaků na počátku řetězce
	while ((escape(str.substring(0, 1)) == "%08") || (escape(str.substring(0, 1)) == "%09") || (escape(str.substring(0, 1)) == "%0A") || (escape(str.substring(0, 1)) == "%0C") || (escape(str.substring(0, 1)) == "%0D") || (escape(str.substring(0, 1)) == "%00") || (escape(str.substring(0, 1)) == "%B6") || (escape(str.substring(0, 1)) == "%20")) {
		str = str.substring(1, len);
		len = str.length;
	}

	return str;
}

//menu
var actmnu = 0;	        //proměnná pro uchování akt. menu
var acttmnu = 0;
function menu(mnu, tmnu, w)
{
    if (typeof tmnu == "undefined" || typeof tmnu != "object")
    {
        return;
    }

	if (w == 1) {
		if (!(tmnu == utmnu1) && !(tmnu == utmnu2))
			tmnu.style.backgroundColor = "#151e77";
		tmnu.style.color = "#03bdd9";
		mnu.style.display = "block";
		actmnu = mnu;
		acttmnu = tmnu;
	}
	else {
		if (!(tmnu == utmnu1) && !(tmnu == utmnu2))
			tmnu.style.backgroundColor = "#182390";
		tmnu.style.color = "#1fdbfd";
        mnu.style.display = "none";
		actmnu = 0;
		acttmnu = 0;
	}
}

//menu_noie
var activeMenu = new Array();

function showMenu(i) {

	if (isActive(i)) {
		hideMenu(i);
		return false;
	}

    $("#menu" + i).show("normal");
	//document.getElementById("menu" + i).style.display = "block";
	//document.getElementById("text" + i).style.fontWeight = "bold";
    if (document.getElementById("text" + i))
    {
        document.getElementById("text" + i).className = "menu_opened";
        document.getElementById("text" + i).blur();
    }

	activeMenu.push(i);
	return true;


}

function hideMenu(i) {

	if (document.getElementById("text" + i))
		//document.getElementById("text" + i).style.fontWeight = "normal";
        document.getElementById("text" + i).className = "menu_closed";
    
	if (document.getElementById("menu" + i))
        $("#menu" + i).hide("fast");
//		document.getElementById("menu" + i).style.display = "none";
	else
		return false;
		
	removeItem(i);
	return true;

}

function removeItem(i) {

	newArr = new Array();

	for (x in activeMenu) {
		if (activeMenu[x] != i) {
			newArr[newArr.length] = x;
		}
	}

	activeMenu = newArr;

}

function isActive(i) {

	for (x in activeMenu) {
		if (activeMenu[x] == i) {
			return true;
		}
	}
	return false;

}
//end of menu_noie

function setstyle(id, w, t, type)
{
    obj = document.getElementById(id);
    if (typeof obj != "undefined")
    {
    	obj.style.display = "none";
    	obj.style.top = t + "px";
    	obj.style.width = w + "px";
    	obj.style.zIndex = 2;
    }
}

//nastavení viditelnosti
function setDisplay(obj, type) {
	document.getElementById(obj).style.display = type;
}

//nastavení pozice okna
function scrollWindow() {
	window.scroll(0, 0);
}

//user_menu_noie a login nalevo vedle menu_noie
function moveTab(id, x, y) {

  if (screen.availWidth > 800) {
  
  	var obj = document.getElementById(id);
  	obj.style.position = "absolute";
  	obj.style.zIndex = "2";
  	obj.style.left = x + "px";
  	obj.style.top = y + "px";
  
  }
	
}

//nastaveni textu do status baru
function defaultStatus() {
	window.status = '..:w3c:..';
}

//article
function insertItem(name, path)
{
    if (typeof tinyMCE != "undefined")
    {
        var str = '';
        if (name == 'img')
        {
            str = '<img src="' + path + '" />';
        }
        else if (name == 'file')
        {
            str = '<p style="text-align: center;"><a href="' + path + '" title="download file" target="_blank"><img src="./pics/downfile.gif" border="0" alt="download" /></a></p>';
        }
        
        if (str.length != 0)
        {
            tinyMCE.execInstanceCommand('article', 'mceInsertContent', false, str, true);
        }
    }
}

//smajlíci
function makeJsSmileys(path, type, inrow)
{
    var order = new Array(
    
    '02', '01', '08', '09', '31', '25', 
    '07', '27', '39', '38', '32', '34',
    '19', '30', '14', '18', '35', '20',
    '29', '15', '13', '28', '33', '22',
    '23', '21', '12', '26', '36', '37',
    '04', '03', '10', '17', '11', '05',
    '43', '42', '40', '06', '16', '41',
    '44' 
    
    );
    //alert(order.length);
    for (j = 0; j < order.length; j++)
    {
        i = order[j];
        document.write("&nbsp;");
        if (i != '')
        {
            document.writeln("<a href=\"javascript:" + (type == 1 ? "addsmiley('" + i + "')" : "EmotionsDialog.insert('" + i + ".gif','')") + "\"><img src=\"" + path + "/pics/smileys/" + i + ".gif\" border=\"0\" /></a>");
        }
        else
        {
            document.write("&nbsp;");
        }
        if (!((j + 1) % inrow))     
        {
            document.write("<br />");
        }
    }
}

var rss_id = 0;
var canMove = false;
var timer;
var delay = 7000;
var request_send = false;

function show_rss(feed_list, limit)
{
    if (!request_send)
    {
        if ($('#more_rss').children().length == 0)
        {
            $('#show_all').html('loading<br /><img src="./pics/loader.gif" />');
            request_send = true;
            $.get('rss_reader.php',
                  { feeds: feed_list },
                  function(data)
                  {
                    $('#more_rss').html(data);
                    $('#more_rss').show('slow');
                    $('#show_all').hide('fast');
                    $('#hide_all').show('fast');
                    $('#show_all').html('..:show all ' + limit + ':..');
                    request_send = false;
                  }
                 );
        }
        else
        {
            $('#more_rss').show('slow');
            $('#show_all').hide('fast');
            $('#hide_all').show('fast');
        }
    }
}

function loadRss()
{
    /*var li = document.createElement('li');
    $('#marquee ul').append($(li));*/
    $('#marquee ul li').html('<img src="./pics/loader.gif" />');
    $('#marquee ul li').show();
    
    $.post('rss_reader.php', { rss_all: true },
           function(data) {
                if (data != '')
                {
                    $('#marquee ul').html('');
                    $('#marquee ul').append(data);
                    $('#rssLeft').show();
                    $('#rssRight').show();
                    canMove = true;
                    $('#marquee ul li:eq(0)').fadeIn('normal', function() {
                        timer = setTimeout('moveRss(1)', delay);
                    });
                }
            });
}

function moveRss(direction)
{
    if (!canMove)
    {
        return;
    }
    
    if ($('#marquee ul li').length <= (rss_id + direction))
    {
        direction -= $('#marquee ul li').length;
    }
    else if ((rss_id + direction) < 0)
    {
        direction += $('#marquee ul li').length;
    }
    
    canMove = false;
    clearTimeout(timer);
    
    $('#marquee ul li:eq(' + rss_id + ')').fadeOut('normal', function() {
        rss_id += direction;
        $('#marquee ul li:eq(' + rss_id + ')').fadeIn('normal', function() {
            canMove = true;
            timer = setTimeout('moveRss(1)', delay);
        });
    });
}

defaultStatus();

function makeFormat(obj, tagStart, tagEnd, promptText)
{
	if (obj.setSelectionRange)
    {
		if (obj.selectionStart !== obj.selectionEnd)
        {
            obj.value = obj.value.substring(0, obj.selectionStart) + tagStart + obj.value.substring(obj.selectionStart, obj.selectionEnd) + tagEnd + obj.value.substring(obj.selectionEnd, obj.value.length);
			return;
		}
  }
  else if (document.selection)
  {
		var selectedText = document.selection.createRange().text; 

		if (selectedText !== "")
        {
			document.selection.createRange().text = tagStart + selectedText + tagEnd;
			return;
		}
	}
	
	var txt = window.prompt(promptText, "");

	if (txt !== null && txt !== "")
    {
		obj.value += tagStart + txt + tagEnd;
		obj.focus();
	}
	
	return;
}

function makeLink(obj, tagStart, tagEnd, err_text)
{
	var selText;
	var linkText = null;
    var descText = null;
	var re = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/i;
	var re2 = /^w{3}.(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/i;

	if (obj.setSelectionRange)
    {
		var start = obj.selectionStart;
		var end = obj.selectionEnd;
		
		selText = obj.value.substring(start, end);
		
		if (start !== end && (re.test(selText) || re2.test(selText)))
        {
			linkText = (re.test(selText)) ? selText : "http://" + selText;
			
            obj.value = obj.value.substring(0, start) + tagStart + selText + "||" + linkText + tagEnd + obj.value.substring(end, obj.value.length);
			return;
		}

    }
    else
    {
		selText = document.selection.createRange().text; 

		if (selText !== null && selText !== "" && (re.test(selText) || re2.test(selText)))
        {
			linkText = (re.test(selText)) ? selText : "http://" + selText;
			
			document.selection.createRange().text = tagStart + selText + "||" + linkText + tagEnd;
			return;
		}
	}
	
    if (selText === null || selText === "")
    {
        descText = window.prompt("Text:", "");
    }
    else
    {
        descText = selText;
    }
	
	if (descText !== null && descText !== "")
    {
        linkText = window.prompt("URL:", "http://");
	
		if (linkText !== null)
        {
			if (re.test(linkText)) 
            {
                if (selText !== null && selText !== "")
                {
                    if (obj.setSelectionRange)
                    {
                        obj.value = obj.value.substring(0, start) + tagStart + selText + "||" + linkText + tagEnd + obj.value.substring(end, obj.value.length);
                        return;
                    }
                    else
                    {
            			document.selection.createRange().text = tagStart + selText + "||" + linkText + tagEnd;
            			return;
                    }
                }
                else
                {
                    obj.value += tagStart + descText + "||" + linkText + tagEnd;
                    obj.focus();
                }
				return;
			}
			else
            {
				alert(err_text);
				return;
			}
		}
	}
	
	return;
}

//jQuery
$(document).ready(function(){
    
    $(".stc_min").click(function () {
        var obj = $(this).parent().parent().parent().parent().parent();
        var iobj = obj.parent().children().index(obj) - 1;
        var table = obj.siblings(":gt(" + iobj + ")").filter(":first");
        var table_text = $(this).parent().siblings("span").html();

        if ($(this).hasClass("stc_min"))
        {
            table.hide("normal");
            if (user_id > 0)
            {
                $.post("sidetable_remember.php", { str_table: table_text, str_option: 0, user_id: user_id } );
            }
            this.className = "stc_max";
        }
        else
        {
            var w = obj.attr("width") + "px";
            table.show("normal", function () { table.children().children().children().css({width: w}); });

            if (user_id > 0)
            {
                $.post("sidetable_remember.php", { str_table: table_text, str_option: 1, user_id: user_id } );
            }
            this.className = "stc_min";
        }
    });
    
     $(":input[type!='submit'][type!='button']").bind("focus", function(e){
      $(this).addClass("input_focus");
    });

     $(":input[type!='submit'][type!='button']").bind("blur", function(e){
      $(this).removeClass("input_focus");
    });
    
    /*$('#marquee marquee').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
            if ($(this).data('drag') == true) {
                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
            }
        }).mousedown(function (event) {
            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        }).mouseup(function () {
            $(this).data('drag', false);
        });*/
     
    //top rss
    $('#rssLeft').bind('click', function() {
           moveRss(-1);
           return false;
        });
    $('#rssRight').bind('click', function() {
           moveRss(1);
           return false;
        });
    loadRss();
           
    //spoiler
    $('.spoiler button').bind('click', function(e) {
        //$(this).siblings('div').toggle();
        if ($(this).siblings('div:hidden').length)
        {
            $(this).siblings('div').fadeIn();
        }
        else
        {
            $(this).siblings('div').fadeOut();
        }
    });
    
    //iccup
    $('#iccup').html('iCCup stats loading<br /><img src="./pics/loader.gif" />');
    $.get('iccup_ajax.php', {  }, function(data) { $('#iccup').html(data); } );
});
//-->