function PropertyPhotoPlayer(){this.main_image_element=null;this.previous_image_element=null;this.next_image_element=null;this.next_button_element=null;this.previous_button_element=null;this.current_photo_count_element=null;this.total_photo_count_element=null;this.caption_element=null;this.current_photo_index=0;this.photos=[];this.animating=false;this.current_selected_cell=null;this.loaded=false;this.image_loading=false;this.playing=false;this.playing_id=null;this.captions={}}PropertyPhotoPlayer.prototype.add_photo=function(url,alt_text,caption){var image=new Image();image.url=url;image.alt=alt_text;if(caption){this.captions[url]=caption}this.photos.push(image);this.hilite_cell(xb_get_element("photo_player_cell_0"))};PropertyPhotoPlayer.prototype.start=function(){this.playing=true;var me=this;var start_me=function(){me.next_photo()};window.setTimeout(start_me,5000)};PropertyPhotoPlayer.prototype.play=function(){this.playing=true;this.next_photo()};PropertyPhotoPlayer.prototype.stop=function(){this.playing=false;if(typeof(this.playing_id)=="number"){clearTimeout(this.playing_id)}};PropertyPhotoPlayer.prototype.next_photo=function(){this.is_loaded();var photo_index=this.current_photo_index+1;if(photo_index<0){photo_index=this.get_photo_count()-1}else{if(photo_index>=this.photos.length){photo_index=0}}this.load_photo(photo_index);if(this.playing){this.playing_id=window.setTimeout("PPP.next_photo()",5000)}return false};PropertyPhotoPlayer.prototype.previous_photo=function(){this.is_loaded();var photo_index=this.current_photo_index-1;if(photo_index<0){photo_index=this.get_photo_count()-1}else{if(photo_index>=this.photos.length){photo_index=0}}this.load_photo(photo_index);return false};PropertyPhotoPlayer.prototype.is_loaded=function(){if(!this.loaded){if(typeof(load_photo_player)=="function"){if(load_photo_player()){this.loaded=true}}}};PropertyPhotoPlayer.prototype.load_photo=function(photo_index){this.is_loaded();if(typeof(this.photos)=="undefined"||!this.photos[photo_index]||!this.photos[photo_index].url||!this.main_image_element||(photo_index<1&&photo_index>this.photos.length)){return false}this.image_loading=true;this.main_image_element.src=this.photos[photo_index].url;this.current_photo_index=photo_index;if(this.current_photo_count_element){this.current_photo_count_element.innerHTML=this.current_photo_index+1}this.hilite_cell(xb_get_element("photo_player_cell_"+photo_index));if(this.total_photo_count_element){this.total_photo_count_element.innerHTML=this.get_photo_count()+" "}if(this.caption_element){if(this.captions[this.main_image_element.src]){this.caption_element.innerHTML=this.captions[this.main_image_element.src]}else{this.caption_element.innerHTML="&nbsp;"}}};PropertyPhotoPlayer.prototype.finish_load=function(){PPP.set_opacity(PPP.main_image_element,0);PPP.fade_in(PPP.main_image_element.id,0)};PropertyPhotoPlayer.prototype.fade_in=function(element_id,opacity){var element=document.getElementById(element_id);if(element&&opacity<=100){opacity+=10;this.set_opacity(element,opacity);window.setTimeout("PPP.fade_in('"+element_id+"',"+opacity+")",25)}else{PPP.image_loading=false}};PropertyPhotoPlayer.prototype.set_opacity=function(element,opacity){opacity=(opacity==100)?99.999:opacity;element.style.opacity=opacity/100;element.style.filter="alpha(opacity:"+opacity+")";element.style.KHTMLOpacity=opacity/100;element.style.MozOpacity=opacity/100};PropertyPhotoPlayer.prototype.register_image_elements=function(image_element,previous_image_element,next_image_element){this.main_image_element=image_element;this.main_image_element.onload=this.finish_load;this.previous_image_element=previous_image_element;this.next_image_element=next_image_element};PropertyPhotoPlayer.prototype.register_counter_elements=function(current_count_element,total_photo_count_element){if(current_count_element){this.current_photo_count_element=current_count_element;this.current_photo_count_element.innerHTML=this.current_photo_index+1}if(total_photo_count_element){this.total_photo_count_element=total_photo_count_element}};PropertyPhotoPlayer.prototype.register_caption_element=function(caption_element){if(caption_element){this.caption_element=caption_element}};PropertyPhotoPlayer.prototype.hilite_cell=function(selected_cell){if(selected_cell){remove_class(this.current_selected_cell,"selected_cell_image");add_class(selected_cell,"selected_cell_image");this.current_selected_cell=selected_cell}};PropertyPhotoPlayer.prototype.get_photo_count=function(){return this.photos.length};
