function EstateWeb_Objects_Property(){
	this.propertyReference = "";
	this.officeID = -1;
	this.propertyAddress = new EstateWeb_Objects_Property_PropertyAddress();
	this.propertyPrice = new EstateWeb_Objects_Property_PropertyPrice(this);
	this.mapping = new EstateWeb_Objects_Property_Mapping(this);
	this.propertyTypes = new EstateWeb_Objects_Property_PropertyTypes();
	this.propertyType = this.propertyTypes.residential;
	this.propertyStatuses = new EstateWeb_Objects_Property_PropertyStatuses();
	this.propertyStatusID = this.propertyStatuses.available;
	this.propertyListingTypes = new EstateWeb_Objects_Property_PropertyListingTypes(this);
	this.propertyListingType = this.propertyListingTypes.unspecified;
	this.propertyDetails = new EstateWeb_Objects_Property_PropertyDetails(this);
	this.detailsURL = "";
}

function EstateWeb_Objects_Property_PropertyDetails(o){
	this.parent = o;
	this.googleBriefDetails = "";
	this.propertyDetailTypes = new EstateWeb_Objects_Property_PropertyDetails_PropertyDetailsTypes();
	this.getPropertyDetails = EstateWeb_Objects_Property_PropertyDetails_GetPropertyDetails;
	this.getObjectInPropertyDetails = EstateWeb_Objects_Property_PropertyDetails_GetObjectsInPropertyDetails;
}

function EstateWeb_Objects_Property_PropertyDetails_GetObjectsInPropertyDetails(type, tagName, elemID){
	var ocontainer = document.createElement("div");
	switch ( type ){
		case this.propertyDetailTypes.googleBriefDetails:
			ocontainer.innerHTML = this.googleBriefDetails;
			this.googleBriefDetails = ocontainer.innerHTML;
			var ocontaineritems = ocontainer.getElementsByTagName(tagName);
			for ( var i = 0; i < ocontaineritems.length; i ++ ){
				if ( ocontaineritems[i].id.toLowerCase() == elemID.toLowerCase() ){
					return ocontaineritems[i];
				}
			}
			break;
	}
	
}

function EstateWeb_Objects_Property_PropertyDetails_GetPropertyDetails(type,withRefresh,mapReferenceName){
	switch ( type ){
		case this.propertyDetailTypes.googleBriefDetails:
			if ( this.googleBriefDetails.length == 0 || withRefresh ){
				var oresponse = MapView.GetPointerBriefDetails( this.parent.propertyReference, mapReferenceName );
				if ( oresponse.value ){
					this.googleBriefDetails = oresponse.value;
				}else{
					alert("Error");
				}
			}
			return this.googleBriefDetails;
			break;
	}
}

function EstateWeb_Objects_Property_PropertyDetails_PropertyDetailsTypes(){
	this.googleBriefDetails = 0;
}

function EstateWeb_Objects_Property_PropertyListingTypes(o){
	this.unspecified = -1;
	this.sale = 5;
	this.rent = 6;
}

function EstateWeb_Objects_Property_PropertyAddress(o){
	this.nameOrNumber = "";
	this.street = "";
	this.locality =  "";
	this.town = "";
	this.county = "";
	this.country = "";
	this.postcode = "";
	this.formattedAddress = "";
}

function EstateWeb_Objects_Property_PropertyPrice(o){
	this.parent = o;
	this.price = 0;
	this.salePrefix = "";
	this.saleNote = "";
	this.rentPer = "";
	this.rentNote = "";
	this.rentPeriod = "";
	this.priceHide = false;
	this.priceAltText = "";
	this.formattedPrice = "";
}

function EstateWeb_Objects_Property_Mapping(o){
	this.parent = o;
	this.latitude = 0.0;
	this.longitude = 0.0;
}

function EstateWeb_Objects_Property_PropertyStatuses(){
	this.available = 0;
	this.soldSubjectToContract = 1;
	this.letAgreed = 2;
	this.underOffer = 3;
	this.sold = 4;
	this.withDrawn = 5;
	this.let = 6;
	this.letPending = 7;
	this.letSubjectToContract = 8;
	this.completed = 9;
	this.exchanged = 10;
}

function EstateWeb_Objects_Property_PropertyTypes(){
	this.residential = 0;
	this.commercial = 1;
	this.overseas = 2;
	this.developments = 3;
}
