var ajax_win=true;var ajax_showid=false;var ajax_hideMath;var ajax_focus=false;function InitAjax(){    var http_request;    if(window.XMLHttpRequest){        http_request=new XMLHttpRequest();          if(http_request.overrideMimeType){            http_request.overrideMimeType("text/xml");        }     }else if(window.ActiveXObject){        try{            http_request=new ActiveXObject("Msxml2.XMLHttp");        }catch(e){            try{                http_request=new ActiveXobject("Microsoft.XMLHttp");            }catch(e){}        }    }else{	         return false;    }    return http_request;}function show_ajaxMenu(showid,type) {    ajax_hideMath=Math.round(Math.random()*100000);    wysiwyg=0;    var showobj = $(showid);		    var ctrlobj = $(showid);    var menuobj = $(showid + '_menu');    var menuobjTop;    $('append_parent2').style.display = '';	    if(type==2){        $('ajax_loading').style.display = 'none';        $('ajax_con').style.display = '';    }else{        $('ajax_loading').style.display = '';        $('ajax_con').style.display = 'none';	    }	    menuobj.style.position = 'absolute';    menuobj.style.zIndex = 99;    menuobj.style.display = '';    var offset = 1;    showobj.pos = fetchOffset(showobj);    showobj.X = showobj.pos['left'];    showobj.Y = showobj.pos['top'];    showobj.w = showobj.offsetWidth;    showobj.h = showobj.offsetHeight;    menuobj.w = menuobj.offsetWidth;    menuobj.h = menuobj.offsetHeight;				    if (document.documentElement && document.documentElement.scrollTop) {        var t = document.documentElement.scrollTop;    } else if(document.body) {        var t = document.body.scrollTop;    }    if (document.documentElement && document.documentElement.clientHeight) {        var hj = document.documentElement.clientHeight;    } else if(document.body) {        var hj = document.body.clientHeight;    }    var pj=t +  hj - showobj.Y - showobj.h - menuobj.h;    if(pj>0){	        menuobjTop =  (showobj.Y + showobj.h);    }else if(showobj.Y-t-20-menuobj.h>0){        menuobjTop =showobj.Y-menuobj.h;    }else menuobjTop =t + 20;    menuobj.style.top=menuobjTop + 'px';    menuobj.style.left = (showobj.X + menuobj.w > document.body.clientWidth) && (showobj.X + showobj.w - menuobj.w >= 0) ? showobj.X + showobj.w - menuobj.w + 'px' : showobj.X + 'px';    if(menuobj.style.clip && !is_opera) {        menuobj.style.clip = 'rect(auto, auto, auto, auto)';    }    if(type==3){        setTimeout("hideajaxMenu('"+showid+"',true,'"+ajax_hideMath+"')", 5000);	    }    if(ajax_focus!=false) {        $(ajax_focus).focus();        ajax_focus=false;    }}function ajax_quote(tid,author,kma,showid){    if(ajax_win==false) return;    ajax_win=false;    if(!$(showid) || !showid){        showid=ajax_showid==false?'ajax_help':ajax_showid;	    }    ajax_showid=showid;    var showobj=$(showid);    var innet_close='<div class="ajax_close" id="ajax_close"><a href="javascript:void(0)" onclick="hideajaxMenu(\''+showid+'\');">[关闭]</a></div>';    var innet_load='<div class="ajax_loading" id="ajax_loading"><span id="ajax_loadingimg"></span>正在读取...</div>';    var innet_html='<div class="ajax-body"><h3>引用</h3><form method="post" action="post.php?type=newreply&id='+tid+'" enctype="multipart/form-data">引用1:<br /><textarea name="quote[]" style="width:60px; height:40px;word-break: break-all;"></textarea><br />引用2:<br /><textarea name="quote[]" style="width:60px; height:40px;word-break: break-all;"></textarea><br />引用3:<br /><textarea name="quote[]" style="width:60px; height:40px;word-break: break-all;"></textarea><br />引用4:<br /><textarea name="quote[]" style="width:60px; height:40px;word-break: break-all;"></textarea><br /><input class="button" type="button" name="topicsubmit" id="postsubmit" onClick="ajax_send(\'author='+author+'&kma='+kma+'\',\''+showid+'\',this.form)" value="提 交" /></form> <div class="clear-both"></div></div>';	    if(!$(showid+'_menu')) $('append_parent2').innerHTML='<div class="ajax_Tips" id="'+showid+'_menu">'+innet_close+innet_load+'<div class="ajax_con" id="ajax_con">'+innet_html+'</div></div>';	    textobj = $(editorid + '_textarea');    ajax_win=true;    show_ajaxMenu(showid,2);	}function cache_send(url,showid){    var showobj=$(showid);    var http_request = InitAjax();    if(http_request===false) return;    http_request.onreadystatechange=function(){        if(http_request.readyState==4 && http_request.status==200){               showobj.innerHTML=http_request.responseText;        }    }    var rexp = /\?/;    url+=(rexp.test(url)?'&':'?') + 'ajaxsid='+sid;    http_request.open('GET',url,true);    http_request.send(null);}function ajax_reply(tid,showid){    if(ajax_win==false) return;    ajax_win=false;    if(!$(showid) || !showid){        showid=ajax_showid==false?'ajax_help':ajax_showid;	    }    ajax_showid=showid;    var showobj=$(showid);    var emid= new Array();    var userem='';    if(userems!=''){          emid=userems.split("|");    }else{        for (i=0;i<smilies && i<10;i++ ) emid.push(i+1);    }    for (i=0;i<emid.length && i<10;i++ )        {              userem+=' <img src="'+emotedir+'/em'+emid[i]+'.gif" id="smilie_'+emid[i]+'" border="0" onclick="insertSmiley('+emid[i]+')" onmouseover="this.style.cursor = is_ie ? \'hand\' : \'pointer\'"/>';        }     var innet_close='<div class="ajax_close" id="ajax_close"><a href="javascript:void(0)" onclick="hideajaxMenu(\''+showid+'\');">[关闭]</a></div>';    var innet_load='<div class="ajax_loading" id="ajax_loading"></span>正在读取...</div>';    var innet_html='<div class="ajax-body">  <h3>快速回复</h3>  <div class="xbb-tab ajax-4"> <form name="postquick" method="post" id="postform" action="savepost.php" enctype="multipart/form-data">  <div class="xbb-list first-child"> <div class="xbb-list-l"><div style=""><input value="1" id="parseurloff" name="parseurloff" type="checkbox">禁用[url]</div><div style=""><input value="1" id="smileyoff" name="smileyoff" type="checkbox">禁用[em]</div><div style=""><input value="1" name="bbcodeoff" type="checkbox">禁用UBB</div><div style=""><input value="1" name="signoff" type="checkbox">屏蔽签名</div></div> <div class="xbb-list-r"><div class="editor_text">  <textarea name="message" style="width:98%; height:100px;word-break: break-all;" id="posteditor_textarea"  onKeyDown="if((event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83)) ajax_send(\'\',\''+showid+'\',this.form);"></textarea></div><input type="hidden" value="'+tid+'" name="id" /><input type="hidden" value="newreply" name="type" /><input type="hidden" value="'+randomChar(5)+'" name="sign" /><table width="100%" cellpadding="4" cellspacing="0">  <tr> <td><div>  <input type="button" class="lightbutton" value="-" onClick="resizeEditor(-100,1)" />  <input type="button" class="lightbutton" value="+" onClick="resizeEditor(100,1)" /></div></td> <td align="right">[alt+s][ctrl+回车]<input name="button" type="button" class="lightbutton"  onclick="clearcontent()" value="清 空" /><input class="button" type="button" name="topicsubmit" id="postsubmit" onClick="ajax_send(\'\',\''+showid+'\',this.form)" value="提 交" /></td>  </tr></table> </div> <div class="clear-both"></div>  </div>  <div class="xbb-list"> <div class="xbb-list-l">心情图标<input name="button" type="button" onclick="QuickReplyImg()" value="刷" />:</div> <div class="xbb-list-r" id="QRemimg">'+userem+' </div> <div class="clear-both"></div>  </div></form>  </div>  <div class="clear-both"></div></div>';	    if(!$(showid+'_menu')) $('append_parent2').innerHTML='<div class="ajax_Tips" id="'+showid+'_menu">'+innet_close+innet_load+'<div class="ajax_con" id="ajax_con">'+innet_html+'</div></div>';	    textobj = $(editorid + '_textarea');    ajax_win=true;    ajax_focus='posteditor_textarea';    show_ajaxMenu(showid,2);}function QuickReplyImg(){    var html=$('QRemimg').innerHTML;    $('QRemimg').innerHTML='';    $('QRemimg').innerHTML=html;}function ajax_send(url,showid,form){    var query_string=null;    var method=form?'post':'get';    var autoclose=false;    if(ajax_win==false) return;    ajax_win=false;    if(!$(showid) || !showid){        showid=ajax_showid==false?'ajax_help':ajax_showid;	    }    ajax_showid=showid;    var showobj=$(showid);    var innet_close='<div class="ajax_close" id="ajax_close"><a href="javascript:void(0)" onclick="hideajaxMenu(\''+showid+'\');">[关闭]</a></div>';    var innet_load='<div class="ajax_loading" id="ajax_loading">正在读取...</div>';    var innet_con='<div class="ajax_con" id="ajax_con"></div>';    if(!$(showid+'_menu')) $('append_parent2').innerHTML='<div class="ajax_Tips" id="'+showid+'_menu">'+innet_close+innet_load+innet_con+'</div>';	    var http_request = InitAjax();    if(http_request===false) return;    show_ajaxMenu(showid,1);    if (method=='post')    {        if(url!='') {            var rexp = /\?/;	            url=form.action+(rexp.test(form.action)?'&':'?') + url;	        }else            url=form.action;        query_string=formToRequestString(form);	     }    http_request.onreadystatechange=function(){        if(http_request.readyState==4 && http_request.status==200){	               var str='';            var regExp=/<script[^>]*>(.+?)<\/script>/ig;            while ((regExp.exec(http_request.responseText))){		                   str+=RegExp.$1;            } 	               var ex = new RegExp("autoclose=true");             autoclose=ex.test(str)?true:false;	               $(autoclose==true?'ajax_loading':'ajax_con').innerHTML=http_request.responseText;            eval(str);            ajax_win=true;            show_ajaxMenu(showid,autoclose==true?3:2);        }    }    var rexp = /\?/;    url+=(rexp.test(url)?'&':'?') + 'ajaxsid='+sid;    http_request.open(method,url,true);    if (method=="post") http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    http_request.send(query_string);}function hideajaxMenu(showid,kix,hideMath) {    if(!$(showid)) return;    if(kix){        if(hideMath!=ajax_hideMath) return;        if(ajax_win==false) return;    }    $('append_parent2').innerHTML='';	    $('append_parent2').style.display = 'none';	    ajax_win=true;		}function formToRequestString(form) {    var elements = form.elements;    var element;    var i;    var query_string = "";			    for(i=0;i<elements.length;++i) {        var element=elements[i];				        if(element.type=="text" || element.type=="textarea" || element.type=="hidden") {            query_string += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";        }        else if(element.type=="select-one"||element.type=="select-multiple") {            var options=element.options,j,item;            for(j=0;j<options.length;++j){                item=options[j];                if(item.selected) {                    query_string += encodeURIComponent(element.name) + "=" + encodeURIComponent(item.value) + "&";                }            }        } else if(element.type=="checkbox"||element.type=="radio") {            if(element.checked) {                query_string += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";            }        } else if(element.type=="file") {            if(element.value != "") {                query_string += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";            }        } else {            query_string += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";        }    }    return query_string;}	
