﻿// JavaScript Document
// 中文
String.prototype.toNum=function(){
	var n=this.match(/\d+/,"")
	if(n) return parseInt(n)
	else return 0
}
String.prototype.toDate=function(){
	var d=this.split(/\D+/)
	--d[1]
	return new Date(d[0],d[1],d[2],d[3],d[4],d[5])
}
String.prototype.toHTML=function(){
	return this.replace(/&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/"/g,"&quot;").replace(/\r\n|\r|\n/g,"<br/>").replace(/[\s\xa0]/g,"&nbsp;")
}
String.prototype.toAttribute=function(){
	return this.replace(/&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/"/g,"&quot;").replace(/\r\n|\r|\n/g,"&#13;&#10;").replace(/[\s\xa0]/g,"&nbsp;")
}
String.prototype.toURL=function(){
	return encodeURIComponent(this)
}
Date.prototype.toString=function(){
	return String(this.getFullYear()+"-0"+(this.getMonth()+1)+"-0"+this.getDate()+" 0"+this.getHours()+":0"+this.getMinutes()+":0"+this.getSeconds()).replace(/(\D)0(\d{2})/g,"$1$2")
}
var $=function(id){return document.getElementById(id)}
//========================================================================================= Cookie
var Cookie={}
Cookie.set=function(key, value, expires){
	var root = ""
	var base = ""
	var newCookie=""
	if(!value){
		value = ""
		expires = "1986-7-21 00:00:00"
	}
	if(key.indexOf(".")!=-1){
		var rootName=key.substr(0,key.indexOf("."))
		var subName =key.substr(key.indexOf(".")+1)
		root = Cookie.__getRecursion(document.cookie, rootName, 0)
		if(root){
			root = String(root).split("&")
			for(i=0;i <root.length; i++){
				var cName = root[i].substr(0, root[i].indexOf("="))
				var cValue = root[i].substr(root[i].indexOf("=")+1)
				if (cName != subName){
					base += cName + "=" + encodeURIComponent(cValue) + "&"
				}
			}
		}else{
			base = ""	
		}
		newCookie = rootName + "=" + base + subName + "=" + encodeURIComponent(value)
	}else{
		newCookie = key + "=" + encodeURIComponent(value)
	}
 	if(typeof expires == "string")expires=expires.toDate()
	if(expires)expires = "; expires=" + expires.toGMTString()
	else expires=""
	document.cookie = newCookie + expires + "; domain=.qqbiji.com; path=/"
}
Cookie.get=function(key){
	return Cookie.__getRecursion(document.cookie, key, 0)
}
Cookie.__getRecursion=function(string, key, level){ //获取Cookie递归函数
	key = key.split(".")
	if(level==0){
		string = string.split(";")
	}else{
		string = string.split("&")
	}
	for(var i=0;i<string.length;i++){
		var cName = string[i].substr(0, string[i].indexOf("=")).replace(/\s/,"")
		var cValue = string[i].substr(string[i].indexOf("=") + 1)
		if(cName == key[level]){
			if(!key[level+1]){
				return String(decodeURIComponent(cValue.replace(/\+/g," ")))
			}else{
				return Cookie.__getRecursion(cValue, key.join("."), level+1)
			}
		}
	}
	return
}
Cookie.alert=function(){alert(document.cookie)}
//========================================================================================= Cookie End

var writeLogin=function(){
	if(Cookie.get("ddLogin.ddNickName")){
		$("divLogin").innerHTML='欢迎回来, '+Cookie.get("ddLogin.ddNickName").toHTML()+'!<br /><a href="/user/'+Cookie.get("ddLogin.ddUserName").toURL()+'">我的QQ笔记主页</a> <a href="/my/">我的个人中心</a> <a href="/do/do.asp?action=logout">退出</a>'
	}else{
		$("divLogin").innerHTML='<a href="/login/">登陆QQ笔记</a> <a href="/register/" class="registerLink">注册成为QQ笔记会员</a>'
	}
}

function resizePicture(object ,maxWidth, maxHeight){
	var img=new Image()
	img.src=object.src
	var width=img.width
	var height=img.height
	if(width <= maxWidth && height <= maxHeight) {
		object.width=width
		object.height=height
		object.style.visibility=''
		return true
	}
	var scale=Math.min(width>maxWidth?maxWidth/width:1,height>maxHeight?maxHeight/height:1)
	
	object.width = width * scale
	object.height = height * scale
	object.style.visibility=''
	return true
}

function doSearch(form){
	if($("searchKey").value=="请输入关键字" || !$("searchKey").value){
		$("searchKey").focus()
		$("searchKey").select()
		return false
	}
	window.open(Math.random()>.5?("http://www.google.cn/search?hl=zh-CN&newwindow=1&q=site%3Aqqbiji.com+"+$("searchKey").value.toURL()+"&aq=f"):("http://www.baidu.com/s?ie=utf-8&cl=3&f=8&tn=baidu&wd=site%3Aqqbiji.com+"+$("searchKey").value.toURL()+"&ct=0"))
	return false
}
function writeSearch(){
	//document.write('<iframe id="baiduframe" marginwidth="0" marginheight="0" scrolling="no" framespacing="0" vspace="0" hspace="0" frameborder="0" width="400" height="60" src="http://unstat.baidu.com/bdun.bsc?tn=1000ys_pg&cv=0&cid=1117032&csid=106&bgcr=transparent%7Dinput%2Cselect%7Bborder-style%3A%20solid%3B%20border%3A%201px%20solid%20%23CCCCCC%3B%20font%3A%209pt%20%27Trebuchet%20MS%27%3B%20vertical-align%3A%20middle%3Bcolor%3A%233DA0BC%3B%20margin-right%3A%205px%3B%20height%3A%2026px%3B%20background%3A%20%23FFFFFF%3B%20%7D.sb%7B%20background%3A%20%233CA9BF%3B%20color%3A%20%23FFF%3B%20border%3A%201px%20outset%20%233CA9BF%3B%20cursor%3A%20pointer%3B%20line-height%3A%2022px%3B%20height%3A%2025px%21Important%3B%20position%3A%20relative%3B%20left%3A%20-8px%3B &ftcr=000000&urlcr=3DA0BC;display:none&tbsz=200&sropls=2,5,6,7,9,99&insiteurl=www.qqbiji.com&kwgp=0" allowtransparency="true"></iframe>')
	document.write('<form onsubmit="return doSearch(this)"><input type="text" class="input" id="searchKey" value="请输入关键字" size="30" onmousedown="if(this.value==\'请输入关键字\'){this.value=\'\'}" onblur="if(!this.value){this.value=\'请输入关键字\'}"/> <input type="submit" value=" 搜索 " id="searchButton"/></form>')
}

function writeFooter(){
	document.write('<script src="/js/tongji.js" type="text/javascript"></script>')
}


function contactQQ(sigKey){
	var ifr=$("contactQQIframe")
	if(!ifr){
		ifr=document.createElement("IFRAME")
		ifr.style.display="none"
		ifr.id="contactQQIframe"
		document.body.appendChild(ifr)
	}
	ifr.src="http://sighttp.qq.com/cgi-bin/check?sigkey="+sigKey
}


document.writeln("<script src=\"http:\/\/s87.cnzz.com\/stat.php?id=2004703&web_id=2004703\" language=\"JavaScript\"><\/script>");
document.writeln("")