	function changeform(fts) {
		var ind = 'document.invoicetype';

		switch (fts) {
			case 'invoice' :
				document.invoiceform.invoice.checked=true;
				document.getElementById('invoices').style.display = "block";
				document.getElementById('allowances').style.display = "none";
			break;
			case 'allowance' :
				document.invoiceform.allowance.checked=true;
				document.getElementById('allowances').style.display = "block";
				document.getElementById('invoices').style.display = "none";
			break;
		}
	}

	function currencyupdate(changed) {
		var a = document.invoiceform;
		var gst = 0.1;
		switch(changed) {
			case 'orig' :
				a.invoiceamount_AUD.value = eval(document.invoiceform.invoiceamount_orig.value / document.invoiceform.invoiceexchangerate.value);
				if(a.invoiceGST.checked==true) {
					a.invoiceGST_amount.value=eval(a.invoiceamount_AUD.value * gst);
				}
				else
					a.invoiceGST_amount.value=0;
//				a.invoiceamounttotal.value = eval(document.invoiceform.invoiceamount_AUD.value * document.invoiceform.invoiceexchangerate.value);
				break;
			case 'rate' :
				document.invoiceform.invoiceamount_AUD.value = eval(document.invoiceform.invoiceamount_orig.value / document.invoiceform.invoiceexchangerate.value);
				if(a.invoiceGST.checked==true) {
					a.invoiceGST_amount.value=eval(a.invoiceamount_AUD.value * gst);
				}
				else
					a.invoiceGST_amount.value=0;
				break			
			case 'AUD' :
				document.invoiceform.invoiceexchangerate.value = eval(document.invoiceform.invoiceamount_orig.value / document.invoiceform.invoiceamount_AUD.value);
				if(a.invoiceGST.checked==true) {
//					alert(a.invoiceamount
					a.invoiceGST_amount.value=eval(a.invoiceamount_AUD.value * gst);
				}
				else
					a.invoiceGST_amount.value=0;
				break		
			// GST
			case 'currency' :
				// change the gst flag
				if(a.invoicecurrency.value == 'AUD') {
					a.invoiceGST.checked=true;
					a.invoiceGST_amount.value = eval(a.invoiceamount_AUD.value * gst);
				}	
				else {
					a.invoiceGST.checked=false;
					a.invoiceGST_amount.value = 0;
				}	
				break;	
			case 'GST' :
				if(document.invoiceform.invoicecurrency.value=='AUD') {
					if(a.invoiceGST.checked ==true)
	 					a.invoiceGST_amount.value = eval(document.invoiceform.invoiceamount_AUD.value / ((1+gst)*10));
	 				else
	 					a.invoiceGST_amount.value = 0;
	 			}
	 			else {
	 				a.invoiceGST.checked=false;
	 					a.invoiceGST_amount.value = 0;
	 					alert('Only Australian Currency can have GST');
	 				}
				break			
			}
		}
		
	function editlist(a) {
		hwin=window.open("content.php?page=" + a + "&pop=1","hwin","height=600,width=700,menubar=no,location=no,toolbar=no,scrollbars=yes,directories=no,resizeable=yes");
	}
	
	function showtimer() {
		hwin=window.open("timer.php","hwin","height=200,width=250,menubar=no,location=no,toolbar=no,scrollbars=yes,directories=no,resizeable=yes");
	}
	
	