/////////////////////////////
////  月影社区 WF66.COM  ////
////  JS  调用 VER 3.0   ////
/////////////////////////////

/////////////////////////////背景图片
//if (screen.width==1024){;document.write("<body background=../../images/bg.gif>");}else{;document.write("<body background=images/bg2.gif>");}


/////////////////////////////确认框
function checkclick(msg){if(confirm(msg)){event.returnValue=true;}else{event.returnValue=false;}}


//MAIL登陆
function gook() {
if (usernameshow.value == "")
{
alert("用户名不可为空");
usernameshow.focus();
return ;
}

if (pwshow.value == "")
{
alert("密码不可为空");
pwshow.focus();
return ;
}
f1.username.value = usernameshow.value;
f1.pwhidden.value = encode(pwshow.value, parseInt(f1.picnum.value));
f1.submit();
}

function encode(datastr, bassnum) {
var tempstr;
var tchar;
var newdata = "";
for (var i = 0; i < datastr.length; i++)
{
tchar = 65535 + bassnum - datastr.charCodeAt(i);
tchar = tchar.toString();
while(tchar.length < 5)
{
tchar = "0" + tchar;
}
newdata = newdata + tchar;
}
return newdata;
}

////////////////////CHAT登陆
function check()
{
 if(!validstr(Login.user)) return false;
 //if(screen.width <= 800 && screen.height <= 600 && Login.fullscreen.checked == false)
 //Login.fullscreen.checked = confirm("系统建议您以全屏方式进入聊天室，您同意吗？") ;

 //if(Login.fullscreen.checked)
 {
 window.resizeTo(screen.availWidth, screen.availHeight) ;
 window.moveTo(0,0);
 }

 return true;
}
function validstr(str)
{
 var s,i,j;

 s=" +=|'#&<>%*`^/\\\";,.";
 str1=str.value.toString();
 for (i=0; i<str1.length; i++)
 {
 for(j=0;j<s.length;j++)
 {
 if (str1.charAt(i) == s.charAt(j))
 {
 alert("名字中不能包含特殊字符: +=|'#&<>%*`^/\\\";,.空格.");
 str.focus();
 return false;
 }
 }
 }
 return true;
}

