﻿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 isIE(){return BROWSER.indexOf('ie') > -1;}
function setCopy(_sTxt){try{clipboardData.setData('Text',_sTxt)}catch(e){}}
function output(_sHtml, _box){var oOutput = typeof(_box) == "object" ? _box : $(_box);oOutput.innerHTML = _sHtml;}
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 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 initSendTime(){
	SENDTIME = new Date();
}
function getSend(){
	var sCurrTime = Math.floor((new Date() - SENDTIME)/1000);
	return sCurrTime < 0 ? 20 : sCurrTime;
}
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 win_opener_location()
{
	if(opener.document.getElementById("mainFrame"))
	{
		opener.document.getElementById("mainFrame").src = '/control/section/wizard.php';
	}
	else
	{
		opener.window.location.href = '/control/section/wizard.php';
	}
	void 0;
	opener.focus();
	window.close();
}

function img_resize(id)
{
	_pObj = document.getElementById(id);
	var width = 180;
	var height = 120;
	if(_pObj.width < width && _pObj.height < height)return;
	if (width/_pObj.width < height/_pObj.height){
		_pObj.width     = _pObj.width * (width / _pObj.width);
	}
	else{
		_pObj.height    = _pObj.height * (height / _pObj.height);
	} 
	//alert(_pObj.width + ' ' + _pObj.height);
}
// 判断中英问混排时候的长度
function byteLength (sStr) {
	aMatch = sStr.match(/[^\x00-\x80]/g);
	return (sStr.length + (! aMatch ? 0 : aMatch.length));
}
function changeMaxLen(obj, len) {
	var num = 0;
	var strlen = 0;
	var obj_value_arr = obj.value.split("");
	for(var i = 0; i < obj_value_arr.length; i ++) {
		if(i < len && num + byteLength(obj_value_arr[i]) <= len) {
			num += byteLength(obj_value_arr[i]);
			strlen = i + 1;
		}
	}
	if(obj.value.length > strlen) {
		obj.value = obj.value.substr(0, strlen);
	}
}

// 获取指定对象的绝对位置
function getXY(Obj) {
	var sumTop = 0, sumLeft = 0;
	while(Obj != document.body){
		sumLeft += Obj.offsetLeft;
		sumTop += Obj.offsetTop;
		Obj = Obj.offsetParent;
		}
	return {x:sumLeft, y:sumTop};
}
// 获取地址栏的CGI参数
function GetQueryString(str) {
	var rs = new RegExp("(^|)" + str + "=([^\&]*)(\&|$)", "gi").exec(String(window.location.href)), tmp;
	if(tmp = rs)return tmp[2];
	return null;
}
// 获取指定标签的父对象
function getParent(el, pTagName) {
	if(el == null)return null;
	else if(el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())
		return el;
	else
		return getParent(el.parentNode, pTagName);
}
// 获得指定对象
function $(Obj) {
	return document.getElementById(Obj);
}

// 返回指定对象的指定函数
function getFunc(FuncName) {
	if(!FuncName)return function(){};
	var s = FuncName.toString();
	return s.slice(12,-1);
}
// 返回指定对象的类型
function _typeof(o){
	if(!o)return null;
	var s=o.constructor.toString();
	return s.slice(10,s.indexOf("()"));
	}
// 创建对象
function $c(o) {
	if(! o)return;
	return document.createElement(o);
}
// 动态表格增加按钮
function AddButton(sCSS, sParent, oFunc) {
	var oDIV = document.createElement("img");
	oDIV.src = "http://image2.sina.com.cn/blog/tmpl/v3/control/images/supertable/blank.gif";
	oDIV.className = sCSS;
	if(oFunc != null)
		oDIV.onclick = oFunc;
	document.getElementById(sParent).appendChild(oDIV);
}
// 切换可显示层
function ArrowControl(_sCSS, _sCSS_Over, _sNodeName, _tNodeName) {
	
	if (_tNodeName){
    	var _this = document.getElementById(_tNodeName);
    }
    else{
    	var _this = event.srcElement;
    }
    var _o = document.getElementById(_sNodeName);
    if(_o.style.display == "none") {
        _o.style.display = "";
        _this.className = _sCSS;
    }
    else {
        _o.style.display = "none";
        _this.className = _sCSS_Over;
    }
}
var SENDTIME = new Date("2005","9","8","10","0","0");
// 控制面版 上部帮助缩放操作函数
var help_topic_desc = "";				// 帮助实际内容
var help_topic_desc0 = " \
<div align='right' style='cursor: pointer; cursor: hand;line-height=150%;color:#999999' onclick='sw_help_topic()'> \
——点击此处，查阅更多关于“%%%%%%”的内容介绍 \
&nbsp;&nbsp</div>";					// 帮助收缩后显示的内容
var help_topic_desc0_parameter = "";			// 帮助收缩后显示内容中的%%%%%%
var help_topic_title = "";				// 帮助title的内容
var help_topic_init = 0;				// 初始化帮助状态

