
function Contests ()
{
	this.action = function (type,contest_id,card_id)
	{
		data = new Object();
		$.post(Contests.NORMAL_URL+"index.php?pn=contest_page&fn=ContestManager->performAction&entity_id="+card_id+"&contest_id="+contest_id+"&vote="+type,data,function(data)
		{
			switch(data.code)
			{
				case "1" :
					$("#vote_up_contest_"+data.contest_id+"_"+data.card_id).html(data.vote_up);
					$("#vote_down_contest_"+data.contest_id+"_"+data.card_id).html(data.vote_down);
				break;
				case "2":
//					alert(data.msg);
					$("#icp_error_msg").html(data.msg).slideDown("slow", function () {
						setTimeout("$('#icp_error_msg').slideUp('slow')",2000);
					});
			break;
			}
		},
		"json");
		
	}
	this.addToContest = function (contest_id,card_id)
	{
		data = new Object();
		$.post(Contests.NORMAL_URL+"index.php?pn=contest_page&fn=ContestManager->addCardToContest&card_id="+card_id+"&contest_id="+contest_id,data,function(data){
//			alert("Cartea postala a fost inscrisa in concurs");
			$("#not_in_contest_box_"+data.contest_id).fadeOut("slow");
		},
		"json");
		
	}
	
	
}


Contests.NORMAL_URL = "http://hellohello.ro/";

Contests.__instance__=null;

Contests.getInstance=function()
{
	if(Contests.__instance__==null)
	{
		Contests.__instance__=new Contests();
	}
	return Contests.__instance__;
}
