﻿var __Text_History = "";
var __Text_Action = "";

//
// 页面载入操作
function B_InitData()
{
	//alert("window.location.hash:"+window.location.hash);
	if(window.location.hash == null || window.location.hash == "")
	{
		window.location.hash = "/m.home/x.index";
	}
	if(__Text_History == "")
	{
		__Text_History = window.location.hash;
	}
	B_LoadContentLeft();
	B_LoadContentMain();	
};
function B_LoadContentLeft()
{
	//alert("ok");
	 var _sUrl = A_GetAspxPath("ascx")+"left.aspx";
	 var _sXml = "";
	_sXml += "<form>\n";
	_sXml += "<ascxpath><![CDATA[left.ascx]]></ascxpath>\n";
	_sXml += "</form>";
	
	//alert("_sUrl:"+_sUrl);
	//alert("_sXml:"+_sXml);
	
	$Ajax(_sUrl,null,null,"content_left");
}
function B_LoadContentMain(_objHtml)
{
	var __HtmlKey   = A_GetHtmlKey();
	
	var __HtmlValue = A_ArrayHtmlGet(__HtmlKey);
	
	__Text_Action = A_GetUrlParameter("a");
	//return;
	
	if(__HtmlValue == null && __HtmlValue != "" && __HtmlValue != "null")
	{
		var _sFileName = "";
		if(A_GetUrlParameter("x") == null)
		{
			_sFileName = "index";
		}
		else
		{
			if(A_GetUrlParameter("a") == null)
			{
				_sFileName = A_GetUrlParameter("x");
			}
			else
			{
				var _sAction = A_GetUrlParameter("a");
				
				if(_sAction == "examine") _sAction = "list";
				if(_sAction == "recovery") _sAction = "list";
				if(_sAction == "delete") _sAction = "list";
				
				_sFileName = A_GetUrlParameter("x")+"_"+_sAction;
			}
		}
		var _sUrl = A_GetAspxPath("ascx");
		
		//alert(_sUrl);
		
		if(_objHtml != null)
		{
			_sUrl += "h1,";
		}
		_sUrl += _sFileName+".aspx";
		
		//alert(_sUrl);
		
		var _sXml = "";
		_sXml += "<form>\n";
		
		
		_sXml += "<ascxpath><![CDATA["+_sFileName+".ascx]]></ascxpath>\n";
		_sXml += "</form>";
		
		
		//alert("_sUrl1:"+_sUrl);
		//alert("_sXml:"+_sXml);
		
		//
		// 装载内容
		$Ajax(_sUrl,null,_objHtml==null?"content_main":_objHtml,_objHtml==null?"content_main":_objHtml,B_LoadContentMainEnd);
	
		
	}
	else
	{
		var id = null;
		id = A_GetUrlParameter("i");
		//
		// 审核
		var examine  = null;
		//
		// 删除
		var recovery = null;
		//
		// 彻底删除
		var ruin     = null;
		
		var _sAction = A_GetUrlParameter("a");
		
		if(id != null && (_sAction == "examine" || _sAction == "recovery" || _sAction == "delete"))
		{
			if(_sAction == "examine")
			{
				examine = A_GetUrlParameter("i");
			}
			if(_sAction == "recovery")
			{
				if(!confirm("您确认要删除这条信息吗?"))
				{
					return;
				}
				recovery = A_GetUrlParameter("i");
			}
			if(_sAction == "delete")
			{
				if(!confirm("您确认要删除这条信息吗?\n删除后不能恢复的!"))
				{
					return;
				}
				ruin = A_GetUrlParameter("i");
			}
			var _sHash = "/m."+A_GetUrlParameter("m")+"/x."+A_GetUrlParameter("x")+"/a."+A_GetUrlParameter("a",__Text_History);
			if(A_GetUrlParameter("c") != null)
			{
				_sHash += "/c."+A_GetUrlParameter("c");
			}
			if(A_GetUrlParameter("p") != null)
			{
				_sHash += "/p."+A_GetUrlParameter("p");
			}
			if(A_GetUrlParameter("u") != null)
			{
				_sHash += "/u."+A_GetUrlParameter("u");
			}
			window.location.hash = _sHash;
		}
		
		if(window.location.hash != __Text_History) 
		{
			$("content_main").innerHTML = __HtmlValue;
		}
		else
		{
			//alert("未更新.");
		}
		if($("message_update") == null) 
		{
			C_SetChannelClick();
			return;
		}
		var _sUrl = A_GetAspxPath("xml")+""+A_GetUrlParameter("x")+"_list.aspx";
		
		if(A_GetUrlParameter("r") != null)
		{
			_sUrl = A_GetAspxPath("xml")+""+A_GetUrlParameter("x")+"_list_reply.aspx";
		}
		
		//if(A_GetUrlParameter("a") != null)
		//{
		//	_sUrl += A_GetUrlParameter("a")+".aspx"
		//}
		//else
		//{
		//	_sUrl += "list.aspx";
		//}
		//alert("更新1...");

		var _sXml = "";
		_sXml += "<form>\n";
		
		if(A_GetUrlParameter("i") != null)
		{
			_sXml += "<item>"+A_GetUrlParameter("i")+"</item>";
			if(A_GetUrlParameter("x") == "manage")  
			{
				_sXml += "<xslpath><![CDATA[{this}/edit.xslt]]></xslpath>";
			}
			if( (A_GetUrlParameter("a") == "read" || __A_AspxPathBase != "manage") && A_GetUrlParameter("a") != "edit" ) 
			{
				_sXml += "<xslpath><![CDATA[{this}/list.xslt]]></xslpath>";
			}
		}
		else
		{
			//if(A_GetUrlParameter("x") == "item") 	
			//{
				_sXml += "<xslpath><![CDATA[{this}/list.xslt]]></xslpath>";
			/*
			}
			if(A_GetUrlParameter("x") == "channel") 
			{
				_sXml += "<xslpath><![CDATA[/{virtualpath}"+__A_AspxPathBase+"/template/default/xslt/channel/channelList.xslt]]></xslpath>";
			}
			if(A_GetUrlParameter("x") == "module")  
			{
				_sXml += "<xslpath><![CDATA[/{virtualpath}"+__A_AspxPathBase+"/template/default/xslt/module/ModuleList.xslt]]></xslpath>";
			}
			if(A_GetUrlParameter("x") == "manage")  
			{ 
				_sXml += "<xslpath><![CDATA[/{virtualpath}"+__A_AspxPathBase+"/template/default/xslt/item/ItemListMemberManage.xslt]]></xslpath>";
			}
			if(A_GetUrlParameter("x") == "member") 
			{
				_sXml += "<xslpath><![CDATA[/{virtualpath}"+__A_AspxPathBase+"/template/default/xslt/item/ItemListMember.xslt]]></xslpath>";
			}
			
			if(A_GetUrlParameter("m") == "member" && A_GetUrlParameter("x") == "item" && A_GetUrlParameter("a") == "list") 
			{
				_sXml += "<xslpath><![CDATA[/{virtualpath}"+__A_AspxPathBase+"/template/default/xslt/item/ItemListMember.xslt]]></xslpath>";
			}
			*/
			//
			// 审核信息
			if(examine != null)
			{
				_sXml += "<system_examine>"+examine+"</system_examine>";
			}
			//
			// 删除信息
			if(recovery != null)
			{
				_sXml += "<system_recovery>"+recovery+"</system_recovery>";
			}
			//
			// 审核信息
			if(ruin != null)
			{
				_sXml += "<system_delete>"+ruin+"</system_delete>";
			}
			//=======================================================================
			//alert("B_LoadContentMain:"+__Text_History);
			//if(id == null)
			//{
				//alert(A_GetUrlParameter("a"));
				//
				// 过滤信息
				if(A_GetUrlParameter("a") == "examine")
				{
					_sXml += "<isExamine>0</isExamine>";
				}
				if(A_GetUrlParameter("a") == "recovery")
				{
					_sXml += "<isDelete>1</isDelete>";
				}
			//}
			if(A_GetUrlParameter("c") != null && A_GetUrlParameter("c") != "0")
			{
				_sXml += "<channel>"+A_GetUrlParameter("c")+"</channel>";
			}
			if(__A_AspxPathBase != "manage")
			{
				_sXml += "<isExamine>1</isExamine>";
			}
			if(A_GetUrlParameter("p") != null)
			{
				_sXml += "<page>"+A_GetUrlParameter("p")+"</page>";
			}
			if(__A_AspxPathBase == "manage")
			{
				if(A_GetUrlParameter("x") == "item")
				{
					_sXml += "<count>10</count>";
				}
			}
			if(A_GetUrlParameter("m") == "message")
			{
				_sXml += "<isShowContent>true</isShowContent>";
			}
			//alert($("c_key").value);
			//
			// 搜索处理
			if($("c_key") != null && $("c_key").value != "" && $("c_key").value != "标题关键字")
			{
				_sXml += "<searchTitle><![CDATA["+$("c_key").value+"]]></searchTitle>";
			}
		}
		_sXml += "</form>";
		
		//alert($("c_key").value);
		//alert("_sUrl2:"+_sUrl);
		//alert(_sXml);
		//alert("更新2...");
		//return;
		//
		// 更新内容
		if(A_GetUrlParameter("i") == null && A_GetUrlParameter("a") == "edit")
		{
			//
			// 清除表单
			//alert("清除表单");
			A_CloseForm("i_");
			C_InitPage();
		}
		else
		{
			//alert(_sUrl);
			if(A_GetUrlParameter("i") != null && A_GetUrlParameter("x") != "manage")
			{
				//alert("更新1");
				try
				{
				A_CloseForm("i_");
				$("i_title").value= "正在装载数据...";
				}catch(err){}
				$Ajax(_sUrl,_sXml,"message_update","message_update",B_LoadContentMainEnd);
			}
			else
			{
				//alert("更新2");
				$Ajax(_sUrl,_sXml,"message_filter","message_update",B_LoadContentMainEnd);
			}
		}
	}
	
	
	//else
	//{
	//	alert("i:"+A_GetUrlParameter("i")+"\n"+"a:"+A_GetUrlParameter("a"));
	//}
	//A_ArrayHtmlUpdate(__HtmlKey,"haha");
	//A_ArrayHtmlGet(__HtmlKey);
	//alert(__HtmlKey+":"+A_ArrayHtmlGet(__HtmlKey));
}
function B_LoadContentMainEnd(request,htmlstatus,htmlcontent)
{
	//alert(request.responseText);
	if(htmlstatus == "message_filter")
	{
		$(htmlstatus).innerHTML = _AjaxText;
		_AjaxText = "";
	}
	if(htmlstatus == "message_submit")
	{
		$(htmlstatus).innerHTML = _AjaxText;
		_AjaxText = "";
	}
	if(htmlstatus == "message_update" && A_GetUrlParameter("i") != null)
	{
		$(htmlstatus).innerHTML = "";
		_AjaxText = "";
	}
	
	//alert(A_GetUrlParameter("i"));
	
	if(A_GetUrlParameter("i") != null && htmlstatus == "message_update" && A_GetUrlParameter("a") != "read")
	{
		//alert(request.responseText);
		var _oXmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		_oXmlDoc.loadXML(request.responseText.trim());
		var _oColumns = _oXmlDoc.documentElement.selectSingleNode("item").childNodes;
		A_SetForm(_oColumns,"i_");
		for(var i=0; i < window.frames.length; i++)
		{
			try{window.frames.item(i).__InitData();}catch(e){}
		}
	}
	else
	{
		//alert($(htmlcontent).innerHTML);
		try
		{
			$(htmlcontent).innerHTML = request.responseText;
		}catch(e){$(htmlcontent).innerText = request.responseText.stripTags();}
	}
	
	if(A_GetUrlParameter("a") != "reply")
	{
		try
		{
		A_ArrayHtmlUpdate(A_GetHtmlKey(),$("content_main").innerHTML);
		}
		catch(e){}
	}
	//alert("3");
	if(A_GetUrlParameter("x") =="manage")
	{
		__S_UpdateManageListSelect();
	}
	//alert("4");
	if((A_GetUrlParameter("x")+A_GetUrlParameter("a")) == "channellist" && __Text_Action == "delete")
	{
		try
		{
		B_LoadContentLeft();
		}
		catch(e){}
	}
	//alert("5");
	try
	{
	C_SetChannelClick();
	}
	catch(e){}
	//alert("6");
	C_InitPage();
};
function __doChannelIndex()
{
	var _sUrl = A_GetAspxPath()+"__"+A_GetUrlParameter("x")+"_edit.aspx";
	
	$Ajax(_sUrl,A_GetForm("index_"),"message_submit",null,__doChannelIndexEnd);

	return false;
};
function __doSearch()
{
	/*
	var _sHash = "/m."+A_GetUrlParameter("m")+"/x."+A_GetUrlParameter("x")+"/a."+A_GetUrlParameter("a");
	if(A_GetUrlParameter("c") != null)
	{
		_sHash += "/c."+A_GetUrlParameter("c");
	}
	if(A_GetUrlParameter("p") != null)
	{
		_sHash += "/p."+A_GetUrlParameter("p");
	}
	window.location.hash = _sHash;
	*/
	if($("c_key").value != "" && $("c_key").value != "标题关键字")
	{
		B_LoadContentMain();
	}
	else
	{
		alert("请输入您要搜索的关键字!");
	}
	return false;
};
function __doChannelIndexEnd(request,htmlstatus,htmlcontent)
{
	if(request.responseText == 1)
	{
		alert("排序操作成功!");
	}
	else
	{
		alert("排序操作失败!\n\n"+request.responseText);
	}
	$(htmlstatus).innerHTML = _AjaxText;
	B_LoadContentMain();
	if(A_GetUrlParameter("x") == "channel")
	{
		B_LoadContentLeft();
	}
};
function __S_UpdateManageListSelect()
{
	var _sUrl =  A_GetAspxPath()+"__manage_list_select.aspx";
	var _sPostXml = "";
		_sPostXml += "<form>";
		_sPostXml += "<xslpath><![CDATA[{this}/select.xslt]]></xslpath>";
		_sPostXml += "</form>";
	try
	{
		var myAjax = new Ajax.Updater("manage_update",_sUrl, {method: 'post',postBody:_sPostXml});
	}catch(err){ alert(err.message);}
};
//
// 更新类别信息
function __S_LoadDataListChannelSelect()
{
	//alert("类别下拉框更新开始...");
	var _sUrl = A_GetAspxPath()+"__channel_list_select.aspx";
	var _sPostXml = "";
		_sPostXml += "<form>";
		_sPostXml += "<id>i_category</id>";
		_sPostXml += "<name>i_category</name>";
		_sPostXml += "<xslpath><![CDATA[{this}/selectNull.xslt]]></xslpath>";
		_sPostXml += "</form>";
	var myAjax = new Ajax.Updater("category_update",_sUrl, {method: 'post',postBody:_sPostXml});
	
	//alert("类别下拉框更新完成...");
	
};
function __doSubmitAction(__sUrl)
{
	var _sUrl = "";
	if(__sUrl == null)
	{
		try
		{
			if(A_GetUrlParameter("m") == "member" && A_GetUrlParameter("x") == "item")
			{
				_sUrl = A_GetAspxPath(null)+"__member_edit.aspx";
			}
			else
			{
				_sUrl = A_GetAspxPath(null)+"__"+A_GetUrlParameter("x")+"_edit.aspx";
			}
		}
		catch(err)
		{
			alert(err.message);	
			return false;
		}
	}
	else
	{
		_sUrl = __sUrl;
	}
	var _sXml = "";
	try
	{
		_sXml = A_GetForm("i_");
	}
	catch(err)
	{
		alert(err.message);	
		return false;
	}
	//alert(_sUrl);
	try
	{
	$Ajax(_sUrl,_sXml,"message_submit",null,__doSubmitActionEnd2);
	}
	catch(err2)
	{
		alert(err2.message);	
		return false;
	}
	return false;
	//alert(_AjaxText);
};
function __doSubmitActionEnd2(request,htmlstatus,htmlcontent)
{
	//alert("ok");
	$(htmlstatus).innerHTML = _AjaxText;
	
	
	if(request.responseText == 1)
	{
		if(A_GetUrlParameter("i") != null)
		{
			alert("编辑成功!");
		}
		else
		{
			alert("添加成功!");
		}
	}
	else
	{
		alert("操作失败!\n"+request.responseText);
		//A_WriteHtml(request.responseText);
	}
	
	if(A_GetUrlParameter("x") =="manage")
	{
		B_LoadContentMain();
	}
	if((A_GetUrlParameter("x")+A_GetUrlParameter("a")) == "channeledit")
	{
		//alert("B_LoadContentLeft");
		B_LoadContentLeft();
		__S_LoadDataListChannelSelect();
		//__S_LoadDataEdit(true);
		//return;
	}
};
//
// 信息取消事件
function __doCancelAction()
{
	//alert("取消");
	
	window.location.hash = __Text_History+(__Text_History.indexOf("o.return") != -1?"":"/o.return");
    B_LoadContentMain();
	return false;
};
function __doCategoryChange(val,cause)
{
	C_AutoInit();
	try
	{
		if(val == "0" || val == null || val == "")
		{
			if($("item_table_main") != null) $("item_table_main").style.display = "none";
			$("submit_button_span").style.display = "none";
			return;
		}
	}
	catch(e){};
	
	
	
	
	try
	{
	$("submit_button_span").style.display = "none";
	}
	catch(e){};
	//alert(val);
	// 清除缓存
	var __HtmlKey   = A_GetHtmlKey();
	
	A_ArrayHtmlUpdate(__HtmlKey,null);
	
	var _sHash = "/m."+A_GetUrlParameter("m")+"/x."+A_GetUrlParameter("x")+"/a."+A_GetUrlParameter("a");
	_sHash += "/c."+val;
	if(A_GetUrlParameter("i") != null)
	{
		_sHash += "/i."+A_GetUrlParameter("i");
	}
	if(A_GetUrlParameter("p") != null)
	{
		_sHash += "/p."+A_GetUrlParameter("p");
	}
	if(A_GetUrlParameter("u") != null)
	{
		_sHash += "/u."+A_GetUrlParameter("u");
	}
	//if(cause != null)
	//{
		_sHash += "/o.1";
	//}
	window.location.hash = _sHash;
	
		
	//alert($("item_main"));
	//
	// 刷新页面
	document.getElementById("i_category").disabled = true;
	B_LoadContentMain("item_main");
};
function __doCategoryChange2(val,cause)
{
	try
	{
		if(val == "0" || val == null || val == "")
		{
			if($("item_table_main") != null) $("item_table_main").style.display = "none";
			$("submit_button_span").style.display = "none";
			return;
		}
	}
	catch(e){};
	
	
	
	
	try
	{
	$("submit_button_span").style.display = "none";
	}
	catch(e){};
	//alert(val);
	// 清除缓存
	var __HtmlKey   = A_GetHtmlKey();
	
	A_ArrayHtmlUpdate(__HtmlKey,null);
	
	var _sHash = "/m."+A_GetUrlParameter("m")+"/x."+A_GetUrlParameter("x")+"/a."+A_GetUrlParameter("a");
	_sHash += "/c."+val;
	if(A_GetUrlParameter("i") != null)
	{
		_sHash += "/i."+A_GetUrlParameter("i");
	}
	if(A_GetUrlParameter("p") != null)
	{
		_sHash += "/p."+A_GetUrlParameter("p");
	}
	if(A_GetUrlParameter("u") != null)
	{
		_sHash += "/u."+A_GetUrlParameter("u");
	}
	//if(cause != null)
	//{
		_sHash += "/o.1";
	//}
	window.location.hash = _sHash;
	
		
	//alert($("item_main"));
	//
	// 刷新页面
	document.getElementById("i_category").disabled = true;
	B_LoadContentMain("item_main");
};
//=======================================================================================================================
//
// 装载模块/主要用于导航条的点击
function B_LoadModule(_sModule)
{
	try
	{
		__Text_History = window.location.hash;
		
		var _sHash = "";
		
		if(_sModule == "home")
		{
			_sHash = "/m."+_sModule+"/x.index";
		}
		else
		{
			//window.location.hash = "/m."+_sModule+"/x.item/a.list";
			//_sHash = "/m."+_sModule+"/x.index";
			_sHash = "/m."+_sModule+"/x.item/a.list";
		}
		
		if(A_GetUrlParameter("u") != null)
		{
			_sHash += "/u."+A_GetUrlParameter("u");
		}
		window.location.hash = _sHash;
			//
		// 更换模块重新载入
		//_A_Config.__Html_Content_Main.innerHTML = "";
		
		B_LoadContentLeft();
		B_LoadContentMain();
		
		//C_SetModuleClick();
	}
	catch(err)
	{ 
	   alert("B_LoadModule\n"+err.message);
	}
	return false;
};
//
// AJAX链接点击事件
function __doLinkByAction(_sHref)
{
	//alert("__doLinkByAction:"+__Text_History);
	try
	{
		var __sModule = null,__sAscx = null,__sAction = null,__sType=null,__iChannel = -1,__iItem = -1,__iPage = -1,__iUser = -1,__iReply = -1;
		var _url = _sHref.split("/");
		_sHref =  _url[_url.length-1];
		_url = _sHref.split(".");
		_sHref =  _url[0];
		_url = _sHref.split(",");
		//
		// 模块是第一个
		__sModule = _url[0];
		//
		// 分析出操作的文件名
		var _ascx = _url[_url.length-1];
		if(_ascx.indexOf("_") > 0)
		{
			__sAscx 	= _ascx.split("_")[0];
			__sAction	= _ascx.split("_")[1];
		}
		else
		{
			__sAscx 	= _ascx;
			if(__sAscx != "index")
			{
				__sAction	= "list";
			}
		}
		try
		{
			//
			// 分析参数
			if(_url.length > 2)
			{
				for(i=1; i < _url.length-1; i++)
				{
					if(_url[i].substring(0,1) == "c")
					{
						__iChannel = _url[i].substring(1,_url[i].length);
					}
					if(_url[i].substring(0,1) == "i")
					{
						__iItem = _url[i].substring(1,_url[i].length);
					}
					if(_url[i].substring(0,1) == "p")
					{
						__iPage = _url[i].substring(1,_url[i].length);
					}
					if(_url[i].substring(0,1) == "t")
					{
						__sType = _url[i].substring(1,_url[i].length);
					}
					if(_url[i].substring(0,1) == "u")
					{
						__iUser = _url[i].substring(1,_url[i].length);
					}
					if(_url[i].substring(0,1) == "r")
					{
						__iReply = _url[i].substring(1,_url[i].length);
					}
				}
			}
		}
		catch(err)
		{
			//alert(err.message);
			return false;
		}
		/*
		alert("__sModule="+__sModule);
		alert("__sAscx="+__sAscx);
		alert("__sAction="+__sAction);
		alert("__iChannel="+__iChannel);
		alert("__iItem="+__iItem);
		alert("__iPage="+__iPage);
		*/
		
		__doLink(__sModule,__sAscx,__sAction,__sType,__iChannel,__iItem,__iPage,__iUser,__iReply);
			
	}
	catch(err)
	{ 
	//alert(err.message); 
	}
	return false;
};
//
// 响应点击事件
// +-1.如果这个控件已经被载入就显示出来
// |  +--1.输入控件
// |  |   +--1.添加新信息就直接显示
// |  |   +--2.编辑信息就装载数据
// |  +--2.显示信息的控件
// |      +--1.更新数据
// +-2.如果没有载入是第一次访问就装载控件
function __doLink(_sModule,_sAscx,_sAction,_sType,_iChannel,_iItem,_iPage,_iUser,_iReply)
{
	
	var _sNewAscx = _sAscx+_sAction;
	//
	// 更新地址栏
	var _sHash = "/m."+_sModule+"/x."+_sAscx;
	if(_sAction != null)
	{
		if(_sAction == "examine" && _iReply != -1)
		{
			_sHash += "/a.reply";
		}
		else
		{
			_sHash += "/a."+_sAction;
		}
	}
	if(_sType != null)
	{
		_sHash += "/t."+_sType;
	}
	if(_iUser != -1)
	{
		_sHash += "/u."+_iUser;
	}
	if(_iChannel != -1)
	{
		_sHash += "/c."+_iChannel;
	}
	if(_iItem != -1)
	{
		_sHash += "/i."+_iItem;
	}
	if(_iPage != -1)
	{
		_sHash += "/p."+_iPage;
	}
	if(_iReply != -1)
	{
		_sHash += "/r."+_iReply;
	}
	
	var _sLoadLeft = false;
	
	if(_sModule != A_GetUrlParameter("m"))
	{
		_sLoadLeft = true;
	}
	if(A_GetUrlParameter("i") == null)
	{
		__Text_History = window.location.hash;
	}
	else
	{
		if(A_GetUrlParameter("a") != "examine" && A_GetUrlParameter("a") != "recovery" && A_GetUrlParameter("a") != "delete")
		__Text_History = window.location.hash;	
	}
	if(window.location.hash != "#"+_sHash)
	{
		window.location.hash = _sHash;
		//_A_Config.__Html_Content_Main.innerHTML = "";
	}
	//
	// 写历史记录
	/*
	if(A_GetUrlParameter("i") == null)
	{
		__Text_History = window.location.hash;
	}
	else
	{
		if(A_GetUrlParameter("a") != "examine" && A_GetUrlParameter("a") != "recovery" && A_GetUrlParameter("a") != "delete")
		__Text_History = window.location.hash;	
	}
	*/
	//
	// 载入主要内容/如果有缓存就从缓存转载
	//_A_Config.A_InitDataUrl();
	
	//if(_sLoadLeft)
	//{
	//	S_LoadContentLeft();
	//}
	
	//B_LoadContentLeft();
	B_LoadContentMain();
	C_SetChannelClick();
	
	return false;
};
//=======================================================================================================================
// Helper
//=======================================================================================================================
__Array_HtmlKey 	= new Array();
__Array_HtmlContent = new Array();