var help_particular_nav = "";	// 详细帮助导航
var help_particular_url = "";				// 详细帮助的URL
var help_particular_title = "";				// 详细帮助的title

var add_arr = new Array();
help_particular_url = "http://blog.sina.com.cn/lm/html/2005-08-25/167.html?location=";
help_particular_url0 = "http://blog.sina.com.cn/lm/html/2005-08-25/167.html";

add_arr["/control/writing/explorer/article_list.php"] = help_particular_url + "161.html";
add_arr["/control/writing/explorer/article_list_sort.php"] = help_particular_url + "161.html";
add_arr["/control/writing/explorer/article_list_draft.php"] = help_particular_url + "161.html";
add_arr["/control/writing/explorer/article_list_recycle.php"] = help_particular_url + "161.html";

add_arr["/control/writing/article_class_manager.php"] = help_particular_url + "162.html";

add_arr["/control/comment/review_list.php"] = help_particular_url + "164.html";


add_arr["/control/blog/blog_set.php"] = help_particular_url + "156.html";
add_arr["/control/blog/blog_template.php"] = help_particular_url + "158.html";

add_arr["/control/section/wizard.php"] = help_particular_url + "159.html";
add_arr["/control/section/notice/notice_list.php"] = help_particular_url + "159.html";
add_arr["/control/section/notice/notice_add.php"] = help_particular_url + "159.html";
add_arr["/control/section/notice/notice_edit.php"] = help_particular_url + "159.html";
add_arr["/control/section/label/label_list.php"] = help_particular_url + "159.html";
add_arr["/control/section/label/label_add.php"] = help_particular_url + "159.html";
add_arr["/control/section/label/label_edit.php"] = help_particular_url + "159.html";
add_arr["/control/section/links/link_list.php"] = help_particular_url + "159.html";
add_arr["/control/section/links/link_add_title.php"] = help_particular_url + "159.html";
add_arr["/control/section/links/link_add_body.php"] = help_particular_url + "159.html";
add_arr["/control/section/links/link_edit.php"] = help_particular_url + "159.html";
add_arr["/control/section/links/link_edit_body.php"] = help_particular_url + "159.html";
add_arr["/control/section/special/special_list.php"] = help_particular_url + "159.html";
add_arr["/control/section/special/special_add_title.php"] = help_particular_url + "159.html";
add_arr["/control/section/special/special_add_body.php"] = help_particular_url + "159.html";
add_arr["/control/section/special/special_edit_body.php"] = help_particular_url + "159.html";
add_arr["/control/section/special/special_edit.php"] = help_particular_url + "159.html";
add_arr["/control/section/search/search_set.php"] = help_particular_url + "159.html";

add_arr["/control/member/base/modify_base.php"] = help_particular_url + "151.html";

add_arr["/control/member/raise/update_wizard.php"] = help_particular_url + "153.html";
add_arr["/control/member/raise/blog_update_succ.php"] = help_particular_url + "153.html";
add_arr["/control/member/raise/blog_update.php"] = help_particular_url + "153.html";
add_arr["/control/member/raise/blog_version.php"] = help_particular_url + "153.html";
add_arr["/control/member/raise/uhost_succ.php"] = help_particular_url + "153.html";
add_arr["/control/member/raise/uhost_register.php"] = help_particular_url + "153.html";

