﻿function htliclick_mainside()
{
  clearallaclass();
  hideallul();
  this.className = aclassName;
  ph_uls[this.i].style.display = "block";
  return false;
}

function hideallul()
{
  for( var i=0; i<ph_uls.length; i++ )
  {
	ph_uls[i].style.display = "none";
  }
}

function clearallaclass()
{
  for( var i=0; i<date_as.length; i++ )
  {
	date_as[i].className = "";
  }
}

function ddsover()
{
var tempobj = comiclassdivs[this.i];
if( this.i%2 != 0 ) tempobj.style.background = "#fff1d0";
  this.style.background = "#fff1d0";
  
}

function ddsout()
{
  var tempobj = comiclassdivs[this.i];
  if( this.i%2 != 0 ) tempobj.style.background = "#fffbeb";
  this.style.background = "none";
}
function cdivs()
{
  var tempnum = 0;
  var tempobj = [];
  var temp =  comiclass.getElementsByTagName("div");
  for( var i=0; i<temp.length; i++ )
  {
	if( temp[i].className == "rightceg" || temp[i].className == "rightce" )
	 {
		tempobj[tempnum] = temp[i];
		 tempnum++;
	 }
  }
  return tempobj;
}

function htliclick()
{
  clearallclass();
  hidealldiv();
  this.className = upclassName;
  hotces_divs[this.i].style.display = "block";
}

function hidealldiv()
{
  for( var i=0; i<hotces_divs.length; i++ )
  {
	hotces_divs[i].style.display = "none";
  }
}

function clearallclass()
{
  for( var i=0; i<hotce_t_lis.length; i++ )
  {
	hotce_t_lis[i].className = "";
  }
}
function getHello()
{
	day = new Date( ) 
	sj = day.getHours();
	var str;
	if(sj>=6&&sj<12){
		str = "早上好！";
	}
	else if(sj>=12&&sj<13){
		str = "中午好！";			
	}
	else if(sj>=13&&sj<18){
		str = "下午好！";
	}
	else if(sj>=18&&sj<24){
		str = "晚上好！";
	}
	else if(sj>=0&&sj<6){
		str = "夜深了,注意身体哦^_^！";
	}
	return str;
}
function  addfavorite()
{
if (document.all)
{
window.external.addFavorite("http://www.bengou.com","笨狗漫画");

}
else if (window.sidebar)
{
window.sidebar.addPanel("笨狗漫画","http://www.bengou.com","");

}
}
function sethomepage()
{
if (document.all)
{
	document.body.style.behavior='url(#default#homepage)';
	document.body.sethomePage('http://www.bengou.com/');
} else if (window.sidebar) {
	if(window.netscape)
	{
		try
		{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}
		catch (e)
		{
			alert("Firefox暂无此功能，请手动设置。" );
		}
	}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage','http://www.bengou.com/');
	  alert("设置http://www.bengou.com为浏览器首页成功");
}
}

function getCookieValue(varname)
{
	if(varname)
	{
		var a=document.cookie.indexOf(varname+"=");
		if(a!=-1)
		{
			return document.cookie.substring((a+varname.length+1),document.cookie.length).split(";")[0];
		}
		else
		{
			return "";
		}
	}
}
			
function showLogin()
{
	document.getElementById("imgDiv").style.display = "none";
	document.getElementById('fomlogin').style.display='block';
	document.getElementById("other_nav").onmouseover = null;
	document.getElementById("other_nav").onmouseout = null;
	
}

function showContent()
{
	if(mid =="")
	{
		document.getElementById("login_cont").style.display="none";
		
		document.getElementById("flogin").style.display="block";
		
		//document.getElementById("username").focus();
	}
}

function hideContent()
{
	if(mid=="")
	{
		document.getElementById("login_cont").style.display="block";
		document.getElementById("flogin").style.display="none";
	}
}
function shareBookShelf(){
	board=window.document.location.href;
	window.clipboardData.setData("Text",board);
	alert("复制成功，Ctrl+V 黏贴到QQ上告诉你的好友们吧~");
}
function logins(){
	var username = document.getElementById("username");
	var urls = window.location.href;
	document.getElementById('url').value = urls;
	document.getElementById('fomlogin').submit();
}
function loginout(){
	var url = window.location.href;
	window.location.href = "http://www.bengou.com/shelf/logout.jsp?url="+url+"";
}

function hongkong(){
	alert("港台漫画栏目暂时关闭，整理数据，请留意开放时间。给您带来不便，敬请原谅！");
}

function ltrim(s)
{   
	return s.replace(/(^\s*)/g, "");
} 

function rtrim(s)
{ 
  return s.replace(/(\s*$)/g, "");
}
function indexsearch(){
	var searchstr = document.getElementById("txtSearch");
	if(rtrim(ltrim(searchstr.value))==''){
		alert("请输入查询条件!");
		searchstr.focus();
		return;
	}
	
	var str = escape(searchstr.value);
	var strtype="";
	var obj = document.getElementById("searchtype");
	var option = obj.options;
	for(i=0;i<option.length;i++)
	{
		if(option[i].selected)
		strtype=option[i].value;
	}
	location.href="http://www.bengou.com/Result?searchstr="+str+"&searchtype="+strtype+"";
}
function changefocus(id,e)
{
	var e = e?e:window.event;
	var kcode = e.keyCode;
 	var pages = document.getElementById(id);
 	var thePath = document.getElementById("thePath");
	var maxPage = document.getElementById("maxPage");
 	if (kcode==13)
 	{
 		if(Number(pages.value)>Number(maxPage.value)){
			alert('页数大于最大页！');
			return;
		}
 		var url = thePath.value+pages.value+'.html';
 		window.location.href= url;
 	}
}
function share(){
		board=window.document.location.href;
 		copyToClipboard(board);
}

function copyToClipboard(txt) {   
    if(window.clipboardData) {   
              window.clipboardData.clearData();   
              window.clipboardData.setData("Text", txt);   
              AG("地址复制成功，请直接粘贴(Ctrl＋V)发送给您的好友。");
      } else if(navigator.userAgent.indexOf("Opera") != -1) {   
           window.location = txt;   
      } else if (window.netscape) {   
           try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
           } catch (e) {   
                AG("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");   
           }   
           var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);   
           if (!clip)   
                return;   
           var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);   
           if (!trans)   
                return;   
           trans.addDataFlavor('text/unicode');   
           var str = new Object();   
           var len = new Object();   
           var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);   
           var copytext = txt;   
           str.data = copytext;   
           trans.setTransferData("text/unicode",str,copytext.length*2);   
           var clipid = Components.interfaces.nsIClipboard;   
           if (!clip)   
                return false;   
           clip.setData(trans,null,clipid.kGlobalClipboard);
           AG("地址复制成功，请直接粘贴(Ctrl＋V)发送给您的好友。");
      }
	}
