function GetCategoryTitle(sCategory, sUrl, sRel)
{
	var sHtml = "";
	sHtml += '<div class="ClearFix" style="height:24px;background:url(../images/main_categorytitle_bg.jpg) repeat-x top;">';
	sHtml += '	<div style="float:left;display:inline;height:24px;margin-left:35px;padding:2px 10px 0 10px;color:#CB7A43;background:#FFFFFF;font-size:14px;font-weight:bold;">' + sCategory + '</div>';
	if (sUrl)
	{
		if (!sRel) sRel = "";
		sHtml += '	<div style="float:right;padding:5px 10px 0 0;"><a class="More" rel="' + sRel + '" href="' + sUrl + '">&gt;&gt;&nbsp;更多..</a></div>';
	}
	sHtml += '</div>';
	document.write(sHtml);
}

function GetSubCategoryTitle(sCategory, sUrl, sRel)
{
	var sHtml = "";
	sHtml += '<div class="ClearFix" style="height:24px;background:url(../images/main_categorytitle_bg.jpg) repeat-x top;">';
	sHtml += '	<div style="float:left;display:inline;height:24px;margin-left:35px;padding:2px 10px 0 10px;color:#0364A2;background:#FFFFFF;font-size:14px;font-weight:bold;">' + sCategory + '</div>';
	if (sUrl)
	{
		if (!sRel) sRel = "";
		sHtml += '	<div style="float:right;padding:5px 10px 0 0;"><a class="More" rel="' + sRel + '" href="' + sUrl + '">&gt;&gt;&nbsp;更多..</a></div>';
	}
	sHtml += '</div>';
	document.write(sHtml);
}

function GetNavTitle(sCategory, sHtml)
{
	if (!sHtml) sHtml = sCategory;
	var sTitleWidth = 18 * sCategory.length + 30;
	document.write("			<table width=" + sTitleWidth + " height='26' cellpadding='0' cellspacing='0' style='background:url(../images/sub_ArticleCategory_bg.gif);'>");
	document.write("				<tr>");
	document.write("					<td width='1'><img src='../images/sub_ArticleCategory_left.gif' /></td>");
	document.write("					<td align='left' class='CurPos2'>");
	document.write("						" + sHtml);
	document.write("					</td>");
	document.write("					<td width='1'><img src='../images/sub_ArticleCategory_right.gif' /></td>");
	document.write("				</tr>");
	document.write("			</table>");
}

function GetNavTitle2(sCategory, sHtml)
{
	if (!sHtml) sHtml = sCategory;
	var sTitleWidth = 18 * sCategory.length + 30;
	document.write("			<table width=" + sTitleWidth + " height='26' cellpadding='0' cellspacing='0' style='background:url(../images/sub_ArticleCategory_bg2.gif);'>");
	document.write("				<tr>");
	document.write("					<td width='1'><img src='../images/sub_ArticleCategory_left2.gif' /></td>");
	document.write("					<td align='left' class='CurPos2' style='filter:glow(Color=#83650a,Strength=1);'>");
	document.write("						" + sHtml);
	document.write("					</td>");
	document.write("					<td width='1'><img src='../images/sub_ArticleCategory_right2.gif' /></td>");
	document.write("				</tr>");
	document.write("			</table>");
}

function GetSectionTitle(sCategory, sUrl)
{
	document.write("			<table width='100%' height='25' cellpadding='0' cellspacing='0'>");
	document.write("				<tr>");
	document.write("					<td width='50%' class='SectionTitle'>&nbsp;&nbsp;<img src='../images/li_05.gif' />&nbsp;&nbsp;" + sCategory + "</td>");
	document.write("					<td width='50%' class='SectionTitle2' align='right' style='padding-right:30px;'>");
	if (sUrl)
	{
		document.write("					<a class='More' href='" + sUrl + "'>&gt;&gt;&nbsp;更多..</a>");
	}
	document.write("					</td>");
	document.write("				</tr>");
	document.write("			</table>");
}

function GetSectionTitle2(sCategory, sUrl)
{
	document.write("			<table width='100%' cellpadding='0' cellspacing='0'>");
	document.write("				<tr>");
	document.write("					<td width='50%' style='color:#319ED9;padding-left:20px;'><img src='../images/li_04.jpg' />&nbsp;【" + sCategory + "】</td>");
	document.write("					<td width='50%' align='right' style='padding-right:30px;'>");
	if (sUrl)
	{
		document.write("					<a class='More' href='" + sUrl + "'>&gt;&gt;&nbsp;更多..</a>");
	}
	document.write("					</td>");
	document.write("				</tr>");
	document.write("			</table>");
}

//WORD附件上传
function UploadDocument(p_TextBox)
{
	var oReturn = showModalDialog("../Modules/eWebEditor/dialog/file_doc.htm", window, "dialogWidth:350px;dialogHeight:125px;help:no;scroll:no;status:no");
	if (oReturn != null) p_TextBox.value = oReturn;
}

