var bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
var bwIE70 = (navigator.appVersion.indexOf("MSIE 7.0") != -1) ? "True" : "False";

$(function ()
{
	// top menu
	$(".hlbMenuMain li").each(function ()
	{
		// menu SHOW
		$(this).mouseenter(function ()
		{
			$("a:first", this).toggleClass("hlbMenuMainSelected");
			var offset = $("a:first", this)[0].offsetLeft;
			if (bwIE60 == "True" || bwIE70 == "True")
			{
				offset = this.offsetLeft;
			}
			$("div:first", this).css("left", offset + "px");
			$("div:first", this).show();
		});
		// menu HIDE
		$(this).mouseleave(function ()
		{
			$("div:first", this).hide();
			$("a:first", this).toggleClass("hlbMenuMainSelected");
		});
	});
	
	$(".subMenuMain li").each(function ()
	{
		// menu SHOW
		$(this).mouseenter(function ()
		{
			//$("a:first", this).toggleClass("subMenuMainSelected");
			if ($("a:first", this).attr('class')=='vLiSelected') {
			    menuclass = 0;
			} else {
			    $("a:first", this).toggleClass("vLiSelected");
			    menuclass = 1;
			}
			var offsetLeft = $("a:first", this)[0].offsetLeft;
			var offsetTop = $("a:first", this)[0].offsetTop;
			if (bwIE60 == "True" || bwIE70 == "True")
			{
				offsetLeft = this.offsetLeft;
				offsetTop = this.offsetTop;
			}
			$("div:first", this).css("left", offsetLeft + "px");
			$("div:first", this).css("top", (offsetTop + 32) + "px");
			$("div:first", this).css("border-top", "1px solid white");
			$("div:first", this).show();
		});
		// menu HIDE
		$(this).mouseleave(function ()
		{
			$("div:first", this).hide();
			if (menuclass) {
			    $("a:first", this).toggleClass("vLiSelected");
			}
		});
	});


	// model menu
	$(".mmMenuMain li", this).each(function ()
	{
		// menu SHOW
		$(this).mouseenter(function ()
		{
//			if ($("a:first").hasClass('mmMenuMainSelected')) {
//			} else {
//			    $("a:first", this).toggleClass("mmMenuMainSelected");
//			}

			$("div:first", this).show();
//			$("a:first", this).removeClass("mmMenuMain");
			$("a:first", this).addClass("mmMenuMainSelected");
			var offset = $("a:first", this)[0].offsetLeft;
			var width = $("div:first", this)[0].offsetWidth;
			if (bwIE60 == "True" || bwIE70 == "True")
			{
				offset = this.offsetLeft;
			}
			if (offset + width > 920)
			{
				var diff = 920 - (offset + width);
				offset = offset + diff;
			}
			$("div:first", this).css("left", offset + "px");
		});
		// menu HIDE
		$(this).mouseleave(function ()
		{
			$("div:first", this).hide();
//			$("a:first", this).toggleClass("mmMenuMainSelected");
			$("a:first", this).removeClass("mmMenuMainSelected");
//			$("a:first", this).addClass("mmMenuMain");
		});
	});


    $("#featured").tabs({
	event: 'mouseover',
	fx:{opacity: 'toggle',duration: 'slow'}
    }).tabs("rotate", 6000, true);

    $("#xtabspanel").hover(
	function() {
	    $("#featured").tabs("rotate",0,true);
	},
	function() {
	    $("#featured").tabs("rotate",6000,true);
	}
    );

    var tabContainers = $('div.tabs1 > div');
    $('div.tabs1 ul.tabNavigation1 a').click(function () {
	tabContainers.hide().filter(this.hash).show();
	$('div.tabs1 ul.tabNavigation1 a').parent().removeClass('selected');
	$(this).parent().addClass('selected');
	return false;
//    }).filter(':first').click(function () {
//	return false;
    });

    var tabContainers2 = $('div.tabs2 > div');
    $('div.tabs2 ul.tabNavigation2 a').click(function () {
	tabContainers2.hide().filter(this.hash).show();
	$('div.tabs2 ul.tabNavigation2 a').parent().removeClass('selected');
	$(this).parent().addClass('selected');
	return false;
    });



});

function fasel() {
    return false;
}


var bIsFirebugReady = (!!window.console && !!window.console.log);

