// 根据鼠标或焦点事件，设置文本框和按钮样式,此函数会与样式相关
function IEvent(sType,oInput)
{
	var onStyle,offStyle,eleType;
	eleType = oInput.type;
	// 设置关联样式
	if("button" == eleType || "submit" == eleType || "reset" == eleType || "textarea" == oInput.tagName)
	{
		onStyle = "button_on";
		offStyle = "button_off";
	}
	else
	{
		onStyle = "input_on";
		offStyle = "input_off";
	}
	// 根据事件选择样式
	switch (sType)
	{
		case "focus" :
			oInput.isfocus = true;
		case "mouseover" :
			oInput.className = onStyle;
			break;
		case "blur" :
			oInput.isfocus = false;
		case "mouseout" :
			if(!oInput.isfocus)
			{
				oInput.className = offStyle;
			}
			break;
	}
}


// 根据ID获取页面元素
function $(id)
{	
	return document.getElementById(id);
}
function trim(str)
{
	return str.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}
String.prototype.trim = function()
{
	return this.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}
//弹出模拟对话框窗口
function OpenWindowsReturnValue(url, name, height, width, formName) {
    var feature = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;scroll:yes;status:no;help:no;center:1";
    var returnTarget = window.showModalDialog(url, name, feature);
    if (returnTarget != undefined && returnTarget.length > 1) {
        formName.ctl00_ContentPlaceHolder1_ntitleimg.value = returnTarget;
    }
    return false;
}
//弹出页面关闭并刷新父页面
function OpenWindowsReturnLoad(url, kuan, gao) {
    var obj = new Object();
    showModalDialog(url, obj, "dialogWidth:" + kuan + "px;dialogHeight:" + gao + "px; center: Yes; scroll:Yes; resizable: yes; status: No; help: No;")
    document.location.reload();
}
//不用模板页弹出模拟对话框窗口
function OpenWindowsReturnValues(url, name, height, width, formName) {
    var feature = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;scroll:yes;status:no;help:no;center:1";
    var returnTarget = window.showModalDialog(url, name, feature);
    if (returnTarget != undefined && returnTarget.length > 1) {
        formName.ntitleimg.value = returnTarget;
    }
    return false;
}
//不用模板页弹出模拟对话框窗口并显示图片
function OpenWindowsReturnShopValue(url, name, height, width, formName) {
    var feature = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;scroll:yes;status:no;help:no;center:1";
    var returnTarget = window.showModalDialog(url, name, feature);
    if (returnTarget != undefined && returnTarget.length > 1) {
        formName.ntitleimg.value = returnTarget;
        formName.PicShow.src = returnTarget;
    }
    return false;
}
//用户弹出模拟对话框窗口并显示图片
function OpenWindowsReturnUserValue(url, name, height, width, formName) {
    var feature = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;scroll:yes;status:no;help:no;center:1";
    var returnTarget = window.showModalDialog(url, name, feature);
    if (returnTarget != undefined && returnTarget.length > 1) {
        formName.ctl00_ContentPlaceHolder1_ntitleimg.value = returnTarget;
        formName.PicShow.src = returnTarget;
    }
    return false;
}
// 外部链接访问
function LinkOut(url) {
    if (url == "") {
        return;
    }
    window.open(url);
}
// 过滤字符串中html，保留换行
function clearHtml (str) {
    var re = new RegExp("<p.*?>|<br\\s*/?>", "ig");
    str = str.replace(re, "[br]");
    re = new RegExp("<script.+?</script>", "ig");
    str = str.replace(re, "");
    re = new RegExp("<.+?>", "ig");
    str = str.replace(re, "");
    str = str.replace(/&nbsp; /ig, "[nbsp]");
    str = str.replace(/&nbsp;&nbsp;/ig, "[nbsp]");
    str = str.replace(/&nbsp;/ig, " ");
    re = new RegExp("<.+?$", "g");
    str = str.replace(re, "");
    re = new RegExp("&.{0,4}$", "g");
    str = str.replace(re, "");
    re = new RegExp("\\[nbsp]", "g");
    str = str.replace(re, "　");
    re = new RegExp("\\[br]", "g");
    str = str.replace(re, "<br/>");
    //	re = new RegExp("\r?\n","g");
    //	str = str.replace(re,"<br/>");
    re = new RegExp("<br/>(\\s*<br/>\\s*)+", "g");
    str = str.replace(re, "<br/>");
    re = new RegExp("^\\s*<br/>(\\s*<br/>\\s*)*", "g");
    str = str.replace(re, "");
    return str;
};

// 从新闻内容生成简介
  function setSummary() {
    var str = document.getElementById('txt_ncontent').value;
    str =clearHtml(str);
    var idx = str.IndexOf("<br/>");
    if (idx > 50 && idx < str) {
        str = str.Left(idx - 1);
    } else if (str.Len()> str) {
        str = str.Left(idx.summaryLength, "...");
    }
    //	alert(str);
    var ed;
    ed.getBody().innerHTML = str;
};
//判断三元运算符
function GetJudge( strjudge,  strright,  strerror) {
 return (strjudge == "1" )? "<font color=\"red\">"+strright+"</font>" : strerror;
}