///////////////////MOONCODE
function www_wf66_com(content)
{
document.write(mooncode("<span >"+content+"</span>"));
}
function mooncode(temp) 
{
temp = temp.replace(/&amp;/ig,"&");
temp = temp.replace(/\[b\]/ig,"<b>");
temp = temp.replace(/\[\/b\]/ig,"<\/b>");
temp = temp.replace(/\[i\]/ig,"<i>");
temp = temp.replace(/\[\/i\]/ig,"<\/i>");
temp = temp.replace(/\[u\]/ig,"<u>");
temp = temp.replace(/\[\/u\]/ig,"<\/u>");
temp = temp.replace(/\[strike\]/ig,"<strike>");
temp = temp.replace(/\[\/strike\]/ig,"<\/strike>");
temp = temp.replace(/\[center\]/ig,"<center>");
temp = temp.replace(/\[\/center\]/ig,"<\/center>");
temp = temp.replace(/\[marquee\]/ig,"<marquee>");
temp = temp.replace(/\[\/marquee\]/ig,"<\/marquee>");
temp = temp.replace(/\[QUOTE\]/ig,"<BLOCKQUOTE><strong>引用</strong>：<HR Size=1>");
temp = temp.replace(/\[\/QUOTE\]/ig,"<HR SIZE=1><\/BLOCKQUOTE>");
temp = temp.replace(/(\[font=)([^.:;`'"=\]]*)(\])/ig,"<FONT face='$2'>");
temp = temp.replace(/\[\/font\]/ig,"<\/FONT>");
temp = temp.replace(/(\[COLOR=)([^.:;`'"=\]]*)(\])/ig,"<FONT COLOR='$2'>");
temp = temp.replace(/\[\/COLOR\]/ig,"<\/FONT>");
temp = temp.replace(/(\[size=)([0-9]*)(\])/ig,"<FONT size='$2'>");
temp = temp.replace(/\[\/size\]/ig,"<\/FONT>");
temp = temp.replace(/(\[URL\])([^]]*)(\[\/URL\])/ig,"<A TARGET=_blank HREF='$2'>$2</A>");
temp = temp.replace(/(\[URL=)([^]]*)(\])/ig,"<A TARGET=_blank HREF='$2'>");
temp = temp.replace(/\[\/URL\]/ig,"<\/A>");
temp = temp.replace(/(\[EMAIL\])(\S+\@[^]]*)(\[\/EMAIL\])/ig,"<a href=mailto:$2>$2</a>");
temp = temp.replace(/(\[RM=([0-9]*)\,([0-9]*)\])([^]]*)(\[\/RM\])/ig,"<OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA width=$2 height=$3><PARAM NAME=SRC VALUE=$6><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=true><\/OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=60 width=500><PARAM NAME=SRC VALUE=$4><PARAM NAME=CONTROLS VALUE=ControlPanel,StatusBar><PARAM NAME=CONSOLE VALUE=Clip1><\/OBJECT>");
temp = temp.replace(/(\[MP=([0-9]*)\,([0-9]*)\])([^]]*)(\[\/MP\])/ig,"<object classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 width=$2 height=$3><param name=ShowStatusBar value=-1><param name=Filename value=$4><\/object>");
temp = temp.replace(/(\[FLASH=([0-9]*)\,([0-9]*)\])([^]]*)(\[\/FLASH\])/ig,"<embed width=$2 height=$3 src='$4' wmode=transparent>");
//无点放大功能
temp = temp.replace(/(\[IMG\])([^];]*)(\[\/IMG\])/ig,"<img border=0 src='$2' onmousewheel='return moon_img(event,this)' onload='javascript:if(this.width>body.clientHeight)this.width=body.clientHeight'> ");
//下面的可以点放大图片
//temp = temp.replace(/(\[IMG\])([^];]*)(\[\/IMG\])/ig,"<a href='$2' TARGET=_blank ><img border=0 src='$2' onmousewheel='return moon_img(event,this)' onload='javascript:if(this.width>body.clientHeight)this.width=body.clientHeight'></a> ");
temp = temp.replace(/(\[em)([0-9]*)(\])/ig,"<IMG border=0 SRC=images/Emotions/$2.gif>");
temp = temp.replace(/([^]='])(| |<br>)((http|https|ftp|rtsp|mms):(\/\/|\\\\)[^< ]+)(| |<br>)/ig,"$1$2<A TARGET=_blank HREF='$3'>$3</A>");
return (temp);
}
function moon_img(e, o)
{
var zoom = parseInt(o.style.zoom, 10) || 100;
zoom += event.wheelDelta / 12;
if (zoom > 0) o.style.zoom = zoom + '%';
return false;
}
/////////////////////////////横点线
function bian_a(){
document.write("<table cellSpacing=0 cellPadding=0 align=center border=0><tr><td height=8 width=8><img src=images/bian/bg_0ltop.gif></td><td background=images/bian/bg_01.gif></td><td><img src=images/bian/bg_0rtop.gif></td></tr><tr><td background=images/bian/bg_03.gif></td><td vAlign=center align=middle bgColor=#ffffff>")
}

function bian_b(){
document.write("</td><td background=images/bian/bg_04.gif></td></tr><tr><td><img src=images/bian/bg_0lbottom.gif></td><td background=images/bian/bg_02.gif></td><td height=8 width=8><img src=images/bian/bg_0rbottom.gif></td></tr></table>")
}

function xian(){
document.write("<center><table border=0 width=760  cellpadding=0 cellspacing=0 bgcolor=#FFFFFF background=images/t-bg-5.gif height=1><tr><td></td></tr></table></center>")
}

function xian2(){
document.write("<center><table border=0 width=100%  cellpadding=0 cellspacing=0 bgcolor=#FFFFFF background=images/t-bg-5.gif height=1><tr><td></td></tr></table></center>")
}


////////////////////////////搜索
function gosearch()
 {
var key=document.myform.keyword.value;
 var openNum=0;
 for (var i=0;i<document.myform.checkbox.length;i++)
 {
 if (document.myform.checkbox[i].checked)
 {
 openNum += 1;
 if (key!="")
 {
 window.open(document.myform.checkbox[i].value.replace("wf66com",key));
 }else{
 window.open(document.myform.checkbox[i].value);
 }
 }
 }
 //如果没有选择搜索引擎用第一个搜索引擎搜索
 if (openNum==0)
 {
 if (key!="")
 {
 window.open(document.myform.checkbox[0].value.replace("wf66com",key));
 }else{
 window.open(document.myform.checkbox[0].value);
 } 
 }
 return false;
 }

//***********连接标题默认设置定义.*********************
tPopWait=0;//停留tWait豪秒后显示提示。
tPopShow=5000;//显示tShow豪秒后关闭提示
showPopStep=1000;
popOpacity=1000;

//***************内部变量定义*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText {  background-color: #FFFFFF; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>");

function showPopupText(){
var o=event.srcElement;
	MouseX=event.x;
	MouseY=event.y;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};

if(o.title!=null && o.title!=""){o.dypop=o.title;o.alt=""};






	if(o.dypop!=sPop) {
			sPop=o.dypop;
			clearTimeout(curShow);
			clearTimeout(tFadeOut);
			clearTimeout(tFadeIn);
			clearTimeout(tFadeWaiting);	
			if(sPop==null || sPop=="") {
				dypopLayer.innerHTML="";
				dypopLayer.style.filter="Alpha()";
				dypopLayer.filters.Alpha.opacity=0;	
				}
			else {
				if(o.dyclass!=null) popStyle=o.dyclass 
					else popStyle="cPopText";
				curShow=setTimeout("showIt()",tPopWait);
			}
			
	}
}



