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=[],p=0;p<d.length;p++){var j=d[p];j!=b&&e.push(j)}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,l){a("#added_to_list_"+l).show();a("#add_to_list_"+l).hide()})},p=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])}}},j=function(c){c=a(c.currentTarget).data("id");a.ajax({success:p(c),
dataType:"json",error:function(){alert("Error")},data:{id:c},type:"POST",url:b.current_list_url})},r=function(c){return function(g){if(g.fail)alert(g.errinfo);else{g=true;if(c){var l=a("#results_table #remove_from_list_"+c);if(!l.length){g=false;l=a("#results_container #remove_from_list_"+c)}l.parent().parent().remove()}l=false;if((l=g?a("#results_table tr").length===1:a("#results_container > p").length===0)||!c){a("#records_ui").hide();a("#no_records_message").show()}}}},q=function(c){c=a(c.currentTarget).data("id");
a.ajax({success:r(c),dataType:"json",error:function(){alert("Error")},data:{ID:c,RemoveItem:b.domain},type:"POST",url:b.current_list_url})},k=function(){a.ajax({success:r(),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)}},o=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(l,n){a("#ct_added_to_previous_request_"+n).show()});a(".ListUI img").prop("src",function(l,n){return n.replace("list","referral")});a("#list_header_text").hide();a("#ct_header_text").show();b.current_list_url=b.ct_update_url;m()}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);m()};!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()},m=function(){a(".HideListUI").delegate(".add_to_list","click",j).delegate(".remove_from_list","click",q).removeClass("HideListUI");a("#remove_all_from_list").click(k);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:o,
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){p.lastIndex=0;return p.test(h)?'"'+h.replace(p,function(o){var i=q[o];return typeof i==="string"?i:"\\u"+("0000"+o.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+h+'"'}function d(h,o){var i,m,c,g,l=j,n,f=o[h];if(f&&typeof f==="object"&&typeof f.toJSON==="function")f=f.toJSON(h);if(typeof k==="function")f=k.call(o,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";j+=r;n=[];if(Object.prototype.toString.apply(f)==="[object Array]"){g=f.length;for(i=0;i<g;i+=1)n[i]=d(i,f)||"null";c=n.length===0?"[]":j?"[\n"+j+n.join(",\n"+j)+"\n"+l+"]":"["+n.join(",")+"]";j=l;return c}if(k&&typeof k==="object"){g=k.length;for(i=0;i<g;i+=1){m=k[i];if(typeof m==="string")if(c=d(m,f))n.push(b(m)+(j?": ":":")+c)}}else for(m in f)if(Object.hasOwnProperty.call(f,m))if(c=d(m,f))n.push(b(m)+(j?": ":":")+c);c=n.length===0?"{}":j?"{\n"+j+n.join(",\n"+j)+
"\n"+l+"}":"{"+n.join(",")+"}";j=l;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,
p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,j,r,q={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},k;if(typeof JSON.stringify!=="function")JSON.stringify=function(h,o,i){var m;r=j="";if(typeof i==="number")for(m=0;m<i;m+=1)r+=" ";else if(typeof i==="string")r=i;if((k=o)&&typeof o!=="function"&&(typeof o!=="object"||typeof o.length!=="number"))throw Error("JSON.stringify");return d("",
{"":h})};if(typeof JSON.parse!=="function")JSON.parse=function(h,o){function i(c,g){var l,n,f=c[g];if(f&&typeof f==="object")for(l in f)if(Object.hasOwnProperty.call(f,l)){n=i(f,l);if(n!==undefined)f[l]=n;else delete f[l]}return o.call(c,g,f)}var m;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,""))){m=eval("("+h+")");return typeof o==="function"?i({"":m},""):m}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,p){p(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(p,j){j(e)});restore_form_values(a,e.form_values)}}}
(function(){var a=jQuery,b={"en-CA":"d M yy",de:"dd.mm.yy",fr:"d M yy",it:"d M yy",nl:"d M yy",no:"d M yy",pt:"d-mm-yy",sv:"d M yy",hu:"M d. yy",ro:"d M yy",hr:"d M yy",sl:"d M yy",bg:"d MM yy",ru:"d M yy",tr:"d M yy",lv:"d M yy",lt:"d M yy",ko:"yy/mm/dd","zh-CN":"yy/mm/dd",th:"d M yy"},d={"en-CA":true,"":true},e={},p={"fr-CA":"fr","es-MX":"es"},j=function(){var q=a(this),k=q.data("culture");q.datepicker(a.extend({},a.datepicker.regional[k],{dateFormat:b[k]||a.datepicker.regional[k].dateFormat})).prop("autocomplete",
"off")},r=function(q){a.getScript("http://ajax.googleapis.com/ajax/libs/jqueryui/"+a.ui.version+"/i18n/jquery.ui.datepicker-"+q+".min.js",function(){d[q]=true;a.each(e[q],function(){j.call(this)});delete e[q]})};a.datepicker.regional["en-CA"]=a.extend({},a.datepicker.regional[""]);a.fn.extend({autodatepicker:function(){return this.each(function(){var q=a(this),k;k=q.parents("[lang]").first().prop("lang")||"en-CA";k=p[k]||k;q.data("culture",k);if(d[k])j.call(this);else{arr=e[k];if(!arr){arr=e[k]=[];
r(k)}arr.push(this)}})}});jQuery(function(){a("input.DatePicker").autodatepicker()})})();

