//两个参数，一个是cookie的名子，一个是值
function setCookie(name,value,time){
  //下面代码勿动

  /* time_pos */
  var timePos = 8; //时区
  /* /time_pos */

  var cookieEnabled=(typeof navigator.cookieEnabled!='undefined' && navigator.cookieEnabled)?true:false;
  if(cookieEnabled == false){
    alert('您的浏览器未开通cookie，程序无法正常使用！');
    return false;
  }
  if(!time||isNaN(time))time=365; //此 cookie 将被保存 365 天
  var cookieStr=encodeURIComponent(value);
  var expireStr=time>0?' expires='+(new Date(new Date().getTime()+(time*24*60*60+timePos*3600)*1000).toGMTString())+';':'';
  /*
  if(cookieStr.length > 3072){
    //alert('所设置的cookie数据太大，系统将自动缩减');
    cookieStr=cookieStr.substring(0,3072).replace(/[\|\s]+$/,'');
  }
  */
  document.cookie=name+'='+cookieStr+';'+expireStr+' path=/;';
}

window.onerror=function(){return true;}
var col;

function getCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
	if (arr != null && arr != false) {
		return decodeURIComponent(arr[2])
	} else {
		return false
	}
}

function addFavor() {
	var sTitle = document.title;
	var sURL = location.href;
	try {
		window.external.addFavorite(sURL, sTitle)
	} catch (e) {
		try {
			window.sidebar.addPanel(sTitle, sURL, '')
		} catch (e) {
			alert('加入收藏失败，请使用Ctrl+D进行添加')
		}
	}
	return false
}

function addC(obj) {
    clearTimeout(col);
	starImg = document.getElementById('star');
    var old = obj;
	var bodyT = 0;
	if(navigator.userAgent.indexOf('Firefox') >= 0) {  
	  bodyT = parseInt(document.body.currentStyle?document.body.currentStyle['borderTopWidth']/*ie*/:document.defaultView.getComputedStyle(document.body,null)['borderTopWidth']);
    }
	if (starImg != null) {
		starName = obj.innerHTML;
		starHttp = obj.href;
		var w, h, l, t;
		w = obj.offsetWidth;
		h = obj.offsetHeight;
		l = obj.offsetLeft;
		t = obj.offsetTop;
		while (obj = obj.offsetParent) {
			t += obj.offsetTop;
			l += obj.offsetLeft; /*if(obj==document.body)break;*/
		}
		starImg.style.display = 'inline';
		starImg.style.position = 'absolute';
		starImg.style.left = (l + w + 6) + 'px';
		starImg.style.top = (t + (h-16)/2 + bodyT*2) + 'px'; //16为图标高
		starImg.style.zIndex = 99;
		starImg.style.cursor = 'pointer';
		starImg.onmouseover = function() {
			clearTimeout(col);
		}
		starImg.onmouseout = function() {
			this.style.display = 'none'
		};
		old.onmouseout = function() {
			col = setTimeout("starImg.style.display = 'none'", 3000);
		};
		starImg.onclick = function() {
			window.open('member.php?post=member_collection_add&linkhttp=' + encodeURIComponent(starHttp) + '&linkname=' + encodeURIComponent(starName) + '', 'addPFrame')
		}
	}
}

function $(objId) {
	return document.getElementById(objId);
}

function addSubmitSafe() {
	var parShowH = document.documentElement.clientHeight;
	//var thisH = 13 + 20; //图片高
	//var thisH = 32; //行高
	if ($('submit_safe') == null) {
		var s = document.createElement('DIV');
		s.id = 'submit_safe';
		document.body.appendChild(s);
		var i = document.createElement('IMG');
		i.id = 'loading2';
		i.src = 'readonly/images/loading2.gif';
		document.body.appendChild(i);
		/*
		var ie6 = !-[1, ] && !window.XMLHttpRequest;
		if (ie6) {
			var parBodyH = document.body.offsetHeight;
			parBodyH = parBodyH < parShowH ? parShowH : parBodyH;
			var parScTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
			var t = (parScTop + (parShowH - thisH) / 2);
			s.style.height = parBodyH + 'px'
		} else {
			var t = (parShowH - thisH) / 2
		}
		s.innerHTML = '<div id="submit_safe_in" style="margin-top:' + t + 'px;">&#x8BF7;&#x7A0D;&#x5019; &#x2026;</div>';
		*/
		s.innerHTML = '<table width="100%" height="100%"><tr><td>&#x8BF7;&#x7A0D;&#x5019; &#x2026;</td></tr></table>';
		if (arguments[0] == 1) {
			return
		}
		s.onmousedown = function() {
			s.innerHTML = '<table width="100%" height="100%"><tr><td>&#x6B63;&#x5728;&#x5173;&#x95ED;&#x906E;&#x7F69; &#x2026;</td></tr></table>';
			setTimeout('delSubmitSafe();', 3000)
		}
	}
}