function A_ArrayHtmlGet(_sHtmlKey)
{
	//
	// 先判断缓存里面有没有
	var _iIndex = -1;
	for(var i=0; i < __Array_HtmlKey.length; i++)
	{
		if(__Array_HtmlKey[i] == _sHtmlKey)
		{
			_iIndex = i;
		}
	}
	if(_iIndex != -1)
	{
		return __Array_HtmlContent[_iIndex];
	}
	else
	{
		return null;
	}
};
function A_ArrayHtmlInsert(_sHtmlKey,_sHtmlContent)
{
	var _iIndex = __Array_HtmlKey.length;
	
	__Array_HtmlKey[_iIndex]     = _sHtmlKey;
	__Array_HtmlContent[_iIndex] = _sHtmlContent;
};
function A_ArrayHtmlUpdate(_sHtmlKey,_sHtmlContent)
{
	var _iIndex = -1;
	for(var i=0; i < __Array_HtmlKey.length; i++)
	{
		if(__Array_HtmlKey[i] == _sHtmlKey)
		{
			_iIndex = i;
		}
	}
	if(_iIndex != -1)
	{
		//
		// 更新内容
		__Array_HtmlContent[_iIndex] = _sHtmlContent;
	}
	else
	{
		A_ArrayHtmlInsert(_sHtmlKey,_sHtmlContent);
	}
};
function A_ArrayHtmlClose()
{
	__Array_HtmlKey = null;
	__Array_HtmlContent = null;
};
function A_GetAspxPath(type)
{
	var _sFilePath = "";
	if(__A_AspxPathBase != "wwwroot")
	{
		//if(A_GetUrlParameter("m") == "briefing")
		//{
		//	_sFilePath += "/manage2/";
		//}
		//else
		//{
			_sFilePath += "/"+__A_AspxPathBase+"/";
		//}
	}
	if(type != null)
	{
		_sFilePath+=type+"/";
	}
	var _sHash = A_GetUrlParameter("m");
	
	if(_sHash == "home" && A_GetUrlParameter("x") == "member")
	{
		_sHash = "member";
	}
	if(_sHash != null)
	{
		_sFilePath += _sHash+",";
	}
	if(A_GetUrlParameter("c") != null) 		_sFilePath += "c"+A_GetUrlParameter("c")+",";
	if(A_GetUrlParameter("i") != null) 		_sFilePath += "i"+A_GetUrlParameter("i")+",";
	if(A_GetUrlParameter("p") != null) 		_sFilePath += "p"+A_GetUrlParameter("p")+",";
	if(A_GetUrlParameter("u") != null) 		_sFilePath += "u"+A_GetUrlParameter("u")+",";
	if(A_GetUrlParameter("r") != null) 		_sFilePath += "r"+A_GetUrlParameter("r")+",";
	return _sFilePath;
};
function A_GetHtmlKey()
{
	var _sHtmlKey =__A_AspxPathBase+"_"+A_GetUrlParameter("m");
	
	if(A_GetUrlParameter("x") == null)
	{
		_sHtmlKey += "_index";
	}
	else
	{
		_sHtmlKey += "_"+A_GetUrlParameter("x");
		if(A_GetUrlParameter("a") != null)
		{
			var _sAction = A_GetUrlParameter("a");
			
			if(_sAction == "examine") _sAction = "list";
			if(_sAction == "recovery") _sAction = "list";
			if(_sAction == "delete") _sAction = "list";
			
			
			_sHtmlKey += "_"+_sAction;
		}
	}
	//alert(_sHtmlKey);
	return _sHtmlKey;
};
// 浏览器地址栏操作返回当前的URL碎片的参数值
function A_GetUrlParameter(_sKey,_sHash)
{
	var hash = window.location.hash;
	if(_sHash != null && _sHash != "undefined")
	{
		hash = _sHash;
	}
	if(hash == null)
	{
		return null;
	}
	else
	{
		if(hash.length > 1)
		{
			hash = hash.substring(1,hash.length);
		}
		var reg = new RegExp("(^|\/)"+ _sKey +".([^\/]*)(\/|$)");
		hash = hash.match(reg);
		if(hash != null)
		{
			return unescape(hash[2]);
		}
	}
	return null;
};
//=======================================================================================================================
/*
function C_SetModuleClick()
{
	C_InitNavigate();
	
	var __Click_Navigate_Module = C_GetModule();
	
	$("navigate_module").innerHTML = __Click_Navigate_Module.innerText;
	__Click_Navigate_Module.className = "nav_click";
	$("navigate_channel").innerHTML = "";
};
function C_GetModule()
{
	var __Click_Navigate_Module = "";
	try
	{
		__Click_Navigate_Module = $("nav_"+A_GetUrlParameter("m"));
		if(__Click_Navigate_Module == null)
		{
			__Click_Navigate_Module = $("nav_home");
		}
	}catch(err){}
	return __Click_Navigate_Module;
};
function C_SetChannelClick()
{
	C_SetModuleClick();
	
	//alert(__Click_Navigate_Channel);
	
	var __Click_Navigate_Channel = C_GetChannel();
	if(__Click_Navigate_Channel == null) return;
	
	$("navigate_channel").innerHTML = ">>"+__Click_Navigate_Channel.innerText;
	__Click_Navigate_Channel.className = "left_click";
	
	if($("left_"+A_GetUrlParameter("x")+"_"+A_GetUrlParameter("a")) != null)
	{
		$("left_"+A_GetUrlParameter("x")+"_"+A_GetUrlParameter("a")).className = "left_click";
	}
};
function C_GetChannel()
{
	var __Click_Navigate_Channel = null;
	try
	{
		if(A_GetUrlParameter("c") != null && A_GetUrlParameter("a") != "edit")
		{
			__Click_Navigate_Channel = $("left_"+A_GetUrlParameter("c"));
		}
		else
		{
			__Click_Navigate_Channel = $("left_"+A_GetUrlParameter("x")+"_"+A_GetUrlParameter("a"));
		}
		
	}catch(err){}
	return __Click_Navigate_Channel;
};
function C_InitNavigate()
{
	var _oObj = document.getElementsByTagName("span");
	for(i= 0;i<=_oObj.length -1;i++)
	{
		if(_oObj[i].id != null && _oObj[i].id != "")
		{
			if(_oObj[i].id.length > 4 && _oObj[i].id.substring(0,4) == "nav_")
			{
				_oObj[i].className = "nav_init";
			}
		}
	}
	for(i= 0;i<=_oObj.length -1;i++)
	{
		if(_oObj[i].id != null && _oObj[i].id != "")
		{
			if(_oObj[i].id.length > 5 && _oObj[i].id.substring(0,5) == "left_")
			{
				_oObj[i].className = "left_init";
			}
		}
	}
};
*/
//=============================================================================================================================
function ShowDiv(input)
{
	var aid = "a_"+input;
	var bid = "b_"+input;
	try
	{
		var a = $(aid);
		var b = $(bid);
		
		if(b.style.display == "none")
		{
			b.style.display = "block";
			a.bgColor = "#FFFFaa";
		}
		else
		{
			b.style.display = "none";
			a.bgColor = "#dcdcdc";
		}
	}
	catch(err)
	{
	}
};
function __doShowType(val)
{
	var obj_pagesize = $('obj_pagesize');
	var obj_colspan  = $('obj_colspan');
	if(val == 1)
	{
		obj_pagesize.style.display = "inline";
		obj_colspan.style.display = "inline";
	}
	else
	{
		if(val == -1)
		{
			obj_pagesize.style.display = "none";
		}
		else
		{
			obj_pagesize.style.display = "inline";
		}
		obj_colspan.style.display = "none";
	}
};
function A_DisplayByCheckbox(_oObj,_oDiv)
{
	A_Display(_oDiv,_oObj.checked);
};
function A_ShowImage(intput,output,div)
{
	var _oIn = $(intput);
	var _oOu = $(output);
	_oOu.src = _oIn.value;
	_oOu.title = _oIn.value;

	A_Display(div,"auto");
};
//
// 显示或者隐藏
function A_Display(_oObj,_bIsShow)
{
	var obj_showImg = $(_oObj);
	
	if(obj_showImg == null)
	{
		return false;
	}
	
	if(_bIsShow == "auto")
	{
		if(obj_showImg.style.display == "none")
		{
			obj_showImg.style.display = "inline";
		}
		else
		{
			obj_showImg.style.display = "none";
		}
	}
	else
	{
		if(_bIsShow)
		{
			obj_showImg.style.display = "inline";
		}
		else
		{
			obj_showImg.style.display = "none";
		}
	}
	if(_oObj == "tr_info_content")
	{
		//$("iframe1").window.location.reload();
	}
	C_AutoSize();
	return true;
};
//
// 选择服务器上的文件
function A_ServerFile(_sFileType,_sObjId)
{
	var retvalue;
	var _sUrl = "/manage/textbox/common/"+_sFileType+".aspx";
	//alert(_sUrl);
	retvalue = window.showModalDialog(_sUrl,"","dialogHeight=40;dialogWidth=703px;center=1;status=0;resizable=0;help=0");
	try
	{
		var input =  $(_sObjId);
		input.value = retvalue["filename"];
	}
	catch(err){}	
};
//图片按比例缩放
var flag=false;
function DrawImage(ImgD,iwidth,iheight)
{
	var image=new Image();

	image.src=ImgD.src;
	if(image.width>0 && image.height>0)
	{
		flag=true;
		if(image.width/image.height>= iwidth/iheight)
		{
			if(image.width>iwidth)
			{ 
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
				if((iheight - ImgD.height)/2 > 0) ImgD.vspace = (iheight - ImgD.height)/2;
			}
			else
			{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}

			ImgD.alt=image.width+"X"+image.height;
		}
		else
		{
			if(image.height>iheight)
			{
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height;
			}
			else
			{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt=image.width+"X"+image.height;
		}
	}
} 