//**Validate Execution Date and select Functionality**		
			
		function dutyOld(dutiableAmount)
		{
			var v = dutiableAmount/1000;
		
			var x = (0.065*v*v)+21*v;
			
			if ((((x*100) % 1) > 0.99999) || (((x*100) % 1) < 0.00001)) //minute variances can occur during the previous line
			{
					x = Math.round(x*100)/100;
			}
			
			var y = 0.054*dutiableAmount;
			
			if ((((y*100) % 1) > 0.99999) || (((y*100) % 1) < 0.00001)) //minute variances can occur during the previous line
			{
					y = Math.round(y*100)/100;
			}
			
			if(dutiableAmount<=0)
				return 0;
			else if(dutiableAmount<=500000)
				return x;  
			else
				return y;
		}
		
		function dutyNew(dutiableAmount)
		{
			var v = dutiableAmount/1000;
		
			var x = (0.06571441*v*v)+15*v
			
			if ((((x*100) % 1) > 0.99999) || (((x*100) % 1) < 0.00001)) //minute variances can occur during the previous line
			{
					x = Math.round(x*100)/100;
			}
			
			var y = 0.0495*dutiableAmount
		
			if ((((y*100) % 1) > 0.99999) || (((y*100) % 1) < 0.00001)) //minute variances can occur during the previous line
			{
					y = Math.round(y*100)/100;
			}
			
			if(dutiableAmount<=0)
				return 0;
			else if(dutiableAmount<=525000)
				return x;  
			else
				return y;
		}

		
		function dutyThird(dutiableAmount)
		{
			var v = dutiableAmount/1000;
		
			var x = (0.06571441*v*v)+15*v
			
			if ((((x*100) % 1) > 0.99999) || (((x*100) % 1) < 0.00001)) //minute variances can occur during the previous line
			{
					x = Math.round(x*100)/100;
			}
			
			var y = 0.0495*dutiableAmount
		
			if ((((y*100) % 1) > 0.99999) || (((y*100) % 1) < 0.00001)) //minute variances can occur during the previous line
			{
					y = Math.round(y*100)/100;
			}
			
			var z = 0.0545*dutiableAmount
		
			if ((((z*100) % 1) > 0.99999) || (((z*100) % 1) < 0.00001)) //minute variances can occur during the previous line
			{
					z = Math.round(z*100)/100;
			}
			
			if(dutiableAmount<=0)
				return 0;
			else if(dutiableAmount<=525000)
				return x;  
			else if(525000.01 <= dutiableAmount && 2999999.99 >= dutiableAmount)
				return y;
			else
				return z;
		}