function reply_to(id,from_facebox) {

        tema_id = $('#listingform input[name="tema"]').getValue();
        clanok_id = $('#listingform input[name="id"]').getValue();
        //alert('tema: ' + tema_id + ' | id: ' + clanok_id);
	    $.ajax({  
	        url: '?forum=comment_form&tema=' + tema_id + '&id=' + clanok_id + '&prispevok=' + id,
	        type: "GET",
	        cache: false,
	        async: false,
	        success: function (html) {
	            if (from_facebox) {
	                jQuery.facebox(html);
	            } else {
	                $("div#facebox .content").html(html);
	            }
	        }
	    });
	}
	

function add_friends(login,id,from_facebox) {
	    $.ajax({  
	        url: '/community/index.php',
	        type: "POST",
        	data: 'action=add_friend&usr_id=' + id + '&usr_name=' + login,
	        cache: false,
	        async: false,
	        success: function (html) {
	    	    if (html.success) {
	    		output = "<img id='checkmark' src='/community/rating/green_check.png' /><br />"+ html.message;
	    	    } else {
	    		output = '<span class="show_error">' + html.message + '</span>';
	    	    }
	            if (!from_facebox) {
	                jQuery.facebox(output);
	            } else {
	                $("div#facebox .content").html(output);
	            }
	        }
	    });
	    return false;
	}

function add_ignore(login,id,from_facebox) {
	    $.ajax({  
	        url: '/community/index.php',
	        type: "POST",
        	data: 'action=add_ignore&usr_id=' + id + '&usr_name=' + login,
	        cache: false,
	        async: false,
	        success: function (html) {
	    	    if (html.success) {
	    		output = "<img id='checkmark' src='/community/rating/green_check.png' /><br />"+ html.message;
	    	    } else {
	    		output = '<span class="show_error">' + html.message + '</span>';
	    	    }
	            if (!from_facebox) {
	                jQuery.facebox(output);
	            } else {
	                $("div#facebox .content").html(output);
	            }
	        }
	    });
	    return false;
	}
	

function show_podmienky() {
	jQuery.facebox({ div: '/login/index.php?page=podmienky'});
	return false;
}
function submit_bug() {
	    the_id = 'user';
	    the_url = window.location;
	    jQuery.facebox({ div: '/community/index.php?page=submit_bug&url=' + the_url});
/*
    	    jQuery.facebox(function() {
    		jQuery.post('/community/index.php?page=submit_bug', { usr_id: the_id, url: the_url })
    	    })
*/
}


function send_message_form(login,id,from_facebox) {

	    $.ajax({  
	        url: '/community/index.php',
	        type: "POST",
        	data: 'action=pm_form&usr_id=' + id + '&usr_name=' + login,
	        cache: false,
	        async: false,
	        success: function (html) {
	            if (!from_facebox) {
	                jQuery.facebox(html);
	            } else {
	                $("div#facebox .content").html(html);
	            }
	        }
	    });
	    return false;
	}
	
	
function send_pm() {

    	dataString = $("#pm_form").serialize();
    	
    	if (!$("#pm_form #pm_message").val()) {
        	$("#facebox #error_text").fadeOut("fast");
            $('#facebox #error_text').html("Nezadaný text správy!");
            $('#facebox textarea').css("border","1px solid #cc0000");
        	$("#facebox #error_text").fadeIn();
    	    return false;
    	}

        $.ajax({
            type: "POST",
            url: "/community/index.php",
            async: false,
            data: dataString,
            success: function(data) {
                if (data.success) {
                    message = "<h3>Odoslanie kratkej spravy!</h3>";
                    $('#facebox .content').html(message);
            	    $('#facebox .content').append("<img id='checkmark' src='/community/rating/green_check.png' />");
            	    $('#facebox .content').append("<p>"+data.message+"</p>");
            	} else {
            	    $('#add_comment_autor').html('<span class="show_error">' + data.message + '</span>');
            	}
            }
        });

	    return false;
	}
	