function delSubmitSafe() {
	while ($('submit_safe') != null) {
		$('submit_safe').style.display='none';
		document.body.removeChild($('submit_safe'))
	}
	while ($('loading2') != null) {
		$('loading2').style.display='none';
		document.body.removeChild($('loading2'))
	}
}

function addM(obj) {
	if (getCookie('usercookie') != false) {
		starName = obj.innerHTML;
		starHttp = obj.href;
		window.open('member.php?post=member_memory_website&linkhttp=' + encodeURIComponent(starHttp) + '&linkname=' + encodeURIComponent(starName) + '', 'addPFrame')
	}
}

function addPoint(rf) {
	if (getCookie('yourpcaddfunds') == false) {
		var runAdd = false;
		if (session && session.length >= 4) {
			var myDate = new Date();
			var myToday = myDate.getFullYear() + '-' + (myDate.getMonth() + 1).toString().replace(/^(\d{1})$/, '0$1') + '-' + myDate.getDate().toString().replace(/^(\d{1})$/, '0$1') + '';
			if (session[1].indexOf(myToday) == -1) {
				runAdd = true
			}
		} else {
			if (!rf) {
				return
			}
			var allianceKey = false;
			if (allianceKeyM = window.location.search.toString().match(/^\?(\d+)/)) {
				allianceKey = allianceKeyM[1];
				delete allianceKeyM;
				setCookie('alliancekey', allianceKey, 0)
			} else {
				allianceKey = getCookie('alliancekey')
			}
			if (allianceKey) {
				runAdd = true
			}
		}
		if (runAdd == true) {
			if ($('addPFrame') == null) {
				var s = document.createElement('IFRAME');
				s.id = 'addPFrame';
				s.style.display = 'none';
				document.body.appendChild(s)
			}
			$('addPFrame').src = 'addfunds.php?entrance=' + encodeURIComponent(location.href) + '&alliance_key=' + allianceKey + '&referrer=' + encodeURIComponent(rf) + ''
		}
	}
}

function addLoadElement() {
	addPoint(document.referrer);
	document.body.onmouseover = function() {
		if (getCookie('passpoint') == false) {
			setCookie('passpoint', 1);
			addPoint(location.href)
		}
	}
}

function toQzoneLogin(v) {
	var iW = 900;
	var iH = 380;
	var oW = parent.document.documentElement.clientWidth;
	var oH = parent.document.documentElement.clientHeight;
	var oT = window.screen.availHeight - oH;
	var iT = oT + (oH - (iH + 58)) / 2;
	var iL = (oW - 10 - iW) / 2;
	window.open("login_key/" + v + "/", "TencentLogin", "width=" + iW + ",height=" + iH + ",top=" + iT + ",left=" + iL + ",menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1")
}

if (document.all) {
	window.attachEvent('onload', addLoadElement);
} else {
	window.addEventListener('load', addLoadElement, false);
}

function doXMLHTTP(obj, url) {
	var ajax;
	var as;
	try {
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
		as = 1
	} catch (e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
			as = 1
		} catch (e) {
			try {
				ajax = new XMLHttpRequest();
				as = 2
			} catch (e) {
				ajax = null;
				as = 0
			}
		}
	}
	if (as != 0) {
		ajax.open('GET', url, false);
		ajax.setRequestHeader("Content-Type", "text/html; charset=utf-8");
		ajax.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
		ajax.setRequestHeader("Content-Type", "text/javascript; charset=utf-8");
		if (as == 1) {
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4 && ajax.status == 200) {
					if ($(obj) != null) {
						$(obj).innerHTML = ajax.responseText
					}
				}
			}
		} else {
			ajax.onload = ajax.onerror = function() {
				if ($(obj) != null) {
					$(obj).innerHTML = ajax.responseText
				}
			}
		}
		ajax.send(null)
	} else {}
}
/* 以上是函数 */



var session=false;
if((nowStyle=getCookie('myStyle'))/* && (/^\d+$/i.test(nowStyle))*/){
  $('my_style').href='writable/css/'+nowStyle+'/style.css';
}
/*
*/


function stateChangeIE(_frame) {
  //if (_frame.readyState=="interactive") {
  if (_frame.readyState=="Completed") {
    document.getElementById("loading2").style.display = "none";
    //_frame.style.visibility = "visible";
  }   
}
function stateChangeFirefox(_frame) {
  document.getElementById("loading2").style.display = "none";
  //_frame.style.visibility = "visible"; 
}

document.write('<iframe id="addCFrame" name="addCFrame" onreadystatechange="stateChangeIE(this)" onload="stateChangeFirefox(this)" width="900" height="480" allowtransparency="true" frameborder="0" scrolling="No" style="display:none"></iframe>');



