﻿// JavaScript Document
(function(ns){
	ns.Browser={
		IE:     !!(window.attachEvent &&
						  navigator.userAgent.indexOf('Opera') === -1),
						Opera:  navigator.userAgent.indexOf('Opera') > -1,
						WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
						Gecko:  navigator.userAgent.indexOf('Gecko') > -1 &&
						  navigator.userAgent.indexOf('KHTML') === -1,
						MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/),
						Width: function(){
									var bodyCW; 
									if(window.innerWidth){
										bodyCW=window.innerWidth;
									}
									else if(document.documentElement&&document.documentElement.clientWidth){ 
										bodyCW=document.documentElement.clientWidth;
									}else if(document.body){
										bodyCW=document.body.clientWidth; 
									}
									return bodyCW;
						},
						Height: function(){
									var bodyCH;
									if(window.innerHeight){
										bodyCH=window.innerHeight;
									}else if(document.documentElement&&document.documentElement.clientHeight){ 
										bodyCH=document.documentElement.clientHeight; 
									}else if(document.body){
										bodyCH=document.body.clientHeight;
									}
									return bodyCH;
						}
	}
})(window);


function $(ElementId){
	if(!document.getElementById(ElementId))  return null;
	return document.getElementById(ElementId);
}
String.prototype.trim = function(){
	return this.replace(/(^[ \s]+)|([ \s]+$)/g, "");
}
String.prototype.leftTrim = function(){
	return this.replace(/^[ \s]+/, "");
}
String.prototype.rightTrim = function(){
	return this.replace(/[ \s]+$/, "");
}

function GetAjax(o, RequestText, Url, PostData){
	var AjaxObj=new XMLHttpRequest();
	var ReturnStr="";
	if(AjaxObj){
		AjaxObj.onreadystatechange = function(){
  	  		if (AjaxObj.readyState == 4) { // Complete
      			if (AjaxObj.status == 200) { // OK response		
       				ReturnStr=unescape(AjaxObj.responseText);
      			} else {
        			ReturnStr="Problem with server response:" + AjaxObj.statusText;
      			}
    		}else {
				if(RequestText!=null){
					o.innerHTML=RequestText;
				}
			}
		}
		if(PostData!=null){
      		AjaxObj.open("POST", Url, false); //was post
			AjaxObj.setRequestHeader("Content-Length",PostData.length);   
			AjaxObj.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded"); 
      		AjaxObj.send(PostData);
		}else{
      		AjaxObj.open("Get", Url, false); //was post
      		AjaxObj.send(null);
		}
	}else{
		ReturnStr="抱歉，系统错误"
	}
	return ReturnStr;
}

function SetCookie(Name, value, hour){
	var expdate = new Date();
	expdate.setTime(expdate.getTime() +  hour * 3600 * 1000);
	document.cookie = Name +"="+ value + "; expires=" + expdate.toGMTString() + "; path=/";
}

function GetCookieValue(Name){
	var cookieStr=document.cookie;
	if(cookieStr=="") return null;
	var Index=cookieStr.indexOf(Name +"=");
	if(Index!=-1){
		cookieStr=cookieStr.substr(Index+ (Name +"=").length);
		cookieStr=cookieStr.split(";")[0];
		return cookieStr;
	}else{
		return null;
	}
}


function deleteCookie(name) { 
	var expdate = new Date(); 
	expdate.setTime(expdate.getTime() - (86400 * 1000 * 1)); 
	document.cookie = name + "=; expires=" + expdate.toGMTString() + "; path=/"; 
} 


var statusStr="【七仙女】非官方纪念站欢迎您的光临！！|七仙女系列专辑正在陆续添加中，请耐心等待|本站各项功能正在完善中|如果您知道有关【七仙女】一切相关信息，请您在本站留言告知|如果您有任何问题或者建议，请在本站留言|【七仙女】非官方纪念站谢谢您的支持|愿您平安、健康、幸福|再次谢谢您的支持 www.on-cn.cn";
function SetWinstatus(){
	var ArrStatus=statusStr.split("|");
	var statusTimes=GetCookieValue("statusTimes");
	if(statusTimes==null) statusTimes=0;
	statusTimes=parseInt(statusTimes);
	if(statusTimes>=ArrStatus.length)statusTimes=0;
	window.status=ArrStatus[statusTimes];
	SetCookie("statusTimes", statusTimes + 1, 24);
	window.setTimeout("SetWinstatus()",4000);
}
SetWinstatus();
function Error(){
	alert("此功能正在开发中\n\n本站谢谢您的支持");
	return false;
}



function copycode(Msg, obj) {
	var rng = document.body.createTextRange();
	rng.moveToElementText(obj);
	rng.scrollIntoView();
	rng.select();
	rng.execCommand("Copy");
	rng.collapse(false);
	if(Msg!=""&&Msg!=null) alert(Msg);
}

