// this is going to be ratings specific JavaScript script
var action = (ratingSelections.mode == 'ratings')
			? "ratings" 
			: "ratingchanges";

jQuery(document).ready(function() {
	setupRatingsSelectionObserver();
	if ($("#title_empty")) {
		$.ajax({
			  url: "/updates/digest/",
			  dataType: 'html',
			  success: function(html){
				$("#news_empty").hide().replaceWith(html).fadeIn(200);
			  }
		});
		$.ajax({
			  url: "/ad/index/place/2",
			  dataType: 'html',
			  success: function(html){
				$("#ad2_empty").hide().replaceWith(html).fadeIn(3000);
			  }
		});		
		$.ajax({
			  url: "/ad/index/place/1",
			  dataType: 'html',
			  success: function(html){
				$("#ad1_empty").hide().replaceWith(html).fadeIn(3000);
			  }
		});	
	}
});

var setupRatingsSelectionObserver = function() {
	if ($('.ratingsSelection')) {
		$('.ratingsSelection').change( function() {
			$('.white').remove();
			$('.mar-pad').replaceWith('<img src="/images/glove-animation.gif" alt="" />');
			$.ajax({
				  url: "/ratings/" + action + "/sex/" + ratingSelections.sex + "/org/" + ratingSelections.org + "/wgt/" + $('#wgtSelect').val() + "/cp/" + $('#cpSelect').val(),
				  dataType: 'html',
				  success: function(html){
					$("#content").replaceWith(html);
					setupRatingsSelectionObserver();
					$('#footer').show();
				  }
			});
		});
	}
}

