
		function addLoadEvent(f){var ono=window.onload;if(typeof window.onload!='function'){window.onload=f}else{window.onload=function(){ono();f()}}}

		/* Featured property object */
		function FeaturedPropertyModel(details_url, image_url, address, price, description) 
		{
			this.details_url = details_url;
			this.image_url = image_url;
			this.address = address;
			this.price = price.replace("£", String.fromCharCode(163));
			this.description = description;
		};

    function FeaturedProperty(sp,db,err) {
        this.speed = sp;
        this.dbtype = db;
        this.featuredProperties = new Array();
        this.currentIndex = 0;
        this.featureDiv = null;
        this.error = err;
        if (document.getElementById("featureprops")) {
       this.featureDiv = document.getElementById("featureprops");
    } else if  (document.getElementById("featureprops" + this.dbtype)) {
       this.featureDiv = document.getElementById("featureprops"+ this.dbtype);
    }

    }
    
    FeaturedProperty.prototype.ShowNextSlide = ShowNextSlide;
    FeaturedProperty.prototype.AppendFeature = AppendFeature;
    FeaturedProperty.prototype.AddFeature = AddFeature;
    FeaturedProperty.prototype.CreateTextDiv = CreateTextDiv;
    FeaturedProperty.prototype.FeatureLoad = FeatureLoad;      
    FeaturedProperty.prototype.AddFeatureProperty = AddFeatureProperty;  
         

		function ShowNextSlide(me) {
		    if ( me.featuredProperties.length ==0 ) return;
		    if (me.currentIndex >= me.featuredProperties.length) {
			    me.currentIndex = 0;
			}
		    if (me.currentIndex == 0 && me.featuredProperties.length == 1) {
		        me.AddFeature(0);
		    } else if (me.speed == 0 ) {
		        var ul = document.createElement("ul");
		        me.featureDiv.appendChild(ul);
		        for(var i=0; i<me.featuredProperties.length; i++)
		        {
		            var li = document.createElement("li");
		            me.AppendFeature(li, me.featuredProperties[i]);
		            ul.appendChild(li);
		        }
		    } else {
		        var timeout = function () {
		            ShowNextSlide(me);
		        };
	
		        me.AddFeature(me.currentIndex++);
		        window.setTimeout(timeout, me.speed);
		    }

		};
		
		function AppendFeature(targetDiv, fpModel) {
		    var imageDiv = document.createElement("div");
		    imageDiv.className ="fpImage";
		    var imageLink = document.createElement("a");
		    imageLink.setAttribute("href", fpModel.details_url);
		    imageLink.setAttribute("title", "View property details for property in " + fpModel.address + ", " + fpModel.price);
		    var imageTag = document.createElement("img");
		    imageTag.setAttribute("src", fpModel.image_url);
		    imageTag.setAttribute("alt", "Image for property in " + fpModel.address);
		    imageLink.appendChild(imageTag);
		    imageDiv.appendChild(imageLink);
		    var addressDiv = CreateTextDiv("fpAddress", fpModel.address);
		    var priceDiv = CreateTextDiv("fpPrice", fpModel.price);
		    targetDiv.appendChild(imageDiv);
		    targetDiv.appendChild(addressDiv);
		    targetDiv.appendChild(priceDiv);
		};

		function AddFeature(index) {
		    var fpModel = this.featuredProperties[index];
		    var l = this.featureDiv.childNodes.length;
		    for (var i=0; i < l; i++) {
		        var ch = this.featureDiv.firstChild;
		        this.featureDiv.removeChild(ch);
		    }
		    AppendFeature(this.featureDiv, fpModel);
		};
		
	   function AddFeatureProperty(fpModel) {
		    this.featuredProperties[this.featuredProperties.length] = fpModel;
		};

		function CreateTextDiv(id, text) {
		    var textDiv = document.createElement("div");
		    textDiv.className= id;
		    var paraElement = document.createElement("p");
		    textDiv.appendChild(paraElement);
		    var textElement = document.createTextNode(text);
		    paraElement.appendChild(textElement);
		    textDiv.appendChild(paraElement);
		    return textDiv;
		};

		function FeatureLoad() { 
          if (this.error == null && this.featureDiv != null)
          {
            var propCount = this.featuredProperties.length;
            var randomPropIndex = Math.floor(Math.random() * propCount);
            this.currentIndex = randomPropIndex;
            this.ShowNextSlide(this);
	        } 
          else if (this.error != null && this.featureDiv != null)
          {
	          var p = document.createElement("p");
	          p.appendChild(document.createTextNode(error));
	          this.featureDiv.appendChild(p);
	        }
    };
        
		
		
		
		

      // this variable name needs to be unique
      var featuredObj1;
      function initFeaturedProp() {
        featuredObj1 = new FeaturedProperty(0,1, null);
        
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22983766",
      "http://images.vebra.com/images/1150/006/type1/firsla~2.jpg",
      "2.09 Acres Pasture Land, At Firs Farm, Knowle, West Midlands, B93 8PR",
      "£20,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22977341",
      "http://images.vebra.com/images/1150/007/type1/4sw.jpg",
      "4, Sammons Way, Banners Brook, Tile Hill, CV4 9TD",
      "£214,950",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22974463",
      "http://images.vebra.com/images/1150/005/type1/5bonfv.jpg",
      "5, Boningale Way, Dorridge, West Midlands, B93 8SF",
      "£499,950",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22972860",
      "http://images.vebra.com/images/1150/005/type1/29neefv.jpg",
      "29, Needhill Close, Knowle, West Midlands, B93 9QS",
      "£265,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22972528",
      "http://images.vebra.com/images/1150/008/type1/14scfv.jpg",
      "14, Sandbarn Close, Monkspath, West Midlands, B90 4TQ",
      "£225,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22971274",
      "http://images.vebra.com/images/1150/008/type1/6upavfv.jpg",
      "6, Upwey Avenue, Solihull, West Midlands, B91 1LR",
      "£439,950",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22971198",
      "http://images.vebra.com/images/1150/006/type1/cle00002.jpg",
      "Cleobury Barn, Cleobury Lane, Earlswood, West Midlands, B94 6AF",
      "£875,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22971199",
      "http://images.vebra.com/images/1150/006/type1/cleost~1.jpg",
      "Land And Stables At, Cleobury Barn, Earlswood, West Midlands, B94 6AF",
      "£275,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22969275",
      "http://images.vebra.com/images/1150/009/type1/39mpfr.jpg",
      "39, Meadow Pleck Lane, Dickens Heath, West Midlands, B90 1SW",
      "£340,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22965650",
      "http://images.vebra.com/images/1150/009/type1/12alfr.jpg",
      "12, Ascote Lane, Dickens Heath, West Midlands, B90 1TP",
      "£147,500",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22964544",
      "http://images.vebra.com/images/1150/007/type1/hrnew.jpg",
      "High Ridge, Hob Lane, Nr Balsall Common, Warwickshire, CV8 1QA",
      "£765,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22964545",
      "http://images.vebra.com/images/1150/008/type1/212wmrfv.jpg",
      "212, Widney Manor Road, Solihull, West Midlands, B91 3JW",
      "£395,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22964546",
      "http://images.vebra.com/images/1150/008/type1/17ytlfv.jpg",
      "17, Yew Tree Lane, Solihull, West Midlands, B91 2PA",
      "£699,950",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22964547",
      "http://images.vebra.com/images/1150/009/type1/garsq3.jpg",
      "2, Rose Court, Dickens Heath, West Midlands, B90 1FH",
      "£159,950",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22964190",
      "http://images.vebra.com/images/1150/007/type1/hbcnew.jpg",
      "Hollyberry Cottage, Harvest Hill Lane, Meriden, Solihull, CV7 7HW",
      "£434,950",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22962972",
      "http://images.vebra.com/images/1150/008/type1/chofrt.jpg",
      "Croft Holme, St. Peters Lane, Bickenhill, West Midlands, B92 0DP",
      "£712,500",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22962973",
      "http://images.vebra.com/images/1150/063/type1/hlctbrv2.jpg",
      "Holly Cottage,9, Kings Lane, Broom, Broom, Alcester, B50 4HB",
      "£925,000",
      ""));
    
      featuredObj1.AddFeatureProperty(  new FeaturedPropertyModel(
      "http://search.thinkproperty.com/johnshepherd/property/22962890",
      "http://images.vebra.com/images/1150/006/type1/4catesfv.jpg",
      "Apt 1, Catesby House, Lapworth, West Midlands, B94 5QS",
      "£450,000",
      ""));
    
      featuredObj1.FeatureLoad();
      
      }
      addLoadEvent(initFeaturedProp);

    
