// JavaScript Document
// Javascript output for Asthma Plan
// Created by Marina Norio  01/05/2003  marina.norio@wch.org.au

 function validateForm(theForm)  {      

	    <!-- check that Releiver Medication & Attack dose formfields have been completed -->		

	 if (theForm.relmed1.value == "") {
	    alert("Please select a reliever medication");
	    theForm.relmed1.focus();
	 	return false;
	 } 

	 if (theForm.attackdose.value == "") {
	    alert("Please select a dose for attacks");
		theForm.attackdose.focus();
		return false;
	 } 	 

	  <!-- set date variables  -->

    var monName = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var now = new Date;       

	    <!-- Set variables from form to display optional sections of Plan -->

	 var sport = document.asthma_plan.sport.value
	 var prevmed1 = document.asthma_plan.prevmed1.value
	 var instructions = document.asthma_plan.instructions.value
	 var preddose = document.asthma_plan.preddose.value
	 var PatientName = document.asthma_plan.PatientName.value
	 var remed1 = document.asthma_plan.relmed1.value
	 var attackdose = document.asthma_plan.attackdose.value
	 var prevmed2 = document.asthma_plan.prevmed2.value	 	 

	    <!-- Set variables to display Plan  --> 	  

	var header ="<font face=arial><table width=100% border=0 cellpadding=3 cellspacing=0 align=center>" +
				"<tr><td align='center' colspan='2'><h2>Asthma Action Plan for  <i>" +  
				    document.asthma_plan.PatientName.value  +
				"</i></h2>" +
			    "<tr><td>Written by" + " " +  
				   (document.asthma_plan.completingdr1.value || document.asthma_plan.completingdr2.value) +  
				" on  " + now.getDate() + " " + monName[now.getMonth()] + ", " + now.getYear() +  "</td>" +
				"<td align=right>UR number " + 
				    document.asthma_plan.PatientUR.value  +
				"</td></tr></table><br>";
		

var plan = "<font size=4><b>IF YOU GET SYMPTOMS OF ASTHMA</b></font size=4><br>" +
				"<font size=3>(wheezing, chest tightness, shortness of breath)</font><br><br>" +
                "<b>For mild symptoms: take 2 puffs of " + 
				    document.asthma_plan.relmed1.value + "</b><br>"  +
	            "<b>For more severe syptoms: take " + document.asthma_plan.attackdose.value + " of " + 
				    document.asthma_plan.relmed1.value + "</b>" +
	            "<p>Use your spacer if you have one. Repeat doses as often as you need to. Don't stop taking your preventer." + 
			    " If you need " + document.asthma_plan.relmed1.value + " more often than every 3 hours, then see your doctor or go to hospital.<br>" +
	                document.asthma_plan.otherinstructions.value  + "</p>";				

var prednisolone ="<font face=arial>" +  "<b>Prednisolone</b><br>" +
				 "If from previous experience you suspect this is a more severe attack," + 
                 " or if the symptoms are not getting better in about 6 to 8 hours " + 
  			     " with regular use of "  + document.asthma_plan.relmed1.value +
		         " take prednisolone "  +  document.asthma_plan.preddose.value +  
				 " immediately then once each morning for up to 3 days.<br>" +
	                  document.asthma_plan.predcomment.value + "<br><br></font>"; 				

var thisEpisode = "<font face=arial><font size=4><b>INSTRUCTIONS FOR THIS EPISODE OF ASTHMA</b></font size=4><br><br>"  +  
			     "Take your reliever as often as required until symptoms settle.</br>" +
                 "See your doctor or return to hospital if symptoms are getting worse or not settling.</br>" +
                 "Remember to continue your usual dose of preventer medication if you have one.<br><br>" +
                 "Take the prescribed dose of prednisolone " + document.asthma_plan.R2.value + "<br><br><hr></font>";				 

var preventer = "<font face=arial><font size=4><b>PREVENTER TREATMENT</b></font size=4><br>"  +
	              "<b>" + document.asthma_plan.prevmed1.value + "&nbsp;&nbsp;" + 
				     document.asthma_plan.prevmed1dose.value + "&nbsp;&nbsp;" + 
				     document.asthma_plan.prevmed1freq.value + "</b><br>"  +
	              "<b>" + document.asthma_plan.prevmed2.value + "&nbsp;&nbsp;" + 
				     document.asthma_plan.prevmed2dose.value + "&nbsp;&nbsp;" + 
				     document.asthma_plan.prevmed2freq.value + "</b><br>"   +
	              "<b>" + document.asthma_plan.otherprevinst.value + "</b>"  +
                  "<br><br>If you have been prescribed a preventer - you should use it every day.<br>If you have a spacer - you should use it for your preventer.<br>If you use an inhaled steriod (eg. Flixotide, Becotide, Pulmicort) - you should rinse you mouth out after using it.<br><br></font>";				  

    var sportInc = "<font face=arial><b>Sport or exercise</b><br>" +
                  "If this usually makes you wheezy, take 2 puffs of " + 
					  document.asthma_plan.relmed1.value + " before starting.<br>"  +
                  "You may need to repeat the dose if you also get symptoms during sport<br><br></font>";				

     var help = "<font face=arial><font size=4><b>WHEN TO SEEK HELP FROM THE DOCTOR / HOSPITAL</b></font size=4><br>"  +
                 "<ul><li>If you have a bad attack or are worried</li><li>If you need " + 
				    document.asthma_plan.relmed1.value + 
				 " more than every 3 hours</li><li>If you get little or no relief from " + 
				    document.asthma_plan.relmed1.value + 
				 "</li><li>Wheezing lasts more than 24 hours and is not getting better</li>" +
				 "<li><b>If you have a very severe attack: call an ambulance & take " + document.asthma_plan.attackdose.value + " of " +
				    document.asthma_plan.relmed1.value +  " every 15 to 30 minutes</b></li></ul></font>";				

  var footer = "<font face=arial font size=1><b>"  +
               "Keep this plan readily available at all times. Please take this plan and all medications to all doctors visits. Give copies to others who are involved in the care of the patient (eg. grandparents, creche, kinder, school)<br>"  +
	           "If you use a spacer, wash it in soapy water at least once a month and let it drip dry.</b></font><br><hr>";			   

			   <!-- Create a new window add document which outputs Asthma Action Plan-->		            				

				newWindow = window.open("","","menubar,status,scrollbars,width=750,height=600");
				newWindow.document.open();
				newWindow.document.write("<head><title>Asthma Action Plan</title></head>");
				newWindow.document.write(header);
				if(instructions != "No")
                {   newWindow.document.write(thisEpisode);  }
				if(prevmed1 != "")
                {  newWindow.document.write(preventer); }
				if(sport != "No")
                {  newWindow.document.write(sportInc); }
				if (prevmed1 !="" | sport != "No")  
				{  newWindow.document.write("<hr>");  }
				newWindow.document.write(plan);
				if(preddose != "")
                {  newWindow.document.write(prednisolone); }
				newWindow.document.write("<hr>");
				newWindow.document.write(help);
				newWindow.document.write("<hr>");
				newWindow.document.write(footer);
				newWindow.document.write("<p align=center><input type=button value='Print Asthma Action Plan - 3 copies suggested'  onClick=\"window.print()\" ></p>");
                newWindow.document.close();			 

	 }