var hodnoceniState = false;
var pripominkaState = false;

function showHodnoceni(){
	if (hodnoceniState){
		$("#hodnoceniContent").animate({
			height: '0px'
			}
		, 500, function(){ hodnoceniState = false;});
	}else{
		$("#hodnoceniContent").animate({
			height: '65px'
			}
		, 500, function(){ hodnoceniState = true;});
	}
	
}
function showPripominka(){
	if (pripominkaState){
		$("#pripominkaContent").animate({
			height: '0px'
			}
		, 500, function(){ pripominkaState = false;});
	}else{
		$("#pripominkaContent").animate({
			height: '210px'
			}
		, 500, function(){ pripominkaState = true;});
	}
	
}

$(document).ready(function(){
	$.ajaxSetup({ timeout: 10000 }); 
});

function articleVote(vote, article){
	setVoteState(2);
	$.ajax({
        url: "/articlevoteservice",
        data: { vote: vote, article: article },
        success: articleVoteSuccess,
        error: articleVoteError
    });
}

function articleVoteSuccess(result){
	if (result=="1"){
		setVoteState(3);
	}
	else{
		setVoteState(4);
	}
}

function articleVoteError(){
	setVoteState(4);
}

function setVoteState(state){
	//1=vote, 2=send, 3=sent, 4=err
	document.getElementById('voteState1').style.display='none';
	document.getElementById('voteState2').style.display='none';
	document.getElementById('voteState3').style.display='none';
	document.getElementById('voteState4').style.display='none';
	document.getElementById('voteState' + state).style.display='block';
}

function removeDefault(obj, text){
	if (obj.value==text) obj.value="";
}

function addDefault(obj, text){
	if (obj.value=="") obj.value=text;	
}




