function ShowRecArticles(templGroup, patternId, maxNews, oid){

	var recElement = $('#recArticlesBlock');
	//send request
	$.post("ajaxResponder.php", { recommended: "1", templGroup: templGroup, patternId: patternId, maxNews: maxNews, oid: oid },
		  function(data){
		    recElement.html(data);
	});
}

function ShowPoll( action, pollId ) {

	var pollElement = $('#surveyContent');
	
	// Chech for selected answer
	if(action == 'answer'){
		
		for (var i=0; i < document.pollForm.answer.length; i++){
			
			if (document.pollForm.answer[i].checked) var selectedAnswer = document.pollForm.answer[i].value;
		}
		
	}
	
	//send request
	$.post("ajaxResponder.php", { polls: "1", action: action, pollId: pollId, answerId: selectedAnswer },
		  function(data){
		    pollElement.html(data);
	});
}

function ShowWeather( lid ) {
	
	var container = $('#navWeather');
	
	//send request
	$.post("ajaxResponder.php", { weather: "1", lid: lid },
		  function(data){
		    container.html(data);
		    
		   if($.browser.msie) fixPng( document.getElementById('pngWeather') );
	});
	
	$('#searchCity').hide();
}

function SearchCity() {
	
	var sValue = $('#searchCityField').val();
	var container = $('#searchCityResults');
		
	if(sValue) {
		sValue = encodeURI(sValue);
		//send request
		$.post("ajaxResponder.php", { city: sValue },
			  function(data) {
			    container.html(data);
		});
	}
}

function increaseRating( articleId ){
	
	$.post("ajaxResponder.php", { rating: articleId },
			  function(data) {
			    $('.RatingIn'+articleId).html(data);
		});
		
}
/*
function delComment( cId , aId){
	
	var answer = confirm ("Сигурен ли си че искаш да изтриеш коментара?");

	if (answer){
		
		$.post("ajaxResponder.php", { delComment: cId, articleId: aId },
			  function(data) {
			  	
					$('#comment'+cId).css("background","#fb6c6c");
					$('#comment'+cId).slideUp(1000,function() {
					            $('#comment'+cId).remove();
          });

			});
	}
}
function approveComment( cId , aId){


		$.post("ajaxResponder.php", { approve: cId, articleId: aId },
			  function(data) {

					$('#abusiveMessage'+cId).remove();
                                        $('#abusiveShow'+cId).remove();
                                        $('#approveBtn'+cId).remove();
					$('#abusive'+cId).show();

			});

}
*/

function delComment( cId , aId, uId, logicAction){

	if(logicAction == 1) answer = confirm("Сигурни ли сте, че искате коментарът да се показва свит?");
        else answer = confirm("Сигурни ли сте, че искате да изтриете коментара?");

	if (answer){
		$("#cHide_"+cId).html('<img id="ajax-loader" src="images/loader.gif" alt="Моля изчакайте..." />');
		$.post("ajaxResponder.php", {abusiveCommentInit : 1, commId : cId, articleId: aId, commentMakerId : uId, abusiveComment : logicAction}, function(data) {
                    eval(data);
                    $("#cHide_"+cId).hide();
                });
	}
}
function reportAbusiveComment(cId, aId){
        var answer = confirm ("Сигурни ли сте, че искате да докладвате за нередност за този коментар?");

	if (answer){
                //$("#report_"+cId).html('<img src="images/loader.gif" alt="моля, изчакайте..." />');
                $("#abuseBtn"+cId).remove();
		$.post("ajaxResponder.php", {reportAbusiveComment : cId},
                    function(data) {
                        if(data != ""){
                           $("#comment_control_block_"+cId+" > .userReportAnswer").next().remove();
                           $("#comment_control_block_"+cId+" > .userReportAnswer").after(data);
                        }
                        //$("#report_"+cId).remove();
                    });
	}
}

function voteComment(cId, vType){
        //$("#vote_"+cId).html('<img src="images/loader.gif" alt="моля, изчакайте..." />');
        var countFirst, countSecond;
        if(vType == "positive"){
            countFirst = parseInt($("#comment_control_block_"+cId+" > .userVoteUpDownSelector > .userVoteUp").next().html());
            countSecond = $("#comment_control_block_"+cId+" > .userVoteUpDownSelector > .userVoteDown").next().html();
        }else{
            countFirst = parseInt($("#comment_control_block_"+cId+" > .userVoteUpDownSelector > .userVoteDown").next().html());
            countSecond = $("#comment_control_block_"+cId+" > .userVoteUpDownSelector > .userVoteUp").next().html();
        }
        countFirst++;
        //alert(countFirst);alert(countSecond);return;
        $("#comment_control_block_"+cId+" > .userVoteUpDownSelector").html('<span class="userVoteUpDis"></span><span>'+$("#comment_control_block_"+cId+" > .userVoteUpDownSelector > .userVoteUp").next().html()+'</span>'
                                                                    +'<span class="userVoteDownDis"></span><span>'+$("#comment_control_block_"+cId+" > .userVoteUpDownSelector > .userVoteDown").next().html()+'</span>');

	$.post("ajaxResponder.php", {voteComment : cId, voteType : vType, countFirst : countFirst, countSecond : countSecond}, function(data) {
             if(data != ""){
                $("#comment_control_block_"+cId+" > .userReportAnswer").next().remove();
                $("#comment_control_block_"+cId+" > .userReportAnswer").after(data);
             }
             //$("#vote_"+cId).remove();
        });
}

