		function SelectSubCat() {

			window.frames['ifTown'].location = 'CTChild.php4?MyArea='+document.SearchForm.MyCounty.value;   
			document.SearchForm.STID.value ='';
			
		}


		function UpDateSel(){

			var MySelection
			MySelection=''

				j=1;
				tnlen = (document.forms['MyTowns'].elements['MyTown'].length) ;
				for ( i=0; i<tnlen ; i++){
					if (document.forms['MyTowns'].elements['MyTown'].options[i].selected == true ) {

						if (j==1){
							MySelection = document.forms['MyTowns'].elements['MyTown'].options[i].value
							j=j+1;
						}
						else{
							MySelection =MySelection + ',' + document.forms['MyTowns'].elements['MyTown'].options[i].value
						}

						
					}
				}


			parent.document.SearchForm.STID.value = MySelection;

		}


		function ShortList(MyPID){

			window.frames['ifShort'].location = 'ShortlistChild.php4?PID='+MyPID;   

		}


		
		
		function AZAnchor(MyAnchor,MyPage){

			location.href = MyPage + '#' + MyAnchor;

		}


		function Switch( Elem, ElemID ) {


			if (Elem=='bdiv')
			{
				ptargetb = 'pbdiv' + ElemID
				ptargetp = 'ppdiv' + ElemID
				ptargetn = 'pndiv' + ElemID

				document.getElementById( ptargetb ).style.display = "";
				document.getElementById( ptargetp ).style.display = "none";
				document.getElementById( ptargetn ).style.display = "none";

				dtargetb = 'dbdiv' + ElemID
				dtargetp = 'dpdiv' + ElemID
				dtargetn = 'dndiv' + ElemID

				document.getElementById( dtargetb ).style.display = "";
				document.getElementById( dtargetp ).style.display = "none";
				document.getElementById( dtargetn ).style.display = "none";

			}

			if (Elem=='pdiv')
			{
				ptargetb = 'pbdiv' + ElemID
				ptargetp = 'ppdiv' + ElemID
				ptargetn = 'pndiv' + ElemID

				document.getElementById( ptargetb ).style.display = "none";
				document.getElementById( ptargetp ).style.display = "";
				document.getElementById( ptargetn ).style.display = "none";

				dtargetb = 'dbdiv' + ElemID
				dtargetp = 'dpdiv' + ElemID
				dtargetn = 'dndiv' + ElemID

				document.getElementById( dtargetb ).style.display = "none";
				document.getElementById( dtargetp ).style.display = "";
				document.getElementById( dtargetn ).style.display = "none";
			}

			if (Elem=='ndiv')
			{
				ptargetb = 'pbdiv' + ElemID
				ptargetp = 'ppdiv' + ElemID
				ptargetn = 'pndiv' + ElemID

				document.getElementById( ptargetb ).style.display = "none";
				document.getElementById( ptargetp ).style.display = "none";
				document.getElementById( ptargetn ).style.display = "";

				dtargetb = 'dbdiv' + ElemID
				dtargetp = 'dpdiv' + ElemID
				dtargetn = 'dndiv' + ElemID

				document.getElementById( dtargetb ).style.display = "none";
				document.getElementById( dtargetp ).style.display = "none";
				document.getElementById( dtargetn ).style.display = "";
			}


		}


		function toggle(On, Off) {

			elementCount = (document.all(On).length)
			for (i=0; i<elementCount; i++) {
				document.all(On ,i).style.display = "";
			}

			elementCount = (document.all(Off).length)
			for (i=0; i<elementCount; i++) {
				document.all(Off ,i).style.display = "none";
			}

			if (On=='M2'){
				window.frames['ifShort'].location = 'ShortlistChild.php4?DefMyArea='+On;   
			}

			if (On=='F2'){
				window.frames['ifShort'].location = 'ShortlistChild.php4?DefMyArea='+On;   
			}

			if (On=='H2'){
				window.frames['ifShort'].location = 'ShortlistChild.php4?DefMyOut='+On;   
			}

			if (On=='A2'){
				window.frames['ifShort'].location = 'ShortlistChild.php4?DefMyOut='+On;   
			}

		}


		function toggle2(On, Off, off2) {

			elementCount = (document.all(On).length)
			for (i=0; i<elementCount; i++) {
				document.all(On ,i).style.display = "";
			}

			elementCount = (document.all(Off).length)
			for (i=0; i<elementCount; i++) {
				document.all(Off ,i).style.display = "none";
			}

			elementCount = (document.all(off2).length)
			for (i=0; i<elementCount; i++) {
				document.all(off2 ,i).style.display = "none";
			}


			window.frames['ifShort'].location = 'ShortlistChild.php4?DefMyCur='+On;   

		}


		function AdvSC_1(Field) 
		{

			var Item = document.AdvSearchForm.MyCounty_1.selectedIndex;		
			var Path = document.AdvSearchForm.MyCounty_1.options[Item].value;

			if (Item==0){
				alert('Please select a county')
			}
			else{
				smallwindow=window.open("AdvSearchCounty.php4?County="+Path+"&FLD="+Field,"","height=500, scrollbars=yes,width=800, left=50, top=50");
			}
			
		}

		function AdvSC_2(Field) 
		{

			var Item = document.AdvSearchForm.MyCounty_2.selectedIndex;
			var Path = document.AdvSearchForm.MyCounty_2.options[Item].value;

			if (Item==0){
				alert('Please select a county')
			}
			else{
				smallwindow=window.open("AdvSearchCounty.php4?County="+Path+"&FLD="+Field,"","height=500, scrollbars=yes,width=800, left=50, top=50");
			}
		}

		function AdvSC_3(Field) 
		{

			var Item = document.AdvSearchForm.MyCounty_3.selectedIndex;
			var Path = document.AdvSearchForm.MyCounty_3.options[Item].value;

			if (Item==0){
				alert('Please select a county')
			}
			else{
				smallwindow=window.open("AdvSearchCounty.php4?County="+Path+"&FLD="+Field,"","height=500, scrollbars=yes,width=800, left=50, top=50");
			}
		}

		function ClearID(Field){

			document.getElementById(Field).value = '';
		}


		function UpdateSel_ADV(){
		 
			j=1;
			document.AdvSearchcountyForm.SelIDs.value = '';
			for (var i = 0; i < document.AdvSearchcountyForm.elements.length; i++){
				if (document.AdvSearchcountyForm.elements[i].name == 'CID')	{
					if (document.AdvSearchcountyForm.elements[i].checked==true)	{
						if (j==1){
							document.AdvSearchcountyForm.SelIDs.value = document.AdvSearchcountyForm.elements[i].value
							j=j+1;
						}
						else{
							document.AdvSearchcountyForm.SelIDs.value = document.AdvSearchcountyForm.SelIDs.value + ','+ document.AdvSearchcountyForm.elements[i].value
						}
					}
				}
			}
		}

		function Accept(Field) {

			opener.document.getElementById(Field).value = document.AdvSearchcountyForm.SelIDs.value
			window.close();

		}

		function SelectAll(){
		 
			for (var i = 0; i < document.AdvSearchcountyForm.elements.length; i++){

				if (document.AdvSearchcountyForm.elements[i].name == 'CID')	{
					document.AdvSearchcountyForm.elements[i].checked=true
				}
			}
			UpdateSel_ADV()
		}

		function ClearAll(){
		 
			for (var i = 0; i < document.AdvSearchcountyForm.elements.length; i++){

				if (document.AdvSearchcountyForm.elements[i].name == 'CID')	{
					document.AdvSearchcountyForm.elements[i].checked=false
				}
			}
		}




		function CheckSelection(Field){

				
				var check_length = document.AdvSearchcountyForm.elements.length;		
				var str = opener.document.getElementById(Field).value;

				if (str.length>0)
				{

					ClearAll()

				}
				for (element_index=0;element_index<check_length;element_index++)
					{
						if (document.AdvSearchcountyForm.elements[element_index].name == 'CID')
						{
							if ((str.match(document.AdvSearchcountyForm.elements[element_index].value)) == null)
								{
								}
							else
								{
								document.AdvSearchcountyForm.elements[element_index].checked = true;
								}
						}
					}
					UpdateSel_ADV()
		}


		function CalcMort(){

			var P = document.FrmMort.Amt.value;
			var I = document.FrmMort.Rate.value;
			var L = 30;

			J = (I/(12 * 100));
			N = (L * 12)*(-1);
			M = P * (J / (1 - (Math.pow((1 + J),(N)))));

			document.FrmMort.Result.value = '€'+formatAsMoney(M);

		}


		function formatAsMoney(mnt) {
			mnt -= 0;
			mnt = (Math.round(mnt*100))/100;
			return (mnt == Math.floor(mnt)) ? mnt + '.00' 
					  : ( (mnt*10 == Math.floor(mnt*10)) ? 
							   mnt + '0' : mnt);
		}
		 


		function CalcLegal(){

			var Amount = document.FrmLegal.Amt.value;
			var Result = (Amount / 100) * 1.21;
			document.FrmLegal.Result.value = '€'+formatAsMoney(Result);

		}

		function CalcHStamp(){
				
			var P = document.FrmHStamp.HPrice.value;
			var I = document.FrmHStamp.PurType.value; 
			var Rate =0;
			var Stamp = 0;

			if (document.FrmHStamp.PurType[0].checked){

				if (P<127000){Rate = 0}
				else if ((P>=127001) && (P<190500)){Rate = 0}
				else if ((P>=190501) && (P<254000)){Rate = 0}
				else if ((P>=254001) && (P<317500)){Rate = 0}
				else if ((P>=317501) && (P<381000)){Rate = 0.03}
				else if ((P>=381001) && (P<635000)){Rate = 0.06}
				else if (P>=635000){Rate = 0.09}
			}


			if (document.FrmHStamp.PurType[1].checked){

				if (P<127000){Rate = 0}
				else if ((P>=127001) && (P<190500)){Rate = 0.03}
				else if ((P>=190501) && (P<254000)){Rate = 0.04}
				else if ((P>=254001) && (P<317500)){Rate = 0.05}
				else if ((P>=317501) && (P<381000)){Rate = 0.06}
				else if ((P>=381001) && (P<635000)){Rate = 0.075}
				else if (P>=635000){Rate = 0.09}

			}
		
			Stamp = (Rate * P)
			document.FrmHStamp.Result.value = '€'+formatAsMoney(Stamp);

		}




		function CalcLStamp(){		
		
			var P = document.FrmLStamp.LPrice.value;
			var Rate =0;
			var Stamp = 0;

			if (P<10000){Rate = 0}
			else if ((P>=10001) && (P<20000)){Rate = 0.01}
			else if ((P>=20001) && (P<30000)){Rate = 0.02}
			else if ((P>=30001) && (P<40000)){Rate = 0.03}
			else if ((P>=40001) && (P<70000)){Rate = 0.04}
			else if ((P>=70001) && (P<80000)){Rate = 0.05}
			else if ((P>=80001) && (P<100000)){Rate = 0.06}
			else if ((P>=100001) && (P<120000)){Rate = 0.07}
			else if ((P>=120001) && (P<150000)){Rate = 0.08}
			else if (P>=150000){Rate = 0.09}

			Stamp = (Rate * P)
			document.FrmLStamp.Result.value = '€'+formatAsMoney(Stamp);

		}


		function EmailPage(URL) 
		{

			smallwindow=window.open("EmailPage.php4?URL='"+URL+"'","","height=300, scrollbars=yes,width=600, left=50, top=50");		

		}
