$(document).ready(function(){

$(".fbcomments").click(function(){
	$(".fbcom").show();
	$(".allcomments").hide();
	$("#respond").hide();
return false; });

$(".normalcomments").click(function(){
	$(".fbcom").hide();
	$("#respond").show();
	$(".allcomments").show();
return false; });

$("#comment").submit(function(){
	
	var getText = tinyMCE.get('kform').getContent();
	var getName = $(".usernick").val();

	if( getText == '' ){
	
                    $("#dialog:ui-dialog").dialog("destroy");
                    $("#dialog-message").html("Twój komentarz jest za krótki, minimalna długość to 20 znaków");
                    $("#dialog-message").dialog({
                        modal: true,
                        title: "Wystąpił błąd",
                        buttons: {
                            Zamknij: function () {
                                $(this).dialog("close");
                            }
                        }
                    });
	return false; }
	
	if( getName == '' || getName == 'Twój nick' ){
	
                    $("#dialog:ui-dialog").dialog("destroy");
                    $("#dialog-message").html("Nie podałeś swojego nicka lub jest on za krótki");
                    $("#dialog-message").dialog({
                        modal: true,
                        title: "Wystąpił błąd",
                        buttons: {
                            Zamknij: function () {
                                $(this).dialog("close");
                            }
                        }
                    });
	return false; }
	
});

		$( "#slider" ).slider({
			max : 20,
			min : 10,
			value : 13,
			slide : function( event,ui )
				{
					
					$("#text_arta p").css("font-size",ui.value);
					$("#text_arta p span").css("font-size",ui.value);
					$("#text_arta p").css("line-height",19+(ui.value/3)+"px");
					
					$("#text_arta div").css("font-size",ui.value);
					$("#text_arta div span").css("font-size",ui.value);
					$("#text_arta div").css("line-height",19+(ui.value/3)+"px");

				}
		});

$(".tips,.priv_message,.zglos,.vote").tipTip({ edgeOffset: 10 });
$("#kasuj").html("Potwierdź usunięcie tego komentarza");
    $(".delete").click(function () {
        var hr = $(this).attr("href");
        $("#dialog:ui-dialog").dialog("destroy");
        $("#kasuj").dialog({
            resizable: false,
            title: "Usunąć komentarz?",
            height: 140,
            modal: true,
            buttons: {
                "Usuń komentarz": function () {
                    location.replace(hr)
                },
                Anuluj: function () {
                    $(this).dialog("close")
                }
            }
        });
        return false
    });



	$("#trackopt").change( function(){
		var opt = $(this).val();
		var kl = $(this).attr("name");
		$.ajax({
			type: "POST",
			url: "validart/trackopt.php",
			data: "val="+opt+"&id="+kl,
			beforeSend: function(){ $("#wait").html("<img src='img/22ajax-loader.gif' style='margin-left:2px; vertical-align:middle;'>"); },
			success: function(data){
				$("#wait").html(" <span>"+data+"</span>");
			},
			error: function(){  }
			});
	});


	$(".ukryj").click(function(){
	
		if( $(this).attr("rel") == 1 ){
			$("#contentright").fadeOut();
			$("#contentleft").animate({
				width: "100%"
			}, 800);
			
			$(this).attr("rel","2"); }
		else{
			$("#contentright").fadeIn();
			$("#contentleft").animate({
				width: "680px"
			}, 800);
			$(this).attr("rel","1"); }
		
		
		return false;
	});

$(".favorite").click( function(){ 
var favid = $(this).attr("name"); if( $(this).attr("rel") == "0" ){ $(this).attr("rel","1");
	$(this).html("<img style=\"vertical-align: middle; margin-right: 5px;\" src=\"img/1259852406_Favorite_16x16.png\">Usuń z ulubionych"); $(this).css("color","red"); }
	else{ $(this).attr("rel","0"); $(this).html("<img style=\"vertical-align: middle; margin-right: 5px;\" src=\"img/1259852406_Favorite_16x16.png\">Dodaj do ulubionych"); $(this).css("color","darkblue"); }
	$.ajax({ type: "GET", url: "validart/ajax_favorite.php?id="+favid, success: function(data){  }, });	return false; });

$(".recomend").click( function(){ 
var reid = $(this).attr("name"); if( $(this).attr("rel") == "0" ){ $(this).attr("rel","1");
$(this).html("<img style=\"vertical-align: middle; margin-right: 5px;\" src=\"img/1262810701_thumb-up.png\">Usuń z polecanych"); $(this).css("color","red");  } 
else{ $(this).attr("rel","0"); $(this).html("<img style=\"vertical-align: middle; margin-right: 5px;\" src=\"img/1262810701_thumb-up.png\">Dodaj do polecanych"); $(this).css("color","darkblue");  }
$.ajax({ type: "GET", url: "validart/ajax_rec.php?id="+reid, success: function(data){  }, });	return false; });

$(".vote").click( function(){
	glos = $(this).attr("name");
	idn = $(this).attr("alt");
	artid = $(this).attr("rel");
	$("#k1-"+idn).html('<img title="Ten komentarz był już przez Ciebie oceniany" src="images/plus.png" style="opacity:0.4;filter:alpha(opacity=40);"><img title="Ten komentarz był już przez Ciebie oceniany" src="images/minus.png" style="opacity:0.4;filter:alpha(opacity=40);">');
	$.get("ajaxfunctions/ajax_comvote.php?id="+idn+"&vote="+glos+"&artid="+artid, function(data){
	$("#p-"+idn).html(data);
		return false;
});	return false;});
});
