// submission validation 
	fieldconverter=new Array();
	fieldconverter[0]='postcode';
	fieldconverter[1]='address';
	fieldconverter[2]='type of property';
	fieldconverter[3]='style of property';
	fieldconverter[4]='no of bedrooms';
	fieldconverter[5]='no of receptions';
	
	function valForm(){
		inputsChk=validateForm('postcode<s>,addressPointTOID<s>,displayPropTypeId<s>,displayPropStyleId<s>,bedrooms<s>,receptions<s>','propertyDetailsForm');
			
		if(inputsChk.length != 0){
			showAlert(inputsChk);
			return false;
		}
		return true;
	}
	
	
// Populate address
	function postcodeChange(postcodeEntered,selectedAddressPointTOID,clearAlert){		
		if(document.propertyDetailsForm.addressPointTOIDSelectedPostcode.value != document.propertyDetailsForm.postcode.value || document.propertyDetailsForm.addressPointTOID.options[0].text == 'Enter a postcode above'){
			if(clearAlert){
				showAlert("");
			}
			if(postcodeEntered.length != 0){
				document.propertyDetailsForm.addressPointTOID.options.length = 2;
				document.propertyDetailsForm.addressPointTOID.options[0].text = 'Loading...';
				
				
				callServer(myself  + "address.getAddresses&postcode=" + postcodeEntered, "displayData", false);
				
			}
			document.propertyDetailsForm.postcode.value=postcodeEntered;
			document.propertyDetailsForm.addressPointTOIDSelectedPostcode.value=postcodeEntered;
		}	
		
		return true;
	}
	
	function displayData(returnedData){	
		//eval(returnedData);
		var addressTxt
		
		count = returnedData.getRowCount();
		document.propertyDetailsForm.addressPointTOID.options.length = count+1;
	
		if(count==0){
			showAlert("The postcode you entered " + document.propertyDetailsForm.postcode.value + " was either incomplete,<br style='clear: both;'> incorrect, may have recently changed or is not covered by us at present. <br style='clear: both;'>Please re-enter your postcode.");
			document.propertyDetailsForm.addressPointTOID.options.length = 2;
			document.propertyDetailsForm.addressPointTOID.options[0].text = 'Enter a postcode above';
			
		}
		else{
			for (x=0; x < count; x++)
			{
				
				addressTxt="";
				document.propertyDetailsForm.addressPointTOID.options[x].value = returnedData["addresspointtoid"][x];
	
				if(returnedData["thoroughfare"][x].length > 47){
					addressTxt=returnedData["thoroughfare"][x].substring(0,47)+"...";
				}
				else{
					addressTxt=returnedData["thoroughfare"][x];
				}
				document.propertyDetailsForm.addressPointTOID.options[x].text = addressTxt;
			}
			 document.propertyDetailsForm.addressPointTOID.options[x].text="----------------------------------------------------------------";
		}
		
		selectAddressPointTOID(document.propertyDetailsForm.selectedAddressPointTOID.value)
		return true;
	}
	
	function selectAddressPointTOID(selectedAddressPointTOID){	
		if(selectedAddressPointTOID != ""){
			with(document.propertyDetailsForm.addressPointTOID){					
				for (x=0; x < options.length; x++){				
					if(options[x].value==selectedAddressPointTOID){
						options[x].selected=true;
						break;
					}
				}
			}	
		}
	}	
	
	function postcodeChangeOnload(){
		if(document.propertyDetailsForm.postcode.value != ""){
			postcodeChange(document.propertyDetailsForm.postcode.value);
		}
	}	
	
//	populate Property Style
	function addPropertyStyleIds(selectedproptypeid,setfocus){
		count=(selectedproptypeid !== "" & selectedproptypeid !== " ")? proptypeid[selectedproptypeid].length : 0 ;
		with(document.propertyDetailsForm.displayPropStyleId){
			options.length=(count+1);
			if(selectedproptypeid != ""){
				for (x=0; x < count; x++){
					values=proptypeid[selectedproptypeid][x].split("|");
					options[x+1].text=values[1];
					options[x+1].value=values[0];
					if(values[0] == setfocus){
						setfocus=x+1;
						break;
					}
				}
				selectedIndex=setfocus;
			}
		}				
		
		if(document.propertyDetailsForm.displayPropStyleId.length==1){
			document.propertyDetailsForm.displayPropStyleId.options[0].values="";
			document.propertyDetailsForm.displayPropStyleId.options[0].text="Select an option above";					
		} else {
			document.propertyDetailsForm.displayPropStyleId.options[0].values="";
			document.propertyDetailsForm.displayPropStyleId.options[0].text="Select an option";					
		}
	}
	
	
	function populatePropStyle(selectedDisplayPropStyleId){			
		with(document.propertyDetailsForm.displayPropStyleId){
			options.length=1;
			options[0].values="";
			options[0].text="Select an option";
			addPropertyStyleIds(document.propertyDetailsForm.displayPropTypeId[document.propertyDetailsForm.displayPropTypeId.selectedIndex].value);
			selectPropStyle(selectedDisplayPropStyleId);
		}	
		
	}	
	
	function selectPropStyle(selectedPropStyle){
		with(document.propertyDetailsForm.displayPropStyleId){
			for (x=0; x < options.length; x++){
				if(options[x].value==selectedPropStyle){
					options[x].selected=true;
					break;
				}
			}	
		}	
	}
	

	

	 