
/*
 * The information and software code below,
 * located at http://www.ringrevenue.com/feed.js ,
 * are confidential and are the sole property of RingRevenue.
 * Your application or use of this information in any way is subject to
 * RingRevenue’s Terms of Service, which are located at
 * http://www.ringrevenue.com/terms_of_service. In accordance with those terms, your
 * use of this information and code may be terminated by RingRevenue at any time
 * for any reason.  The rights granted to you under those terms are expressly
 * non-exclusive. You may not sell, assign, sublicense, or otherwise transfer or
 * agree to transfer all or any portion of those rights without RingRevenue’s
 * prior written consent.  You agree not to copy, republish, frame, download,
 * transmit, modify, rent, lease, loan, sell, assign, distribute, license,
 * sublicense, reverse engineer, or create derivative works based on the
 * information and/or software code on this page except as expressly authorized
 * in RingRevenue’s Terms of Service.  Your use and continued use of this
 * information and/or code constitute your acceptance of RingRevenue’s Terms of Service.
 *
 * Copyright (c) 2009 RingRevenue (r)
 */



if(typeof(RingRevenue)=="undefined")
{var RingRevenue={URLRewriter:function(rewrite_url,rewrite_options)
{function build_regexp(regexp)
{if(regexp=='')
{return null;}
return new RegExp(regexp,'i');}
this.rewrite_base_url=rewrite_url;this.regexp=build_regexp(rewrite_options.regexp);this.insecure_prefix_regexp=new RegExp('^http:');this.secure_prefix='https:';this.secure_prefix_regexp=new RegExp('^'+this.secure_prefix);this.rewrite_url=function(url)
{if(this.regexp&&url.match(this.regexp))
{var base_url=this.rewrite_base_url;if(url.match(this.secure_prefix_regexp))
{base_url=base_url.replace(this.insecure_prefix_regexp,this.secure_prefix);}
return base_url+encodeURIComponent(url);}
return null;}},NetworkOptions:function()
{this.link_rewrite_options={};this.add=function(network_id,rewrite_options)
{this.link_rewrite_options[network_id]=rewrite_options;}
this.get_url_rewriter=function(affiliate_id,network_id)
{rewrite_options=this.link_rewrite_options[network_id];if(!rewrite_options)
{throw"Request for url_rewriter for unknown network "+network_id;}
return new RingRevenue.URLRewriter(affiliate_rewrite_url(affiliate_id,rewrite_options.affiliate_click_url_template),rewrite_options);}
function affiliate_rewrite_url(affiliate_id,url_template)
{return url_template.replace('affiliate_id',affiliate_id);}},LinkRewriter:function()
{this.url_rewriters=[];this.network_options=new RingRevenue.NetworkOptions();this.add_network_option=function(network_id,rewrite_options)
{this.network_options.add(network_id,rewrite_options);}
this.add_url_rewriter=function(affiliate_id,network_id)
{this.url_rewriters.push(this.network_options.get_url_rewriter(affiliate_id,network_id));}
this.rewrite_url=function(url)
{for(var i=0;i<this.url_rewriters.length;i++)
{var ur=this.url_rewriters[i];var new_url=ur.rewrite_url(url);if(new_url!=null)
{return new_url;}}
return url;}
this.rewrite_tag=function(tag)
{var href=tag.attr('href')
if(href!=null)
{tag.attr('href',this.rewrite_url(href));}}
this.rewrite_all=function()
{var context=this;jQuery('a').each(function(index,element){context.rewrite_tag(jQuery(this));})}},add_affiliate:function(affiliate_id,network_id)
{this.link_rewriter.add_url_rewriter(affiliate_id,network_id);},document_ready:function()
{this.link_rewriter.rewrite_all();}}
RingRevenue.link_rewriter=new RingRevenue.LinkRewriter();jQuery(document).ready(function(){RingRevenue.document_ready();});}
RingRevenue.link_rewriter.add_network_option(69,{regexp:'^https?://(www\\.)?clickserve\\.cc\\-dt\\.com',affiliate_click_url_template:'http://googleaffiliatenetwork.ringrevenue.com/c/69/-affiliate_id-?t=feed&us='});