﻿/******************************************************************************

  Crossday Discuz! Board - Common Modules for Discuz!

  Copyright 2001-2005 Comsenz Technology Ltd (http://www.comsenz.com)

*******************************************************************************/



var currentpos,timer;

function initialize()

{

timer=setInterval("scrollwindow()",10);

}

function sc(){

clearInterval(timer);

}

function scrollwindow()

{

currentpos=document.body.scrollTop;

window.scroll(0,++currentpos);

if (currentpos != document.body.scrollTop)


sc();

} 
document.onmousedown=sc

document.ondblclick=initialize

var sPop = null;

var postSubmited = false;

var userAgent = navigator.userAgent.toLowerCase();

var is_opera  = (userAgent.indexOf('opera') != -1);

var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == "Apple Computer, Inc."));

var is_webtv  = (userAgent.indexOf('webtv') != -1);

var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));

var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));

var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));

var is_kon    = (userAgent.indexOf('konqueror') != -1);

var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));

var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));

document.write("<style type='text/css'id='defaultPopStyle'>");

document.write(".cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}");



document.write("</style>");

document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");



function showPopupText(event) {

	if(event.srcElement) o = event.srcElement; else o = event.target;

	MouseX=event.clientX;

	MouseY=event.clientY;

	if(o.alt!=null && o.alt!="") { o.pop=o.alt;o.alt="" }

	if(o.title!=null && o.title!=""){ o.pop=o.title;o.title="" }

	if(o.pop!=sPop) {

		sPop=o.pop;

                if(sPop==null || sPop=="") {

                        findobj("popLayer").style.visibility="hidden";        

                } else {

                        if(o.dyclass!=null) popStyle=o.dyclass 

                        else popStyle="cPopText";

                        findobj("popLayer").style.visibility="visible";

                        showIt();

                }

        }

}



function showIt() {

        findobj("popLayer").className=popStyle;

        findobj("popLayer").innerHTML=sPop.replace(/<(.*)>/g,"&lt;$1&gt;").replace(/\n/g,"<br>");;

        popWidth=findobj("popLayer").clientWidth;

        popHeight=findobj("popLayer").clientHeight;

        if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24

                else popLeftAdjust=0;

        if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24

                else popTopAdjust=0;

        findobj("popLayer").style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;

        findobj("popLayer").style.top=MouseY+12+document.body.scrollTop+popTopAdjust;

}



function ctlent(event) {

	if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83)) {

		if(this.document.input.pmsubmit) {

			postSubmited = true;

			this.document.input.pmsubmit.disabled = true;

			this.document.input.submit();

		} else if(validate(this.document.input)) {

			postSubmited = true;

			if(this.document.input.topicsubmit) this.document.input.topicsubmit.disabled = true;

			if(this.document.input.replysubmit) this.document.input.replysubmit.disabled = true;

			if(this.document.input.editsubmit) this.document.input.editsubmit.disabled = true;

			this.document.input.submit();

		}

	}

}



function checkall(form, prefix, checkall) {

	var checkall = checkall ? checkall : 'chkall';

	for(var i = 0; i < form.elements.length; i++) {

		var e = form.elements[i];

		if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {

			e.checked = form.elements(checkall).checked;;

		}

	}

}



function findobj(n, d) {

	var p, i, x;

	if(!d) d = document;

	if((p = n.indexOf("?"))>0 && parent.frames.length) {

		d = parent.frames[n.substring(p + 1)].document;

		n = n.substring(0, p);

	}

	if(x != d[n] && d.all) x = d.all[n];

	for(i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];

	for(i = 0; !x && d.layers && i < d.layers.length; i++) x = findobj(n, d.layers[i].document);

	if(!x && document.getElementById) x = document.getElementById(n);

	return x;

}





function copycode(obj) {

	var rng = document.body.createTextRange();

	rng.moveToElementText(obj);

	rng.scrollIntoView();

	rng.select();

	rng.execCommand("Copy");

	rng.collapse(false);

}



