﻿ 
var eventListener = new Array();
function OnLoad()
{  
 var i;
 for (i=0; i < eventListener.length; i++)
 {
  var func=eventListener[i];

  func.call();
 }
}
window.onload = OnLoad;
function RegisterOnloadEvent(onloadEvent)
{ 
 eventListener[eventListener.length]=onloadEvent;
}
function AddObjEvent(obj,eventName, eventHandler){	if (obj.attachEvent != null)	{		obj.attachEvent('on' + eventName, eventHandler);	}	else	{		obj.addEventListener(eventName, eventHandler, false);	}} 
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 rsstry(_sUrl){try {new ActiveXObject("SinaRss.RssObject");window.open(_sUrl, "_self");}catch(e){window.open("http://www.bfor.cn");}}
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 dwSwf(_sName, _sSrc, _sWidth, _sHeight, _sMode){_sMode = _sMode ? " wmode='transparent' " : "";return '<embed name="' + _sName + '" src="' + _sSrc + '"' + _sMode + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + _sWidth + '" height="' + _sHeight + '"></embed>';}
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 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 navigator.userAgent.toLowerCase().indexOf('ie') > -1;}
function openWindow(_sUrl, _sWidth, _sHeight, _sTitle, _sScroll){var oEdit = new dialog();oEdit.init();oEdit.set('title', _sTitle ? _sTitle : "Sys Message" );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 isEmail(emailStr)
{
var reg=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
return reg.test(emailStr)
}
function isDigit(s)
{
var patrn=/^[0-9]{1,20}$/;
if (!patrn.exec(s)) return false
return true
}
var SENDTIME;
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){setTimeout("resize()",500);}}
	this.resize = function(){if(_oObj.width > _iWidth){_oObj.width = _iWidth;}}
}

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";
}


function getFrameNode(sNode){
	return document.frames ? document.frames[sNode] : document.getElementById(sNode).contentWindow;
}
function weblog_rating(postID,account,rank,sid)
{
spaces_rating(1,postID,account,rank,sid);
}
function spaces_rating(type,entityID,account,rank,sid)
{
var strSoap='<?xml version="1.0" encoding="UTF-8"?>\n\n<SOAP-ENV:Envelope'
    +' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"'
    +' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
    +' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
    +' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
    +'<SOAP-ENV:Body>'
    +'<Rating xmlns="http://www.bfor.cn/">'
    +'<type>'+type+'</type>'
    +'<entityID>'+entityID+'</entityID>'
    +'<account>'+account+'</account>'
    +'<rank>'+rank+'</rank>'
    +'</Rating>'
    +'</SOAP-ENV:Body>'
    +'</SOAP-ENV:Envelope>';
    var postAppPath=spaces_ApplicationPath+'/BlogService.asmx';
  var loader=new net.ContentLoader(
    postAppPath,
    rating_Response,
    spacesErrorHandler,
    "POST",
    strSoap,
    "text/xml",
    {
      Man:"POST http://www.bfor.cn/Rating HTTP/1.1",
      MessageType:"CALL"
    },
    true
  );
  if(sid!=null){var ssid=$(sid); if(ssid!=null){ssid.style.width=getRankWidth(rank);}}
}
function rating_Response()
{
var root =this.req.responseXML;  
if(!root)
root=GetXMLDoc(this.req.responseText);
var msg;
if(root.childNodes[1]&&root.childNodes[1].text)
msg=root.childNodes[1].text;
 else
msg=root.childNodes[0].textContent;
 _msg_show(msg,'',2);
}
function GetXMLDoc(str)
{
if(str==null&&str.trim()=='')
return null;
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(str);
return new  xmlDoc ;
}

function spacesErrorHandler(){
 _msg_show("error contacting i-favourite!",'',2);
}
function getRankWidth(point)
{
 var w='0px';
 switch(point)
 {
  case 1:w='15px';break;case 2:w='30px';break;case 3:w='45px';break;case 4:w='58px';break;case 5:w='70px';break;
 }return w;
}
