// ==== Rainbow =====
function MakeArray(n){
this.length=n;
for(var i=1; i<=n; i++) this[i]=i-1;
return this
}

hex=new MakeArray(16);
hex[11]="A"; hex[12]="B"; hex[13]="C"; hex[14]="D"; 
hex[15]="E"; hex[16]="F";

function ToHex(x)
{      // Changes a int to hex (in the range 0 to 255)
	var high=x/16;
	var s=high+"";        //1
	s=s.substring(0,2);   //2 the combination of these = the trunc funct.
	high=parseInt(s,10);  //3
	var left=hex[high+1]; // left part of the hex-value
	var low=x-high*16;    // calculate the rest of the values
	s=low+"";             //1
	s=s.substring(0,2);   //2 the combination of these = the trunc funct.
	low=parseInt(s,10);   //3
	var right=hex[low+1]; // right part of the hex-value
	var string=left+""+right; // add the high and low together
	return string;
}
nGlobalSequence=0;
nMaxSequence=10;
nMaxColor=160;
function RainbowText(text)
{
	var szOutput = "";
	
	color_d1=nMaxColor;         // any value in 'begin' 0 to 255
	mul=color_d1/nMaxSequence;
	for(i=0;i<text.length;i++)
	{
	  color_d1=nMaxColor*Math.sin(nGlobalSequence/(nMaxSequence/3)); 
	  colorR=ToHex(nMaxColor);
	  colorG=ToHex(color_d1);
	  color_d2=mul*nGlobalSequence;
	  colorB=ToHex(color_d2);
	  szOutput += "<FONT COLOR='#" + colorR + colorG + colorB +
	                 "'>"+text.substring(i,i+1)+'</FONT>';
	  nGlobalSequence ++;
	  if (nGlobalSequence >= nMaxSequence)
		nGlobalSequence = 0;
	}
	return szOutput;
}

