		
		var newwindow = '';
		function aqiref(url)
		{
			if (!newwindow.closed && newwindow.location)
			{
				newwindow.location.href = url;
			}
			else
			{
				newwindow=window.open(url,'aqirefpage','height=400,width=300');
				if (!newwindow.opener) newwindow.opener = self;
			}
			if (window.focus) {newwindow.focus()}
		}
		
		
		var newwindow = 'pdf';
		function pdflaunch(url)
		{
			if (!newwindow.closed && newwindow.location)
			{
				newwindow.location.href = url;
			}
			else
			{
				newwindow=window.open(url,'pdf','height=500,width=700');
				if (!newwindow.opener) newwindow.opener = self;
			}
			if (window.focus) {newwindow.focus()}
		}
		
		var newwindow = 'calendar';
		function callaunch(url)
		{
			if (!newwindow.closed && newwindow.location)
			{
				newwindow.location.href = url;
			}
			else
			{
				newwindow=window.open(url,'pdf','height=467,width=554');
				if (!newwindow.opener) newwindow.opener = self;
			}
			if (window.focus) {newwindow.focus()}
		}
		
		var win = null;
		function NewWindow(mypage,myname,w,h,scroll){
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =
		'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
		win = window.open(mypage,myname,settings)
		}

		var newwindow = 'external';
		function extlink(mypage,myname,w,h,scroll)
		{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =
		'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
		win = window.open(mypage,myname,settings)
			
		}
		
		/*
		var newwindow = 'external';
		function extlink(url)
		{
			if (!newwindow.closed && newwindow.location)
			{
				newwindow.location.href = url;
			}
			else
			{
				newwindow=window.open(url,'external','height=550,width=800,scrollbars=1,toolbar=1,location=1');
				if (!newwindow.opener) newwindow.opener = self;
			}
			if (window.focus) {newwindow.focus()}
		}
		*/
		
		var newwindow = 'internal';
		function intlink(url)
		{
			if (!newwindow.closed && newwindow.location)
			{
				newwindow.location.href = url;
			}
			else
			{
				newwindow=window.open(url,'internal','height=600,width=770,toolbar=0,scrollbars=1');
				if (!newwindow.opener) newwindow.opener = self;
			}
			if (window.focus) {newwindow.focus()}
		}
		
		
		var factor = 2.95523093447905E-05;
		var p = new Array(3.71,1.78,3.24,2.95,2.56,1.94,6.03);
		var permit = new Array(
		'NONE. Operation does not require a permit at this time. Click the PRINT PAGE button to print this page for your records.',
		'LOCAL PERMIT. Please call the District Engineering section at 530-757-3650 for further assistance.',
		'TITLE V PERMIT. Please call the District Engineering section at 530-757-3650 for further assistance.'
		);
		
		function calculate(form) {
			var result = 0;
			for (var i = 0; i < p.length; i++) {
				var a = eval('form.a'+(i+1)+'.value');
				var w = eval('form.w'+(i+1)+'.value');
				result += p[i]*a*w;
			}
			result *= factor;
			document.getElementById('result').innerHTML=result.toFixed(2) + ' Tons/Year';
			if      (result < 12.5) message = 0;
			else if (result < 25)   message = 1;
			else				    message = 2;
			document.getElementById('permit').innerHTML=permit[message];
		}
		function clear_all(form)
		{
			document.getElementById('result').innerHTML='';
			document.getElementById('permit').innerHTML='';
		}
		function a_submit(a, form_id)
		{
			var form = document.getElementById(form_id);
			
			if (a.href) form.action = a.href;
			form.submit();
			
			return false;
		}
		var editor = null;
		function popup_editor(a, width, height)
		{
			var url = a.href;
			
			if (editor && !editor.closed) {
				editor.location.href = url;
			} else {
				var left = (screen.width - width) / 2;
				var top = (screen.height - height) / 2;
				var settings = 'left='+left+',top='+top+',width='+width+',height='+height+',resizable';
				editor = window.open(url, 'html', settings);
			}

			if (editor) editor.focus();
			
			return false;
		}