/*
HTTP Host: static.ak.fbcdn.net
Generated: March 20th 2010 3:31:05 AM PDT
Machine: 10.16.139.103
Locale: nu_ll
Path: js/polls/social_poll.js
*/

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/polls\/social_poll.js"]); }

function SocialPollController(a,b,c){this.poll_id=a;this.is_answered=b;this.is_social=c;this._init();}copy_properties(SocialPollController,{POLL_STATE_INITIAL:0,POLL_STATE_ANSWERED:1,MAX_RESULT_WIDTH:300});copy_properties(SocialPollController.prototype,{_init:function(){if(!this.is_answered){var a=DOM.scry($('choices_'+this.poll_id),'input[type="radio"]');if(a)for(var b=0;b<a.length;b++){var c=a[b];c.listen('click',this._vote.bind(this,c));}}if(this.is_social){var d=DOM.scry($('who_voted_'+this.poll_id),'a.show_friend_votes');if(d){show_friend_link=d[0];show_friend_link.listen('click',this._showFriends.bind(this));}}var f=DOM.scry(ge('delete_'+this.poll_id),'a.x_to_hide');if(f.length>0){var e=f[0];e.listen('click',this.deleteSocialPoll.bind(this));}},_showFriends:function(){var b=DOM.scry($('answers_'+this.poll_id),'div.friends');for(var c=0;c<b.length;c++){var a=b[c];if(a.childNodes.length>0)if(!shown(a)){animation(a).show().from('height',0).to('height','auto').duration(200).go();}else animation(a).to('height',0).duration(200).hide().go();}return false;},_vote:function(h){var j=h.value;var b=$('choices_'+this.poll_id);var g=DOM.scry(b,'input.inputradio');var a=0;var i=Vector2.getElementPosition(h);var c=Vector2.getElementPosition(b);var f=new Vector2(a,i.y-c.y,'document');for(var d=0;d<g.length;d++)g[d].disabled=true;var e=b.find('img.submit_progress');f.setElementPosition(e);h.setStyle('visibility','hidden');e.removeClass('hidden');new AsyncRequest().setURI("/ajax/polls/social_poll_vote.php").setMethod('POST').setData({poll_id:this.poll_id,vote:j}).setHandler(this.socialPollShowResults.bind(this)).setErrorHandler(this._socialPollAjaxFailureHandler.bind(this)).setTransportErrorHandler(this._socialPollAjaxFailureHandler.bind(this)).send();return false;},_socialPollAjaxFailureHandler:function(b){var a=$('choices_'+this.poll_id);var c=a.find('img.submit_progress');c.addClass('hidden');},socialPollShowResults:function(b){var a=$('choices_'+this.poll_id);var c=a.find('img.submit_progress');c.addClass('hidden');DOM.replace($('choices_'+this.poll_id),HTML(b.getPayload()));this.animatePollResults();show($('who_voted_'+this.poll_id));},animatePollResults:function(){var c=DOM.scry($('answers_'+this.poll_id),'div.result_bar');for(var b=0;b<c.length;b++){var a=c[b];var d=a.offsetWidth;a.setStyle('width','0px');animation(a).from('width',0).to('width',d).duration(500).ease(animation.ease.both).go();}},deleteSocialPoll:function(){new Dialog().setTitle(_tx("Szavaz\u00e1s t\u00f6rl\u00e9se")).setBody(_tx("Biztos vagy benne, hogy t\u00f6r\u00f6lni akarod ezt a szavaz\u00e1st? Nem tudod visszavonni k\u00e9s\u0151bb.")).setButtons([Dialog.OK,Dialog.CANCEL]).setHandler(this._deleteSocialPoll.bind(this)).show();},_deleteSocialPoll:function(){var b=$('pollrow_'+this.poll_id).find('div.polltitle h3');DOM.setContent(b,_tx("Szavaz\u00e1s t\u00f6rl\u00e9se..."));hide(ge('answers_'+this.poll_id));hide(ge('choices_'+this.poll_id));hide(ge('who_voted_'+this.poll_id));hide(ge('vote_count_'+this.poll_id));var c=DOM.find($('delete_'+this.poll_id),'a.x_to_hide');c.setStyle('background','url(/images/loaders/indicator_blue_small.gif?8:111099)'+' no-repeat scroll center');c.setStyle('width','16px');var a=new AsyncRequest().setURI('/ajax/polls/social_poll_delete.php').setMethod('POST').setData({poll_id:this.poll_id}).setHandler(this._deleteSocialPollAjaxHandler.bind(this)).setErrorHandler(this._deleteSocialPollAjaxFailureHandler.bind(this)).send();},_deleteSocialPollAjaxHandler:function(b){var a=$('pollrow_'+this.poll_id);DOM.empty(a);hide(a);return false;},_deleteSocialPollAjaxFailureHandler:function(a){hide($('delete_'+this.poll_id));}});

if (window.Bootloader) { Bootloader.done(["js\/polls\/social_poll.js"]); }