// ====== OpenPage =======
function jsOpenPage(szURL, szTitle, nWidth, nHeight, bScrollBar) 
{
	var w = 800;
	var h = 600;
	
	if(bScrollBar)
		szScrollBar = "yes";
	else
		szScrollBar = "no";
		
	if(document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (w-nWidth)/2;
	var leftPos = (h-nHeight)/2;

	var newwin=window.open(szURL,szTitle,'width=' + nWidth + ',height='+nHeight+',top='+topPos+',left='+leftPos + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+szScrollBar+",resizable=yes");
	newwin.focus();
	return false;
}
function opPic(szURL)
{
	return jsOpenPage(szURL, "Pic", 620, 420, true);
}
function opInfo(szURL)
{
	return jsOpenPage(szURL, "Info", 600, 350, true);
}
function opMsg(szURL)
{
	return jsOpenPage(szURL, "Message", 520, 350, true);
}
function opPost(szURL)
{
	return jsOpenPage(szURL, "Post", 700, 500, true);
}
function opVote(szURL)
{
	return jsOpenPage(szURL, "Vote", 500, 160, true);
}
function opLogin(szURL)
{
	return jsOpenPage(szURL, "Login", 340, 220, true);
}
function opForm(szURL)
{
	return jsOpenPage(szURL, "Form", 600, 400, true);
}
function opShow(szURL)
{
	return jsOpenPage(szURL, "Show", 600, 380, true);
}
//----------- jsOpenRedirect ------------
function jsRedirect(url) 
{
	if (window.parent)
		window.parent.location.href = url;
	else
		window.location.href = url;
		
  	return false;
}
function jsWriteStyle()
{
	var szWrite = "" +
		'<style type="text/css">' +
		'.title       { font-size: 22pt; line-height: 140%; valign="top"; font-family: "宋体";}' +
		'.title2      { font-size: 14pt; line-height: 140%; valign="top"; font-family: "宋体";}' +
		'.author      { font-size: 11pt; line-height: 140%; font-family: "楷体_GB2312";}' +
		'.text        { font-size: 12pt; line-height: 140%; valign="top"; font-family: "宋体"}' +
		'.PreviewText { font-size: 9pt; line-height: 120%; valign="top" ; font-family: "宋体"; color: #3333FF}'+
		'.HeadText    { font-size: 12pt; line-height: 140%; valign="top"; font-family: "楷体_GB2312"}'+
		'a:link       { color: #3333CC; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'a:visited    { color: #333366; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'a:hover      { color: #3333EE; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'small		 {font-size:8pt;font-family:"宋体";color:#339933;}' +
		'.Time		 {font-size:8pt;font-family:"宋体";color:#006699;}' +
	    '.RootMessageText { font-size: 10pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.MessageText { font-size: 9pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.LargeRootMessageText { font-size: 12pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.LargeMessageText { font-size: 11pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.HintText { font-size: 9pt; line-height: 150%; valign="top" ; font-family: "宋体"; color: #003366}' +
		'body {  background-attachment: fixed; background-repeat: no-repeat; background-position: center center}' +
		'.MenuDiv {width:102px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDiv span{width:102px;height:16px;letter-spacing:1px;}' +
		'.MenuDiv a:link{width:102px;height:16px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDiv a:visited{width:102px;height:16px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDiv a:hover{background:#A8FFCC;text-decoration:none; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDivFrame {width:86px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDivFrame span{width:86px;height:6px;letter-spacing:1px;}' +
		'.MenuDivFrame a:link{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrame a:visited{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrame a:hover{background:#A8FFCC;text-decoration:none; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide {width:190px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDivFrameWide span{width:86px;height:6px;letter-spacing:1px;}' +
		'.MenuDivFrameWide a:link{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide a:visited{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide a:hover{background:#A8FFCC;text-decoration:none; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'</style>';
	document.write(szWrite);
}
function jsWriteArticleStyle()
{
	var szWrite = "" +
		'<style type="text/css">' +
		'.title       { font-size: 22pt; line-height: 140%; valign="top"; font-family: "宋体";}' +
		'.title2      { font-size: 14pt; line-height: 140%; valign="top"; font-family: "宋体";}' +
		'.author      { font-size: 11pt; line-height: 140%; font-family: "楷体_GB2312";}' +
		'.text        { font-size: 12pt; line-height: 140%; valign="top"; font-family: "宋体"}' +
		'.PreviewText { font-size: 9pt; line-height: 120%; valign="top" ; font-family: "宋体"; color: #3333FF}'+
		'.HeadText    { font-size: 12pt; line-height: 140%; valign="top"; font-family: "楷体_GB2312"}'+
		'a:link       { color: #3333CC; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'a:visited    { color: #333366; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'a:hover      { color: #3333EE; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'small		 {font-size:8pt;font-family:"宋体";color:#339933;}' +
		'.Time		 {font-size:8pt;font-family:"宋体";color:#006699;}' +
	    '.RootMessageText { font-size: 10pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.MessageText { font-size: 9pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.LargeRootMessageText { font-size: 12pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.LargeMessageText { font-size: 11pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.HintText { font-size: 9pt; line-height: 150%; valign="top" ; font-family: "宋体"; color: #003366}' +
		'body {  background-attachment: fixed; background-repeat: no-repeat; background-position: center center}' +
		'.ArticleText {padding-top:2px;background-image:url(' + sz_WebSrcPath + '/Images/ArticleRow.gif);font-size:16px;line-height:30px;text-align:left;text-justify:inter-word; background-position: bottom; font-family: "宋体"}' +
		'.MenuDiv {width:102px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDiv span{width:102px;height:16px;letter-spacing:1px;}' +
		'.MenuDiv a:link{width:102px;height:16px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDiv a:visited{width:102px;height:16px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDiv a:hover{background:#A8FFCC;text-decoration:none; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDivFrame {width:86px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDivFrame span{width:86px;height:6px;letter-spacing:1px;}' +
		'.MenuDivFrame a:link{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrame a:visited{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrame a:hover{background:#A8FFCC;text-decoration:none; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide {width:190px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDivFrameWide span{width:86px;height:6px;letter-spacing:1px;}' +
		'.MenuDivFrameWide a:link{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide a:visited{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide a:hover{background:#A8FFCC;text-decoration:none; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'</style>';
	document.write(szWrite);
}
function jsWriteStyleWithTileBk()
{
	var szWrite = "" +
		'<style type="text/css">' +
		'.Title       { font-size: 22pt; line-height: 140%; valign="top"; font-family: "宋体";}' +
		'.Title2      { font-size: 14pt; line-height: 140%; valign="top"; font-family: "隶书";}' +
		'.author      { font-size: 11pt; line-height: 140%; valign="top"; font-family: "楷体_GB2312"; text-indent: 24pt}' +
		'.text        { font-size: 12pt; line-height: 140%; valign="top"; font-family: "宋体"}' +
		'.PreviewText { font-size: 9pt; line-height: 120%; valign="top" ; font-family: "宋体"; color: #3333FF}'+
		'.HeadText    { font-size: 12pt; line-height: 140%; valign="top"; font-family: "楷体_GB2312"}'+
		'a:link       { color: #3333CC; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'a:visited    { color: #333366; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'a:hover      { color: #3333EE; text-decoration: none; font-size: 12pt ; font-family: "楷体_GB2312"}' +
		'small		 {font-size:8pt;font-family:"宋体";color:#006699;}' +
	    '.RootMessageText { font-size: 10pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.MessageText { font-size: 9pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.LargeRootMessageText { font-size: 12pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.LargeMessageText { font-size: 11pt; line-height: 150%; valign="top" ; font-family: "宋体"}' +
	    '.HintText { font-size: 9pt; line-height: 150%; valign="top" ; font-family: "宋体"; color: #003366}' +
		'body {  background-attachment: fixed; }' +
		'.MenuDiv {width:102px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDiv span{width:102px;height:16px;letter-spacing:1px;}' +
		'.MenuDiv a:link{width:102px;height:16px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDiv a:visited{width:102px;height:16px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDiv a:hover{background:#A8FFCC;text-decoration:none; font-size: 11pt; font-family: "楷体_GB2312";}' +
		'.MenuDivFrame {width:86px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDivFrame span{width:86px;height:6px;letter-spacing:1px;}' +
		'.MenuDivFrame a:link{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrame a:visited{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrame a:hover{background:#A8FFCC;text-decoration:none; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide {width:190px;background:#DFFFF3;border:1px solid #9BE1FF;padding:2px 2px 2px 2px;position:absolute;z-index:9;display:none}' +
		'.MenuDivFrameWide span{width:86px;height:6px;letter-spacing:1px;}' +
		'.MenuDivFrameWide a:link{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide a:visited{width:86px;height:6px;padding:2px 9px 0px 9px;color:#003366;background:#DFFFF3; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'.MenuDivFrameWide a:hover{background:#A8FFCC;text-decoration:none; font-size: 9pt; font-family: "宋体";line-height: 100%;}' +
		'</style>';
	document.write(szWrite);
}
function jsWriteSkyTitle()
{
	var szWrite = "" +
	' <a href="../index.php"><img src="../Images/Mark.gif" width="146" height="36" align="texttop" border="0"> ' +
	'    <script language="JavaScript">{document.write(RainbowText("' + sz_WebName + '"));}</script>' +
	'    </a>&nbsp;&nbsp;&nbsp;&nbsp; <br>';
	document.write(szWrite);
}
function jsWriteTitle()
{
	var szWrite = "" +
	'<table style="font-size: 12pt; font-family: 楷体_GB2312;" cellpadding="0" cellspacing="0">' +
	'	<tr valign="top">' +
	'		<td>' +
	'			<a href="' + sz_WebBase + '/index.php" onClick="return jsRedirect(this.href);"><img src="../Images/Mark.gif" width="146" height="36" align="texttop" border="0"></a>' +
	'		</td>' +
	'		<td>' +
	'			<div MenuID=MenuHome style="position:static; behavior:url(' + sz_WebSrcPath + '/System/Menu.htc)">' + 
	'				<table border=0 cellspacing=0 cellpadding=0><tr><td>' +
	'				<div MenuID=MenuHome style="position:static; behavior:url(' + sz_WebSrcPath + '/System/SubMenu.htc)"><a href="' + sz_WebBase + '/News/index.php" onClick="return jsRedirect(this.href);">' + RainbowText("新闻") + '&nbsp;</a></div>' +
	'				</td></tr>' +
	'	      <tr><td>' +
	'				<div class=MenuDivFrame id=MenuHome>' +
						'<span><a id="link" href="' + sz_WebBase + '/News/index.php?bPrimeOnly=1" onClick="return jsRedirect(this.href);">精华区</a></span>' +
	'				</div>' +
	'				</td></tr>' +
	'				</table>' +
	'			</div>' + 
	'		</td>' +
	'		<td>' +
	'			<div MenuID=MenuHeart style="position:static; behavior:url(' + sz_WebSrcPath + '/System/Menu.htc)">' + 
	'				<table border=0 cellspacing=0 cellpadding=0><tr><td>' +
	'				<div MenuID=MenuHeart style="position:static; behavior:url(' + sz_WebSrcPath + '/System/SubMenu.htc)"><a href="' + sz_WebBase + '/Forum/index.php" onClick="return jsRedirect(this.href);">' + RainbowText("论坛") + '&nbsp;</a></div>' +
	'				</td></tr><tr><td>' +
	'				<div class=MenuDivFrame id=MenuHeart>' +
						'<span><a id="link" href="' + sz_WebBase + '/Forum/index.php?bPrimeOnly=1" onClick="return jsRedirect(this.href);">精华区</a></span>' +
	'				</div>' +
	'				</td></tr></table>' +
	'			</div>' + 
	'		</td>' +
	'		<td>' +
	'			<div MenuID=MenuFiles style="position:static; behavior:url(' + sz_WebSrcPath + '/System/Menu.htc)">' + 
	'				<table border=0 cellspacing=0 cellpadding=0><tr><td>' +
	'				<div MenuID=MenuFiles style="position:static; behavior:url(' + sz_WebSrcPath + '/System/SubMenu.htc)"><a href="' + sz_WebBase + '/Files/index.php" onClick="return jsRedirect(this.href);">' + RainbowText("文件交流") + '&nbsp;</a></div>' +
	'				</td></tr><tr><td>' +
	'				<div class=MenuDivFrame id=MenuFiles>' +
						'<span><a id="link" href="' + sz_WebBase + '/Files/index.php?bPrimeOnly=1" onClick="return jsRedirect(this.href);">精华区</a></span>' +
	'				</div>' +
	'				</td></tr></table>' +
	'			</div>' + 
	'		</td>' +
	'		<td>' +
	'			<div MenuID=MenuChat style="position:static; behavior:url(' + sz_WebSrcPath + '/System/Menu.htc)">' + 
	'				<table border=0 cellspacing=0 cellpadding=0><tr><td>' +
	'				<div MenuID=MenuChat style="position:static; behavior:url(' + sz_WebSrcPath + '/System/SubMenu.htc)"><a href="' + sz_WebBase + '/Ch/index.php" onClick="return jsRedirect(this.href);">' + RainbowText("聊天室") + '&nbsp;</a></div>' +
	'				</td></tr><tr><td>' +
	'				<div class=MenuDivFrame id=MenuChat>' +
	'					<span><a id="link" href="' + sz_WebBase + '/Ch/index.php" onClick="return jsRedirect(this.href);">聊天室</a></span>' +
	'					<span><a id="link" href="' + sz_WebBase + '/Ch/indexCh.php" onClick="return jsRedirect(this.href);">旧版聊天室</a></span>' +
	'				</div>' +
	'				</td></tr></table>' +
	'			</div>' + 
	'		</td>' +
	'		<td>' +
	'			<div MenuID=MenuGBook style="position:static; behavior:url(' + sz_WebSrcPath + '/System/Menu.htc)">' + 
	'				<table border=0 cellspacing=0 cellpadding=0><tr><td>' +
	'				<div MenuID=MenuGBook style="position:static; behavior:url(' + sz_WebSrcPath + '/System/SubMenu.htc)"><a href="' + sz_WebBase + '/GBook/GBook.php" onClick="return jsRedirect(this.href);">' + RainbowText("留言板") + '&nbsp;</a></div>' +
	'				</td></tr><tr><td>' +
	'				<div class=MenuDivFrame id=MenuGBook>' +
	'					<span><a id="link" href="' + sz_WebBase + '/GBook/GBook.php" onClick="return jsRedirect(this.href);">留言板</a></span>' +
	'					<span><a id="link" href="' + sz_WebBase + '/GBook/HotUsers.php" onClick="return jsRedirect(this.href);">叱咤风云榜</a></span>' +
	'				</div>' +
	'				</td></tr></table>' +
	'			</div>' + 
	'		</td>' +
	'	</tr>' +
	'</table>' +
	'   &nbsp;&nbsp;&nbsp;&nbsp;';
	document.write(szWrite);
}
function jsWriteHelp()
{
	var szWrite = '<div id="LayerHelp" style="position:absolute; width:50px; height:27px; z-index:1; left: 750px; top: 18px">' +
		'<a href="Help.htm" onClick="return opInfo(this.href);"><img src="../Images/Help.gif" width="10" height="10" border="0"></a>' +
		'</div>';

	//document.write(szWrite);
}
