﻿var baseUrl = "";

String.prototype.trim = function(){return this.replace(/(^[ |　]*)|([ |　]*$)/g, "");}
function $(s){return document.getElementById(s);}
function $$(s){return document.frames?document.frames[s]:$(s).contentWindow;}
function $c(s){return document.createElement(s);}
function swap(s,a,b,c){$(s)[a]=$(s)[a]==b?c:b;}
function exist(s){return $(s)!=null;}
function dw(s){document.write(s);}
function hide(s){$(s).style.display=$(s).style.display=="none"?"":"none";}
function isNull(_sVal){return (_sVal == "" || _sVal == null || _sVal == "undefined");}
function removeNode(s){if(exist(s)){$(s).innerHTML = '';$(s).removeNode?$(s).removeNode():$(s).parentNode.removeChild($(s));}}
function getStyleCss(_sId, _sCss){var oObj = document.getElementById(_sId);return oObj.currentStyle ? oObj.currentStyle[_sCss] : window.getComputedStyle(oObj, "")[_sCss];}
function setHome(){try{window.external.AddFavorite(window.document.location,window.document.title)}catch(e){};}
function hideList(_sId,_sStr,_iBegin,_iEnd,_sShow){for(var i = _iBegin; i <= _iEnd; i++)if(exist(_sId + i)){$(_sId + i).style.display = _sStr;_sStr == 'none' ? $(_sShow + i).className = 'down' : $(_sShow + i).className = 'up'}}
function getAnchor(_sStr){_sStr = _sStr ? _sStr : '#' ;var sUrl=document.location.href;return sUrl.indexOf(_sStr) != -1 ? sUrl.substr(sUrl.lastIndexOf(_sStr) + 1) : null;}
function read(_sUid,_sDate){get( baseUrl + '/sns/service.aspx?m=aListByDate&uid=' + _sUid + '&date=' + _sDate, baseUrl + '/xsl/feeds.xsl','feeds','output','box_2');}
function commentSubmit(_sVid){$("src_title" + _sVid).value = $("commentText" + _sVid).innerHTML;$("src_uname" + _sVid).value = AUTHOR;$('form' + _sVid).submit();}
function output(_sHtml, _box){var oOutput = typeof(_box) == "object" ? _box : $(_box);oOutput.innerHTML = _sHtml;}
function setCopy(_sTxt){try{clipboardData.setData('Text',_sTxt)}catch(e){}}
function isIE(){return BROWSER.indexOf('ie') > -1;}
function openWindow(_sUrl, _sWidth, _sHeight, _sTitle, _sScroll){var oEdit = new dialog();oEdit.init();oEdit.set('title', _sTitle ? _sTitle : "系统提示信息" );oEdit.set('width', _sWidth);oEdit.set('height', _sHeight);oEdit.open(_sUrl, _sScroll ? 'no' : 'yes');}
function initLoad(){if(BONLOADMARK){for(key in AONLOAD){eval(AONLOAD[key]);}}}
function vbbcode_winshow(c, p){	var i = p.style.display;c.innerHTML	= c.innerHTML == "&lt;&lt;&nbsp;" ? "&gt;&gt;&nbsp;" : "&lt;&lt;&nbsp;"; p.style.display = (i == "") ? "none" : "";}
function onfocus(s){var _sStr; if(exist(s)){_sStr=$(s).value;}else{return;}$(s).focus();if(_sStr!=""){$(s).select();}}
function dwSwf(_sName, _sSrc, _sWidth, _sHeight, _sMode, _aValue){
	var sValue = '';
	var aFlashVars = [];
	if(_aValue){
		for(key in _aValue){
			aFlashVars[aFlashVars.length] = key + "=" + _aValue[key];
		}
		sValue = aFlashVars.join('&');
	}
	_sMode = _sMode ? 'wmode="transparent"' : '';
	return '<embed id="' + _sName + '" name="' + _sName + '" src="' + _sSrc + '" ' + _sMode + ' quality="high" align="top" salign="lt" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + _sWidth + '" height="' + _sHeight + '" flashVars="' + sValue + '"></embed>';
}
function initSendTime(){
	SENDTIME = new Date();
}
function getSend(){
	var sCurrTime = Math.floor((new Date() - SENDTIME)/1000);
	return sCurrTime < 0 ? 20 : sCurrTime;
}
function resizeImg(_oObj, _iWidth){
	var tMark = true;var iWidth = 0;var sOuterHtml;var aNode = _oObj.attributes;
	for(var i = 0; i < aNode.length; i++){if(aNode[i].specified){if(aNode[i].name == "width" || aNode[i].name == "height"){tMark = false;}}}
	if(tMark){
		if(_iWidth){
			if(_oObj.width > _iWidth){
				_oObj.width = _iWidth;
			}
		}
	}
}
function showCount(){
	try{
		show=VISITCOUNT;
		if(Math.abs(show) > 0){
			for(i = show.length; i < 5; i++){show = "0" + show;}
			for(i = 0; i < show.length; i++){
				document.write("<img alt='" + show.substr(i,1) + "' title='" + VISITCOUNT + "' src='/images/counter/" + COUNTTHEME + "/" + show.substr(i,1) + ".gif'/>");
			}
		}
	}
	catch(e){}
}
function handleKeyDown(eEvent){
	var oParent = eEvent.target ? eEvent.target : event.srcElement;
	if(eEvent.keyCode == 9){
		if(eEvent.target){
			var oStart = oParent.selectionStart;
			var oPos = oParent.selectionEnd;
			var sStart = oParent.value.slice(0, oStart);
			var sEnd = oParent.value.slice(oPos);
			oParent.value = sStart + String.fromCharCode(9) + sEnd;
			setTimeout(function(){oParent.focus()}, 200);
			oParent.selectionEnd = oPos + 1;
		}else{
			oParent.selection = document.selection.createRange();
			oParent.selection.text = String.fromCharCode(9);
			eEvent.returnValue = false;
		}
	}
}
function browserDetect(){
	var sUA = navigator.userAgent.toLowerCase();
	var sIE = sUA.indexOf("msie");
	var sOpera = sUA.indexOf("opera");
	var sMoz = sUA.indexOf("gecko");
	if (sOpera != -1) return "opera";
	if (sIE != -1){
		nIeVer = parseFloat(sUA.substr(sIE + 5));
		if (nIeVer >= 6) return "ie6";
		else if (nIeVer >= 5.5) return "ie55";
		else if (nIeVer >= 5 ) return "ie5";
	}
	if (sMoz != -1)	return "moz";
	return "other";
}
var BROWSER = browserDetect();
document.write("<script type='text/javascript' src='" + baseUrl + "/library/script/" + BROWSER + ".js'></script>");
var CACHE = {"outline":[]};
var CONFIG = {"readfile":""};
var AONLOAD = [];
var SENDTIME = new Date("2005","9","8","10","0","0");
var BONLOADMARK = true;

