﻿// streamFeaturedProps.min.js
// Used for the featured properties piece on the streamrealty.com/portfolio/property-search.aspx page
// Used for production only

var Stream=window.Stream||{}; Stream.featuredProps=function(){function l(c){if(c&&c.length>0){a=c;b=Math.floor(Math.random()*c.length);j()}}function m(c){alert(c.get_message())}function j(){if(f){var c=parent.document.URL;if(c.indexOf("?pid=")>0){c=c.substring(c.indexOf("?pid=")+5);for(var d=0;d<a.length;d++)if(c==a[d].id){b=d;d=a.length}}}var h=$j("<img></img").attr("alt","").attr("src",n+a[b].image).css({position:"absolute","z-index":"-1",width:"274px",height:"240px",padding:"2px"});$j("#featured-prop-img-wrapper").append(h);if(f){g= h.css("z-index","10").show();f=false}else g.animate({width:"toggle"},500,function(){var o=g;g=h.css("z-index","10");o.remove()});$j("#featured-prop-name").text(a[b].propName);$j("#featured-prop-description").html(a[b].description);e.empty();c=$j("<a></a>");d=$j("<a></a>");var i=$j("<a></a>");if(a[b].contact1Name&&a[b].contact1Name.length>0){c.text(a[b].contact1Name).css("color","#0084a9");a[b].contact1Email&&a[b].contact1Email.length>0&&c.attr("href","mailto:"+a[b].contact1Email);e.append(c);if(a[b].contact2Name&& a[b].contact2Name.length>0){d.text(a[b].contact2Name).css("color","#0084a9");a[b].contact2Email&&a[b].contact2Email.length>0&&d.attr("href","mailto:"+a[b].contact2Email);e.append("&nbsp;|&nbsp;").append(d);if(a[b].contact3Name&&a[b].contact3Name.length>0){i.text(a[b].contact3Name).css("color","#0084a9");a[b].contact3Email&&a[b].contact3Email.length>0&&i.attr("href","mailto:"+a[b].contact3Email);e.append("&nbsp;|&nbsp;").append(i)}}}k=setTimeout(sfp.rotate,8E3)}var a,b,n="../images/featured-props/", e,k,f,g;return{init:function(){f=true;e=$j("#featured-prop-contactInfo");wsPortfolio.getFeaturedProps(l,m)},rotate:function(){clearTimeout(k);if(++b===a.length)b=0;j()}}}();var sfp=Stream.featuredProps;