function GetMsg(MsgType, classid, Curpage, ObjContent){
	var ObjDiv=eval("document.getElementById('"+ObjContent+"')");
	ObjDiv.innerHTML="<div align=\"center\"><img src=\"images/loading.gif\" align=\"absmiddle\"/>评论正在载入中</div>";
	
	if (window.ActiveXObject){
		var xmlDom=new ActiveXObject("Microsoft.XMLDOM");
	}else{
		if (document.implementation&&document.implementation.createDocument){
			var xmlDom=document.implementation.createDocument("","msg",null);
		}
	}
	xmlDom.async = false;
	xmlDom.preserveWhiteSpace=false;
	xmlDom.load("XmlMessage.asp?MsgType="+ MsgType +"&classid="+ classid +"&Curpage="+ Curpage);
	var msgHeader=xmlDom.documentElement.childNodes[0];
	var count=parseInt(msgHeader.attributes.getNamedItem("count").nodeValue);
	if(count==0){ObjDiv.innerHTML="";return false;}
	var Msgs=xmlDom.documentElement.childNodes[1].childNodes;
	var InnerStr="";
	for(var i=0; i<Msgs.length; i++){
		InnerStr+="<div class=\"CommentBox\">";
		InnerStr+="<div class=\"writerImg\"><img src=\"images/Nophoto.jpg\" width=\"94\" height=\"64\"/></div>";
		InnerStr+="<div class=\"CommentTitle\">";
		InnerStr+="<a href=\"JavaScript:Error();void(0)\" >"+ Msgs[i].attributes.getNamedItem("userName").nodeValue +"</a>";
		InnerStr+="<span>"+ Msgs[i].attributes.getNamedItem("addTime").nodeValue +"</span>";
		InnerStr+="</div>";
		
		InnerStr+="<div class=\"CommentContent\">"+ Msgs[i].text +"</div>";
		InnerStr+="</div>";
	}
	var PageTotal=parseInt(msgHeader.attributes.getNamedItem("pagetotal").nodeValue);
	InnerStr+=GetShowPage(MsgType, classid, ObjContent, Curpage, PageTotal, count);
	ObjDiv.innerHTML=InnerStr;
	
}

function GetShowPage(MsgType, classid, ObjContent, CurPage, PageTotal, Total){
	if(CurPage>PageTotal)CurPage=pageTotal;
	var ShowPageStr="<div class=\"p_bar\">";
	ShowPageStr+="<a class=\"p_total\">&nbsp;"+ Total +"&nbsp;</a><a class=\"p_pages\">&nbsp;"+ CurPage +"\/"+ PageTotal +"&nbsp;</a>";
	if(CurPage>=4)ShowPageStr+="<a href=\"Javascript:GetMsg("+ MsgType +","+ classid +", 1,'"+ ObjContent +"');void(0)\" class=\"p_redirect\">&lsaquo;&lsaquo;</a>";
	if(CurPage >=2)ShowPageStr+="<a href=\"Javascript:GetMsg("+ MsgType +","+ classid +", "+ (CurPage - 1) +",'"+ ObjContent +"');void(0)\"  class=\"p_redirect\">&lsaquo;</a>";
	var ThePagePosition=parseInt(CurPage / 10); 
	var PageStart=ThePagePosition * 10 + 1;
	var PageEnd=ThePagePosition * 10 + 10;
	if(PageEnd > PageTotal)PageEnd=(ThePagePosition * 10) + (PageTotal % 10);
	if((CurPage % 10 < 5)&&(CurPage >=10)){
		PageStart = PageStart - 3
		if(PageTotal - PageEnd > 3) PageEnd = PageEnd - 3;
	}
	for(var a_=PageStart; a_<=PageEnd; a_++){
		ShowPageStr+="<a ";
		if(a_==CurPage){
			ShowPageStr+="class=\"p_curpage\" ";
		}else{
			ShowPageStr+="href=\"Javascript:GetMsg("+ MsgType +","+ classid +", "+ a_ +",'"+ ObjContent +"');void(0)\" class=\"p_num\" ";
		}
		ShowPageStr+=">"+ a_ +"</a>";
	}
	if((CurPage!=PageTotal)&&(CurPage >= 4))ShowPageStr+="<a href=\"Javascript:GetMsg("+ MsgType +","+ classid +", "+ (CurPage + 1) +",'"+ ObjContent +"');void(0)\"  class=\"p_redirect\">&rsaquo;</a>";
	if((CurPage<PageTotal)&&((PageTotal - CurPage) >=4))ShowPageStr+="<a href=\"Javascript:GetMsg("+ MsgType +","+ classid +", "+ PageTotal +",'"+ ObjContent +"');void(0)\"  class=\"p_redirect\">&rsaquo;&rsaquo;</a>"
	ShowPageStr+="</div>";
	return ShowPageStr;
}

	
/*
	
	
	ShowPageStr=ShowPageStr& "<a class=""p_pages"" style=""padding: 0px""><input class=""p_input"" type=""text"" name=""custompage"" onKeyDown=""if(event.keyCode==13) {window.location='"& PagePath &"CurPage='+this.value; return false;}""></a>"
	ShowPage=ShowPageStr &"</div>"			
End Function

*/











/*
'	Set rs=Conn.execute("Select * from [message] where MsgType=4 and classid="& specialid &" and del=0 and check=1 order by id desc")
'		if not rs.eof then
'			do while not rs.eof
'				wtv("			<div class=""CommentBox"">")
'				wtv("				<div class=""writerImg""><img src=""images/Nophoto.jpg"" width=""94"" height=""64""/></div>")
'				wtv("				<div class=""CommentTitle""><a href=""JavaScript:Error();void(0)"" >"& rs("UserName") &"</a><span>"& rs("Add_time") &"</span></div>")
'				wtv("<div class=""CommentContent"">"& rs("Content") &"</div>")
'				wtv("			</div>")
'			rs.movenext
'			loop
'		end if
'	Set rs=nothing	
*/