var speed = 5;
var currentpos=1;
var timer;

//滚动公告
function Gundong(){
	document.write('');	
}

function ShowCopyRight(){
document.write('重要声明：本站所有的文章、图片、评论等，均由小说爱好者发表或上传并维护或收集自网络，属个人行为，与28小说立场无关。<br />如果您是某作品的版权所有者但不愿意我们转载您的作品，请通知我们解决。任何非本站因素导致的法律后果，本站均不负任何责任。<br />Copyright &copy; 2009-2010 28小说  All rights reserved. 技术支持：<a href="http://www.28bk.com" target="_blank"><font color=red>28小说</font></a><br /><a href="http://www.miibeian.gov.cn/">闽ICP备08006382</a><br />');
}


function myAddPanel(title,url,desc) 
{ 
	if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
	//Gecko 
	{ 
		window.sidebar.addPanel(title,url,desc); 
	} 
	else
	//IE 
	{ 
		window.external.AddFavorite(url,title); 
	} 
}

//复制内容到剪贴板
function CopyToClipBoard(BookName,BookID)
{
	var s = "28小说网每日更新大量免费小说在线阅读、下载！\n";
	s += "网址:http://www.28bk.com\r\n";
	s += "小说《" + BookName + "》阅读地址:http://www.28bk.com/xiaoshuo/0"+BookID+".htm";
	window.clipboardData.setData("Text",s); 
	alert('已复制本页链接,您可以使用Ctrl+V粘贴后,发送给好友!');
}

//写cookie
function writeCookie(name, value, hours)
{
	var expire = "";
	if(hours != null)
	{
		expire = new Date((new Date()).getTime() + hours *3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + escape(value) + expire;
}

//读cookie
function readCookie(name)
{
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);
		if(offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if(end == -1)
				end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}

function GetSetCss(){
    if(readCookie("ReadMain")!=""){document.getElementById("main").className=readCookie("ReadMain");}
    if(readCookie("ReadContent")!=""){document.getElementById("content").className=readCookie("ReadContent");}	
}

//设置阅读页面背景颜色
function ChangeMode(v)
{
	var Mainclass=document.getElementById("main").className;
	var ArrBodyclass=Mainclass.split(" ");
	document.getElementById("main").className=v+" "+ArrBodyclass[1];
	writeCookie("ReadMain", document.getElementById("main").className, 1);
}
//设置阅读页面字体
function ChangeFont(v)
{
	document.getElementById("content").className=v;
	writeCookie("ReadContent", v, 1);
}

String.prototype.replaceAll = function(s1,s2){
	return this.replace(new RegExp(s1,"gm"),s2);
}

function SelectColors()
{
	for(var i=1; i<=8; i++)
	{
		document.write("<a href='javascript:void(0);' onclick=javascript:ChangeMode('colors"+i+"'); class='color_"+i+"'>color"+i+"</a>");
	}
}

//双击滚动屏幕
function stopScroll()
{
    clearInterval(timer);
}
function beginScroll()
{
	timer=setInterval("scrolling()",300/5);
}

function scrolling()
{
	currentpos=document.documentElement.scrollTop;
    window.scroll(0,++currentpos);
    if(currentpos!=document.documentElement.scrollTop) clearInterval(timer);
}

document.onmousedown=stopScroll;
document.ondblclick=beginScroll;
//双击滚动屏幕结束

function SetHome(obj,vrl)
{
	try
	{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}
	catch(e){
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch (e) {
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]设置为'true'");
			}
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage',vrl);
			}
	}
}