function toggle_collapse(objname) {

	obj = findobj(objname);

	img = findobj(objname+"_img");

	collapsed = getcookie("discuz_collapse");

	cookie_start = collapsed ? collapsed.indexOf(objname) : -1;

	cookie_end = cookie_start + objname.length + 1;



	if(obj.style.display == "none") {

		obj.style.display = "";

		img_re = new RegExp("_yes\\.gif$");

		img.src = img.src.replace(img_re, '_no.gif');

		if(cookie_start != -1) collapsed = collapsed.substring(0, cookie_start) + collapsed.substring(cookie_end, collapsed.length);

	} else {

		obj.style.display = "none";

		img_re = new RegExp("_no\\.gif$");

		img.src = img.src.replace(img_re, '_yes.gif');

		if(cookie_start == -1) collapsed = collapsed + objname + " ";

	}



	expires = new Date();

	expires.setTime(expires.getTime() + (collapsed ? 86400 * 30 : -(86400 * 30 * 1000)));

	document.cookie = "discuz_collapse=" + escape(collapsed) + "; expires=" + expires.toGMTString() + "; path=/";

}



function imgzoom(o) {

	if(event.ctrlKey) {

		var zoom = parseInt(o.style.zoom, 10) || 100;

		zoom -= event.wheelDelta / 12;

		if(zoom > 0) {

			o.style.zoom = zoom + '%';

		}

		return false;

	} else {

		return true;

	}

}



function getcookie(name) {

	var cookie_start = document.cookie.indexOf(name);

	var cookie_end = document.cookie.indexOf(";", cookie_start);

	return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));

}





function Discuz_init()

{

	if (dzmenu_usepopups && dzmenu_registered.length > 0)

	{

		for (i in dzmenu_registered)

		{

			dzmenu_init(dzmenu_registered[i]);

		}

		document.onclick = dzmenu_close;

	}

	if (!document.onmouseover) document.onmouseover=function(e) { if (!e) showPopupText(window.event); else showPopupText(e); };

	

	return true;

}

var pltsPop=null;

var pltsoffsetX = 10;

var pltsoffsetY = 15;

var pltsPopbg="#FFFFEE"; //里是背景色

var pltsPopfg="#ffffff"; //里是前景色

var pltsTitle="";

document.write('<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>');

function pltsinits()

{

    document.onmouseover   = plts;

    document.onmousemove = moveToMouseLoc;

}

function plts()

{  var o=event.srcElement;

    if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};

    if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};

    pltsPop=o.dypop;

    if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")

    {

        pltsTipLayer.style.left=-1000;

        pltsTipLayer.style.display='';

        var Msg=pltsPop.replace(/\n/g,"<br>");

        Msg=Msg.replace(/\0x13/g,"<br>");

        var re=/\{(.[^\{]*)\}/ig;

        if(!re.test(Msg))pltsTitle="信息提示";

        else{

          re=/\{(.[^\{]*)\}(.*)/ig;

            pltsTitle=Msg.replace(re,"$1")+"&nbsp;";

          re=/\{(.[^\{]*)\}/ig;

          Msg=Msg.replace(re,"");

          Msg=Msg.replace("<br>","");}

          var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");

               var content =

              '<table style="FILTER:alpha(opacity=80) shadow(color=#bbbbbb,direction=135);" id=toolTipTalbe border=0><tr><td width="100%"><table class=tableBorder1 cellspacing="1" cellpadding="0" style="width:100%" bgcolor="white">'+

              '<tr id=pltsPoptop><th height=18 valign=bottom><font color=green><b><p id=topleft align=left>↖'+pltsTitle+'</p><p id=topright align=right style="display:none">'+pltsTitle+'↗</font></b></font></th></tr>'+

              '<tr><td "+attr+" class=tablebody1 style="padding-left:14px;padding-right:14px;padding-top: 6px;padding-bottom:6px;line-height:135%">'+Msg+'</td></tr>'+

              '<tr id=pltsPopbot style="display:none"><th height=18 valign=bottom><font color=white><b><p id=botleft align=left>↙'+pltsTitle+'</p><p id=botright align=right style="display:none">'+pltsTitle+'↘</font></b></font></th></tr>'+

              '</table></td></tr></table>';

               pltsTipLayer.innerHTML=content;

               toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);

               moveToMouseLoc();

               return true;

       }

    else

    {

            pltsTipLayer.innerHTML='';

              pltsTipLayer.style.display='none';

               return true;

    }

}



function moveToMouseLoc()

{

        if(pltsTipLayer.innerHTML=='')return true;

        var MouseX=event.x;

        var MouseY=event.y;

        //window.status=event.y;

        var popHeight=pltsTipLayer.clientHeight;

        var popWidth=pltsTipLayer.clientWidth;

        if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)

        {

                  popTopAdjust=-popHeight-pltsoffsetY*1.5;

                  pltsPoptop.style.display="none";

                  pltsPopbot.style.display="";

        }

         else

        {

                   popTopAdjust=0;

                  pltsPoptop.style.display="";

                  pltsPopbot.style.display="none";

        }

        if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth)

        {

                popLeftAdjust=-popWidth-pltsoffsetX*2;

                topleft.style.display="none";

                botleft.style.display="none";

                topright.style.display="";

                botright.style.display="";

        }

        else

        {

                popLeftAdjust=0;

                topleft.style.display="";

                botleft.style.display="";

                topright.style.display="none";

                botright.style.display="none";

        }

        pltsTipLayer.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust;

        pltsTipLayer.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust;

          return true;

}

