function generic_dialog(a,b){this.className=a;this.content=null;this.obj=null;this.popup=null;this.overlay=null;this.modal=null;this.iframe=null;this.hidden_objects=[];if(b==true){this.modal=true}}generic_dialog.dialog_stack=null;generic_dialog.prototype.should_hide_objects=ua.osx();generic_dialog.prototype.should_use_iframe=ua.ie()<7||(ua.osx()&&ua.firefox());generic_dialog.prototype.show_dialog=function(b){if(!this.obj){this.build_dialog()}set_inner_html(this.content,b);if(generic_dialog.prototype.should_hide_objects){var c=this.content.getElementsByTagName("img");for(var a=0;a<c.length;a++){c[a].onload=c[a].onload?function(){this.onload.apply(this.img,arguments);this.dialog.hide_objects()}.bind({img:c[a],dialog:this,onload:c[a].onload}):this.hide_objects.bind(this)}}this.show();this.focus_first_textbox();this.on_show_callback&&this.on_show_callback();return this};generic_dialog.prototype.focus_first_textbox=function(){function a(b){var c=(b.tagName=="INPUT"&&b.type.toLowerCase()=="text")||(b.tagName=="TEXTAREA");
if(c){try{b.focus();return false}catch(d){}}return true}iterTraverseDom(this.content,a)};generic_dialog.prototype.set_top=function(a){return this};generic_dialog.prototype.make_modal=function(){if(this.modal){return}this.modal=true;if(ua.ie()==7){this.build_iframe()}this.build_overlay();this.reset_iframe()};generic_dialog.prototype.show_loading=function(a){return this.show_dialog('<div id="structs" class="share_composer share_status_post"><div class="loading"><p>'+a+"</p></div></div>")};generic_dialog.prototype.show_ajax_dialog_custom_loader=function(a,d,e){e=e||false;this.show_loading(a);var b=this;var c=new XnAjax(function(f,g){b.show_dialog(g)});if(e){c.post(d,e)}else{c.get(d)}return this};generic_dialog.prototype.show_ajax_dialog=function(b,c){c=c||false;var a="载入中...";return this.show_ajax_dialog_custom_loader(a,b,c)};generic_dialog.prototype.show_prompt=function(b,a){return this.show_dialog("<h2><span>"+b+'</span></h2><div class="dialog_content">'+a+"</div>")};generic_dialog.prototype.show_message=function(c,b,a){if(a==null){a="Okay"
}return this.show_choice(c,b,a,function(){generic_dialog.get_dialog(this).fade_out(100)})};generic_dialog.prototype.show_choice=function(title,content,button1,button1js,button2,button2js,buttons_left_msg,button3,button3js){var buttons='<div class="dialog_buttons" id="dialog_buttons">';if(typeof(buttons_left_msg)!="undefined"){buttons+='<div class="dialog_buttons_left_msg">';buttons+=buttons_left_msg;buttons+="</div>"}buttons+='<input class="inputsubmit" type="button" value="'+button1+'" id="dialog_button1" />';if(button2){buttons+='<input class="inputsubmit" type="button" value="'+button2+'" id="dialog_button2" />'}if(button3){buttons+='<input class="inputsubmit" type="button" value="'+button3+'" id="dialog_button3" />'}this.show_prompt(title,this.content_to_markup(content)+buttons);var inputs=this.obj.getElementsByTagName("input");if(button3){button1obj=inputs[inputs.length-3];button2obj=inputs[inputs.length-2];button3obj=inputs[inputs.length-1]}else{if(button2){button1obj=inputs[inputs.length-2];
button2obj=inputs[inputs.length-1]}else{button1obj=inputs[inputs.length-1]}}if(button1js&&button1){if(typeof button1js=="string"){eval("button1js = function(){"+button1js+"}")}button1obj.onclick=button1js}if(button2js&&button2){if(typeof button2js=="string"){eval("button2js = function(){"+button2js+"}")}button2obj.onclick=button2js}if(button3js&&button3){if(typeof button3js=="string"){eval("button3js = function(){"+button3js+"}")}button3obj.onclick=button3js}if(!this.modal){document.onkeyup=function(e){var keycode=(e&&e.which)?e.which:event.keyCode;var btn2_exists=(typeof button2obj!="undefined");var btn3_exists=(typeof button3obj!="undefined");var is_webkit=ua.safari();if(is_webkit&&keycode==13){button1obj.click()}if(keycode==27){if(btn3_exists){button3obj.click()}else{if(btn2_exists){button2obj.click()}else{button1obj.click()}}}document.onkeyup=function(){}};button1obj.focus()}return this};generic_dialog.prototype.show_choice_ajax=function(h,a,f,c,e,g,b,d,i){this.show_loading("Loading...");
var j=function(k){this.show_choice(h,k.getPayload(),f,c,e,g,b,d,i)}.bind(this);new AsyncRequest().setURI(a).setHandler(j).send();return this};generic_dialog.prototype.show_form_ajax=function(g,a,d,b){this.show_loading("Loading...");var h="dialog_ajax_form__"+gen_unique();var f=function(l,k){if(k.getError()!=true){l.hide();ErrorDialog.showAsyncError(k)}else{l.show_choice(g,k.getPayload(),"Okay",function(){l.fade_out(200)})}}.bind(null,this);var j=function(l,k){var m='<form id="'+h+'" onsubmit="return false;">'+k.getPayload()+"</form>";l.show_choice(g,m,d,i,"Cancel",function(){l.fade_out(200)})}.bind(null,this);var i=function(){new AsyncRequest().setURI(a).setData(serialize_form(ge(h))).setHandler(e).setErrorHandler(c).send()};var e=function(l,k){l.show_choice(g,k.getPayload(),"Okay",function(){l.fade_out(200)});if(b){window.location.reload()}else{setTimeout(function(){l.fade_out(500)},750)}}.bind(null,this);var c=function(l,k){if(k.getError()==1346001){j(k)}else{if(k.getError()!=true){ErrorDialog.showAsyncError(k)
}else{f(k)}}}.bind(null,this);new AsyncRequest().setURI(a).setReadOnly(true).setHandler(j).setErrorHandler(f).send();return this};generic_dialog.prototype.show_form=function(e,b,a,d){b='<form action="'+d+'" method="post">'+this.content_to_markup(b);var c=ge("post_form_id");if(c){b+='<input type="hidden" name="post_form_id" value="'+c.value+'" />'}b+='<div class="dialog_buttons"><input class="inputsubmit" name="confirm" type="submit" value="'+a+'" />';b+='<input type="hidden" name="next" value="'+htmlspecialchars(document.location.href)+'"/>';b+='<input class="inputsubmit" type="button" value="Cancel" onclick="generic_dialog.get_dialog(this).fade_out(100)" /></form>';this.show_prompt(e,b);return this};generic_dialog.prototype.content_to_markup=function(a){return(typeof a=="string")?'<div class="dialog_body">'+a+"</div>":'<div class="dialog_summary">'+a.summary+'</div><div class="dialog_body">'+a.body+"</div>"};generic_dialog.prototype.hide=function(b){if(this.obj){this.obj.style.display="none"
}if(this.iframe){this.iframe.style.display="none"}if(this.overlay){this.overlay.style.display="none"}if(this.timeout){clearTimeout(this.timeout);this.timeout=null;return}if(this.hidden_objects.length){for(var d=0,c=this.hidden_objects.length;d<c;d++){this.hidden_objects[d].style.visibility=""}this.hidden_objects=[]}clearInterval(this.active_hiding);if(!b){if(generic_dialog.dialog_stack){var a=generic_dialog.dialog_stack;for(var d=a.length-1;d>=0;d--){if(a[d]==this){a.splice(d,1)}}if(a.length){a[a.length-1].show()}}if(this.obj){this.obj.parentNode.removeChild(this.obj);this.obj=null}}return this};generic_dialog.prototype.fade_out=function(a,b){if(!this.popup){return this}animation(this.obj).duration(b?b:0).checkpoint().to("opacity",0).hide().duration(a?a:350).ondone(this.hide.bind(this)).go();return this};generic_dialog.prototype.show=function(){if(this.obj&&this.obj.style.display){this.obj.style.visibility="hidden";this.obj.style.display="";this.reset_dialog();this.obj.style.visibility="";
this.obj.dialog=this}else{this.reset_dialog()}this.hide_objects();clearInterval(this.active_hiding);this.active_hiding=setInterval(this.active_resize.bind(this),500);var a=generic_dialog.dialog_stack?generic_dialog.dialog_stack:generic_dialog.dialog_stack=[];for(var b=a.length-1;b>=0;b--){if(a[b]==this){a.splice(b,1)}else{a[b].hide(true)}}a.push(this);return this};generic_dialog.prototype.enable_buttons=function(b){var a=this.obj.getElementsByTagName("input");for(var c=0;c<a.length;c++){if(a[c].type=="button"||a[c].type=="submit"){a[c].disabled=!b}}};generic_dialog.prototype.active_resize=function(){if(this.last_offset_height!=this.content.offsetHeight){this.hide_objects();this.last_offset_height=this.content.offsetHeight}};generic_dialog.prototype.hide_objects=function(){var f=[];var c=["",0,1,2,4,5,9,3];for(var b=0;b<c.length;b++){var h=ge("ad_"+c[b]);if(h!=null){f.push(h);this.should_hide_objects=true}}if(!this.should_hide_objects){return}var e={x:elementX(this.content),y:elementY(this.content),w:this.content.offsetWidth,h:this.content.offsetHeight};
var g=document.getElementsByTagName("iframe");for(var b=0;b<g.length;b++){if(g[b].className.indexOf("share_hide_on_dialog")!=-1){f.push(g[b])}}var a=document.getElementsByTagName("embed");for(var b=0;b<a.length;b++){f.push(a[b])}for(var b=0;b<f.length;b++){var d=f[b].offsetHeight?f[b]:f[b].parentNode;swf_rect={x:elementX(d),y:elementY(d),w:d.offsetWidth,h:d.offsetHeight};if(!is_descendent(f[b],this.content)&&e.y+e.h>swf_rect.y&&swf_rect.y+swf_rect.h>e.y&&e.x+e.w>swf_rect.x&&swf_rect.x+swf_rect.w>e.w&&array_indexOf(this.hidden_objects,d)==-1){this.hidden_objects.push(d);d.style.visibility="hidden";d.style.visibility="hidden"}}};generic_dialog.prototype.build_dialog=function(){if(!this.obj){this.obj=document.createElement("div")}this.obj.className="generic_dialog"+(this.className?" "+this.className:"");this.obj.style.display="none";onloadRegister(function(){document.body.appendChild(this.obj)}.bind(this));if(this.should_use_iframe||(this.modal&&ua.ie()==7)){this.build_iframe()}if(!this.popup){this.popup=document.createElement("div");
this.popup.className="generic_dialog_popup"}this.popup.style.left=this.popup.style.top="";this.obj.appendChild(this.popup);if(this.modal){this.build_overlay()}};generic_dialog.prototype.build_iframe=function(){if(!this.iframe&&!(this.iframe=ge("generic_dialog_iframe"))){this.iframe=document.createElement("iframe");this.iframe.id="generic_dialog_iframe"}this.iframe.frameBorder="0";onloadRegister(function(){document.body.appendChild(this.iframe)}.bind(this))};generic_dialog.prototype.build_overlay=function(){this.overlay=document.createElement("div");this.overlay.id="generic_dialog_overlay";if(document.body.clientHeight>document.documentElement.clientHeight){this.overlay.style.height=document.body.clientHeight+"px"}else{this.overlay.style.height=document.documentElement.clientHeight+"px"}onloadRegister(function(){document.body.appendChild(this.overlay)}.bind(this))};generic_dialog.prototype.reset_dialog=function(){if(!this.popup){return}onloadRegister(function(){this.reset_dialog_obj();this.reset_iframe()
}.bind(this))};generic_dialog.prototype.reset_iframe=function(){if(!this.should_use_iframe&&!(this.modal&&ua.ie()==7)){return}if(this.modal){this.iframe.style.left="0px";this.iframe.style.top="0px";this.iframe.style.width="100%";if((document.body.clientHeight>document.documentElement.clientHeight)&&(document.body.clientHeight<10000)){this.iframe.style.height=document.body.clientHeight+"px"}else{if((document.body.clientHeight<document.documentElement.clientHeight)&&(document.documentElement.clientHeight<10000)){this.iframe.style.height=document.documentElement.clientHeight+"px"}else{this.iframe.style.height="10000px"}}}else{this.iframe.style.left=elementX(this.frame)+"px";this.iframe.style.top=elementY(this.frame)+"px";this.iframe.style.width=this.frame.offsetWidth+"px";this.iframe.style.height=this.frame.offsetHeight+"px"}this.iframe.style.display=""};generic_dialog.prototype.reset_dialog_obj=function(){};generic_dialog.prototype.set_width=function(a){this.obj.style.width=a?a+"px":""};generic_dialog.get_dialog=function(a){while(!a.dialog&&a.parentNode){a=a.parentNode
}return a.dialog?a.dialog:false};function pop_dialog(a,c,b){this.top=125;this.parent.construct(this,a,b);this.on_show_callback=c}pop_dialog.extend(generic_dialog);pop_dialog.prototype.build_dialog=function(){this.parent.build_dialog();this.obj.className+=" pop_dialog";this.popup.innerHTML='<table id="pop_dialog_table" class="pop_dialog_table"><tr><td class="pop_topleft"></td><td class="pop_border"></td><td class="pop_topright"></td></tr><tr><td class="pop_border"></td><td class="pop_content" id="pop_content"></td><td class="pop_border"></td></tr><tr><td class="pop_bottomleft"></td><td class="pop_border"></td><td class="pop_bottomright"></td></tr></table>';this.frame=this.popup.getElementsByTagName("tbody")[0];this.content=this.popup.getElementsByTagName("td")[4]};pop_dialog.prototype.reset_dialog_obj=function(){this.popup.style.top=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)+this.top+"px"};pop_dialog.prototype.set_top=function(a){this.top=a
};function contextual_dialog(a){this.parent.construct(this,a)}contextual_dialog.extend(generic_dialog);contextual_dialog.prototype.set_context=function(a){this.context=a;return this};contextual_dialog.prototype.build_dialog=function(){this.parent.build_dialog();this.obj.className+=" contextual_dialog";this.popup.innerHTML='<div class="contextual_arrow"><span>^_^keke1</span></div><div class="contextual_dialog_content"></div>';this.arrow=this.popup.getElementsByTagName("div")[0];this.content=this.frame=this.popup.getElementsByTagName("div")[1]};contextual_dialog.prototype.reset_dialog_obj=function(){var b=elementX(this.context);var a=(document.body.offsetWidth-this.popup.offsetWidth)/2;if(b<document.body.offsetWidth/2){this.arrow.className="contextual_arrow_rev";var d=Math.min(a,b+this.context.offsetWidth-this.arrow_padding_x);var c=b-d+this.context.offsetWidth+this.arrow_padding_x}else{this.arrow.className="contextual_arrow";var d=Math.max(a,b-this.popup.offsetWidth+this.arrow_padding_x);
var c=b-d-this.arrow_padding_x-this.arrow_width}this.popup.style.top=(elementY(this.context)+this.context.offsetHeight-this.arrow.offsetHeight+this.arrow_padding_y)+"px";this.popup.style.left=d+"px";this.arrow.style.backgroundPosition=c+"px"};contextual_dialog.prototype._remove_resize_events=function(){if(this._scroll_events){for(var a=0;a<this._scroll_events.length;a++){removeEventBase(this._scroll_events[a].obj,this._scroll_events[a].event,this._scroll_events[a].func)}}this._scroll_events=[]};contextual_dialog.prototype.show=function(){this._remove_resize_events();var b=this.context;while(b){if(b.id!="content"&&(b.scrollHeight&&b.offsetHeight&&b.scrollHeight!=b.offsetHeight)||(b.scrollWidth&&b.offsetWidth&&b.scrollWidth!=b.offsetWidth)){var a={obj:b,event:"scroll",func:this.reset_dialog_obj.bind(this)};addEventBase(a.obj,a.event,a.func)}b=b.parentNode}var a={obj:window,event:"resize",func:this.reset_dialog_obj.bind(this)};addEventBase(a.obj,a.event,a.func);this.parent.show()};contextual_dialog.prototype.hide=function(){this._remove_resize_events();
this.parent.hide()};contextual_dialog.prototype.arrow_padding_x=5;contextual_dialog.prototype.arrow_padding_y=10;contextual_dialog.prototype.arrow_width=13;function ErrorDialog(){this.parent.construct(this,"errorDialog",null,true);return this}ErrorDialog.extend(pop_dialog);copy_properties(ErrorDialog.prototype,{showError:function(b,a){return this.show_message(b,a)}});copy_properties(ErrorDialog,{showAsyncError:function(a){try{return(new ErrorDialog()).showError(a.getErrorSummary(),a.getErrorDescription())}catch(b){aiert(a)}}});