	
	function showUsersComments() {
		document.getElementById('userCommentsTr').style.display = 'block';
		document.getElementById('showUsersCommentsSpan').innerHTML = 'Wasze komentarze';
		showCommentForm();
	}
	
	function showCommentForm() {
		document.getElementById('addCommentNickTr').style.display = 'block';
		document.getElementById('addCommentTextLabelTr').style.display = 'block';
		document.getElementById('addCommentTextareaTr').style.display = 'block';
		document.getElementById('addCommentCodeImageTr').style.display = 'block';
		document.getElementById('addCommentCodeInputTr').style.display = 'block';	
		document.getElementById('addCommentBtnTr').style.display = 'block';
	}
	
	function faq(pk) {
        var pe = 'faq' + pk;
        var obj = document.getElementById(pe);
        var old = obj.style.display;

        if (old == 'block') {
			var nw = 'none';
        } else {
			var nw = 'block';
        }

        obj.style.display = nw;
	}


jQuery.fn.rating = function(){
    return this.each(function(){
        var div = jQuery("<div/>").attr({
            title: this.title,
            className: this.className
        }).insertAfter( this );

        jQuery(this).find("select option").each(function(){
            div.append( this.value == "0" ?
                "<div class=\"cancel\"><a href=\"http://wapacz.pl/page/objectRate/" + this.title + ",0\" title=\"Oceń ten obiekt na: 0\" onclick=\"alert('" + this.title + "')\">Ocena na 0</a></div>" :
                "<div class=\"star\"><a href=\"http://wapacz.pl/page/objectRate/" + this.title + "," + this.value + "\" title=\"Oceń ten obiekt na: " + this.value + "\" onclick=\"window.location='http://wapacz.pl/page/objectRate/" + this.title + "," + this.value + "'\">" + this.value + "</a></div>" );
        });

        var averageRating = this.title.split(/:\s*/)[1].split("."),
            url = this.action,
            averageIndex = averageRating[0],
            averagePercent = averageRating[1];

        // hover events and focus events added
        var stars = div.find("div.star")
            .mouseover(drainFill).focus(drainFill)
            .mouseout(drainReset).blur(drainReset)
            .click(click);

        // cancel button events
        div.find("div.cancel")
            .mouseover(drainAdd).focus(drainAdd)
            .mouseout(resetRemove).blur(resetRemove)
            .click(click);

        reset();

        function drainFill(){ drain(); fill(this); }
        function drainReset(){ drain(); reset(); }
        function resetRemove(){ reset(); jQuery(this).removeClass('on'); }
        function drainAdd(){ drain(); jQuery(this).addClass('on'); }

        function click(){
            averageIndex = stars.index(this) + 1;
            averagePercent = 0;

            if ( averageIndex == 0 )
                drain();

            jQuery.post(url,{
                rating: jQuery(this).find('a')[0].href.slice(1)
            });

            return false;
        }

        // fill to the current mouse position.
        function fill( elem ){
            stars.find("a").css("width", "100%");
            stars.lt( stars.index(elem) + 1 ).addClass("hover");
        }
    
        // drain all the stars.
        function drain(){
            stars.removeClass("on hover");
        }

        // Reset the stars to the default index.
        function reset(){
            stars.lt(averageIndex).addClass("on");

            var percent = averagePercent ? averagePercent * 10 : 0;
            if (percent > 0)
                stars.eq(averageIndex).addClass("on").children("a").css("width", percent + "%");
        }
    }).remove();
};

jQuery.fn.disabledRating = function(){
    return this.each(function(){
        var div = jQuery("<div/>").attr({
            title: this.title,
            className: this.className
        }).insertAfter( this );

        jQuery(this).find("select option").each(function(){
            div.append( this.value == "0" ?
                "<div class=\"cancel\"><span>Ocena na 0</span></div>" :
                "<div class=\"disabledStar\"><span>" + this.value + "</span></div>" );
        });

        var averageRating = this.title.split(/:\s*/)[1].split("."),
            url = this.action,
            averageIndex = averageRating[0],
            averagePercent = averageRating[1];

        // hover events and focus events added
        var stars = div.find("div.disabledStar")
            .mouseover(drainFill).focus(drainFill)
            .mouseout(drainReset).blur(drainReset)
            .click(click);

        // cancel button events
        div.find("div.cancel")
            .mouseover(drainAdd).focus(drainAdd)
            .mouseout(resetRemove).blur(resetRemove)
            .click(click);

        reset();

        function drainFill(){ drain(); fill(this); }
        function drainReset(){ drain(); reset(); }
        function resetRemove(){ reset(); jQuery(this).removeClass('disabledOn'); }
        function drainAdd(){ drain(); jQuery(this).addClass('disabledOn'); }

        function click(){
            return false;
        }

        // fill to the current mouse position.
        function fill( elem ){
        }
    
        // drain all the stars.
        function drain(){
        }

        // Reset the stars to the default index.
        function reset(){
            stars.lt(averageIndex).addClass("disabledOn");

            var percent = averagePercent ? averagePercent * 10 : 0;
            if (percent > 0)
                stars.eq(averageIndex).addClass("disabledOn").children("span").css("width", percent + "%");
        }
    }).remove();
};

// fix ie6 background flicker problem.
if ( jQuery.browser.msie == true )
    document.execCommand('BackgroundImageCache', false, true);	
	
