﻿//首页的图片转动
function setfoc(id){
	//alert("start.........."+id);
	document.getElementById("focpic").src = picarry[id];
	document.getElementById("foclnk").href = lnkarry[id];
	document.getElementById("tpbt").innerHTML = ttlarry[id];
	//alert("id:........"+id);
	focpic.style.visibility = "hidden";
	focpic.filters[0].Apply();
	if (focpic.style.visibility == "visible"){
		focpic.style.visibility = "hidden";
		focpic.filters.revealTrans.transition=12;
	}else{
		focpic.style.visibility = "visible";focpic.filters[0].transition=12;
	}
	focpic.filters[0].Play();
}
//设置字体大小
function setFont(x)
{
  switch (x){
    case 1:
		document.getElementById("endtext").className="endbig";		
		document.getElementById("e_b").className="sel";
		document.getElementById("e_n").className="unsel";
		document.getElementById("e_s").className="unsel";
	break;
	case 2:
		document.getElementById("endtext").className="endnomal";
		document.getElementById("e_n").className="sel";
		document.getElementById("e_b").className="unsel";
		document.getElementById("e_s").className="unsel";
	break;
	case 3:
		document.getElementById("endtext").className="endsmall";
		document.getElementById("e_s").className="sel";
		document.getElementById("e_n").className="unsel";
		document.getElementById("e_b").className="unsel";
      break;
	}
} 
/**
 * 加入收藏夹
 * @param title
 * @param url
 */
function addFavorite(title, url) {
    if (window.sidebar) { 
        window.sidebar.addPanel(title, url, ""); 
    } else if (window.external) {
        window.external.AddFavorite(url, title);
    }
    return false;
}
/**
 * TRS分页方法
 * @param _nPageCount 总页数
 * @param _nCurrIndex 当前页
 * @param _sPageName 文件名
 * @param _sPageExt 文件后缀
 * @param _nRecordCount 记录数
 */
function createPageHTML (_nPageCount, _nCurrIndex, _sPageName, _sPageExt, _nRecordCount) {
    if (_nPageCount && _nPageCount > 1) {
        document.write('<a href="' + _sPageName + '.' + _sPageExt + '">首页</a>');
        var nCurrIndex = _nCurrIndex || 0;
        if (nCurrIndex == 0) {
            //document.write('<a href="#none">上一页</a>');
            //document.write('<a href="#none" class="current">1</a>');
        } else {
            if (nCurrIndex == 1) {
                document.write('<a href="' + _sPageName + '.' + _sPageExt + '">上一页</a>');
            } else {
                document.write('<a href="' + _sPageName + '_' + (nCurrIndex - 1) + '.' + _sPageExt + '">上一页</a>');
            }
            //document.write('<a href="' + _sPageName + '.' + _sPageExt + '">1</a>');
        }
        for (var i = 0; i < _nPageCount; i++) {
            if (10 < _nPageCount && (i < (_nCurrIndex - 5) || i > (_nCurrIndex + 5))) {
                continue;
            }
            if (i == 0) {
                document.write('<a href="' + _sPageName + '.' + _sPageExt + '"' + ((nCurrIndex == i) ? ' class="current" onclick="return false;"' : '') + '>' + (i + 1) + '</a>');
            } else {
                document.write('<a href="' + _sPageName + '_' + i + '.' + _sPageExt + '"' + ((nCurrIndex == i) ? ' class="current" onclick="return false;"' : '') + '>' + (i + 1) + '</a>');
            }
        }
        if (nCurrIndex === (_nPageCount - 1) && _nPageCount > 1) {
            //document.write('<a href="#none">下一页</a>');
        } else {
            document.write('<a href="' + _sPageName + '_' + (nCurrIndex + 1) + '.' + _sPageExt + '">下一页</a>');
        }
        document.write('<a href="' + _sPageName + '_' + (_nPageCount - 1) + '.' + _sPageExt + '">末页</a>');
    }
    
    document.write('<a href="#none" onclick="return false;">共 ' + _nPageCount + ' 页 ' + _nRecordCount + ' 条</a>');
}

function colorMenu() {
    var c_p = document.getElementById("current_position");
    if (!c_p) {
        return;
    }
    var c_ps = c_p.value.split(">>")
    var menus = document.getElementById("menu");
    var as = menus.getElementsByTagName("a");
    end: for (var i = as.length - 1; i >= 0; i--) {
        for (var j = 0; j < c_ps.length; j++) {
            if (c_ps[j] === as[i].innerHTML) {
                as[i].className = "current";
                break end;
            }
        }
    }
}

function checkXgfj() {
    var xgfj = document.getElementById("xgfj");
    if (xgfj && xgfj.getElementsByTagName("a").length < 1) {
        xgfj.style.display = "none";
    }
}

function checkXgnr() {
    var xgnr = document.getElementById("xgnr");
    if (xgnr && xgnr.getElementsByTagName("a").length < 1) {
        xgnr.style.display = "none";
    }
}

(function () {
    window.setEvent = function (e, f) {
        window[e] = f;
    };
    
    window.appendEvent = function (e, f) {
        var preEvent = window[e];
        window[e] = function () {
            if (preEvent) {
                preEvent();
            }
            f();
        }
    };
	window.appendEvent("onload", colorMenu);
    window.appendEvent("onload", checkXgfj);
    window.appendEvent("onload", checkXgnr);
    window.appendEvent("onload", function () {
		var e_n = document.getElementById("e_n");
		if (e_n && e_n.click) {
			document.getElementById("e_n").click();
		}
	});
    
})();

/**
 * 附件下载调用的JS方法
 * @param url
 * @param fileName
 * @return
 */
function download(url,fileName) {
    //alert("url:"+url+"<------>fileName:"+fileName);
	if (url.lastIndexOf("/") === (url.length - 1)) {
		return false;
	}

    var form = document.getElementById("appendixform");
    document.getElementById("_path").value = url;
    document.getElementById("_fileName").value = fileName;
	
    form.submit();
    form = null;
    return false;
}

  /**
 * 为顶部菜单着色
 */
function colorMenu() {
    var c_p = document.getElementById("current_position");
    if (!c_p) {
        return;
    }
    var c_ps = c_p.value.split(">>")
    var menus = document.getElementById("menu");
    var as = menus.getElementsByTagName("a");
    end: for (var i = as.length - 1; i >= 0; i--) {
        for (var j = 0; j < c_ps.length; j++) {
            if (c_ps[j] === as[i].innerHTML) {
                as[i].className = "current";
                break end;
            }
        }
    }
}