
var c_rfx_flip = false;
var c_rfx_last = 0;

jQuery.fn.c_fixrssurl = function() {

	function c_innerFixrssurl(node) {

		if ( c_rfx_flip) {
			c_rfx_flip = false;
			// Process the 'read more' link.
			node.href = c_rfx_last;
		} else {

			var newurl = "/news/";

			//split the URL into URL and GET params
			var oldurl = node.href.split("?");


			if ( oldurl.length < 2 ) {
				return;
			}
			oldurl = oldurl[1];

			// split the params into KV sets
			var kvs = oldurl.split("&");
			// find the 'p' param
			for (i=0; i< kvs.length; i++){
				p = kvs[i];
				var p1 = p.split("=");
				if (p1[0] == "p" ) {
					c_rfx_flip = true;
					newurl += p1[1];
					c_rfx_last = newurl;
					
					node.href = newurl;
					return;
				}
			}
			// could not find c param. o well
		}

	}
	
	
	return this.each(function() {

		c_innerFixrssurl(this);
	});
};


