
	if (top.location != location) { top.location.href = document.location.href } ;
	var actuate_user = 'ANONYMOUS';

	
			// start variables
			
var def_acpsWhichDate_ctrl="1";
var acpsWhichDate = document.getElementById('acpsWhichDate');
var acpsWhichDate_ctrl = document.getElementById('acpsWhichDate_ctrl_1');
var acpsWhichDate_div = document.getElementById('acpsWhichDate_div');
var def_comment_5391_ctrl="";
var comment_5391 = document.getElementById('comment_5391');
var def_acpsBeginMonth_ctrl="01";
var acpsBeginMonth = document.getElementById('acpsBeginMonth');
var acpsBeginMonth_ctrl = document.getElementById('acpsBeginMonth_ctrl');
var acpsBeginMonth_div = document.getElementById('acpsBeginMonth_div');
var def_acpsBeginYear_ctrl="2021";
var acpsBeginYear = document.getElementById('acpsBeginYear');
var acpsBeginYear_ctrl = document.getElementById('acpsBeginYear_ctrl');
var acpsBeginYear_div = document.getElementById('acpsBeginYear_div');
var def_comment_5392_ctrl="";
var comment_5392 = document.getElementById('comment_5392');
var def_acpsEndMonth_ctrl="12";
var acpsEndMonth = document.getElementById('acpsEndMonth');
var acpsEndMonth_ctrl = document.getElementById('acpsEndMonth_ctrl');
var acpsEndMonth_div = document.getElementById('acpsEndMonth_div');
var def_acpsEndYear_ctrl="2021";
var acpsEndYear = document.getElementById('acpsEndYear');
var acpsEndYear_ctrl = document.getElementById('acpsEndYear_ctrl');
var acpsEndYear_div = document.getElementById('acpsEndYear_div');
var def_acpsSortBy_ctrl="1";
var acpsSortBy = document.getElementById('acpsSortBy');
var acpsSortBy_ctrl = document.getElementById('acpsSortBy_ctrl_1');
var acpsSortBy_div = document.getElementById('acpsSortBy_div');
var def_comment_5393_ctrl="";
var comment_5393 = document.getElementById('comment_5393');
var def_acpsNAICS_ctrl="";
var acpsNAICS = document.getElementById('acpsNAICS');
var acpsNAICS_ctrl = document.getElementById('acpsNAICS_ctrl');
var acpsNAICS_div = document.getElementById('acpsNAICS_div');
var def_acpsOwnership_ctrl="";
var acpsOwnership = document.getElementById('acpsOwnership');
var acpsOwnership_ctrl = document.getElementById('acpsOwnership_ctrl');
var acpsOwnership_div = document.getElementById('acpsOwnership_div');
var def_acpsEvent_ctrl="";
var acpsEvent = document.getElementById('acpsEvent');
var acpsEvent_ctrl = document.getElementById('acpsEvent_ctrl');
var acpsEvent_div = document.getElementById('acpsEvent_div');
var def_acpsSource_ctrl="";
var acpsSource = document.getElementById('acpsSource');
var acpsSource_ctrl = document.getElementById('acpsSource_ctrl');
var acpsSource_div = document.getElementById('acpsSource_div');
var def_acpsCounty_ctrl="";
var acpsCounty = document.getElementById('acpsCounty');
var acpsCounty_ctrl = document.getElementById('acpsCounty_ctrl');
var acpsCounty_div = document.getElementById('acpsCounty_div');
			// end variables

			

		function SetURL()
		{
			direct_link = "Sorry, no link info available";
			lnk.innerHTML = "";
			try
			{
				if(document.getElementById("format_drop")==undefined)
				{
					format="";
				}
				else
				{
					format=document.getElementById("format_drop").value;
				}
				var new_href = "http://www4.cbs.state.or.us/ex/imd/reports/rpt/?fuseaction=parm_action&xP=Y&ProgID=CC8136&hidebacklink=1&format=" + format;
				
							new_href += getCheckRadio("acpsWhichDate");
						
							new_href += "&rpt.acpsBeginMonth=" + escape(acpsBeginMonth_ctrl.value);
						
							new_href += "&rpt.acpsBeginYear=" + escape(acpsBeginYear_ctrl.value);
						
							new_href += "&rpt.acpsEndMonth=" + escape(acpsEndMonth_ctrl.value);
						
							new_href += "&rpt.acpsEndYear=" + escape(acpsEndYear_ctrl.value);
						
							new_href += getCheckRadio("acpsSortBy");
						
							new_href += getSelect("acpsNAICS");
						
							new_href += getSelect("acpsOwnership");
						
							new_href += getSelect("acpsEvent");
						
							new_href += getSelect("acpsSource");
						
							new_href += getSelect("acpsCounty");
						
				direct_link = new_href;
				lnk.innerHTML = "Link directly to this report with the current parameters.";
			}
			catch(er)
			{
				lnk.href = "javascript:alert('Link error: " + er.message + "')";
				lnk.onclick = function() { };
				lnk.innerHTML = "can't directly link to this report";
			}
		}
		function getCheckRadio(parm)
		{
			var ins=1;
			var ctrl = document.getElementById(parm+"_ctrl_"+ins);
			var list = "&rpt."+parm+"=";
			var sep = "";
			while(ctrl!=null)
			{
				if(ctrl.checked)
				{
					list += sep + escape(ctrl.value);
					sep=",";
				}
				ins=ins+1;
				ctrl = document.getElementById(parm+"_ctrl_"+ins);
			}
			return list;
		}
		function getSelect(parm)
		{
			var ctrl = document.getElementById(parm+"_ctrl");
			var list = "&rpt."+parm+"=";
			var sep = "";
			for(x=0; x<ctrl.options.length; x++)
			{
				if(ctrl.options[x].selected)
				{
					list += sep + escape(ctrl.options[x].value);
					sep=",";
				}
			}
			return list;
		}

		function rpt_disable_submit()
		{
			btn=document.getElementById("submit_button");
			btn.disabled = true;
			btn.value = "Loading...";
			btn=document.getElementById("reset_button");
			btn.disabled = true;
			btn=document.getElementById("close_button");
			if(btn!=undefined) btn.disabled = true;
			setTimeout(rpt_enable_submit,10000); // re-enable after 10 seconds
		}


		// the re-enabling of the buttons is needed MAINLY
		// for data downloads where the query may be run several
		// times without reloading the entire screen.

		function rpt_enable_submit()
		{
			btn=document.getElementById("submit_button");
			btn.disabled = false;
			btn.value = "Submit";
			btn=document.getElementById("reset_button");
			btn.disabled = false;
			btn=document.getElementById("close_button");
			if(btn!=undefined) btn.disabled = false;
		}

		window.onbeforeunload=rpt_enable_submit(); // enable the buttons before we leave in case the back button is used


			
	
		direct_link = "Sorry, no link info available";
		lnk = document.getElementById('QuickLink');
		try
		{
			$(lnk).off("click").on("click",function() {
					SetURL();
					prompt('Use this web address to link directly to the report with the parematers you provided.',direct_link);
					return false;
				});
			setTimeout(SetURL,500);
			document.dynForm['rpt.acpsWhichDate'].focus();
		}
		catch(er)
		{
			// Do nothing
		}
	