add_arr["/control/member/mobile/mobile_send.php"] = help_particular_url + "154.html";
add_arr["/control/member/mobile/mobile_check.php"] = help_particular_url + "154.html";
add_arr["/control/member/mobile/mobile_input.php"] = help_particular_url + "154.html";

add_arr["/control/member/base/myinfo_login.php"] = help_particular_url + "155.html";

add_arr["/control/album/blog/article_pic.php"] = help_particular_url + "165.html";
add_arr["/control/album/blog/article_pic_detail.php"] = help_particular_url + "165.html";
add_arr["/control/album/system/system_pic.php"] = help_particular_url + "165.html";

add_arr["/control/gbook/gbook_list.php"] = help_particular_url + "166.html";

add_arr["/control/blog/edit_my_index_add.php"] = help_particular_url + "159.html";

add_arr["/control/album/private/index.php"] = help_particular_url + "370.html";
add_arr["/control/album/private/index_title.php"] = help_particular_url + "370.html";
add_arr["/control/album/private/index_detail.php"] = help_particular_url + "370.html";

add_arr["/control/section/music/music_list.php"] = help_particular_url + "381.html";
add_arr["/control/section/music/music_edit.php"] = help_particular_url + "381.html";
add_arr["/control/section/music/music_edit_body.php"] = help_particular_url + "381.html";

function sw_help_topic_init(title)
{
	var obj = document.getElementById("help_topic");
        var obj_icon = document.getElementById("help_topic_icon");

	help_topic_title = obj_icon.innerHTML;
	help_topic_desc = obj.innerHTML;
	help_topic_desc0_parameter = title;

	
	// 收缩后显示的内容
	help_topic_desc0 = help_topic_desc0.replace("%%%%%%", help_topic_desc0_parameter);

	
	// 帮助导航
	help_particular_nav = help_particular_nav.replace("%%%%%%", title);
	help_particular_nav = help_particular_nav.replace("%%%%%%", title);
	str_href= document.location.pathname;
	if (add_arr[str_href] == null)
	{
		// 当前页面没有帮助
		help_particular_nav = help_particular_nav.replace("%%%URL%%%", help_particular_url0);
	}
	else
	{
		// 当前页面有帮助
		help_particular_nav = help_particular_nav.replace("%%%URL%%%", add_arr[str_href]);
	}

//	alert(help_particular_nav);

	// 标题样式更新
	obj_icon.className = "help_topic_title";

	

	sw_help_topic_ex(help_topic_init);
}

function sw_help_topic()
{               
	var obj = document.getElementById("help_topic");
        var obj_icon = document.getElementById("help_topic_icon");

	if (obj.style.height == "20px")
	{
		b_status = 1;
	}	
	else
	{
		b_status = 0;
	}
	

	sw_help_topic_ex(b_status);
}

function sw_help_topic_ex(b_status)
{
	var obj = document.getElementById("help_topic");
        var obj_icon = document.getElementById("help_topic_icon");

        if (b_status == 1)
        {       
		// 打开
                obj_icon.innerHTML = "- " + help_topic_title;
                obj.style.height = "";
		obj.innerHTML = help_topic_desc + help_particular_nav;
		obj.className = "help_topic_desc";
        }       
        else
        {
		// 关闭
                obj_icon.innerHTML = "+ " + help_topic_title;
                obj.style.height = "20px";
		
		obj.innerHTML = help_topic_desc0;
		obj.className = "help_topic_desc_hidden";
        }

	try 
	{
		parent.iframeResize();       
	}
	catch(e)
	{
	}
}

  
function setSelect(_sName, _sVal){
	var oObj = document.getElementsByName(_sName);
	for (var i = 0; i < oObj.length; i++){
		if (oObj[i].type == "select-one"){
			for (var j = 0; j < oObj[i].options.length; j++){
				if (_sVal == oObj[i].options[j].value){
					oObj[i].options[j].selected = true;
				}
			}
		}
		if ((oObj[i].type == "checkbox" || oObj[i].type == "radio") && _sVal == oObj[i].value){
			oObj[i].checked = true;
		}
	}
}
