
/**
 * Setup form for validate.
 */
function initFormValidators()
{
	$("#loginf").validate();
	$("#forgotf").validate();
	$("#orderYerbookf").validate();
	$("#createaccountf").validate();
	$("#pol1f").validate();
	$("#adsf").validate();

}

/**
 *
 */
function initNameStampingInput()
{
	$("#nameStamping").hide();
	$("#yearbookType").change (function()
	{
		$("#yearbookType :selected").each(function ()
		{
			if($(this).attr("class") == "nameStamping")
				$("#nameStamping").show();
			else
				$("#nameStamping").hide();
		});
	})
	.change();
}

/**
 *
 */
function initPollCombo()
{
	$("#pol1f :input").each(function ()
	{
		if($(this).attr("type") == "select-one")
			$(this).change(function ()
			{
				updatePollCombo(this);
			});
	});
}

/**
 *
 */
function updatePollCombo(selectedObj)
{
	$("#pol1f :input").each(function ()
	{
		if($(this).attr("type") == "select-one" && $(this).attr("name") != $(selectedObj).attr("name"))
		{
			$(this).children().each(function ()
			{
				if($(this).val() == $(selectedObj).val())
					$(this).attr("disabled", true); 
			});
		}
	});
}

/*function setRatingCommands()
{
	$('.ratingLeft').click(
		function()
		{
			idArticle = $(this).attr('id').substr(10);
			alert(idArticle + '');
			$.ajax({
				type: "POST",
				url: "add-vote.php",
				data: "idArticle=" + idArticle + "&rating=0",
				success:
					function(response)
					{
						alert(response);
					}
			})
		}
	)

	$('.ratingRight').click(
		function()
		{
			idArticle = $(this).attr('id').substr(11);
			$.ajax({
				type: "POST",
				url: "add-vote.php",
				data: "idArticle=" + idArticle + "&rating=1",
				success:
					function(response)
					{
						alert(response);
					}
			})
		}
	)
}*/

function updateRating(id, rating) //id - idNews, rating (1 = +, 0 = -)
{
	idArticle = id;
	$.ajax({
		type: "POST",
		url: "add-vote.php",
		data: "idArticle=" + idArticle + "&rating=" + rating,
		success:
			function(response)
			{
				$("#articleRating" + idArticle).html(response);
				//alert(response);
			}
	});

}