var Lang=YAHOO.lang;function SlideshowPoll()
{this.btn_stop_slide="slideshow_poll_btn_submit_";this.most_recent_img_user="slideshow_poll_most_recent_vote_img_user_";this.most_recent_title_user="slideshow_poll_most_recent_vote_title_user_";this.most_recent_entry_title_user="slideshow_poll_most_recent_vote_entry_title_user_";this.cookie_timeout=30;this.slideimage_id=0;this.max_votes=50;this.nAnimCounter=0;this.votes=0;this.c_slides=0;this.permalink='';this.is_anonymous_vote=true;this.is_ip_blocking=true;this.form_slide="slideshow_poll_form_";this.social_enabled=1;this.results_cont="slideshow_poll_results_";this.facebook_share_cont='facebook_share_slideshow_vote_';this.facebook_share_link='facebook_share_slideshow_vote_link_';this.poll_requested=false;this.modal_init=false;this.navigation_cont='slideshow_poll_navigation_';this.slideimage_title='slideshow_poll_title_';this.slideimage_image='slideshow_first_navigation_thumbnail';this.drag_drop_cont='slideshow_poll_drag_drop_';this.drag_drop_ul='most_popular_slides_';this.first_poll_container='slideshow_poll_first_';this.facebook_share_form='slideshow_poll_share_to_facebook_form_';this.google_share_form='slideshow_poll_share_to_google_form_';this.close_fb_share_slideshow_poll='close_fb_share_slideshow_poll_';this.modal_popup='huff_modal_slideshow_poll_';this.close_img_fb_share_slideshow_poll='close_img_fb_share_slideshow_poll_';this.is_requested=false;this.entry_id=0;this.image_anchor='slide_image';this.slideshow_id=0;this.entry_category='';this.facebook_details={};this.libs_loaded=false;this.vote_title='';this.vote_image='';this.navigation_cur_slide=0;this.prev_link='slideshow_poll_prev_link_';this.next_link='slideshow_poll_next_link_';this.radio_checked=false;this.callback=null;this.aSlides=[];this.aSlides_id_key={};this.dragged_slots={};this.class_preloading='';this.top_slides_init=false;this.img_src='';this.base_link='';this.sharing_type='facebook';this.custom_slides={};this.custom_slides_init=false;this.custom_vertical='';this.body_clicked=false;this.dom_lib_loaded=false;this.anim_counter=0;this.anim_value=0;this.anim_container=null;this.anim_way='';this.count_social_slides=0;this.animating=false;this.navigation_module_loaded=false;this.already_voted_slides=[];this.next_link_href=false;this.last_vote=[];this.last_vote_counter=0;var _this=this;if(this.social_enabled&&!SlideshowPoll.prototype.FacebookShare)
{HPUtil.loadAndRun('/include/lib/slideshow/social_features.js?16');}}
SlideshowPoll.prototype.SortAlreadyVotedSlides=function()
{var tmp,min_temp;for(var i=0;i<this.already_voted_slides.length;i++){min_temp=parseInt(this.already_voted_slides[i].split(':')[1]);for(var j=i+1;j<this.already_voted_slides.length;j++){if((min_temp-parseInt(this.already_voted_slides[j].split(':')[1]))<0){min_temp=parseInt(this.already_voted_slides[j].split(':')[1]);tmp=this.already_voted_slides[i];this.already_voted_slides[i]=this.already_voted_slides[j];this.already_voted_slides[j]=tmp;}}}}
SlideshowPoll.prototype.Initialize=function(slideshow_id,slideimage_id,facebook_details)
{if(D.get('tenslides_poll_container'))
HuffPoUtil.ImageLoader.foldCheck('tenslides_poll_container',true);this.permalink=this.entry_id?window.location.href.replace(/\?.*/,'').replace(/#.*/,''):this.permalink;if(!this.count_social_slides)
this.count_social_slides=this.aSlides.length;this.example_img_src='http://'+HPUtil.GetAmazonS3Location()+'/gadgets/slideshows/'+slideshow_id+'/slide_'+slideshow_id+'_1_small.jpg';this.entry_id=!this.entry_id?parseInt(HPUtil.GetEntryID(this.permalink)):this.entry_id;this.image_anchor=this.entry_id?'slide_image':'slide_image_frontpage';this.slideshow_id=slideshow_id;this.slideimage_image=D.get('slideshow_first_navigation_thumbnail')?'slideshow_first_navigation_thumbnail':'slide_image_'+slideshow_id;this.slideimage_id=slideimage_id;this.facebook_details=facebook_details||{};this.slideimage_title=this.slideimage_title+this.slideshow_id;this.next_link=this.next_link+this.slideshow_id;this.prev_link=this.prev_link+this.slideshow_id;this.is_last_slide=slideimage_id==this.aSlides[this.aSlides.length-1].slideimage_id;this.is_enabled_sharing=!(1==HuffCookies.get('slideshow_poll_facebook_shared_'+this.slideshow_id));if(!this.is_last_slide)
{this.next_link_href=D.get(this.next_link).href;}
this.most_recent_img_user=this.most_recent_img_user+this.slideshow_id;this.most_recent_title_user=this.most_recent_title_user+this.slideshow_id;this.most_recent_entry_title_user=this.most_recent_entry_title_user+this.slideshow_id;this.first_poll_container=this.first_poll_container+this.slideshow_id;this.facebook_share_form=this.facebook_share_form+this.slideshow_id;this.google_share_form=this.google_share_form+this.slideshow_id;this.drag_drop_ul=this.drag_drop_ul+this.slideshow_id;this.facebook_share_link=this.facebook_share_link+this.slideshow_id;this.close_img_fb_share_slideshow_poll=this.close_img_fb_share_slideshow_poll+this.slideshow_id;this.facebook_share_cont=this.facebook_share_cont+this.slideshow_id;this.modal_popup=this.modal_popup+this.slideshow_id;this.close_fb_share_slideshow_poll=this.close_fb_share_slideshow_poll+this.slideshow_id;this.drag_drop_cont=this.drag_drop_cont+this.slideshow_id;this.form_slide=this.form_slide+this.slideshow_id;this.results_cont=this.results_cont+this.slideshow_id;this.navigation_cont=this.navigation_cont+this.slideshow_id;this.btn_stop_slide=this.btn_stop_slide+this.slideshow_id;this.c_slides=this.aSlides.length;var _this=this;if(D.getElementsByClassName('tenslides_poll_container').length&&D.getElementsByClassName('tenslides_poll_container')[0].firstChild)
{this.anim_container=D.getElementsByClassName('tenslides_poll_container')[0].firstChild;}
var current_slidenumber=HPUtil.getUrlVar('slidenumber');if(this.aSlides.length>6&&current_slidenumber)
{this.navigation_cur_slide=(parseInt(current_slidenumber)+1).toString()>(this.aSlides.length-6)?this.aSlides.length-6:current_slidenumber;this.anim_container.style.marginLeft=(-79*(this.navigation_cur_slide)).toString()+'px';}
E.on(D.getElementsByClassName('tenslides_poll_left_nav'),'click',function(e)
{E.preventDefault(e);this.MoveLeft();},{},this);E.on(D.getElementsByClassName('tenslides_poll_right_nav'),'click',function(e)
{E.preventDefault(e);this.MoveRight();},{},this);if(this.social_enabled)
{HPUtil.WaitForCondition.apply(this,[function()
{if(this.is_enabled_sharing&&(already_voted_slides_cookie=HuffCookies.get('slideshow_poll_voted_slides_'+slideshow_id)))
{this.already_voted_slides=already_voted_slides_cookie.split('|');if(5==this.already_voted_slides.length||this.is_last_slide)
{this.SortAlreadyVotedSlides();if(1!=HuffCookies.get('slideshow_poll_shared_showed_once_'+this.slideshow_id)&&this.already_voted_slides.length)
this.FacebookShare();HuffCookies.set('slideshow_poll_shared_showed_once_'+this.slideshow_id,1,720);}}
this.ShowStats();setInterval(function(){_this.ShowStats();},300*1000);E.on(this.btn_stop_slide,"click",function(e){E.preventDefault(e);_this.CheckForm();});E.on(this.facebook_share_link,'click',function(e){E.preventDefault(e);_this.FacebookShare();});E.on('slideshow_poll_facebook_login_vote','click',function(e){E.preventDefault(e);_this.FacebookShare();});E.on('top_5_sharing_'+this.slideshow_id,'click',function(e){E.preventDefault(e);_this.FacebookShare();});E.on('top_5_2_sharing_'+this.slideshow_id,'click',function(e){E.preventDefault(e);_this.FacebookShare();});E.on('google_select_top_5_link_'+this.slideshow_id,'click',function(e){E.preventDefault(e);this.FacebookShare();},{},this);E.on('fb_share_link_'+this.slideshow_id,'click',function(e){E.preventDefault(e);this.FacebookShare();},{},this);if(!HuffCookies.get('slideshow_poll_facebook_shared_'+this.slideshow_id))
{D.get(this.facebook_share_cont).style.display='block';}
E.on(D.get(D.getElementsByClassName('tenslides_poll_move_container','div')[0].getElementsByTagName('a')),'click',function(e){if(_this.radio_checked)
{var link=this.href;_this.callback=function(){location.href=link;}
_this.CheckForm();E.preventDefault(e);}});E.on(this.prev_link,'click',function(e){if(_this.radio_checked)
{var link=this.href;_this.callback=function(){location.href=link;}
_this.CheckForm();E.preventDefault(e);}});E.on(this.next_link,'click',function(e){if(_this.radio_checked)
{var link=this.href;_this.callback=function(){location.href=link;}
_this.CheckForm();E.preventDefault(e);}});E.on(document.forms[this.form_slide].elements['slideshow_rating'],'click',function(e){_this.radio_checked=true;});if(-1!=window.location.href.indexOf('userguid='))
{var userguid=HPUtil.getUrlVar('userguid');if(userguid)
{this.ShowFriendsChoicesByUserGuid(userguid);}}
if(-1!=window.location.href.indexOf('usernick='))
{var username=HPUtil.getUrlVar('usernick');if(username)
{this.ShowFriendsChoicesByUsername(username);}}},1,function(){return true;}]);}}
SlideshowPoll.prototype.AnimNavigation=function()
{switch(this.anim_way)
{case'plus':if(this.anim_counter>=this.anim_value)
{clearInterval(this.anim_interval);D.setStyle(this.anim_container,'margin-left',this.anim_value.toString()+'px');this.animating=false;return;}
this.anim_counter+=3;D.setStyle(this.anim_container,'margin-left',this.anim_counter.toString()+'px');break;default:if(this.anim_counter<=this.anim_value)
{clearInterval(this.anim_interval);D.setStyle(this.anim_container,'margin-left',this.anim_value.toString()+'px');this.animating=false;return;}
this.anim_counter-=3;D.setStyle(this.anim_container,'margin-left',this.anim_counter.toString()+'px');break;}}
SlideshowPoll.prototype.FindFirstAndLast=function()
{this.navFirstEl=this.anim_container.firstChild;this.navLastEl=this.anim_container.lastChild;}
SlideshowPoll.prototype._left=function()
{this.navFirstEl.style.marginLeft=-this.nAnimCounter+'px';if((this.nAnimCounter>=77)&&this.anim_interval)
{clearInterval(this.anim_interval);this.navFirstEl.style.marginLeft=0+'px';this.anim_container.removeChild(this.navFirstEl);this.anim_container.insertBefore(this.navFirstEl,this.navLastEl.nextSibling);this.animating=false;}
this.nAnimCounter+=3;}
SlideshowPoll.prototype._right=function()
{this.navFirstEl.style.marginLeft=-this.nAnimCounter+'px';if((this.nAnimCounter<=0)&&this.anim_interval)
{clearInterval(this.anim_interval);this.navFirstEl.style.marginLeft=0+'px';this.animating=false;}
this.nAnimCounter-=3;}
SlideshowPoll.prototype.MoveLeft=function()
{if(this.animating)
return;var me=this;this.animating=true;this.FindFirstAndLast();this.navLastEl.style.marginLeft=-77+'px';this.anim_container.removeChild(this.navLastEl);this.anim_container.insertBefore(this.navLastEl,this.navFirstEl);this.FindFirstAndLast();this.nAnimCounter=77;if(D.get('tenslides_poll_container'))
HuffPoUtil.ImageLoader.foldCheck('tenslides_poll_container',true,[-130,0]);this.anim_interval=setInterval(function(){me._right();},8);}
SlideshowPoll.prototype.MoveRight=function()
{if(this.animating)
return;var me=this;this.animating=true;this.FindFirstAndLast();this.nAnimCounter=1;if(D.get('tenslides_poll_container'))
HuffPoUtil.ImageLoader.foldCheck('tenslides_poll_container',true,[130,0]);this.anim_interval=setInterval(function(){me._left();},8);}