function showIt(){
		dypopLayer.className=popStyle;
		dypopLayer.innerHTML=sPop;
		popWidth=dypopLayer.clientWidth;
		popHeight=dypopLayer.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;
		dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
		dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
		dypopLayer.style.filter="Alpha(Opacity=0)";
		fadeOut();
}



function fadeOut(){
	if(dypopLayer.filters.Alpha.opacity<popOpacity) {
		dypopLayer.filters.Alpha.opacity+=showPopStep;
		tFadeOut=setTimeout("fadeOut()",1);
		}
		else {
			dypopLayer.filters.Alpha.opacity=popOpacity;
			tFadeWaiting=setTimeout("fadeIn()",tPopShow);
			}
}

function fadeIn(){
	if(dypopLayer.filters.Alpha.opacity>0) {
		dypopLayer.filters.Alpha.opacity-=1;
		tFadeIn=setTimeout("fadeIn()",1);
		}
}
document.onmouseover=showPopupText;

////////////////////////////
/////////表单提交///////////
////////////////////////////
function ybbsize(theSmilie){
if (theSmilie) {
document.form.content.value= '[size=' + theSmilie + ']'+ document.form.content.value + '[/size]';
}
}


function ybbfont(theSmilie){
if (theSmilie) {
document.form.content.value= '[font=' + theSmilie + ']'+ document.form.content.value + '[/font]';
}
}

function YBBurl() {
var enterURL   = prompt("请输入主页地址", "http://");
if (enterURL) {
var ToAdd = "[URL]"+enterURL+"[/URL]";
document.form.content.value+=ToAdd;
}
}


function YBBimage() {
var enterURL   = prompt("请输入图片地址", "http://");
if (enterURL) {
var ToAdd = "[IMG]"+enterURL+"[/IMG]";
document.form.content.value+=ToAdd;
}
}


function YBBemail() {
var emailAddress = prompt("请输入邮件地址","");
if (emailAddress) {
var ToAdd = "[EMAIL]"+emailAddress+"[/EMAIL]";
document.form.content.value+=ToAdd;
}
}

function YBBflash() {
var enterURL  = prompt("请输入FLASH地址", "http://");
var entersize = prompt("请输入视频的宽度高度", "500,375");
if (enterURL) {
var ToAdd = "[FLASH="+entersize+"]"+enterURL+"[/FLASH]";
document.form.content.value+=ToAdd;
}
}

function YBBrm() {
var enterURL  = prompt("请输入RealPlayer文件地址", "");
var entersize = prompt("请输入视频宽度,高度", "500,375");
if (enterURL) {
var ToAdd = "[RM="+entersize+"]"+enterURL+"[/RM]";
document.form.content.value+=ToAdd;
}
}

function YBBmp() {
var enterURL  = prompt("请输入Media Player文件地址", "");
var entersize = prompt("请输入视频宽度,高度", "500,420");
if (enterURL) {
var ToAdd = "[MP="+entersize+"]"+enterURL+"[/MP]";
document.form.content.value+=ToAdd;
}
}


function YBBbold() {
document.form.content.value="[B]"+document.form.content.value+"[/B]";
}


function YBBitalic() {
document.form.content.value="[I]"+document.form.content.value+"[/I]";
}


function YBBunder() {
document.form.content.value="[U]"+document.form.content.value+"[/U]";
}

function YBBcenter() {
document.form.content.value="[CENTER]"+document.form.content.value+"[/CENTER]";
}

function YBBquote() {
document.form.content.value="[QUOTE]"+document.form.content.value+"[/QUOTE]";
}



function MM_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=MM_findObj(n,d.layers[i].document); return x;
}

function insertTag(MyString)
{
fontbegin='[color=' + MyString + ']'
fontend='[/color]'
document.form.content.value=fontbegin+document.form.content.value+fontend;
document.form.content.focus();
}


var base_hexa = "0123456789ABCDEF";
function dec2Hexa(number)
{
   return base_hexa.charAt(Math.floor(number / 16)) + base_hexa.charAt(number % 16);
}

function RGB2Hexa(TR,TG,TB)
{
  return "#" + dec2Hexa(TR) + dec2Hexa(TG) + dec2Hexa(TB);
}

function lightCase(MyObject,objName)
{
	MM_findObj(objName).bgColor = MyObject.bgColor;
}

