function checkAll(){for(var t=document.getElementsByClassName("weo-check"),n=0;n<t.length;n++)t[n].type=="checkbox"&&(t[n].checked=!0)}function uncheckAll(){for(var t=document.getElementsByClassName("weo-check"),n=0;n<t.length;n++)console.log(n),t[n].type=="checkbox"&&(t[n].checked=!1)}function prepareQueryString(){var t=document.getElementById("weoStartYear").value,i=document.getElementById("weoEndYear").value;if(Number(t)>Number(i))return alert(alertMessage),"";var r=document.getElementById("ssm")&&document.getElementById("ssm").checked?"1":"0",u=document.getElementById("scsm")&&document.getElementById("scsm").checked?"1":"0",f=document.getElementById("scc")&&document.getElementById("scc").checked?"1":"0",e=document.getElementById("ssd")&&document.getElementById("ssd").checked?"1":"0",o=document.getElementById("ssc")&&document.getElementById("ssc").checked?"1":"0",s=document.getElementById("sic")&&document.getElementById("sic").checked?"1":"0",h=document.getElementById("slSortOrder"),c=h.options[h.selectedIndex].value,l=document.getElementById("slDecimal"),a=l.options[l.selectedIndex].value,v=document.getElementById("slBlankRows"),y=v.options[v.selectedIndex].value,n="?",p=window.location.href;return p.indexOf("?")>-1&&(n+=p.split("?")[1]),t&&(n=n+"&sy="+t),i&&(n=n+"&ey="+i),r&&(n=n+"&ssm="+r),u&&(n=n+"&scsm="+u),f&&(n=n+"&scc="+f),e&&(n=n+"&ssd="+e),o&&(n=n+"&ssc="+o),s&&(n=n+"&sic="+s),c!=-1&&(n=n+"&sort="+c),a!=-1&&(n=n+"&ds="+a),y!=-1&&(n=n+"&br="+y),n}function redirectoNextStep(){var u,r,i,t,n;if(hdnStep=="CountryList"){for(n="",i=document.getElementsByClassName("weo-check"),t=0;t<i.length;t++)i[t].type=="checkbox"&&i[t].checked&&(n=n+i[t].value+",");if(n==""){alert(alertMessage);return}n=n.trim(",");window.location.href=nextUrl+"?c="+n}else if(hdnStep=="CountryGroupAggr"){for(n="",i=document.getElementsByClassName("weo-check"),t=0;t<i.length;t++)i[t].type=="checkbox"&&i[t].checked&&(n=n+i[t].value+",");if(n==""){alert(alertMessage);return}n=n.trim(",");window.location.href=nextUrl+"?a=1&c="+n}else if(hdnStep=="Subject"){for(n="?",u=window.location.href,u.indexOf("?")>-1&&(n+=u.split("?")[1]),r="",i=document.getElementsByClassName("weo-check"),t=0;t<i.length;t++)i[t].type=="checkbox"&&i[t].checked&&(r=r+i[t].value+",");if(r=r.trim(","),r==""){alert(alertMessage);return}n=n+"&s="+r;window.location.href=nextUrl+n}else hdnStep=="DateRange"&&(n=prepareQueryString(),n!=""&&(window.location.href=nextUrl+n))}var hdnStep,nextUrl,alertMessage,url,qs,currentUrl,settingID;!function(n,t,i){function f(t,i){this.element=t;this.settings=n.extend({},e,i);this._defaults=e;this._name=r;this.init()}function u(n){return n.filename?n.filename:"table2excel"}function o(n){var t=/(\s+alt\s*=\s*"([^"]*)"|\s+alt\s*=\s*'([^']*)')/i;return n.replace(/<img[^>]*>/gi,function(n){var i=t.exec(n);return null!==i&&i.length>=2?i[2]:""})}function s(n){return n.replace(/<a[^>]*>|<\/a>/gi,"")}function h(n){var t=/(\s+value\s*=\s*"([^"]*)"|\s+value\s*=\s*'([^']*)')/i;return n.replace(/<input[^>]*>|<\/input>/gi,function(n){var i=t.exec(n);return null!==i&&i.length>=2?i[2]:""})}var r="table2excel",e={exclude:".noExl",name:"Table2Excel"};f.prototype={init:function(){var t=this;t.template={head:'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets>',sheet:{head:"<x:ExcelWorksheet><x:Name>",tail:"<\/x:Name><x:WorksheetOptions><x:DisplayGridlines/><\/x:WorksheetOptions><\/x:ExcelWorksheet>"},mid:"<\/x:ExcelWorksheets><\/x:ExcelWorkbook><\/xml><![endif]--><\/head><body>",table:{head:"<table>",tail:"<\/table>"},foot:"<\/body><\/html>"};t.tableRows=[];n(t.element).each(function(i,r){var u="";n(r).find("tr").not(t.settings.exclude).each(function(i,r){u+="<tr>";n(r).find("td,th").not(t.settings.exclude).each(function(i,r){u+=n(r).find(t.settings.exclude).length>=1?"<td> <\/td>":"<td>"+n(r).html()+"<\/td>"});u+="<\/tr>"});t.settings.exclude_img&&(u=o(u));t.settings.exclude_links&&(u=s(u));t.settings.exclude_inputs&&(u=h(u));t.tableRows.push(u)});t.tableToExcel(t.tableRows,t.settings.name,t.settings.sheetName)},tableToExcel:function(r,f,e){var h,l,c,o=this,s="",a,v;if(o.format=function(n,t){return n.replace(/{(\w+)}/g,function(n,i){return t[i]})},e=void 0===e?"Sheet":e,o.ctx={worksheet:f||"Worksheet",table:r,sheetName:e},s=o.template.head,n.isArray(r))for(h in r)s+=o.template.sheet.head+e+h+o.template.sheet.tail;if(s+=o.template.mid,n.isArray(r))for(h in r)s+=o.template.table.head+"{table"+h+"}"+o.template.table.tail;s+=o.template.foot;for(h in r)o.ctx["table"+h]=r[h];return(delete o.ctx.table,i.documentMode)?"undefined"!=typeof Blob?(s=o.format(s,o.ctx),s=[s],v=new Blob(s,{type:"text/html"}),t.navigator.msSaveBlob(v,u(o.settings))):(txtArea1.document.open("text/html","replace"),txtArea1.document.write(o.format(s,o.ctx)),txtArea1.document.close(),txtArea1.focus(),sa=txtArea1.document.execCommand("SaveAs",!0,u(o.settings))):(a=new Blob([o.format(s,o.ctx)],{type:"application/vnd.ms-excel"}),t.URL=t.URL||t.webkitURL,l=t.URL.createObjectURL(a),c=i.createElement("a"),c.download=u(o.settings),c.href=l,i.body.appendChild(c),c.click(),i.body.removeChild(c)),!0}};n.fn[r]=function(t){var i=this;return i.each(function(){n.data(i,"plugin_"+r)||n.data(i,"plugin_"+r,new f(this,t))}),i}}(jQuery,window,document);hdnStep="";document.getElementById("hdnStep")&&(hdnStep=document.getElementById("hdnStep").value);nextUrl="";document.getElementById("hdnNextUrl")&&(nextUrl=document.getElementById("hdnNextUrl").value);alertMessage="";document.getElementById("hdnAlert")&&(alertMessage=document.getElementById("hdnAlert").value);(hdnStep=="CountryList"||hdnStep=="CountryGroupAggr")&&checkAll();hdnStep==="Report"&&(url=window.location.href,qs="",url.indexOf("?")>-1&&(qs=url.split("?")[1]),currentUrl=document.getElementById("hdnCurrentUrl")?document.getElementById("hdnCurrentUrl").value:"",settingID=document.getElementById("hdnSettingID")?document.getElementById("hdnSettingID").value:"",document.getElementById("downloadreport").setAttribute("href",currentUrl+"/imf/weodatabase/downloadreport?"+qs+"&wsid="+settingID))