window.CIOC={};function CheckAll(){for(var a=document.RecordList,b=a.elements.length,d=0;d<b;d++){var e=a.elements[d];if(e.name=="IDList")e.checked=true}}function ClearAll(){for(var a=document.RecordList,b=a.elements.length,d=0;d<b;d++){var e=a.elements[d];if(e.name=="IDList")e.checked=false}}function add_class(a,b){if(a)if(!RegExp("\\b"+b+"\\b").test(a.className)){if(a.className)b=" "+b;a.className+=b}}
function remove_class(a,b){if(a){for(var d=a.className.split(" "),e=[],o=0;o<d.length;o++){var k=d[o];k!=b&&e.push(k)}a.className=e.join(" ")}}function hide(a){add_class(a,"NotVisible")}function show(a){remove_class(a,"NotVisible")}function openWin(a,b){popWin=window.open(a,b,"toolbar=no,width=490,height=485,location=no,scrollBars=yes,resizable=no,titlebar=yes");popWin.focus()}
function openWinL(a,b){popWin=window.open(a,b,"toolbar=no,width=650,height=520,location=no,scrollBars=yes,resizable=no,titlebar=yes");popWin.focus()}function openWinXL(a,b){popWin=window.open(a,b,"toolbar=no,width=755,height=550,location=no,scrollBars=yes,resizable=no,titlebar=yes");popWin.focus()}jQuery(function(a){var b={sm:openWin,lg:openWinL,xl:openWinXL};a("a.poplink").live("click",function(){var d=a(this).data("popargs");(b[d.size||"sm"]||openWin)(this.href,d.name||"popwin");return false})});
(function(){var a=jQuery,b={},d=function(c){if(c!==null&&typeof c!=="undefined")a("#myListCount").text(c);else if(c=a("#myListCount").text())c=parseInt(c,10);c?b.myListLink.show():b.myListLink.hide()},e=function(c){a.each(c,function(g,j){a("#added_to_list_"+j).show();a("#add_to_list_"+j).hide()})},o=function(c){return function(g){if(g.fail)alert(g.errinfo);else{if(g.ids)d(a.grep(g.ids,h[b.domain]).length);else g.count?d(g.count):d(0);e([c])}}},k=function(c){c=a(c.currentTarget).data("id");a.ajax({success:o(c),
dataType:"json",error:function(){alert("Error")},data:{id:c},type:"POST",url:b.current_list_url})},q=function(c){return function(g){if(g.fail)alert(g.errinfo);else{g=true;if(c){var j=a("#results_table #remove_from_list_"+c);if(!j.length){g=false;j=a("#results_container #remove_from_list_"+c)}j.parent().parent().remove()}j=false;if((j=g?a("#results_table tr").length===1:a("#results_container > p").length===0)||!c){a("#records_ui").hide();a("#no_records_message").show()}}}},r=function(c){c=a(c.currentTarget).data("id");
a.ajax({success:q(c),dataType:"json",error:function(){alert("Error")},data:{ID:c,RemoveItem:b.domain},type:"POST",url:b.current_list_url})},p=function(){a.ajax({success:q(),dataType:"json",error:function(){alert("Error")},data:{ID:"all",RemoveItem:b.domain},type:"POST",url:b.current_list_url})},h={CIC:function(c){return/^[A-Za-z]{3}[0-9]{4,5}$/.test(c)},VOL:function(c){return/^[1-9][0-9]*$/.test(c)}},n=function(c){if(c.fail)i();else if(c.inrequest){var g=a.grep(c.ids,h[b.domain]);e(g);d(g.length);
(c=c.previous_ids)&&a.each(c,function(j,m){a("#ct_added_to_previous_request_"+m).show()});a(".ListUI img").prop("src",function(j,m){return m.replace("list","referral")});a("#list_header_text").hide();a("#ct_header_text").show();b.current_list_url=b.ct_update_url;l()}else i()},i=function(){var c=function(){b.list_view_mode||e(b.already_added||[]);b.current_list_url=b.list_view_mode&&b.list_view_mode==="ct"?b.ct_update_url:b.list_update_url;d((b.already_added||[]).length);l()};!b.list_view_mode&&!b.has_session?
a.ajax({dataType:"json",error:null,url:b.list_update_url,data:{SessionTest:"on"},type:"POST",success:function(g){g.has_session&&c()}}):c()},l=function(){a(".HideListUI").delegate(".add_to_list","click",k).delegate(".remove_from_list","click",r).removeClass("HideListUI");a("#remove_all_from_list").click(p);a.browser.msie&&a.browser.msie<"8.0"&&a(".ListUI").removeClass("FixIE")};window.init_list_adder=function(c){b=c;b.myListLink=a("#myListLink").parent(":hidden").add("#myListLink");c.in_request?a.ajax({success:n,
dataType:"json",error:null,type:"POST",url:c.in_request}):i()}})();if(!this.JSON)this.JSON={};
(function(){function a(h){return h<10?"0"+h:h}function b(h){o.lastIndex=0;return o.test(h)?'"'+h.replace(o,function(n){var i=r[n];return typeof i==="string"?i:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+h+'"'}function d(h,n){var i,l,c,g,j=k,m,f=n[h];if(f&&typeof f==="object"&&typeof f.toJSON==="function")f=f.toJSON(h);if(typeof p==="function")f=p.call(n,h,f);switch(typeof f){case "string":return b(f);case "number":return isFinite(f)?String(f):"null";case "boolean":case "null":return String(f);
case "object":if(!f)return"null";k+=q;m=[];if(Object.prototype.toString.apply(f)==="[object Array]"){g=f.length;for(i=0;i<g;i+=1)m[i]=d(i,f)||"null";c=m.length===0?"[]":k?"[\n"+k+m.join(",\n"+k)+"\n"+j+"]":"["+m.join(",")+"]";k=j;return c}if(p&&typeof p==="object"){g=p.length;for(i=0;i<g;i+=1){l=p[i];if(typeof l==="string")if(c=d(l,f))m.push(b(l)+(k?": ":":")+c)}}else for(l in f)if(Object.hasOwnProperty.call(f,l))if(c=d(l,f))m.push(b(l)+(k?": ":":")+c);c=m.length===0?"{}":k?"{\n"+k+m.join(",\n"+k)+
"\n"+j+"}":"{"+m.join(",")+"}";k=j;return c}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var e=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k,q,r={"":"\\b","\t":"\\t","\n":"\\n","":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},p;if(typeof JSON.stringify!=="function")JSON.stringify=function(h,n,i){var l;q=k="";if(typeof i==="number")for(l=0;l<i;l+=1)q+=" ";else if(typeof i==="string")q=i;if((p=n)&&typeof n!=="function"&&(typeof n!=="object"||typeof n.length!=="number"))throw Error("JSON.stringify");return d("",{"":h})};
if(typeof JSON.parse!=="function")JSON.parse=function(h,n){function i(c,g){var j,m,f=c[g];if(f&&typeof f==="object")for(j in f)if(Object.hasOwnProperty.call(f,j)){m=i(f,j);if(m!==undefined)f[j]=m;else delete f[j]}return n.call(c,g,f)}var l;h=String(h);e.lastIndex=0;if(e.test(h))h=h.replace(e,function(c){return"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(h.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){l=eval("("+h+")");return typeof n==="function"?i({"":l},""):l}throw new SyntaxError("JSON.parse");}})();
function get_form_values(a){var b={};jQuery(a).find("input,select,textarea").each(function(){if(this.name){b[this.name]||(b[this.name]=[]);if(this.nodeName.toLowerCase()==="select"){var d=b[this.name];$(this).find("option").each(function(){this.selected&&d.push(this.value)})}else this.nodeName.toLowerCase()==="input"&&(this.type==="checkbox"||this.type==="radio")&&!this.checked||b[this.name].push(this.value||"")}});return b}
function restore_form_values(a,b){var d=jQuery;d(a).find("input,select,textarea").each(function(){if(this.name){var e=b[this.name];if(!(typeof e=="undefined"||e===null))if(this.nodeName.toLowerCase()==="input"&&(this.type==="checkbox"||this.type==="radio"))this.checked=e.length>1?d.inArray(this.value,e)>=0:e.length==0?false:this.value===e[0];else if(this.nodeName.toLowerCase()==="select")d(this).find("option").each(function(){this.selected=e.length>1?d.inArray(this.value,e)>=0:e.length==0?false:this.value===
e[0]});else this.value=e.length?e[0]:""}})}
function init_cached_state(a){var b=jQuery;a=a||"#EntryForm";onbeforeunload_fns=[];onbeforerestorevalues_fns=[];window.onbeforeunload=function(){var d={form_values:get_form_values(a)};b.each(onbeforeunload_fns,function(e,o){o(d)});document.getElementById("cache_form_values").value=JSON.stringify(d)};window.cache_register_onbeforeunload=function(d){onbeforeunload_fns.push(d)};window.cache_register_onbeforerestorevalues=function(d){onbeforerestorevalues_fns.push(d)};window.restore_cached_state=function(){var d=
document.getElementById("cache_form_values");if(d.value){var e=JSON.parse(d.value);b.each(onbeforerestorevalues_fns,function(o,k){k(e)});restore_form_values(a,e.form_values)}}};

