// JavaScript Document

var tfs=GetCookie('bookfs');
//字体大小
var tbg=GetCookie('bookbg');
//背景颜色
var tfc=GetCookie('bookfc');
//字体颜色

if (tfs != null){
document.write ('<style type="text/css">');
document.write ('#pcontentp {  font-size: '+tfs+'px; }');
document.write ('</style>');
}
if (tbg != null){
document.write ('<style type="text/css">');
document.write ('body {  background-color: '+tbg+' }');
document.write ('</style>');
}
if(tfc != null)
{
document.write('<style type="text/css">');
document.write('#pcontentp {color:'+tfc+'}');
document.write ('</style>');
}

function GetCookieVal(offset)
//获得Cookie解码后的值
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie(name, value)
//设定Cookie值
{
var expires = new Date();
expires.setTime(expires.getTime() + 12 * 30 * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + value + ";expires=" + expires.toGMTString();
}

function DelCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

function GetCookie(name)
//获得Cookie的原始值
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return GetCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function setfs(id){
document.getElementById('pcontentp').style.fontSize=id+"px";
SetCookie('bookfs',id);
}

function setbg(id){
document.getElementsByTagName('body')[0].style.backgroundColor=id;
SetCookie('bookbg',id);
}

function setfc(id)
{
document.getElementById('pcontentp').style.color = id;
SetCookie('bookfc',id);
}