function send_comment() {
        
        dataString = $("#comment_form").serialize();
        
        nadpis = $('#comment_form input[name="nazov"]').getValue();
        text = $('#comment_form textarea[name="text"]').getValue();
        prispevok = $('#comment_form input[name="prispevok"]').getValue();
        
        if (!prispevok && !nadpis) {
            $('#add_comment_autor').html('<span class="show_error">CHYBA: zadajte nadpis vášho príspevku</span>');
            $('#comment_form input[name="nazov"]').css("border","1px solid red");
            $('#comment_form textarea[name="text"]').css("border","1px solid #999");
            return false;
        }
        if (!prispevok && nadpis) {
            $('#comment_form input[name="nazov"]').css("border","1px solid #999");
        }
        
        if (!text) {
            $('#add_comment_autor').html('<span class="show_error">CHYBA: zadajte text vášho príspevku</span>');
            $('#comment_form textarea[name="text"]').css("border","1px solid red");
            return false;
        } else {
            $('#comment_form textarea[name="text"]').css("border","1px solid #999");
        }
        
        povodne = $('#facebox .content').html();

        output = "<img src='/community/rating/spinner.gif' alt='' /> odosiela sa informácia ... ";
//        $('#add_comment_autor').html(output);
        $('#facebox #comment_form_data').fadeOut('slow');
        
        $.ajax({
            type: "POST",
            url: "index.php",
//            async: false,
            data: dataString,
            success: function(data) {
                if (data.success) {
                    message = "<h3>Pridanie príspevku!</h3>";
                    $('#facebox .content').html(message);
            	    $('#facebox .content').append("<img id='checkmark' src='/community/rating/green_check.png' />");
            	    //$('#facebox .content').append("<p>Ďakujeme za Váš názor.</p>");
            	    $('#facebox .content').append("<p>"+data.message+"</p>");
            	} else {
            	    //$('#facebox .content').append("<p>"+data.message+"</p>");
            	    //$('#facebox .content').append(povodne);
            	    $('#add_comment_autor').html('<span class="show_error">' + data.message + '</span>');
                    //$('#facebox #comment_form').fadeIn();
            	}
            }
        });

	    return false;
	}

function report_bug_func() {

        bug_email = $('input[name="bug_email"]').getValue();
        bug_url = $('input[name="bug_url"]').getValue();
        bug_text = $('textarea[name="bug_text"]').getValue();

        $('#facebox .content').empty();
        output = "<img src='/community/rating/spinner.gif' alt='' /> odosiela sa informácia ... ";
        $('#facebox .content').html(output);
        $('#facebox .body').width('400px');
        
        var dataString = 'action=report_bug&bug_url='+ bug_url + '&bug_text=' + bug_text + '&bug_email=' + bug_email;
        $.ajax({
            type: "POST",
            async: false,
            url: "/community/index.php",
            data: dataString,
            success: function() {
                message = "<h3>Upozornenie na chybu!</h3>";
                $('#facebox .content').html(message);
                $('#facebox .content').append("<img id='checkmark' src='/community/rating/green_check.png' />");
                $('#facebox .content').append("<p>Ďakujeme za Váš názor.</p>");
            }
        });
        return false;

}

function report_comment_func() {



        reason = $('input[name="reason"]').getValue();
        reason_text = $('input[name="reason_text"]').getValue();
        report_comment = $('input[name="report_comment_id"]').getValue();

        $('#facebox .content').empty();
        output = "<img src='/community/rating/spinner.gif' alt='' /> odosiela sa informácia ... ";
        $('#facebox .content').html(output);
        $('#facebox .body').width('400px');
        
        var dataString = 'action=report_comment&reason='+ reason + '&reason_text=' + reason_text + '&report_comment=' + report_comment;
        $.ajax({
            type: "POST",
            async: false,
            url: "index.php",
            data: dataString,
            success: function() {
                message = "<h3>Upozornenie na nevhodný príspevok!</h3>";
                $('#facebox .content').html(message);
                $('#facebox .content').append("<img id='checkmark' src='/community/rating/green_check.png' />");
                $('#facebox .content').append("<p>Ďakujeme za Váš názor.</p>");
            }
        });
        return false;

	}

	function xreport_comment_func() {

        $.ajaxSetup({
            async: false
        });
        
        output = "<img src='/community/rating/spinner.gif' alt='' /> odosiela sa informácia ... ";
        $('#facebox .content').html(output);
        $.ajax({
            url: '/spravy/index.php', 
            type: 'POST',
            data: $("#report_comment_form").serialize(),
            success: function(data) {
                html = '<h3>Upozornenie pre redakciu na nevhodný príspevok</h3>';
                html += '<img src="/community/rating/green_check.png" alt="" />';
                $('#facebox .content').empty();
                $('#facebox .content').html(data);
            }
        });

        return false;
	}