col = new Array;
col[0] = new Array(255,0,255,-1,255,-1);
col[1] = new Array(255,0,0,1,0,0);
col[2] = new Array(255,-1,255,0,0,0);
col[3] = new Array(0,0,255,0,0,1);
col[4] = new Array(0,0,255,-1,255,0);
col[5] = new Array(0,1,0,0,255,0);
col[6] = new Array(255,-1,0,0,255,-1);

function rgb(pas,w,h){
	for (j=0;j<6+1;j++){
		for (i=0;i<pas+1;i++){
			r = Math.floor(col[j][0]+col[j][1]*i*(255)/pas);
			g = Math.floor(col[j][2]+col[j][3]*i*(255)/pas);
			b = Math.floor(col[j][4]+col[j][5]*i*(255)/pas);
		  codehex = r + '' + g + '' + b;
		  document.write('<td bgColor=\"' + RGB2Hexa(r,g,b) + '\"onmouseover="lightCase(this,\'ColorUsed\')" onClick=\"insertTag(this.bgColor)\" width=\"'+w+'\" height=\"'+h+'\"><IMG height='+h+' width='+w+' border=0 title=\"字体颜色：'+RGB2Hexa(r,g,b)+'\"></TD>\n');
		}
	}
}



///////////双击自动滚屏/www.wf66.com
var currentpos,timer;
function sc(){clearInterval(timer);}
function initialize(){timer=setInterval("scrollwindow()",1);}
function scrollwindow(){currentpos=document.body.scrollTop;window.scroll(0,++currentpos);}
document.onmousedown=sc
document.ondblclick=initialize


////////////变色连接
var rate = 20; 
var obj; 
var act = 0; 
var elmH = 0; 
var elmS = 128; 
var elmV = 255; 
var clrOrg; 
var TimerID; 
if (navigator.appName.indexOf("Microsoft",0) != -1 && parseInt(navigator.appVersion) >= 4) { 
Browser = true; 
} else { 
Browser = false; 
} 
if (Browser) { 

//document.onmouseover = doRainbowAnchor; 
//document.onmouseout = stopRainbowAnchor; 
} 
function doRainbow() 
{ 
if (Browser && act != 1) { 
act = 1; 
obj = event.srcElement; 
clrOrg = obj.style.color; 
TimerID = setInterval("ChangeColor()",100); 
} 
} 
function stopRainbow() 
{ 
if (Browser && act != 0) { 
obj.style.color = clrOrg; 
clearInterval(TimerID); 
act = 0; 
} 
} 
function doRainbowAnchor() 
{ 
if (Browser && act != 1) { 
obj = event.srcElement; 
while (obj.tagName != 'A' && obj.tagName != 'BODY') { 
obj = obj.parentElement; 
if (obj.tagName == 'A' || obj.tagName == 'BODY') 
break; 
} 
if (obj.tagName == 'A' && obj.href != '') { 
act = 1; 
clrOrg = obj.style.color; 
TimerID = setInterval("ChangeColor()",100); 
} 
} 
} 
function stopRainbowAnchor() 
{ 
if (Browser && act != 0) { 
if (obj.tagName == 'A') { 
obj.style.color = clrOrg; 
clearInterval(TimerID); 
act = 0; 
} 
} 
} 
function ChangeColor() 
{ 
obj.style.color = makeColor(); 
} 
function makeColor() 
{ 
if (elmS == 0) { 
elmR = elmV; elmG = elmV; elmB = elmV; 
} 
else { 
t1 = elmV; 
t2 = (255 - elmS) * elmV / 255; 
t3 = elmH % 60; 
t3 = (t1 - t2) * t3 / 60; 
if (elmH < 60) { 
elmR = t1; elmB = t2; elmG = t2 + t3; 
} 
else if (elmH < 120) { 
elmG = t1; elmB = t2; elmR = t1 - t3; 
} 
else if (elmH < 180) { 
elmG = t1; elmR = t2; elmB = t2 + t3; 
} 
else if (elmH < 240) { 
elmB = t1; elmR = t2; elmG = t1 - t3; 
} 
else if (elmH < 300) { 
elmB = t1; elmG = t2; elmR = t2 + t3; 
} 
else if (elmH < 360) { 
elmR = t1; elmG = t2; elmB = t1 - t3; 
} 
else { 
elmR = 0; elmG = 0; elmB = 0; 
} 
} 
elmR = Math.floor(elmR); 
elmG = Math.floor(elmG); 
elmB = Math.floor(elmB); 
clrRGB = '#' + elmR.toString(16) + elmG.toString(16) + elmB.toString(16); 
elmH = elmH + rate; 
if (elmH >= 360) 
elmH = 0; 
return clrRGB; 
}


//表单透明样式
function App(st) {
st.style.filter = 'alpha(opacity=100)'
}			
function DisApp(st) {
st.style.filter = 'alpha(opacity=38)';
}