pltsinits();

function list1(){

scrolltext.scrollDelay=50;

scrolltext.scrollAmount=2;

scrolltext.direction="up";

}

function list2(){

scrolltext.scrollDelay=220;

scrolltext.scrollAmount=1;

scrolltext.direction="up";

}



function list3(){



scrolltext.scrollDelay=50;

scrolltext.scrollAmount=2;

scrolltext.direction="down";



}

function list4(){

scrolltext.scrollDelay=220;

scrolltext.scrollAmount=1;

scrolltext.direction="up";

}
///////////////////////////////////////////////////MD5/////////////////////////////////////
var hex_chr = "0123456789abcdef";
function rhex(num)
{
  str = "";
  for(j = 0; j <= 3; j++)
    str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
           hex_chr.charAt((num >> (j * 8)) & 0x0F);
  return str;
}

/*
 * Convert a string to a sequence of 16-word blocks, stored as an array.
 * Append padding bits and the length, as described in the MD5 standard.
 */
function str2blks_MD5(str)
{
  nblk = ((str.length + 8) >> 6) + 1;
  blks = new Array(nblk * 16);
  for(i = 0; i < nblk * 16; i++) blks[i] = 0;
  for(i = 0; i < str.length; i++)
    blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
  blks[i >> 2] |= 0x80 << ((i % 4) * 8);
  blks[nblk * 16 - 2] = str.length * 8;
  return blks;
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally 
 * to work around bugs in some JS interpreters.
 */
function add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left
 */
function rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * These functions implement the basic operation for each round of the
 * algorithm.
 */
function cmn(q, a, b, x, s, t)
{
  return add(rol(add(add(a, q), add(x, t)), s), b);
}
function ff(a, b, c, d, x, s, t)
{
  return cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function gg(a, b, c, d, x, s, t)
{
  return cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function hh(a, b, c, d, x, s, t)
{
  return cmn(b ^ c ^ d, a, b, x, s, t);
}
function ii(a, b, c, d, x, s, t)
{
  return cmn(c ^ (b | (~d)), a, b, x, s, t);
}

/*
 * Take a string and return the hex representation of its MD5.
 */
function md5(str)
{
  x = str2blks_MD5(str);
  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;
 
  for(i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;

    a = ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = ff(c, d, a, b, x[i+10], 17, -42063);
    b = ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = ff(d, a, b, c, x[i+13], 12, -40341101);
    c = ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = ff(b, c, d, a, x[i+15], 22,  1236535329);    

    a = gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = gg(c, d, a, b, x[i+11], 14,  643717713);
    b = gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = gg(c, d, a, b, x[i+15], 14, -660478335);
    b = gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = gg(b, c, d, a, x[i+12], 20, -1926607734);
    
    a = hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = hh(b, c, d, a, x[i+14], 23, -35309556);
    a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = hh(d, a, b, c, x[i+12], 11, -421815835);
    c = hh(c, d, a, b, x[i+15], 16,  530742520);
    b = hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a = ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = ii(c, d, a, b, x[i+10], 15, -1051523);
    b = ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = ii(d, a, b, c, x[i+15], 10, -30611744);
    c = ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a = add(a, olda);
    b = add(b, oldb);
    c = add(c, oldc);
    d = add(d, oldd);
  }
  return rhex(a) + rhex(b) + rhex(c) + rhex(d);
}