function commentSubmit(_sVid){
	var enableAuthenCode = $('form' + _sVid)['checkwd'];
	var sHomePage = $('form' + _sVid)['homepage'].value.trim();
	var sLoginName = $('form' + _sVid)['loginname'].value.trim();
	if(enableAuthenCode)
		var sCheckWd = $('form' + _sVid)['checkwd'].value.trim();
	var sContent = $('form' + _sVid)['content'].value.trim();
	var sDialog = new dialog();
	sDialog.init();
	if(getSend()<10){
		sDialog.event('请勿在短时间内多次发送信息 :)<br/> 您需要耐心等待 ' + (10 - getSend()) + ' 秒，就可以发表评论了.','');
		sDialog.button('dialogOk','void 0');
		$('dialogOk').focus();
		return false;
	}
	if(sLoginName == ''){
		sDialog.event('请输入您的昵称!','');
		sDialog.button('dialogOk','void 0');
		$('dialogOk').focus();
		return false;
	}
	
	if(sHomePage != '' && sHomePage.substr(0, 7) != 'http://' && sHomePage.length < 8){
		sDialog.event('请输入URL地址!','');
		sDialog.button('dialogOk','void 0');
		$('dialogOk').focus();
		return false;
	}
	
	if(enableAuthenCode){
		if(sCheckWd == ''){
			sDialog.event('请输入验证码!','');
			sDialog.button('dialogOk','void 0');
			$('dialogOk').focus();
			return false;
		}
	}
	
	if(sContent == ''){
		sDialog.event('请输入评论内容!','');
		sDialog.button('dialogOk','void 0');
		$('dialogOk').focus();
		return false;
	}
	initSendTime();
	//alert("commentText" + _sVid);
	//$("src_title" + _sVid).value = $("commentText" + _sVid).innerHTML;
	//$("src_uname" + _sVid).value = AUTHOR;
	$('form' + _sVid).submit();
}
function gbookSubmit(_sVid){
	var sCheckWd = $('form' + _sVid)['checkwd'].value;
	var sContent = $('form' + _sVid)['content'].value;

	var sDialog = new dialog();
	sDialog.init();
	if(getSend()<10){
		sDialog.event('请勿在短时间内多次发送信息 :)<br/> 您需要耐心等待 ' + (10 - getSend()) + ' 秒，就可以发表留言了.','');
		sDialog.button('dialogOk','void 0');
		$('dialogOk').focus();
		return false;
	}
	if(sCheckWd == ''){
		sDialog.event('请输入验证码!','');
		sDialog.button('dialogOk','void 0');
		$('dialogOk').focus();
		return false;
	}

	if(sContent == ''){
		sDialog.event('请输入留言内容!','');
		sDialog.button('dialogOk','void 0');
		$('dialogOk').focus();
		return false;
	}
	initSendTime();
	return true;
}
function getFrameNode(sNode){
	return document.frames ? document.frames[sNode] : document.getElementById(sNode).contentWindow;
}
function checkwd_reload(){
	if (document.getElementById("user_login_info")) {
		ob = getFrameNode("user_login_info").document.getElementById("chk_img");
	}
	else {
   		 ob = document.getElementById("chk_img");
	 }
	ob.src = baseUrl + '/library/validateimage.aspx?' + new Date();
}
function ResizeSWF(nWidth, nHeight) {
	var swf = $("music");
	var obj = $("musicFlash");
	swf.style.width = nWidth;
	swf.style.height = nHeight;
	obj.width = nWidth;
	obj.height = nHeight;
}
function LocalPlay(sString) {
	window.open(sString);
}
function openPic(sString) {
	window.open(sString);
}
//加载FLASH播放器
function FlashPlayer(url,width,height)
{
	if(width == null)
		width = 500;
	if(height == null)
		height = 400;

	document.write ('<div style="margin-top:20px;margin-bottom:20px;text-align:center">');
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
	document.write ('  <param name="movie" value="' + url + '">');
	document.write ('  <param name="quality" value="high">');
	document.write ('  <embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
	document.write ('</object>');
	document.write ('</div>');
}

function RealPlayer(url,width,height,autostart)
{
	document.write ('<div style="margin-top:20px;margin-bottom:20px;text-align:center">');
	document.write ('<OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=' + width + ' height=' + height + '>');
	document.write ('	<PARAM NAME=AUTOSTART VALUE=' + autostart + '>');
	document.write ('	<PARAM NAME=SRC VALUE=' + url + '>');
	document.write ('	<PARAM NAME=CONSOLE VALUE=Clip1>');
	document.write ('	<PARAM NAME=CONTROLS VALUE=imagewindow>');
	document.write ('	<PARAM NAME=AUTOSTART VALUE=true>');
	document.write ('</OBJECT>');
	document.write ('<br/>');
	document.write ('<OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=' + width + '>');
	document.write ('	<PARAM NAME=SRC VALUE=' + url + '>');
	document.write ('	<PARAM NAME=CONTROLS VALUE=controlpanel>');
	document.write ('	<PARAM NAME=CONSOLE VALUE=Clip1>');
	document.write ('</OBJECT>');
	document.write ('</div>');
}

function MediaPlayer(url,width,height,autostart)
{
	document.write ('<div style="margin-top:20px;margin-bottom:20px;text-align:center">');
	document.write ('<object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=' + width + ' height=' + height + '>');
	document.write ('	<param name=AUTOSTART value=' + autostart + '>');
	document.write ('	<param name=ShowStatusBar value=-1>');
	document.write ('	<param name=Filename value=' + url + '>');
	document.write ('	<embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src=' + url + ' width=' + width + ' height=' + height + '></embed>');
	document.write ('</object>');
	document.write ('</div>');
}
document.write("<script type='text/javascript' src='" + baseUrl + "/library/script/prototype.js'></script>");

/* url */
var URL = {
	getParameter: function(parameter, url){
		var result = url.match(new RegExp("[\\#|\\?]"));
		var queryString = "&" + (isNull(result) ? url : url.substr(result.index+1));	
		result = queryString.match(new RegExp("&"+parameter+"=", "i"));
		return isNull(result) ? "" : queryString.substr(result.index+1).split("&")[0].split("=")[1];	
	},
	
	getSuffix: function(url){
		var dot = url.lastIndexOf(".");
		return dot==-1 ? "" : url.substr(dot+1);
	},
	
	getProtocol: function(url){
		if (!isNull(url.match(new RegExp("(\\w+):\/\/"))))
			return RegExp.$1;
		return "";
	},
	
	getHost: function(url){
		if (!isNull(url.match(new RegExp(":\/\/([A-Za-z0-9.]+)"))))
			return RegExp.$1;
		return "";
	},
	
	isValid: function(url){
		return true;
	},
	
	isLocal: function(url){
		if (!isNull(url.match(new RegExp("^file:", "i"))) || !isNull(url.match(new RegExp("[A-Z]:"))))
			return true;
		return false;
	}
}