//设置鼠标移动到表格某行时高亮显示该行
function HighLightRow(sTableName, iRowIndex)
{
	iRowIndex += 1;
	var myTable = document.getElementById(sTableName);
	var iRowCount = myTable.rows.length;
	for (var i = 1; i < iRowCount; i++)
	{
		var sClassName = myTable.rows(i).className;

		if (i == iRowIndex)
		{
			if (sClassName != "")
			{
				sClassName += " ";
			}
			sClassName += "SelectedRow";
		}
		else
		{
			var iPos = sClassName.indexOf("SelectedRow");
			if (iPos == 0)
			{
				sClassName = "";
			}
			else if (iPos > 0)
			{
				sClassName = sClassName.substring(0, iPos - 1);
			}
		}
		myTable.rows(i).className = sClassName;
	}
}

//若图片尺寸超出指定范围则自动进行调整
function ResizeImg(imgD, iWidth, iHeight)
{
	if (imgD.style.width != "" || imgD.style.height != "") return;		//若已通过css指定了图片大小则不再调整(style="width:)

	var imgTmp = new Image();
	imgTmp.src = imgD.src; 

	if (imgTmp.width != imgD.width || imgTmp.height != imgD.height) return;		//若已在页面中指定了图片大小则不再调整(<img width=)

	if (imgTmp.width > 0 && imgTmp.height > 0)
	{
		//未指定高度，只根据宽度按比例缩小
		if (iWidth && !iHeight)
		{
			if (imgTmp.width > iWidth)
			{
				imgD.width = iWidth; 
				imgD.height = (imgTmp.height * iWidth) / imgTmp.width; 
			}
			return;
		}
		//未指定宽度，只根据高度按比例缩小
		if (iHeight && !iWidth)
		{
			if (imgTmp.height > iHeight)
			{
				imgD.height = iHeight;
				imgD.width = (imgTmp.width * iHeight) / imgTmp.height; 
			}
			return;
		}
		//同时指定了高度和宽度，按原始比例缩小
		if (imgTmp.width / imgTmp.height >= iWidth / iHeight)
		{
			if (imgTmp.width > iWidth)
			{
				imgD.width = iWidth; 
				imgD.height = (imgTmp.height * iWidth) / imgTmp.width; 
			}
			else
			{
				imgD.width = imgTmp.width; 
				imgD.height = imgTmp.height; 
			} 
		} 
		else
		{
			if (imgTmp.height > iHeight)
			{
				imgD.height = iHeight; 
				imgD.width = (imgTmp.width * iHeight) / imgTmp.height; 
			}
			else
			{
				imgD.width = imgTmp.width; 
				imgD.height = imgTmp.height; 
			}
		}
	}
}

//从DataGrid读取数据并重新组织成表格显示
function ShowDetail(dgDetail)
{
	document.write("<table align='center' class='TbDetail' style='width:500px;margin:15px 0;'>");
	if (dgDetail.rows.length == 2)
	{
		for (var i = 0; i < dgDetail.rows[0].cells.length; i++)
		{
			document.write("    <tr>");
			document.write("        <td class='Title'>" + dgDetail.rows[0].cells[i].innerHTML + "：</td>");
			document.write("        <td class='Content'>" + dgDetail.rows[1].cells[i].innerHTML + "</td>");
			document.write("    </tr>");
		}
	}
	document.write("</table>");
}

//页面加载时根据设定的尺寸自动对上传图片大小进行调整
function ResizeContentImgs(oParent, iWidth, iHeight)
{
	var _ResizeContentImgs = function()
	{
		var oImgs;
		oImgs = oParent.getElementsByTagName("img");
		for(var i = 0; i < oImgs.length; i++)
		{
			var oImg = oImgs[i];
			ResizeImg(oImg, iWidth, iHeight);
			//oImg.style.cursor = "pointer";
			//oImg.onclick = function(){window.open(this.src);}
		}
	}

	if (document.all)
	{
		window.attachEvent("onload", _ResizeContentImgs);
	}
	else
	{
		window.addEventListener("load", _ResizeContentImgs, false);
	}
}

//获取元素的位置
function getElementPos(elementId)
{
	var ua = navigator.userAgent.toLowerCase();
	var isOpera = (ua.indexOf('opera') != -1);
	var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof

	var el = document.getElementById(elementId);

	if(el.parentNode == null || el.style.display == 'none') 
	{
		return false;
	}

	var parent = null;
	var pos = [];
	var box;

	if(el.getBoundingClientRect)	//IE
	{
		box = el.getBoundingClientRect();
		var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
		var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);

		return {x:box.left + scrollLeft, y:box.top + scrollTop};
	}
	else if(document.getBoxObjectFor)	// gecko
	{
		box = document.getBoxObjectFor(el);
		   
		var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;
		var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0;

		pos = [box.x - borderLeft, box.y - borderTop];
	}
	else	// safari & opera
	{
		pos = [el.offsetLeft, el.offsetTop];
		parent = el.offsetParent;
		if (parent != el) {
			while (parent) {
				pos[0] += parent.offsetLeft;
				pos[1] += parent.offsetTop;
				parent = parent.offsetParent;
			}
		}
		if (ua.indexOf('opera') != -1 
			|| ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' )) 
		{
				pos[0] -= document.body.offsetLeft;
				pos[1] -= document.body.offsetTop;
		} 
	}
		
	if (el.parentNode) { parent = el.parentNode; }
	else { parent = null; }
  
	while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') 
	{ // account for any scrolled ancestors
		pos[0] -= parent.scrollLeft;
		pos[1] -= parent.scrollTop;
  
		if (parent.parentNode) { parent = parent.parentNode; } 
		else { parent = null; }
	}
	return {x:pos[0], y:pos[1]};
}