function refreshAdThumbnails() {
	//$("#limit").attr("value", limit);
	var id = $(":radio:checked").attr('value');
	
	$.post("ad_thumbnails.php", $("#ad_selector").serialize(), function(data) {
		$("#ad_thumbnails").html(data);
		//$(":radio:eq(0)").attr('checked', true);
		$(":radio[value='"+id+"']").attr("checked", "checked");
		if (!more) {
			$(".NrintThumbnailBox:gt(27)").hide();
			$("#ad_thumbnails_more").hide();
		}
		$("a[rel^='prettyPhoto']").prettyPhoto();
	});	
}

function toggleThumbs() {
	if (more) {
		more = false;
		$(".NrintThumbnailBox:gt(23)").fadeOut("slow");	
		$("#ad_thumbnails_more").slideUp("normal");
		$(".ShowMoreAds p").html("<span style='display:block;width:138px;height:34px;background:url(/style/images/buttons/ShowMoreAds_Button.png) 0 0 no-repeat; text-align:right; padding-right:30px;'><span class='nrc_aural'>Show More Ads</span></span>");
	} else {
		more = true;
		$(".NrintThumbnailBox:gt(23)").fadeIn("slow");
		$("#ad_thumbnails_more").slideDown("normal");
		$(".ShowMoreAds p").html("<span style='display:block;width:138px;height:34px;background:url(/style/images/buttons/ShowFewerAds_Button.png) 0 0 no-repeat; text-align:right; padding-right:30px;'><span class='nrc_aural'>Show Less Ads</span></span>");
	}
		
	return false;
}

function setInput(node) {
	name = $(node).attr("name");
	value = ($(node).text() == '1');
	input = $("[value='"+name+"']");
	label = input.next("label");

	if (value) {
		input.removeAttr("disabled");
		label.removeClass("InputDisabled");
	} else {
		if ((input.attr("name") == "type2") && input.attr("checked")) {
			$("[value='static']").attr("checked", "checked");
		}	
		input.removeAttr("checked");
		input.attr("disabled", "disabled");
		label.addClass("InputDisabled");
	}
}

function setInputsFromXML(size) {
	$.get("ad_sizes.xml", {}, function(xml) {
		imgfile = $(xml).find("#"+size).attr("img");
		src = "/style/images/"+imgfile;
		if ((size == "leaderboard") || (size == "billboard")) {
			$("#AdBox1Img").hide();
			$("#LeaderBoardSpaceImg").attr("src", src);
			$("#LeaderBoardSpace").show();
		} else {
			$("#LeaderBoardSpace").hide();
			$("#AdBox1Img").attr("src", src);
			$("#AdBox1Img").show();
		}			
	
		$(xml).find("#"+size).find("type").each(function() { setInput(this); });
		$(xml).find("#"+size).find("option").each(function() { setInput(this); });
		//$(xml).find("#"+size).find("site").each(function() { setInput(this); });
	});
}

function focusSlider(activeInput) {
	min = $(".NrintSizeSelector").find(":input:first").position().left;
	max = $(".NrintSizeSelector").find(":input:last").position().left - min;
	offset = activeInput.position().left - min;		 
	sliderValue = offset / max * 100;		 
	$("#content-slider").slider('value', sliderValue);
}