//**Function to Calculate Stamp Duty on Normal Conveyance (CONV)**


		function sdCONV(form)
		{
			var date      = auDate(form.date.value);
			var budgdate  = new Date("05/06/2008");
		    var budgdate2 = new Date("07/01/2011");
			
			var price     = form.pv.value;
			
			if (price.indexOf(',')!=-1||price.indexOf('.')!=-1)
			{
				alert("Please enter a property value without commas or full stops.");
			}
			else
			{
				if (date < budgdate)
				{
					sdConvOld(form);		
				}
				else if (budgdate < date && budgdate2 > date)
				{			
					sdConvNew(form);
				}
				else
				{
					sdConvThird(form);
				}
			}
		}
		
		function sdConvThird(form)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
		
			if(isNaN(price) || price<0)
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
				alert("The 'Date of Purchase' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			else
			{
				result = dutyThird(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
		
				if(result<0)
					result = 0;
		
				form.sdp.value = addCommas(result.toFixed(2)); //changed 13/11/2009
			}
		}
		
		function sdConvNew(form)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
		
			if(isNaN(price) || price<0)
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
				alert("The 'Date of Purchase' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			else
			{
				result = dutyNew(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
		
				if(result<0)
					result = 0;
		
				form.sdp.value = addCommas(result.toFixed(2)); //changed 13/11/2009
			}
		}
		
		function sdConvOld(form)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
		
			if(isNaN(price) || price<0)
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
				alert("The 'Date of Purchase' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			else
			{
				result = dutyOld(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
		
				if(result<0)
					result = 0;
		
				form.sdp.value = addCommas(result.toFixed(2)); //changed 13/11/2009
			}
		}
		
//**Function to Calculate Stamp Duty with the First Home Owners Concession (FHOC)**
		
		function sdFHOC(form)
		{
			var date      = auDate(form.date.value);
			var budgdate  = new Date("05/06/2008");
			var budgdate2 = new Date("07/01/2011");
			var fhoc_cap_date = new Date("01/01/2010"); //MM/DD/YYYY 1 January 2010
			var fhoc_cap_land = 385000;
			var fhoc_cap_home = 750000;
			var price     = form.pv.value;
			var flag = "";
			
			var vacant = "";
			var len = form.radioVacant.length;

			for (i = 0; i <len; i++)
			{
				if (form.radioVacant[i].checked)
				{
					vacant = form.radioVacant[i].value;
				}
			}
		
			if(price=="" || isNaN(price) || price<0)
			{
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			}
			else if (price.indexOf(',')!=-1||price.indexOf('.')!=-1)
			{
				alert("Please enter a property value without commas or full stops.");
			}
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
			{
				alert("The 'Date of Contract' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			}
			else if(vacant=="Yes" && price>fhoc_cap_land && date>=fhoc_cap_date)
			{
				flag = "True";
				
				if (date < budgdate)
				{
					sdFHOCOld(form,flag);		
				}
					else if (budgdate < date && budgdate2 > date)
				{
					sdFHOCNew(form,flag);
				}
					else
				{	
					sdFHOCThird(form,flag);
				}
				
				alert("As the value of the land exceeds $385 000, you are not eligible for the First Home Owner Concession. However, you may be eligible for Principal Place of Residence Rebate.");
			}
			else if(vacant=="No" && price>fhoc_cap_home && date>=fhoc_cap_date)
			{
				flag = "True";
				
				if (date < budgdate)
				{
					sdFHOCOld(form,flag);		
				}
					else if (budgdate < date && budgdate2 > date)
				{
					sdFHOCNew(form,flag);
				}
					else
				{	
					sdFHOCThird(form,flag);
				}
				
				alert("As the value of the property exceeds $750 000, you are not eligible for the First Home Owner Concession. However, you may be eligible for Principal Place of Residence Rebate.");
			}
			else
			{
				flag = "False";
			
				if (date < budgdate)
				{
					sdFHOCOld(form,flag);		
				}
					else if (budgdate < date && budgdate2 > date)
				{
					sdFHOCNew(form,flag);
				}
					else
				{	
					sdFHOCThird(form,flag);
				}
			}
		}
		
		function sdFHOCOld(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyOld(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result =  flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				result = dutyOld(price) - flr(dutyOld(fhoc(date))); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
		
			if(result<0)
			{
				result = 0;
			}
		
			form.sdp.value = addCommas(result.toFixed(2)); //changed 13/11/2009
		}
		
		function sdFHOCNew(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyNew(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result =  flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				result = dutyNew(price) - flr(dutyNew(fhoc(date))); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
		
			if(result<0)
			{
				result = 0;
			}
		
			form.sdp.value = addCommas(result.toFixed(2)); // chamged 13/11/2009
		}
		
		function sdFHOCThird(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyThird(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result =  flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				result = dutyThird(price) - flr(dutyNew(fhoc(date))); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
		
			if(result<0)
			{
				result = 0;
			}
		
			form.sdp.value = addCommas(result.toFixed(2)); // chamged 13/11/2009
		}

//Function to Calculate Stamp Duty with First Home Owners Concession along with the Home North Scheme (FHOCHS)

	
		function sdFHOCHS(form)
		{
			var date      = auDate(form.date.value);
			var budgdate  = new Date("05/06/2008");
			var budgdate2 = new Date("07/01/2011");
			var fhoc_cap_date = new Date("01/01/2010"); //MM/DD/YYYY 1 January 2010
			var fhoc_cap_land = 385000;
			var fhoc_cap_home = 750000;
			//var fhocs_cap_value = 420000;
			var price     = form.pv.value;
			var ownership = parseFloat(form.epp.value);
			var flag = "";
			
			var vacant = "";
			var len = form.radioVacant.length;

			for (i = 0; i <len; i++)
			{
				if (form.radioVacant[i].checked)
				{
					vacant = form.radioVacant[i].value;
				}
			}
			
			if(price=="" || isNaN(price) || price<0)
			{
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
				
			}
			else if (price.indexOf(',')!=-1||price.indexOf('.')!=-1)
			{
				alert("Please enter a property value without commas or full stops.");
			}
			//else if (price > fhocs_cap_value)
			//{
			//	alert("To be eligible for HOMESTART NT, the purchase price of the property cannot exceed $420,000.");
			//}
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
			{
				alert("The 'Date of Contract' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			}
			else if(isNaN(ownership) || ownership<=0 || ownership>100)
			{
				alert("The 'Interest Purchased' entered is invalid. Please re-enter value.");
			}
			else if(vacant=="Yes" && price>fhoc_cap_land && date>=fhoc_cap_date)
			{
				flag = "True";
				
				if (date < budgdate)
				{
					sdFHOCHSOld(form,flag);		
				}
					else if (budgdate < date && budgdate2 > date)
				{
					sdFHOCHSNew(form,flag);
				}
					else
				{
					sdFHOCHSThird(form,flag);
				}
				
				alert("As the value of the land exceeds $385 000, you are not eligible for the First Home Owner Concession. However, you may be eligible for Principal Place of Residence Rebate.");
			}
			else if(vacant=="No" && price>fhoc_cap_home && date>=fhoc_cap_date)
			{
				flag = "True";
				
				if (date < budgdate)
				{
					sdFHOCHSOld(form,flag);		
				}
					else if (budgdate < date && budgdate2 > date)
				{
					sdFHOCHSNew(form,flag);
				}
					else
				{
					sdFHOCHSThird(form,flag);
				}
				
				alert("As the value of the property exceeds $750 000, you are not eligible for the First Home Owner Concession. However, you may be eligible for Principal Place of Residence Rebate.");
			}
			else
			{
				flag = "False";
				
				if (date < budgdate)
				{
					sdFHOCHSOld(form,flag);		
				}
					else if (budgdate < date && budgdate2 > date)
				{
					sdFHOCHSNew(form,flag);
				}
					else
				{
					sdFHOCHSThird(form,flag);
				}
			}
			
		}
		
		function sdFHOCHSOld(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var ownership = parseFloat(form.epp.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyOld(price)*ownership/100;
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				//result = flr( dutyOld(price)*ownership/100 - flr(dutyOld(fhoc(date))) );
				result = dutyOld(price)*ownership/100 - flr(dutyOld(fhoc(date)));//unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
		
			if(result<0)
			{
				result = 0;
			}
				
			form.sdp.value = addCommas(result.toFixed(2));
		}
		
		function sdFHOCHSNew(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var ownership = parseFloat(form.epp.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyNew(price)*ownership/100;	//unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				result = dutyNew(price)*ownership/100 - flr(dutyNew(fhoc(date)));	//unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
			
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
			if(result<0)
			{
				result = 0;
			}
		
			form.sdp.value = addCommas(result.toFixed(2));
		}
		
		function sdFHOCHSThird(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var ownership = parseFloat(form.epp.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyThird(price)*ownership/100;	//unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				result = dutyThird(price)*ownership/100 - flr(dutyNew(fhoc(date)));	//unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
			
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
			if(result<0)
			{
				result = 0;
			}
		
			form.sdp.value = addCommas(result.toFixed(2));
		}


//Function to Calculate Stamp Duty with the Principle Place of Residence Rebate (PPRR)


		function sdPPRR(form)
		{
			var date      = auDate(form.date.value);
			var budgdate  = new Date("05/06/2008");
			var budgdate2 = new Date("07/01/2011");
		    
			var price     = form.pv.value;
			
			if (price.indexOf(',')!=-1||price.indexOf('.')!=-1)
			{
				alert("Please enter a property value without commas or full stops.");
			}
			else
			{
				if (date < budgdate)
				{
					sdPPRROld(form);		
				}
					else if (budgdate < date && budgdate2 > date)
				{
					sdPPRRNew(form);
				}
					else
				{
					sdPPRRThird(form);
				}
			}
			
		}
		
		//added extra dates to the function. created else if '(date>=bPPRRdate && date<=cPPRR)' to return 2500 and else return 3500, otherwise it is before 2005/06/19 
		//and returns 1500
		
		function pprr(date)
		{
			var aPPRRdate = new Date("2005/06/19");
			var bPPRRdate = new Date("2005/06/20");
			var cPPRRdate = new Date("2010/05/03");
			var dPPRRdate = new Date("2010/05/04");
		
			if(date<=aPPRRdate)
				return 1500;	
			
			else if (date>=bPPRRdate && date<=cPPRRdate)
				return	2500;
				
			else
				return 3500;
		}
		
		function sdPPRROld(form)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
		
			if(isNaN(price) || price<0)
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
				alert("The 'Date of Purchase' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			else
			{
				result = dutyOld(price)- pprr(date); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
		
				if(result<0)
					result = 0;
		
				form.sdp.value = addCommas(result.toFixed(2)); // changed 13/11/2009
			}
		}


		function sdPPRRNew(form)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
		
			if(isNaN(price) || price<0)
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
				alert("The 'Date of Purchase' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			else
			{
				result = dutyNew(price)- pprr(date); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
		
				if(result<0)
					result = 0;
		
				form.sdp.value = addCommas(result.toFixed(2)); //changed 13/11/2009
			}
		}
		
		function sdPPRRThird(form)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
		
			if(isNaN(price) || price<0)
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
				alert("The 'Date of Purchase' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			else
			{
				result = dutyThird(price)- pprr(date); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
		
				if(result<0)
					result = 0;
		
				form.sdp.value = addCommas(result.toFixed(2)); //changed 13/11/2009
			}
		}


		
//Function to Calculate Stamp Duty on the Motor Vehicles (MVR)

		function sdMVR(form)
		{
			var av = parseFloat(form.pv.value, 10);
			var c = 0;
			var test = 0;
			
			var price     = form.pv.value;
			
			if (price.indexOf(',')!=-1||price.indexOf('.')!=-1)
			{
				alert("Please enter a property value without commas or full stops.");
			}
			else
			{
				if (av <= 0)
				{
					form.sdp.value = "0.00";
				}
				else
				{
					c = (Math.ceil(av/100))*3;
					r = c.toFixed(2);
					strCents = "" + r;
					len = strCents.length; 
					roundCents= strCents.substring(len - 1, len);
			  
					if (roundCents < 5)
					{
						roundCents=0;
					}
					else
					{
						roundCents=5;
					}
			    
					form.sdp.value = addCommas(strCents.substring(0, len - 1)+roundCents);
				}
			
				if (av < 0)
				{
					form.sdp.value = "0.00";
				}
			}
		}

//Print Conveyance Calculator - this function creates a new HTML page that displays details entered in a print friendly format with the TRO banner

		function printConv(form)
		{
			var propertyDetails = form.txtPropDet.value;
			var propertyValue = form.pv.value;
			var execDate = form.date.value;
			var stampDuty = form.sdp.value;
			
			document.write("<html><head>");
			document.write("<title>Northern Territory Treasury - Territory Revenue Office - Conveyance Calculator Result</title>");
			document.write("<img src='TRO_Banner.png' alt='Northern Territory Treasury - Territory Revenue Office' />");
			document.write("</head><body>");
			document.write("<h2>Conveyance Calculator Results</h2>");
			document.write("<table border='1' cellpadding='10'>");
			document.write("<tr><td>Property Details</td><td>" + propertyDetails + "</td></tr>");
			document.write("<tr><td>Property Value</td><td>$" + addCommas(propertyValue) + "</td></tr>");
			document.write("<tr><td>Execution Date</td><td>" + execDate + "</td></tr>");
			document.write("<tr><td><b>Estimated Stamp Duty</b></td><td><b>$" + stampDuty + "</b></td></td>");
			document.write("</table>");
			document.write("<br/>");
			document.write("<a href='javascript:window.print()' style='text-decoration: none; color: gray;'>Print <img src='print.gif' border='0'> </a>");
			document.write("<br/>");
			document.write("<br/>");
			document.write("<a href='javascript:history.go(-1)' align='right' style='text-decoration: none; color: gray;'>Go Back <img src='back.gif' border='0'> </a>");
			document.write("</body></html>");
			window.location.reload();
		}

//Print FHOC Calculator - this function creates a new HTML page that displays details entered in a print friendly format with the TRO banner

		function printFHOC(form)
		{
			var propertyDetails = form.txtPropDet.value;
			var propertyValue = form.pv.value;
			var execDate = form.date.value;
			var stampDuty = form.sdp.value;
			
			var vacant = "";
			var len = form.radioVacant.length;

			for (i = 0; i <len; i++)
			{
				if (form.radioVacant[i].checked)
				{
					vacant = form.radioVacant[i].value;
				}
			}
			
			document.write("<html><head>");
			document.write("<title>Northern Territory Treasury - Territory Revenue Office - FHOC Calculator Result</title>");
			document.write("<img src='TRO_Banner.png' alt='Northern Territory Treasury - Territory Revenue Office' />");
			document.write("</head><body>");
			document.write("<h2>First Home Owner Concession Calculator Results</h2>");
			document.write("<table border='1' cellpadding='10'>");
			document.write("<tr><td>Property Details</td><td>" + propertyDetails + "</td></tr>");
			document.write("<tr><td>Vacant Land</td><td>" + vacant + "</td></tr>");
			document.write("<tr><td>Property Value</td><td>$" + addCommas(propertyValue) + "</td></tr>");
			document.write("<tr><td>Execution Date</td><td>" + execDate + "</td></tr>");
			document.write("<tr><td><b>Estimated Stamp Duty</b></td><td><b>$" + stampDuty + "</b></td></td>");
			document.write("</table>");
			document.write("<br/>");
			document.write("<a href='javascript:window.print()' style='text-decoration: none; color: gray;'>Print <img src='print.gif' border='0'> </a>");
			document.write("<br/>");
			document.write("<br/>");
			document.write("<a href='javascript:history.go(-1)' align='right' style='text-decoration: none; color: gray;'>Go Back <img src='back.gif' border='0'> </a>");
			document.write("</body></html>");
			window.location.reload();
		}

//Print FHOC Calculator - this function creates a new HTML page that displays details entered in a print friendly format with the TRO banner
		
		function printFHOCCEO(form)
		{
			var propertyDetails = form.txtPropDet.value;
			var propertyValue = form.pv.value;
			var execDate = form.date.value;
			var stampDuty = form.sdp.value;
			var ceo = form.epp.value;
			
			var vacant = "";
			var len = form.radioVacant.length;

			for (i = 0; i <len; i++)
			{
				if (form.radioVacant[i].checked)
				{
					vacant = form.radioVacant[i].value;
				}
			}
			
			document.write("<html><head>");
			document.write("<title>Northern Territory Treasury - Territory Revenue Office - FHOC Homestart Calculator Result</title>");
			document.write("<img src='TRO_Banner.png' alt='Northern Territory Treasury - Territory Revenue Office' />");
			document.write("</head><body>");
			document.write("<h2>First Home Owner Concession & Homestart Calculator Results</h2>");
			document.write("<table border='1' cellpadding='10'>");
			document.write("<tr><td>Property Details</td><td>" + propertyDetails + "</td></tr>");
			document.write("<tr><td>Vacant Land</td><td>" + vacant + "</td></tr>");
			document.write("<tr><td>Property Value</td><td>$" + addCommas(propertyValue) + "</td></tr>");
			document.write("<tr><td>Execution Date</td><td>" + execDate + "</td></tr>");
			document.write("<tr><td>Interest Purchased</td><td>" + ceo + "%</td></tr>");
			document.write("<tr><td><b>Estimated Stamp Duty</b></td><td><b>$" + stampDuty + "</b></td></td>");
			document.write("</table>");
			document.write("<br/>");
			document.write("<a href='javascript:window.print()' style='text-decoration: none; color: gray;'>Print <img src='print.gif' border='0'> </a>");
			document.write("<br/>");
			document.write("<br/>");
			document.write("<a href='javascript:history.go(-1)' align='right' style='text-decoration: none; color: gray;'>Go Back <img src='back.gif' border='0'> </a>");
			document.write("</body></html>");
			window.location.reload();
		}
		
//Print PPRR Calculator - this function creates a new HTML page that displays details entered in a print friendly format with the TRO banner

		function printPPRR(form)
		{
			var propertyDetails = form.txtPropDet.value;
			var propertyValue = form.pv.value;
			var execDate = form.date.value;
			var stampDuty = form.sdp.value;
			
			document.write("<html><head>");
			document.write("<title>Northern Territory Treasury - Territory Revenue Office - PPRR Calculator Result</title>");
			document.write("<img src='TRO_Banner.png' alt='Northern Territory Treasury - Territory Revenue Office' />");
			document.write("</head><body>");
			document.write("<h2>Principal Place of Residence Rebate Calculator Results</h2>");
			document.write("<table border='1' cellpadding='10'>");
			document.write("<tr><td>Property Details</td><td>" + propertyDetails + "</td></tr>");
			document.write("<tr><td>Property Value</td><td>$" + addCommas(propertyValue) + "</td></tr>");
			document.write("<tr><td>Execution Date</td><td>" + execDate + "</td></tr>");
			document.write("<tr><td><b>Estimated Stamp Duty</b></td><td><b>$" + stampDuty + "</b></td></td>");
			document.write("</table>");
			document.write("<br/>");
			document.write("<a href='javascript:window.print()' style='text-decoration: none; color: gray;'>Print <img src='print.gif' border='0'> </a>");
			document.write("<br/>");
			document.write("<br/>");
			document.write("<a href='javascript:history.go(-1)' align='right' style='text-decoration: none; color: gray;'>Go Back <img src='back.gif' border='0'> </a>");
			document.write("</body></html>");
			window.location.reload();
		}

//Common Functions used throughout script
		
	// FHOC Date
	
	// fFHOCDate Added (5th May 2010) , wrote 'if (date <=eFHOCdate)' and 'else return 54000'.
	
		function fhoc(date)
			{
			var aFHOCdate = new Date("2005/05/02");
			var bFHOCdate = new Date("2005/06/19");
			var cFHOCdate = new Date("2007/04/30");
		    var dFHOCdate = new Date("2008/05/05");
			var eFHOCdate = new Date("2010/05/04");
		
			if(date<=aFHOCdate)
				return 125000;
				
			else if(date<=bFHOCdate)
				return 200000;	
		
			else if(date<=cFHOCdate)
				return 225000;
		
			else if (date<=dFHOCdate)
				return 350000;
				
			else if (date<eFHOCdate)
				return 385000;
				
			else
				return 540000;
		}

//Rounding down to the nearest 5 cents
	
		function flr(num)
		{
			var x = num*100;
			
			//need an IF function here so that iff (X % 1) is greater than say 0.99999 or less than 0.00001 (in the range of the usual errors by the computer)
			//then use the Math.round function to round it to the nearest 1 (either up or down)
			// the IF function should eliminate any chance of rounding a geniunely correct number
			if (((x % 1) > 0.99999) || ((x % 1) < 0.00001))
			{
				x = Math.round(x);
			}
			
			var y = (x-(x % 5))/100;
			return y;
		}

//Rounding down to the nearest 1 cent
	
		function flr2(num)
		{
			var x = num*100;
			var y = (x-(x % 1))/100;
			return y;
		}
		
//Date String
		
		function auDate(dateStr)
		{
			var date  = dateStr.substr(0,2);
			var month = dateStr.substr(3,2);
			var year  = dateStr.substr(6,4);
			return new Date(year + "/" + month + "/" + date);
		}
		
//Function reading for TRO Calculators

		function sdConvTRO(duty,execDate)
		{

			var budgdate  = new Date("2008/05/06");
			var budgdate2 = new Date("2011/07/01");
			var duty1; 
		   
			if (execDate < budgdate)
			{
				duty1 = dutyOld(duty);
			}
			else if (budgdate < execDate && budgdate2 > execDate)
			{
				duty1 = dutyNew(duty);
			}
			else 
			{
				duty1 = dutyThird(duty);
			}
			
			return duty1;
			
			
		}

		
		function addCommas(nStr)
	{
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) 
		{
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}
	
	//Created this function
		function spcc(date)
		{
			var SPCCdate1 = new Date("2010/05/04");
			
			if(date>=SPCCdate1)
				return 8500;
		}
		
		//Created this function
		
		function sdSPCC(form)
		
		{
			var date      = auDate(form.date.value);
			var budgdate  = new Date("05/04/2010");
			var budgdate2 = new Date("07/01/2011");
			var spcc_cap_date = new Date("05/04/2010"); //MM/DD/YYYY 1 January 2010
			var spcc_cap_land = 385000;
			var spcc_cap_home = 750000;
			var price     = form.pv.value;
			var flag = "";
			
			var vacant = "";
			var len = form.radioVacant.length;

			for (i = 0; i <len; i++)
			{
				if (form.radioVacant[i].checked)
				{
					vacant = form.radioVacant[i].value;
				}
			}
		
			if(price=="" || isNaN(price) || price<0)
			{
				alert("The 'Value of Property' entered is invalid. Please re-enter value.");
			}
			else if (price.indexOf(',')!=-1||price.indexOf('.')!=-1)
			{
				alert("Please enter a property value without commas or full stops.");
			}
			else if(!((form.date.value).match(/\d\d\/\d\d\/\d\d\d\d/)))
			{
				alert("The 'Date of Contract' entered is invalid. Please re-enter in the format dd/mm/yyyy.");
			}
			else if(date<budgdate)
			{
				alert ("The Senior, Pensioner and Carer Concession is not available for contracts before 4 May 2010.");
			}
			else if(vacant=="Yes" && price>spcc_cap_land && date>=spcc_cap_date)
			{
				flag = "True";
				
					if (date < budgdate2)
				{
					sdSPCCNew(form,flag);		
				}
					else 
				{
					sdSPCCThird(form,flag);
				}
				
				alert("As the value of the land exceeds $385 000, you are not eligible for the Senior, Pensioner and Carer Concession . However, you may be eligible for Principal Place of Residence Rebate.");
			}
			else if(vacant=="No" && price>spcc_cap_home && date>=spcc_cap_date)
			{
				flag = "True";
				
				if (date < budgdate2)
				{
					sdSPCCNew(form,flag);		
				}
					else 
				{
					sdSPCCThird(form,flag);
				}
				
				alert("As the value of the property exceeds $750 000, you are not eligible for the Senior, Pensioner and Carer Concession . However, you may be eligible for Principal Place of Residence Rebate.");
			}
			else
			{
				flag = "False";
			
				if (date < budgdate2)
				{
					sdSPCCNew(form,flag);		
				}
					else 
				{
					sdSPCCThird(form,flag);
				}
			}
		}
		
		// Created this function
		
		function sdSPCCNew(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyNew(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				result = dutyNew(price) - spcc(date);
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
		
			if(result<0)
			{
				result = 0;
			}
		
			form.sdp.value = addCommas(result.toFixed(2));
		}
		
		function sdSPCCThird(form,flag)
		{
			var price     = parseFloat(form.pv.value);
			var date      = auDate(form.date.value);
			var result;
			var ineligible = flag;
		
			if (ineligible=="True")
			{
				result = dutyThird(price); //unrounded duty
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
			else if (ineligible=="False")
			{
				result = dutyThird(price) - spcc(date);
				
				if ((((result*100) % 1) > 0.99999) || (((result*100) % 1) < 0.00001)) //minute variances can occur during the previous line
				{
					result = Math.round(result*100)/100;
				}
				
				result = flr2(result); //rounds down to the nearest cent to avoid discrepencies caused by the way javascript handles numbers
				result = flr(result); //rounds down to the nearest 5 cents
			}
		
			if(result<0)
			{
				result = 0;
			}
		
			form.sdp.value = addCommas(result.toFixed(2));
		}