$(function(){


//$.facebox.settings.opacity = 0.8

	$("input.forum_filter").click(function(){
	    filter = $(this).attr('value');
		$.ajax({
			type: "POST",
			data: "action=comments_filter&id="+filter,
			url: "index.php",
			success: function(msg)
			{
            	output = "<img src='/community/rating/spinner.gif' alt='' /> nahrávajú sa diskusné príspevky ... ";
            	jQuery.facebox(output);
			    window.location.reload();
			}
		});
	});
	
	$(".friend_list_msg").click(function(){
	    the_id = $(this).attr('id');
	    the_id = the_id.substr(4);
    	    autor = $('.autor_' + the_id + " .autor").html();
	    //alert(the_id + autor);

    	    jQuery.facebox(function() {
    		jQuery.post('/community/index.php', { usr_name: autor , usr_id: the_id, action: 'pm_form' }, function(data) {
        		jQuery.facebox(data)
    		})
    	    })

	    return false;
	});

	$(".friend_list_add").click(function(){
	    the_id = $(this).attr('id');
	    the_id = the_id.substr(4);
    	    autor = $('.autor_' + the_id + " .autor").html();
	    //alert(the_id + autor);

    		$.ajax({
    			type: "POST",
    			data: "action=confirm_friend&usr_id="+the_id,
    			url: "index.php",
    			success: function(msg)
    			{
    			    $('#row_' + the_id).fadeOut('slow');
    			}
    		});
	    return false;
	});

	$(".friend_list_ignore").click(function(){
	    the_id = $(this).attr('id');
	    the_id = the_id.substr(4);
    	    autor = $('.autor_' + the_id + " .autor").html();
	    //alert(the_id + autor);

    		$.ajax({
    			type: "POST",
    			data: "action=ignore_friend&usr_id="+the_id,
    			url: "index.php",
    			success: function(msg)
    			{
    			    $('#row_' + the_id).fadeOut('slow');
    			}
    		});

	    return false;
	});


	$("a.alt_score").click(function(){
	    the_id = $(this).attr('id');
    	    $("div#alt_score_"+the_id).remove();
    	    $("div#score_"+the_id).fadeIn();
    	    $("a#score_"+the_id).fadeIn();
    	    $("#prispevok_"+the_id+" .prispevok_info").css("opacity","1");
    	    $("#prispevok_"+the_id+" .prispevok_info").css("filter","alpha(opacity=100)");
    	
    	    $("#vote_buttons"+the_id+" a").css("visibility","visible");
    	    $("#vote_buttons"+the_id+" .vote_slider").css("opacity","100");
	});
	
	$("a.vote_up").click(function(){
    	    //get the id
    	    the_id = $(this).attr('id');
    	
    	        // show the spinner
    		$(this).parent().html("<img src='/community/rating/spinner.gif' alt='' />");
    	
        	//fadeout the vote-count 
		$("span#votes_count"+the_id).fadeOut("fast");
    	
    		//the main ajax request
    		$.ajax({
    			type: "POST",
    			data: "action=vote_up&id="+$(this).attr("id"),
    			url: "/spravy/index.php",
    			success: function(msg)
    			{
    				$("span#votes_count"+the_id).html(msg);
    				//fadein the vote count
    				$("span#votes_count"+the_id).fadeIn();
    				//remove the spinner
    				$("span#vote_buttons"+the_id).remove();
    				$("#comment_menu_" + the_id + " li").remove();
    			}
    		});
    		
	});
	
	$("a.vote_down").click(function(){
    	    //get the id
    	    the_id = $(this).attr('id');

    	        // show the spinner
    		$(this).parent().html("<img src='/community/rating/spinner.gif' alt=''/>");

        	//fadeout the vote-count 
		$("span#votes_count"+the_id).fadeOut("fast");
    	
    		//the main ajax request
    		$.ajax({
    			type: "POST",
    			data: "action=vote_down&id="+$(this).attr("id"),
    			url: "/spravy/index.php",
    			success: function(msg)
    			{
    				$("span#votes_count"+the_id).fadeOut();
    				$("span#votes_count"+the_id).html(msg);
    				$("span#votes_count"+the_id).fadeIn();
    				$("span#vote_buttons"+the_id).remove();
    			}
    		});
	});

	$("a.submit_button").click(function(){
	    return false;
	});
	
	$("div.close_comment").click(function(){
	        $(".comment_menu").css("display","none");
	});
	
	$("div.comment_menu").click(function(){
    	    the_id = $(this).attr('id');
    	    the_id = the_id.substr(13);
	        $("#comment_menu_" + the_id + " li").css("list-style","circle");
	});

	$("div.prispevok_info").click(function(){
    	    the_id = $(this).attr('id');
    	    the_id = the_id.substr(15);
	        $("#comment_menu_" + the_id).css("display","block");
    	    $("#comment_menu_" + the_id + " li").css("display","block");
	        $("#comment_menu_" + the_id + " li").css("list-style","circle");
	        $("#comment_menu_" + the_id + " .close_comment").css("display","block");
	});
	
	$("a.report_info_link").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(17);
    	//alert(the_id);
    	output = $('#reports_' + the_id).html();
    	jQuery.facebox(output);
    	
	});
	
	$("img.avatar_img").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(7);
    	autor = $('.autor_' + the_id + " .autor").html();
    	output = '<div align="center">';
    	if (autor) output = '<h3>' + autor + '</h3>';
    	output += '<img src="/avatars/avatar.php/' + the_id + '/'+ autor  + '/2/avatar.jpg?' + (new Date()).valueOf() + '" alt="' + autor  + '" /></div>';
    	
    	jQuery.facebox(function() {
    	    jQuery.post('/avatars/user.php', { login: autor , id: the_id }, function(data) {
    		jQuery.facebox(data)
    	    })
    	})
	});
	
	$("a.delete_comment_1").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(16);

        jConfirm('Naozaj zmeniť text príspevku na ******** ?', '',
            function(r) {
                if(r==true) {
                    $("#box").fadeOut(300);
            		$.ajax({
            			type: "GET",
            			async: false,
            			data: "forum=form&delete_comment_1=true&prispevok="+ the_id,
            			//url: "{REQUEST_URI}",
            			//url: "index.php",
            			success: function(msg)
            			{
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_1").fadeOut();
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_1").html(msg.message);
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_1").fadeIn();
            			    //$("#prispevok_" + the_id).fadeOut();
            			}
            		});
                   }
               });
	});

	$("a.delete_comment_2").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(16);

        jConfirm('Naozaj zmeniť celkom vymazať príspevok #' + the_id + '?', '',
            function(r) {
                if(r==true) {
                    $("#box").fadeOut(300);
            		$.ajax({
            			type: "GET",
            			async: false,
            			data: "forum=form&delete_comment_2=true&prispevok="+ the_id,
            			//url: "{REQUEST_URI}",
            			//url: "index.php",
            			success: function(msg)
            			{
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_2").fadeOut();
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_2").html(msg.message);
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_2").fadeIn();
            			    $("#prispevok_" + the_id).fadeOut();
            			}
            		});
                   }
               });
	});

	$("a.delete_comment_3").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(16);

        jConfirm('Naozaj zmeniť celkom vymazať príspevok #' + the_id + ' a vsetky jeho reakcie ?', '',
            function(r) {
                if(r==true) {
                    $("#box").fadeOut(300);
            		$.ajax({
            			type: "GET",
            			async: false,
            			data: "forum=form&delete_comment_3=true&prispevok="+ the_id,
            			//url: "{REQUEST_URI}",
                        //url: "index.php",
            			success: function(msg)
            			{
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_3").fadeOut();
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_3").html(msg.message);
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_3").fadeIn();
            			    $("#prispevok_" + the_id).fadeOut();
            			}
            		});
                   }
               });
	});

	$("a.delete_comment_5").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(16);

        jConfirm('Naozaj chcete celkom vymazať vsetky prispevky tohto autora zo vsetkych diskusii ?', '',
            function(r) {
                if(r==true) {
                    $("#box").fadeOut(300);
            		$.ajax({
            			type: "GET",
            			async: false,
            			data: "forum=form&delete_comment_5=true&prispevok="+ the_id,
            			//url: "{REQUEST_URI}",
                        //url: "index.php",
            			success: function(msg)
            			{
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_5").fadeOut();
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_5").html(msg.message);
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_5").fadeIn();
            			    $("#prispevok_" + the_id).sleep(1000).fadeOut();
            			}
            		});
                   }
               });
	});


	$("a.make_moderator").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(16);

        jConfirm('Naozaj spraviť z autora príspevku<br /><b>moderatora</b> diskusie na tomto webe ?', '',
            function(r) {
                if(r==true) {
                    $("#box").fadeOut(300);
            		$.ajax({
            			type: "GET",
            			async: false,
            			data: "forum=form&make_moderator=true&prispevok="+ the_id,
            			//url: "{REQUEST_URI}",
            			//url: "index.php",
            			success: function(msg)
            			{
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_4").fadeOut();
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_4").html(msg.message);
            			    $("#comment_menu_" + the_id + " li.li_delete_comment_4").fadeIn();
            			}
            		});
                   }
               });
	});


	$("a.report_comment").click(function(){

        output = $('.div_report_comment').html();
        
    	the_id = $(this).attr('id');
    	autor = $('#comment_autor_' + the_id).html();
    	prispevok = $('#comment_text_' + the_id).html();
    	datum = $('#prispevok_info_' + the_id + ' .datum') .html();
    	$('input[name="report_comment_id"]').setValue(the_id);
        $('#report_comment_autor').html('Autor: ' + autor);
        $('#report_comment_text').html(prispevok + the_id);
        $('#report_comment_datum').html(prispevok + the_id);

	jQuery.facebox(function() {
	    jQuery.post('/community/rating/remote_report_comment.php', { autor: autor , id: the_id, comment: prispevok, datum: datum }, function(data) {
		jQuery.facebox(data)
	    })
	})

	});
	
	$("a.reaguj_a").click(function(){
	    the_id = $(this).attr('id');
    	    the_id = the_id.substr(8);
	    reply_to(the_id,true);
	    return false;
	});
	
	$("input#add_button").click(function(){
	    reply_to(-1,true);
	    return false;
	});

	$("a.reakcia_comment").click(function(){

    	the_id = $(this).attr('id');
        msg = $('#prispevok_info_' + the_id).html();
        //reagovat = '<div class="forum_reaguj" style="height: 30px;"><a class="reaguj_a" href="index.php?id={ID}&amp;forum=form&amp;prispevok=' + the_id + '">Reagovať</a></div>';
        reagovat = '<div class="forum_reaguj" style="height: 30px;"><a class="reaguj_a" href="javascript:reply_to(' + the_id + ')">Reagovať</a></div>';
        if (!msg) {
    		$.ajax({
    			type: "POST",
    			data: "forum=one&ajax=true&id={ID}&prispevok="+the_id,
    			url: "index.php",
    			success: function(data) {
    			    var $response=$(data);
    			    msg = $response.find('#prispevok_info_' + the_id).html();
                	    msg += '<hr />' + $response.find('#comment_text_' + the_id).html();
                	    msg += reagovat;
                	    jQuery.facebox('<h3>Pôvodný príspevok</h3>'+ msg);
    			}
		    });
        } else {
            msg += '<hr />' + $('#comment_text_' + the_id).html();
            msg += reagovat;
            jQuery.facebox('<h3>Pôvodný príspevok</h3>'+ msg);
        }

	});


	$("a.vote_spam").click(function(){
	//get the id
	the_id = $(this).attr('id');
	
	// show the spinner
	$(this).parent().html("<img src='/community/rating/spinner.gif' alt='' />");
	
	//the main ajax request
		$.ajax({
			type: "POST",
			data: "action=vote_spam&id="+$(this).attr("id"),
			url: "index.php",
			success: function(msg)
			{
				$("span#votes_count"+the_id).fadeOut();
				$("span#votes_count"+the_id).html(msg);
				$("span#votes_count"+the_id).fadeIn();
				$("span#vote_buttons"+the_id).remove();
			}
		});
	});


    $(".mail_autor").click(function(){
    	the_id = $(this).attr('id');
    	the_id = the_id.substr(6);
    	autor = $('#autor_' + the_id + ' span').html();
    	output = '<div align="center">';
    	if (autor) output = '<h3>' + autor + '</h3>';
    	output += '<img src="/avatars/avatar.php/' + the_id + '/'+ autor  + '/2/avatar.jpg?' + (new Date()).valueOf() + '" alt="' + autor  + '" /></div>';
    	
    	jQuery.facebox(function() {
    	    jQuery.post('/avatars/user.php', { login: autor , id: the_id }, function(data) {
    		jQuery.facebox(data)
    	    })
    	})
    });

	$("a.mail_delete").click(function(){
	    the_id = $(this).attr('id');
	    the_id = the_id.substr(7);

	    $.post($(this).attr('href'), function(data){
    		if(data.success) {
        		$('#row_msg' + the_id).fadeOut('slow');
		    } else {
	                jQuery.facebox('<span class="show_error">' + data.message + '</span>');
		    }
	    });
    
    	    return false;

	});

});	


function highlight_comment(comment_id) {
	var comment_message_main = document.getElementById('prispevok_' + comment_id);
	comment_message_main.style.border = '1px solid red';
	comment_message_main.style.top = '10px';
}


