function PopupWindow(D){if(typeof (PopupWindow._initialized)=="undefined"){PopupWindow.currentLayer=1;PopupWindow.prototype._init=function(B){for(var A in B){this[A]=B[A]}if(!this.windowId){this.windowId="Iori"}if(!this.container){this.container=document.body}if(!this.mode){this.mode=0}if(this.mode==2&&(typeof (this.paramString)=="undefined")){this.paramString=""}if(!this.area){this.area=0}if(typeof (this.windowCSS)=="undefined"){this.windowCSS=(this.area==0?"w_278 p_alert":"sys_tip w340")}if(typeof (this.barCSS)=="undefined"){this.barCSS=(this.area==0?"alpha30black3":"tr")}if(typeof (this.showCarpet)=="undefined"){this.showCarpet=true}if(!this.showPosition){this.showPosition=0}if(!this.width){this.width=0}if(!this.height){this.height=0}if(typeof (this.top)=="undefined"){this.top=-1}if(typeof (this.left)=="undefined"){this.left=-1}if(typeof (this.mobile)=="undefined"){this.mobile=true}if(this.mode==3){this.showPosition=0;if(typeof (this.zIndex)=="undefined"){this.zIndex=10}if(typeof (this.boxType)=="undefined"){this.boxType=1}if(typeof (this.okText)=="undefined"){this.okText="确定"}if((this.boxType==2)&&(typeof (this.cancelText)=="undefined")){this.cancelText="取消"}}if(!this.windowColor){this.windowColor=""}if(typeof (this.autogeny)=="undefined"){this.autogeny=true}if(typeof (this.suicide)=="undefined"){this.suicide=true}this.timeoutId=null;this.alive=false};PopupWindow.prototype._render=function(){if(this.showCarpet){if(typeof (PopupWindow["carpet"+PopupWindow.currentLayer.toString()])=="undefined"){this.carpet=new Carpet({carpetId:this.windowId+"-Carpet",zIndex:(this.zIndex-1)||0,autogeny:this.autogeny,suicide:false});PopupWindow["carpet"+PopupWindow.currentLayer.toString()]=this.carpet}else{this.carpet=PopupWindow["carpet"+PopupWindow.currentLayer.toString()];this.carpet.setZindex(this.zIndex-1)}}this._createWindow();if(this.mode>0){if(this.mode==4){this.setWholeContent(this.contentString)}else{this._createBar();this._createContent()}}this.alive=true};PopupWindow.prototype.setWholeContent=function(A){this.window.innerHTML=A};PopupWindow.prototype._createWindow=function(){if(this.mode==0){if(!this.mainDiv){throw new Error('Mode0 must have a "mainDiv" argument !')}else{if(this.mainDiv.parentNode){this.mainDiv.parentNode.removeChild(this.mainDiv)}this.window=this.mainDiv}}else{this.window=document.createElement("DIV")}this.window.id=this.windowId;if(typeof (this.zIndex)!="undefined"){this.window.style.position="absolute";this.window.style.zIndex=this.zIndex}if(this.width>0){this.window.style.width=this.width+"px"}if(this.height>0){this.window.style.height=this.height+"px"}if(this.area==0){}else{if(this.windowColor.length>0){this.window.style.background=this.windowColor}}this.window.className=this.windowCSS;if(this.area==0){if(!this.onlySelfCss){this.window.className+=" popupwindow"}}else{if(!this.onlySelfCss){this.window.className+=" popupwindow2"}}this.window.style.display="none";this.container.appendChild(this.window);this.window.hide=function(){C.hide()}};PopupWindow.prototype._createBar=function(){this.bar=document.createElement("DIV");this.bar.id=this.windowId+"-Bar";this.bar.className=this.barCSS;if(this.mobile){this.bar.style.cursor="move";this._onDraggingHandler=this._onDragging.bindAsEventListener(this);this._onDragEndHandler=this._onDragEnd.bindAsEventListener(this);Event.observe(this.bar,"mousedown",this._onDragStart.bindAsEventListener(this))}this.closeIMG=document.createElement("IMG");this.closeIMG.src="/images/close.gif";this.closeIMG.alt="关闭";this.closeIMG.title="关闭";Event.observe(this.closeIMG,"click",this.hide.bindAsEventListener(this));var A=document.createElement("A");A.appendChild(this.closeIMG);this.bar.appendChild(A);this.window.appendChild(this.bar)};PopupWindow.prototype._onDragStart=function(A){this.lastMouseX=A.clientX;this.lastMouseY=A.clientY;Event.observe(document.body,"mousemove",this._onDraggingHandler);Event.observe(document.body,"mouseup",this._onDragEndHandler);return false};PopupWindow.prototype._onDragging=function(A){this.window.style.left=(parseInt(this.window.style.left)+A.clientX-this.lastMouseX)+"px";this.window.style.top=(parseInt(this.window.style.top)+A.clientY-this.lastMouseY)+"px";this.lastMouseX=A.clientX;this.lastMouseY=A.clientY;return false};PopupWindow.prototype._onDragEnd=function(){Event.stopObserving(document.body,"mousemove",this._onDraggingHandler);Event.stopObserving(document.body,"mouseup",this._onDragEndHandler)};PopupWindow.prototype._createContent=function(){switch(this.mode){case 1:if(!this.paramDiv){throw new Error('Mode1 must have a "paramDiv" argument !')}else{if(this.paramDiv.parentNode){this.paramDiv.parentNode.removeChild(this.paramDiv)}this.content=this.paramDiv}break;case 2:if(typeof (this.paramString)=="undefined"){throw new Error('Mode2 must have a "paramString" argument !')}else{this.content=document.createElement("DIV");this.content.id=this.windowId+"-Content";this.content.innerHTML=this.paramString}break;case 3:if(typeof (this.tipString)=="undefined"){throw new Error('Mode3 must have a "tipString" argument !')}else{this.content=document.createElement("DIV");this.content.id=this.windowId+"-Content";var B=document.createElement("P");B.id=this.windowId+"-Tip";this.tip=B;B.className="bold";B.innerHTML=this.tipString;this.content.appendChild(B);if(typeof (this.descriptionString)!="undefined"){B=document.createElement("DIV");B.id=this.windowId+"-Description";this.description=B;B.innerHTML=this.descriptionString;this.content.appendChild(B)}if(this.area==0){if(this.boxType>0){B=document.createElement("P");this.okButton=document.createElement("input");this.okButton.id=this.windowId+"-OK";this.okButton.type="button";this.okButton.className="btn08";this.okButton.value="确 定";Event.observe(this.okButton,"click",this.hide.bindAsEventListener(this));B.appendChild(this.okButton);if(this.boxType==2){this.cancelButton=document.createElement("input");this.cancelButton.id=this.windowId+"-Cancel";this.cancelButton.type="button";this.cancelButton.className="btn09";this.cancelButton.value="取 消";this.cancelButton.onmouseover=function(){this.className="btn08"};this.cancelButton.onmouseout=function(){this.className="btn09"};Event.observe(this.cancelButton,"click",this.hide.bindAsEventListener(this));B.appendChild(this.cancelButton)}this.content.appendChild(B)}var F=document.createElement("DIV");F.className="clear";this.content.appendChild(F)}else{if(this.boxType>0){var A=document.createElement("DIV");A.className="mt20";this.okButton=document.createElement("INPUT");this.okButton.id=this.windowId+"-OK";this.okButton.type="button";this.okButton.value=this.okText;this.okButton.className="btn03";A.appendChild(this.okButton);if(this.okLink){this.okButton.onclick=function(E){window.location.href=E}.bind(this,this.okLink)}else{Event.observe(this.okButton,"click",this.hide.bindAsEventListener(this))}if(this.boxType==2){this.cancelButton=document.createElement("INPUT");this.cancelButton.id=this.windowId+"-Cancel";this.cancelButton.type="button";this.cancelButton.value=this.cancelText;this.cancelButton.className="btn02";this.cancelButton.onmouseover=function(){this.className="btn03"};this.cancelButton.onmouseout=function(){this.className="btn02"};if(this.cancelLink){this.cancelButton.onclick=function(E){window.location.href=E}.bind(this,this.cancelLink)}else{Event.observe(this.cancelButton,"click",this.hide.bindAsEventListener(this))}A.appendChild(this.cancelButton)}this.content.appendChild(A)}}}break}this.window.appendChild(this.content)};PopupWindow.prototype.show=function(){if(this.showCarpet){this.carpet.show();PopupWindow.currentLayer++}this.window.style.display="block";switch(this.showPosition){case 0:Event.observe(window,"resize",this._onWindowResizeHandler);this.setCenter();break;case 1:var A=this.evtCaller?this.evtCaller:GetEvent();this.window.style.left=A.clientX+"px";this.window.style.top=A.clientY+"px";break;case 2:if(this.left>-1){this.window.style.left=this.left+"px"}if(this.top>-1){this.window.style.top=this.top+"px"}break}Event.observe(document.body,"keydown",this._onBodyKeyDownHandler);this.window.focus()};PopupWindow.prototype.hide=function(){if(this.beforeCloseCallback){this.beforeCloseCallback()}Event.stopObserving(document.body,"keydown",this._onBodyKeyDownHandler);if(this.showCarpet){this.carpet.hide();PopupWindow.currentLayer--}if(this.showPosition==0){Event.stopObserving(window,"resize",this._onWindowResizeHandler)}this.window.style.display="none";if(this.suicide){this.container.removeChild(this.window);this.alive=false}if(typeof (this.iframe)!="undefined"){this.iframe.style.display="none"}};PopupWindow.prototype.setCenter=function(){var H;var G;var A;var B;if(window.innerHeight){H=window.innerWidth;G=window.pageXOffset;A=window.innerHeight;B=window.pageYOffset}else{H=document.documentElement.offsetWidth;G=document.documentElement.scrollLeft;A=document.documentElement.offsetHeight;B=document.documentElement.scrollTop}this.window.style.left=(G+(H-this.window.offsetWidth)/2)+"px";this.window.style.top=(B+(A-this.window.offsetHeight)/2)+"px"};PopupWindow.prototype._onKeyDown=function(A){if(A.keyCode==27){this.hide()}};PopupWindow.prototype.appendHandler=function(B,A){if(this.mode==3&&this.boxType>0){if(B=="ok"){Event.observe(this.okButton,"click",A)}if(B=="cancel"&&this.boxType==2){Event.observe(this.cancelButton,"click",A)}}};PopupWindow.prototype.removeHandler=function(B,A){if(this.mode==3&&this.boxType>0){if(B=="ok"){Event.stopObserving(this.okButton,"click",A)}if(B=="cancel"&&this.boxType==2){Event.stopObserving(this.cancelButton,"click",A)}}};PopupWindow.prototype.setTip=function(A){if(this.mode==3){this.tip.innerHTML=A}};PopupWindow.prototype.setDescription=function(A){if(this.mode==3){this.description.innerHTML=A}};PopupWindow.prototype.setContent=function(A){if(this.mode>0){this.content.innerHTML=A}};PopupWindow.prototype.setWindow=function(A){this.window.innerHTML=A};PopupWindow.prototype.setTimeoutHide=function(A){clearTimeout(this.timeoutId);this.timeoutId=setTimeout(this.hide.bind(this),A)};PopupWindow.prototype.appendCloseIMGHandler=function(A){Event.observe(this.closeIMG,"click",A)};PopupWindow._initialized=true}this._onWindowResizeHandler=this.setCenter.bindAsEventListener(this);this._onBodyKeyDownHandler=this._onKeyDown.bindAsEventListener(this);this._init(D);this._render();if(this.autogeny){this.show()}var C=this;if(this.autogeny){this.window.focus()}}function Carpet(B){if(typeof (Carpet._initialized)=="undefined"){Carpet.prototype._init=function(D){for(var A in D){this[A]=D[A]}if(typeof (this.autogeny)=="undefined"){this.autogeny=true}if(typeof (this.suicide)=="undefined"){this.suicide=true}};Carpet.prototype._render=function(){this.carpet=document.createElement("DIV");this.carpet.id=this.carpetId;var A=this.carpet.style;A.zIndex=this.zIndex;A.position="absolute";A.margin="0px";A.padding="0px";A.top=(this.top||0)+"px";A.left=(this.left||0)+"px";A.width=(this.width||((document.body.clientWidth&&(document.body.clientWidth>screen.width))?document.body.clientWidth:screen.width))+"px";A.height=(this.height||((document.body.clientHeight&&(document.body.clientHeight>screen.height))?document.body.clientHeight:screen.height))+"px";A.background="#FFFFFF";A.filter="alpha(opacity=80)";A.opacity=0.8;A.zoom=1;A.display="none";document.body.appendChild(this.carpet)};Carpet.prototype.getCarpet=function(){return this.carpet};Carpet.prototype.show=function(){var G=document.getElementsByTagName("SELECT");var A;for(var H=0;H<G.length;H++){A=G[H].ispop||G[H].getAttribute("ispop");if(!A){G[H].style.visibility="hidden"}}var F=$$("embed");F.each(function(C){C.hide()});this.carpet.style.display="block"};Carpet.prototype.hide=function(){var G=document.getElementsByTagName("SELECT");var A;for(var H=0;H<G.length;H++){A=G[H].ispop||G[H].getAttribute("ispop");if(!A){G[H].style.visibility="visible"}}var F=$$("embed");F.each(function(C){C.show()});this.carpet.style.display="none";if(this.suicide){document.body.removeChild(this.carpet)}};Carpet.prototype.setZindex=function(A){this.carpet.style.zIndex=A};Carpet._initialized=true}this._init(B);this._render()}var errorMessageBoxDisplayArea=null;function setErrorMessage(B){if(errorMessageBoxDisplayArea==null){createBoxOnLoad()}errorMessageBoxDisplayArea.setWindow('<a href="#" title="关闭"><img src="/images/close_g.gif" alt="关闭" onclick="javascript:errorMessageBoxDisplayArea.hide();" /></a><span class="bold">'+B+"</span>");errorMessageBoxDisplayArea.show();errorMessageBoxDisplayArea.setTimeoutHide(5000)}function createBoxOnLoad(){var B=document.createElement("DIV");B.style.width=390+"px";B.innerHTML='<a href="#" title="关闭"><img src="/images/close_g.gif" alt="关闭" onclick="javascript:errorMessageBoxDisplayArea.hide();" /></a><span class="bold"></span>';errorMessageBoxDisplayArea=new PopupWindow({windowId:"errorWindow",container:document.getElementById("errorContainer"),mainDiv:B,showCarpet:false,windowColor:"",windowCSS:"greenbox ml40",autogeny:false,suicide:false,area:1,showPosition:3})}function GetEvent(){if(window.event||document.all){return window.event}var C=GetEvent.caller;while(C!=null){var D=C.arguments[0];if(D){if(D.constructor==Event||D.constructor==MouseEvent){return D}}C=C.caller}return null}function $dialog(F,H,G,E){(function(){var A=new PopupWindow({windowId:"dialog",mode:3,area:1,windowCSS:"sys_tip w340",barCSS:"tr",boxType:2,tipString:F,descriptionString:H});if(G){A.appendHandler("ok",G)}if(E){A.appendHandler("cancle",E)}})()}function $alert(F,D,E){(function(){var A=new PopupWindow({windowId:"alert",mode:3,area:1,windowCSS:"sys_tip w340",barCSS:"tr",tipString:F,descriptionString:"<p>"+D+"</p>",boxType:1});if(!Mtime.isEmpty(E)){A.appendHandler("ok",E);A.appendCloseIMGHandler(E)}})()}var _vote_Result={Vote:function(D,E,F){return Mtime.Component.Ajax.callBack("Mtime.Community.Controls.CommunityPages.VoteResult","Vote",[D,E],F,"/vote/VoteResult.m?Ajax_CallBack=true","post","10000")}};var _vote_checkboxCounter;function _vote_submit(D,E){_vote_init(E);for(key in _vote_checkboxCounter){if(_vote_checkboxCounter[key]==0){var F=new PopupWindow({windowId:"msgBox",mode:3,area:1,tipString:"",descriptionString:'<p class="bold">有未投票的题目</p>',boxType:1});return false}}_vote_Result.Vote(D,Form.serialize(E),_vote_callback);return false}function _vote_callback(E){var D=window.location.href;switch(E.value[1]){case"vote":var F=new PopupWindow({windowId:"msgBox",mode:3,area:1,tipString:"",okText:"查看结果",descriptionString:'<p class="bold">'+E.value[2]+"</p>",boxType:2});F.appendHandler("ok",function(){location.href="/vote/"+E.value[0]+".html"});break;case"userinfo":var F=new PopupWindow({windowId:"msgBox",mode:3,area:1,tipString:"",descriptionString:'<p class="bold">'+E.value[2]+"</p>",boxType:1});F.appendHandler("ok",function(){location.href="/vote/"+E.value[0]+"/userinfo.html?returnURL="+D});break;default:var F=new PopupWindow({windowId:"msgBox",mode:3,area:1,tipString:"",descriptionString:'<p class="bold">'+E.value[2]+"</p>",boxType:1});break}}function _vote_check(G,F,H){_vote_init(G.form);_vote_checkboxCounter["T"+F]+=G.checked?1:-1;if(H==-1){return }if(_vote_checkboxCounter["T"+F]==H){var E=document.getElementsByName(G.name);for(i=0;i<E.length;i++){if(!E[i].checked){E[i].disabled=true}}}else{if(_vote_checkboxCounter["T"+F]==H-1){var E=document.getElementsByName(G.name);for(i=0;i<E.length;i++){E[i].disabled=false}}}}function _vote_init(D){if(_vote_checkboxCounter==undefined){_vote_checkboxCounter=new Object();var C=D.getElementsByTagName("input");for(i=0;i<C.length;i++){if(C[i].type=="checkbox"||C[i].type=="radio"){_vote_checkboxCounter["T"+C[i].name.substr(3)]=0}}}};