﻿document.charset = "utf-8";
var HtmlStr,divTop,docTop,divLeft,divWidth,divHeight,docHeight,docWidth,i = 0;
var timer1,timer2,timer3,J=0,MP=1,MC=0,NP=1,NC=0,CP=1,CC=0;
var timer4,timer0;
var mytimer,msgtimer,anntimer,chatimer;
var eMsg = new Object();
eMsg.id = 'eMsg';
eMsg.obj = function(){return G(eMsg.id);};
eMsg.onLoad = function(){try{divTop = parseInt(eMsg.obj().style.top,10); divLeft = parseInt(eMsg.obj().style.left,10);divHeight = parseInt(eMsg.obj().offsetHeight,10);divWidth = parseInt(eMsg.obj().offsetWidth,10);docWidth = document.documentElement.clientWidth;docHeight = document.documentElement.clientHeight;docTop=document.documentElement.scrollTop;if(Sys.chrome){docTop=document.body.scrollTop;};eMsg.obj().style.top = parseInt(docTop,10) + docHeight + 10+'px';var popWidth=parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth;if(divWidth<250){popWidth=(docWidth-950)/2+955;}eMsg.obj().style.left =popWidth+'px';eMsg.obj().style.visibility="visible";eMsg.timer = window.setInterval(eMsg.move,10);}catch(e){}};
eMsg.onResize = function(){i+=1;try{divHeight = parseInt(eMsg.obj().offsetHeight,10);divWidth = parseInt(eMsg.obj().offsetWidth,10);docWidth = document.documentElement.clientWidth;docHeight = document.documentElement.clientHeight;docTop=document.documentElement.scrollTop;if(Sys.chrome){docTop=document.body.scrollTop;};eMsg.obj().style.top = docHeight - divHeight + parseInt(docTop,10)+'px';var popWidth=parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth;if(divWidth<250){popWidth=(docWidth-950)/2+955;}eMsg.obj().style.left = popWidth+'px';}catch(e){}};
eMsg.move = function(){docTop=document.documentElement.scrollTop;if(Sys.chrome){docTop=document.body.scrollTop;};try{if(parseInt(eMsg.obj().style.top,10)<=(docHeight - divHeight + parseInt(docTop,10))){window.clearInterval(eMsg.timer);eMsg.timer = window.setInterval(eMsg.onResize,1);}divTop = parseInt(eMsg.obj().style.top,10)-1;eMsg.obj().style.top = divTop+'px';}catch(e){}};eMsg.close = function(){if(eMsg.obj()) eMsg.obj().parentNode.removeChild(eMsg.obj());if(eMsg.timer){window.clearInterval(eMsg.timer);}writeCookie('winpop',1,1);};
eMsg.convertWin = function(){var msg = G('box'); var contentdis = G('convert');var flg = msg.style.display=="none";if(flg){contentdis.className="minid";contentdis.title='最小化窗口'; msg.style.display = "block";clearTimeout(anntimer);clearTimeout(msgtimer);clearTimeout(chatimer);}else{contentdis.className="maxid";contentdis.title='最大化窗口'; msg.style.display = "none";mytimer=setTimeout('myPopup()',1000);}}
eMsg.createInstance = function(TStr1,TStr2,TStr3){try{if(eMsg.obj())eMsg.obj().parentNode.removeChild(eMsg.obj());
if(eMsg.timer) window.clearInterval(eMsg.timer);i=0;var odiv = document.createElement('DIV');odiv.id = eMsg.id;
HtmlStr='<div class="statebox" id="statebox" style="display:none" onMouseOver="stateMouse(1);" onMouseOut="stateMouse(0);"><div class="statediv">';
HtmlStr+='<h1><span>会员动态</span><em onclick="showBox();" title="关闭">&nbsp;</em></h1><div class="statemsg" id="stateDiv"></div>';
HtmlStr+='</div></div>';HtmlStr+='<div class="msgbox">';
HtmlStr+='<div class="msgtitle"><ul><li id="state" title="看看大家正在做什么" onclick="showBox();"></li><li class="curr" id="msg_btn_0" onclick="show_div(0)">网站公告</li><li id="msg_btn_1" onclick="show_div(1)">系统信息</li><li id="msg_btn_2" onclick="show_div(2)">会员聊天</li><li id="convert" class="minid" onclick="eMsg.convertWin();" title="最小化窗口">&nbsp;</li><li id="close" onclick="eMsg.close();" title="关闭窗口">&nbsp;</li></ul><IFRAME width="280" height="28" style="position:absolute; left: 0px;z-index:-1; border-style:none;"></IFRAME></div>';HtmlStr+='<div id="box"><div class="boxbox"><IFRAME width="253" height="145" style="position:absolute; left: 27px;z-index:-1; border-style:none;"></IFRAME><div id="msg_div_0">';HtmlStr+=TStr1;HtmlStr+='</div>';HtmlStr+='<div id="msg_div_1" style="display:none">';HtmlStr+=TStr2;HtmlStr+='</div>';
HtmlStr+='<div id="msg_div_2" style="display:none">';HtmlStr+=TStr3;
HtmlStr+='</div><div id="player" style="display:none;"></div></div><div id="msg_box" style="display:none;">|</div><div id="not_box" style="display:none;">|</div><div id="chat_box" style="display:none;">|</div></div>';odiv.innerHTML = HtmlStr;document.body.appendChild(odiv);}catch(e){}};
/*游客层*/
eMsg.createGuest = function(){try{if(eMsg.obj())eMsg.obj().parentNode.removeChild(eMsg.obj());
if(eMsg.timer) window.clearInterval(eMsg.timer);i=0;var odiv = document.createElement('DIV');odiv.id = eMsg.id;
HtmlStr='<div class="msgqck"><ul>';
HtmlStr+='<li id="t2"><a href="/register/" target="_blank"><span></span></a></li>';
HtmlStr+='<li id="t1"><a href="/login.asp" target="_blank"><span></span></a></li>';
HtmlStr+='<li id="t3"><a href="#" onclick="bookmarkit();return false;"><span></span></a></li>';
HtmlStr+='<li id="t4"><a href="#top"><span></span></a></li>';
HtmlStr+='</ul></div>'
odiv.innerHTML = HtmlStr;document.body.appendChild(odiv);}catch(e){}};
/*播放声音提醒*/
function player(pType){var Obj=G('player');if (pType==1){Obj.innerHTML='<embed src="/images/sound/mail.wav" loop="0" autostart="autostart" hidden="true"></embed>';}else{Obj.innerHTML="";}}
/*显示隐藏消息层*/
function show_div(divid){for (i=0;i<3;i++){G('msg_div_'+i).style.display='none';G('msg_btn_'+i).className='';}G('msg_div_'+divid).style.display='block';G('msg_btn_'+divid).className='curr';}
/*显示隐藏动态层*/
function showBox(){if (G('statebox').style.display=='none'){G('statebox').style.display="block";useronline();}else{G('statebox').style.display="none";clearTimeout(timer2);clearTimeout(timer3);}}
/*鼠标移入移出事件*/
function stateMouse(t){if(t==0){timer2=setTimeout('useronline()',1000);}else{clearTimeout(timer2);clearTimeout(timer3);}}
//格式会员动态显示信息,xslt不能有换行或空格存在，firefox会多一个节点*/
function showState(str){var strArray=str.split('|');if (strArray.length>=J && strArray[J]!=''){var rev_msg=G("stateDiv");rev_msg.innerHTML=strArray[J]+rev_msg.innerHTML;var nodeobj=rev_msg.childNodes;if(nodeobj.length>14){rev_msg.removeChild(nodeobj[nodeobj.length-1]);}J+=1;timer3=setTimeout("showState('"+str+"')",2500);}else{clearTimeout(timer3);J=0;timer2=setTimeout('useronline()',3000);}}
//会员动态信息提取
function useronline(){clearTimeout(timer2);var ajaxobj=new AJAXRequest;ajaxobj.method="POST";ajaxobj.url='/events/index.asp?action=user&t='+Math.random();
ajaxobj.callback=function(xmlobj){var response = xmlobj.responseText;if (response!=''){showState(response);};};ajaxobj.send();}
window.onresize = eMsg.onResize;
function myPopup(){var AnnStr,PostStr,IMStr;
AnnStr='<div class="boxbody"><h1>今日新看点，缘分相聚</h1><ul>';AnnStr+='<li id="img"></li>';AnnStr+='<li id="txt">中国残疾人红娘网欢迎你！有朋友联系你，会在这里显示，最好不要关闭这个小窗口哦*_*！</li>';AnnStr+='</ul></div>';
PostStr='<div class="boxbody"><h1 id="t2">暂无系统信息</h1><ul>';PostStr+='<li id="img"></li>';PostStr+='<li id="txt"></li>';PostStr+='</ul></div>';
IMStr='<div class="boxbody"><h1 id="t3">暂无聊天信息</h1><ul>';IMStr+='<li id="img"></li>';IMStr+='<li id="txt"></li>';IMStr+='<li id="tool"><em><a href="/chat/" target=_blank>打开聊天窗口</a></em></li>';IMStr+='</ul>';IMStr+='</div>';
eMsg.createInstance(AnnStr,PostStr,IMStr);eMsg.onLoad();popNotice();msgtimer=setTimeout('msgpop()',2500);chatimer=setTimeout('popchat()',4000);clearTimeout(mytimer);}
function gtPopup(){eMsg.createGuest();eMsg.onLoad();}
function pop_relation(pop_str){var strDiv;strDiv='<div class="boxbody">';strDiv+='<h1 id="t2">您有新消息，请查收</h1>';strDiv+=pop_str;strDiv+='<ul id="page"><li id="prev"><em id="prev_1"><a onclick="prev(1);">上一页</a></em></li><li id="count"><i>'+MP+'</i>/<i>'+MC+'</i></li><li id="next"><em id="next_1"><a onclick="next(1);">下一页</a></em></li></ul>';G("msg_div_1").innerHTML=strDiv;show_div(1);}
function pop_notice(pop_str){var strDiv;strDiv='<div class="boxbody">';strDiv+=pop_str;strDiv+='<ul id="page"><li id="prev"><em id="prev_0"><a onclick="prev(0);">上一页</a></em></li><li id="count"><i>'+NP+'</i>/<i>'+NC+'</i></li><li id="next"><em id="next_0"><a onclick="next(0);">下一页</a></em></li></ul>';G("msg_div_0").innerHTML=strDiv;show_div(0);}
function pop_chat(pop_str){var strDiv;strDiv='<div class="boxbody">';strDiv+=pop_str;strDiv+='<ul id="page"><li id="prev"><em id="prev_2"><a onclick="prev(2);">上一页</a></em></li><li id="count"><i>'+CP+'</i>/<i>'+CC+'</i></li><li id="next"><em id="next_2"><a onclick="next(2);">下一页</a></em></li></ul>';G("msg_div_2").innerHTML=strDiv;show_div(2);}
/*系统信息显示处理*/
function msg_rev(){clearTimeout(timer1);var str=G('msg_box').innerHTML;var strArray=str.split('|');MC=strArray.length-2;pop_relation(strArray[MP]);vis_div(1);player(1);if (MP<MC){timer1=setTimeout("msg_rev();",6000);MP+=1;}else{clearTimeout(timer1);}}
/*公告信息显示处理*/
function not_rev(){clearTimeout(timer0);var str=G('not_box').innerHTML;var strArray=str.split('|');NC=strArray.length-2;pop_notice(strArray[NC]);vis_div(0);}
/*聊天信息显示处理*/
function chat_rev(){clearTimeout(timer4);var str=G('chat_box').innerHTML;var strArray=str.split('|');CC=strArray.length-2;pop_chat(strArray[CP]);vis_div(2);player(1);if (CP<CC){timer4=setTimeout("chat_rev();",6000);CP+=1;}else{clearTimeout(timer4);}}
/*显示上下页函数*/
function vis_div(id){switch(id){case "1":if (MP==1){G('prev_1').style.visibility='hidden';}if (MP==MC){G('next_1').style.visibility='hidden';};break;case "2":if (CP==1){G('prev_2').style.visibility='hidden';}if (CP==CC){G('next_2').style.visibility='hidden';};break;default:if (NP==1){G('prev_0').style.visibility='hidden';}if (NP==NC){G('next_0').style.visibility='hidden';}}}
/*上一页事件*/
function prev(id){switch(id){case 1:MP=MP-1;var str=G('msg_box').innerHTML;var strArray=str.split('|');if (MP>0){pop_relation(strArray[MP]);}else{MP=1;};vis_div(id);break;case 2:CP=CP-1;var str=G('chat_box').innerHTML;var strArray=str.split('|');if (CP>0){pop_chat(strArray[CP]);}else{CP=1;};vis_div(id);break;default:NP=NP-1;var str=G('not_box').innerHTML;var strArray=str.split('|');if (NP>0){pop_notice(strArray[NP]);}else{NP=1;}vis_div(id);}}
/*下一页事件*/
function next(id){switch(id){case 1:MP=MP+1;var str=G('msg_box').innerHTML;var strArray=str.split('|');if(!(MP>MC)){pop_relation(strArray[MP]);}else{MP=MC;};break;case 2:CP=CP+1;var str=G('chat_box').innerHTML;var strArray=str.split('|');if(!(CP>CC)){pop_chat(strArray[CP]);}else{CP=CC;};break;default:NP=NP+1;var str=G('not_box').innerHTML;var strArray=str.split('|');if(!(NP>NC)){pop_notice(strArray[NP]);}else{NP=NC;};break;}vis_div(1);}
/*格式化数据插入对象中*/
function revFormat(divid,str){var obj=G(divid);obj.innerHTML+=str;if(divid=='msg_box'){msg_rev();}if(divid=='not_box'){not_rev();}if(divid=='chat_box'){chat_rev();}}
/*系统信息提取有信息间隔30秒，没有信息间隔1分钟*/
function msgpop(){clearTimeout(msgtimer);var ajaxobj=new AJAXRequest;ajaxobj.method="POST";ajaxobj.url='/events/index.asp?action=evmsg&t='+Math.random();ajaxobj.callback=function(xmlobj){var response = xmlobj.responseText;if(response!=''){revFormat('msg_box',response);msgtimer=setTimeout('msgpop()',30000);}else{msgtimer=setTimeout('msgpop()',60000);}};ajaxobj.send();}
/*公告信息提取间隔1小时*/
function popNotice(){clearTimeout(anntimer);var ajaxobj=new AJAXRequest;ajaxobj.method="POST";ajaxobj.url='/events/index.asp?action=notice&t='+Math.random();ajaxobj.callback=function(xmlobj){var response = xmlobj.responseText;if(response!=''){revFormat('not_box',response);}};ajaxobj.send();anntimer=setTimeout('popNotice()',3600000);}
/*聊天信息提取有记录间隔5秒，没有记录间隔60秒*/
function popchat(){clearTimeout(chatimer);var sendUrl='/chat/chat.asp?action=pop&t='+Math.random()+'';var ajaxobj=new AJAXRequest;ajaxobj.method="POST";ajaxobj.url=sendUrl;ajaxobj.callback=function(xmlobj) {var response = xmlobj.responseText;if (response.ByteCount()>0){response=response.ubbcode();revFormat('chat_box',response);chatimer=setTimeout('popchat()',5000);}else{chatimer=setTimeout('popchat()',60000);}};ajaxobj.send();}
var popSeting=parseInt(readCookie('winpop'));
if(popSeting!=1){if (getCookie("userid")!=0){myPopup();}else{gtPopup();}}
