(function(f){var c;var e=false;function d(){var m=new Array();var o=new Array();var l=new RegExp("^cbpaidsubscriptionsplan[EN]\\[(\\d+)\\]\\[selected\\]\\[\\]$","");if(!e){c.each(function(p){if(f(this).attr("checked")){f(this).attr("cbsubschkdef","1")}});c.each(function(p){var q=l.exec(f(this).attr("name"));if(q[1]=="0"){if(f(this).attr("checked")){c.filter("[name='cbpaidsubscriptionsplanE["+f(this).val()+"][selected][]'],[name='cbpaidsubscriptionsplanN["+f(this).val()+"][selected][]']").filter(function(){return(f(this).attr("cbsubschkdef")=="1")}).attr("checked",true)}}else{if(c.filter("[value='"+parseInt(q[1])+"']").filter("[name='cbpaidsubscriptionsplanE[0][selected][]'],[name='cbpaidsubscriptionsplanN[0][selected][]']").attr("checked")==""){f(this).attr("checked",false)}}})}else{var k=l.exec(f(this).attr("name"));if(k!==false){if(k[1]=="0"){if(f(this).attr("checked")){c.filter("[name='cbpaidsubscriptionsplanE["+f(this).val()+"][selected][]'],[name='cbpaidsubscriptionsplanN["+f(this).val()+"][selected][]']").filter(function(){return(f(this).attr("cbsubschkdef")=="1")}).attr("checked",true)}}else{var n=c.filter("[value='"+parseInt(k[1])+"']").filter("[name='cbpaidsubscriptionsplanE[0][selected][]'],[name='cbpaidsubscriptionsplanN[0][selected][]']");if(f(this).attr("checked")==true){n.attr("checked",true)}}}}c.each(function(p){var q=l.exec(f(this).attr("name"));if((q[1]=="0")&&(f(this).val()!="0")&&(!f(this).attr("checked"))){c.filter("[name='cbpaidsubscriptionsplanE["+f(this).val()+"][selected][]'],[name='cbpaidsubscriptionsplanN["+f(this).val()+"][selected][]']").attr("checked",false)}});c.each(function(p){if(f(this).attr("checked")){o=o.concat(cbpayHideFields[f(this).val()])}else{m=m.concat(cbpayHideFields[f(this).val()])}});if(e){for(var j=0;j<m.length;j++){f("#cbfr_"+m[j]).fadeIn("slow")}for(var j=0;j<o.length;j++){f("#cbfr_"+o[j]).fadeOut("slow")}}else{for(var j=0;j<m.length;j++){f("#cbfr_"+m[j]).show()}for(var j=0;j<o.length;j++){f("#cbfr_"+o[j]).hide()}}f("#cbregUpgrades .cbregDoHideChildren .cbregTick input").each(function(){var i=f(this).parent().next(".cbRegNameDesc").find(".cbregSubPlanSelector");if(f(this).attr("checked")==true){if(e){i.slideDown("slow")}else{i.show()}f(this).parent().parent().removeClass("cbregDoHideChildrenHidden").addClass("cbregDoHideChildrenVisible")}else{if(e){i.slideUp("slow")}else{i.hide()}f(this).parent().parent().removeClass("cbregDoHideChildrenVisible").addClass("cbregDoHideChildrenHidden")}});e=true}var g=[];function a(){var i=/^([^\[]+)[EN]\[([^\]]+)\]\[donate\]\[plan([^\]]+)\]\[donsel\]$/.exec(f(this).attr("name"));f("#"+i[1]+i[3]).attr("checked",(f(this).val()!=="")).triggerHandler("click");if(f(this).val()==="0"){f(this).parent().next("span.cbregDonationValue").fadeIn("slow");if((typeof(g[f(this).attr("name")])=="undefined")||(!g[f(this).attr("name")])){f(this).parent().next("span.cbregDonationValue").children("input.cbregDonationFreeValue").focus();g[f(this).attr("name")]=true}}else{f(this).parent().next("span.cbregDonationValue").fadeOut("slow");g[f(this).attr("name")]=false}return true}function b(){if(f(this).parent().prev("span.cbregDonationSelect").children("select.cbregDonationSelector").val()==="0"){var i=/^([^\[]+)[EN]\[([^\]]+)\]\[donate\]\[plan([^\]]+)\]\[donval\]$/.exec(f(this).attr("name"));var j=(/^ *0*\.?0* *$/.test(f(this).val()));f("#"+i[1]+i[3]).attr("checked",!j).triggerHandler("click")}return true}function h(){f(this).val(/[0-9]*\.?[0-9]*/.exec(f(this).val()));return true}f.extend({cbpaidsubs:{paidsubsInit:function(){c=f("#cbregUpgrades input[type!=hidden]").filter(function(i){return/^cbpaidsubscriptionsplan[EN]\[(\d+)\]\[selected\]\[\]$/.test(f(this).attr("name"))});d();c.click(d);f("#cbregUpgrades select.cbregDonationSelector").click(a);f("#cbregUpgrades input.cbregDonationFreeValue").blur(b).change(h).keyup(h)}}})})(jQuery);