if(MGCCbEvoNS.pm_tabs_on){dojo.require("dijit.layout.TabContainer");dojo.require("dijit.layout.ContentPane")}MGCCbEvoNS.pm_active_tab=0;MGCCbEvoNS.refreshPM_timeout=null;MGCCbEvoNS.pm_first_load=0;MGCCbEvoNS.already_refreshing_pms=0;MGCCbEvoNS.pm_userids_array=new Array();MGCCbEvoNS.pm_chatids_array=new Array();dojo.addOnLoad(function(){MGCCbEvoNS.onload_pm()});MGCCbEvoNS.onload_pm=function(){if(MGCCbEvoNS.pm_tabs_on){dojo.subscribe("tabs_mgc_cb_evo-selectChild",function(c){MGCCbEvoNS.pm_switch_tab(c.id)});var a=dijit.byId("tabs_mgc_cb_evo");var b=new dijit.layout.ContentPane({title:"",id:"tab_mgc_cb_evo_0",closable:true,content:""});a.addChild(b);a.selectChild(b);a.selectChild(dijit.byId("tab_mgc_cb_evo"));a.removeChild(b)}};MGCCbEvoNS.pm_switch_tab=function(a){this.force_scrolling=1;if(a=="tab_mgc_cb_evo"){clearTimeout(this.refreshPM_timeout);this.pm_active_tab=0;this.chatbox_refresh("forced")}else{clearTimeout(this.refreshPM_timeout);MGCCbEvoNS.pm_active_tab=a.split("tab_mgc_cb_evo_")[1];MGCCbEvoNS.chatbox_pm_refresh()}};MGCCbEvoNS.open_pm_tab=function(g,b){if(dojo.byId("tab_mgc_cb_evo_"+g)){var c=dijit.byId("tabs_mgc_cb_evo");var d=dijit.byId("tab_mgc_cb_evo_"+g);c.selectChild(d)}else{if(this.pm_maxtab){var a=dojo.query('div[id^="tab_mgc_cb_evo_"]').length;if(a>=this.pm_maxtab){this.show_dialog(phrase_pm_maxtabs_reached,"");return false}}clearTimeout(this.refresh_timeout);clearTimeout(this.refreshPM_timeout);this.pm_active_tab=g;this.pm_chatids_array[this.pm_active_tab]=0;this.pm_first_load=1;var c=dijit.byId("tabs_mgc_cb_evo");var e='			<div style="width:100%; height: '+this.height+'px;overflow-y: auto;border: none; z-index: 1;float: left;" id="pm_container_'+g+'"> 				<table width="95%" align="'+this.left+'" cellspacing="0"> 					<tbody id="pm_chats_'+g+'"> 					</tbody> 				</table> 			</div>';var f=new dijit.layout.ContentPane({title:b,id:"tab_mgc_cb_evo_"+g,closable:true,content:e});c.addChild(f);c.selectChild(f)}return false};MGCCbEvoNS.chatbox_pm_refresh=function(){var a=dojo.query('div[id^="tab_mgc_cb_evo_"]').length;if(!this.already_sending&&!this.already_refreshing_pms&&(a>1)){this.already_refreshing_pms=1;dojo.style("mgc_cb_evo_refresh_img","visibility","visible");dojo.xhrPost({url:this.jsloc+"mgc_cb_evo_ajax.php",handleAs:"xml",preventCache:true,content:{securitytoken:SECURITYTOKEN,action:"ajax_get_pms",lastchatid:this.pm_chatids_array[this.pm_active_tab],tabuserid:this.pm_active_tab},error:function(b){console.error("Error: ",b)},load:dojo.hitch(this,"wait_chatbox_pm_refresh")})}};MGCCbEvoNS.wait_chatbox_pm_refresh=function(e){if(e){var a=e.getElementsByTagName("chat");var h=0;var g=0;if(a.length){var f=dojo.byId("pm_chats_"+this.pm_active_tab);if(f.hasChildNodes()){var j=f.firstChild}for(i=0;i<a.length;i++){var b=this.create_pm_chatrow(a[i]);var d=a[i].getElementsByTagName("edited")[0].firstChild.nodeValue;if(h==0){h=1;var c=a[i].getElementsByTagName("chatid")[0].firstChild.nodeValue;this.pm_chatids_array[this.pm_active_tab]=c}if(d==1){f.replaceChild(b,dojo.byId("pm_chatrow_"+c))}else{if(this.chats_order==0){if(this.pm_first_load||!f.hasChildNodes()){f.appendChild(b)}else{f.insertBefore(b,j)}}else{if(this.pm_first_load==1){if(f.hasChildNodes()){f.insertBefore(b,f.firstChild)}else{f.appendChild(b)}}else{if(f.hasChildNodes()){f.insertBefore(b,f.lastChild)}else{f.appendChild(b)}}}}}if(this.chats_order){dojo.byId("pm_container_"+this.pm_active_tab).scrollTop=dojo.byId("pm_chats_"+this.pm_active_tab).offsetHeight}}else{if((this.force_scrolling)&&(this.pm_active_tab!=null)){dojo.byId("pm_container_"+this.pm_active_tab).scrollTop=dojo.byId("pm_chats_"+this.pm_active_tab).offsetHeight}}dojo.style("mgc_cb_evo_refresh_img","visibility","hidden");if(this.alt_chat_colors){this.update_row_color_alt_pm("pm_chats_"+this.pm_active_tab)}if(this.sound&&g&&!this.pm_first_load){dojo.byId("mgc_cb_evo_sound_span").innerHTML='<embed src="mgc_cb_evo/clientscript/sound/new_chat.swf" hidden="true" autostart="true" loop="false">'}this.pm_first_load=0;this.force_scrolling=0;this.already_refreshing_pms=0;if(this.autorefresh_on){this.refreshPM_timeout=setTimeout("MGCCbEvoNS.chatbox_pm_refresh()",this.pm_refresh_delay)}}};MGCCbEvoNS.create_pm_chatrow=function(c){var a=c.getElementsByTagName("chatid")[0].firstChild.nodeValue;var b=document.createElement("tr");b.setAttribute("id","pm_chatrow_"+a);if(this.avatar_on){dojo.create("td",{width:"0",valign:this.chat_valign,innerHTML:c.getElementsByTagName("col_avatar")[0].firstChild.nodeValue},b)}if(this.align_chats){dojo.create("td",{width:"0",align:this.left,valign:this.chat_valign,noWrap:"nowrap",innerHTML:c.getElementsByTagName("col_date")[0].firstChild.nodeValue},b);dojo.create("td",{width:"0",align:this.left,valign:this.chat_valign,noWrap:"nowrap",innerHTML:c.getElementsByTagName("col_uname")[0].firstChild.nodeValue},b);dojo.create("td",{width:"100%",align:this.left,valign:this.chat_valign,innerHTML:c.getElementsByTagName("col_chat")[0].firstChild.nodeValue},b)}else{dojo.create("td",{width:"0",align:this.left,valign:this.chat_valign,noWrap:"nowrap",style:{whiteSpace:"nowrap"},innerHTML:c.getElementsByTagName("col_date")[0].firstChild.nodeValue},b);dojo.create("td",{width:"100%",align:this.left,valign:this.chat_valign,innerHTML:c.getElementsByTagName("col_uname")[0].firstChild.nodeValue+c.getElementsByTagName("col_chat")[0].firstChild.nodeValue},b)}return b};MGCCbEvoNS.update_row_color_alt_pm=function(a){var d=dojo.byId(a);if(d.hasChildNodes()){var b="alt2";var e=d.childNodes;for(var c=0;c<e.length;c++){e[c].className=b;if(b=="alt2"){b="alt1"}else{b="alt2"}}}};
