	var RSSFeedURL = "http://www.tynax.com/rssfeeds/rss";
	var RSSPageURL = "http://www.tynax.com/rssgetter/";

	$(document).ready(function(){

		// The change event does not work as expected.
		// it highlights the new radio, but does not remove old highlight.
//		$("input[name='categoryid']").change(function(e){
//			if (this.checked) {
//				$(this).parent().addClass ('highlight');
//			} else {
//				$(this).parent().removeClass ('highlight');
//			}
//		});


		if (newTopics.length) {
			form = document.formRss;
			arrNewTopics = newTopics.split (',');
			
			for (i=0; i<arrNewTopics.length; i++) {
				for (j=0; j< form["categoryid"].length; j++)
				{
					if (form["categoryid"][j].value == arrNewTopics[i]) 
					{
						form["categoryid"][j].checked = true;
						$el = document.getElementById("categoryid" + form["categoryid"][j].value);
						$el.className = "highlight";

						break;
					}
				}
			}
			
			ShowRSSURL (form);
		}
		
		
	});
	
	
	function ShowRSSURL (form)
	{
		var styleid = 0;
		var rssType = "";
		var topicid = 0;

		for (i=0; i<form.rssType.length; i++)
		{
			if (form.rssType[i].checked == true) 
				{
						rssType = form.rssType[i].value; 
						break;
				}
		}

		if (rssType.length == 0)
		{
			alert ("Please select RSS type.");
			return false;	
		}

		for (i=0; i<form.styleid.length; i++)
		{
			if (form.styleid[i].checked == true) 
				{
						styleid = form.styleid[i].value; 
						break;
				}
		}

		for (i=0; i< form.categoryid.length; i++)
		{
			el = $("#categoryid" + form["categoryid"][i].value);
			if (form.categoryid[i].checked == true) 
			{
				topicid = form.categoryid[i].value; 
				form.rssurl.value = RSSFeedURL + rssType + "/" + topicid;
				form.rsspage.value = RSSPageURL + rssType + "getter/" + topicid + "/" + styleid;
				
				el.addClass ('highlight');
				
				// Do not stop loop, since we want to reset the style of highlight.
				// break;
			} else {
				el.removeClass ('highlight');
			}
		}		


		return true;	
	}

	
