//定位到书签位置
function GoBookmark(markName)
{
  window.location = markName; 
}
//输入框自适应程序
//支持 Input ,Textarea
//增加全局变量	hasChange	若页面有操作hasChange为1,默认为0
//@Xiongtao 2009-11-25

var hasChange = 0;

function autoChangeTextAreaSize(which) {
	//复制style
	if(!which.style.fontSize) {
		which.style.fontSize = "10pt";
	}

	if (!!which.style.width) {
	    which.style.removeAttribute("width");
	}

	if (!!which.style.height) {
	    which.style.removeAttribute("height");
	}
	which.style.overflow = "visible";
	which.style.overflowY = "hidden";

    var clientRects = which.createTextRange().getClientRects();
    if (typeof (clientRects[clientRects.length - 1]) == "undefined") {
        return;
    }

	if (which.value === "") {
	    which.style.width = 30 + "px";
		clientRects = which.createTextRange().getClientRects();
	    which.style.height = (clientRects[clientRects.length - 1].bottom - clientRects[0].top + 2) + "px";
	}
	else {
		var parentContainer = which.parentElement;
		while (parentContainer) {
			if (parentContainer.tagName.toUpperCase() == "TD" || parentContainer.tagName.toUpperCase() == "FORM"
				|| parentContainer.tagName.toUpperCase() == "BODY") {
				break;
			}
			parentContainer = parentContainer.parentElement;
		}
		
	    var offsetLeft;
	    if (which.offsetLeft == 0 && which.offsetParent.tagName.toUpperCase() == "BODY") {
	    	offsetLeft = which.offsetLeft + which.offsetParent.offsetLeft + 10 - (document.documentElement.clientWidth - which.offsetParent.offsetWidth) / 2;
	    }
	    else {
	    	offsetLeft = which.offsetLeft;
	    }
	    
	    if (parentContainer.offsetWidth - offsetLeft - 20 > 10) {
			which.style.width = (parentContainer.offsetWidth - offsetLeft - 20) + "px";
		}

	    clientRects = which.createTextRange().getClientRects();
	    if (clientRects.length) {
		    which.style.width = (clientRects[0].right - clientRects[0].left) + "px";
			while (which.createTextRange().getClientRects().length > 1 && offsetLeft + which.offsetWidth + 20 < parentContainer.offsetWidth) {
		        which.style.width = (which.offsetWidth + 5) + "px";
			}
			
			clientRects = which.createTextRange().getClientRects();
		    which.style.height = (clientRects[clientRects.length - 1].bottom - clientRects[0].top + 2) + "px";
	        //textarea的Value属性值最后两位为“\r\n”（回车）时，将控件的高度加一行，否则行高会少一行。
	        if (which.value.length > 2 && which.value.substring(which.value.length - 2) == "\r\n")
	        {
		    	which.style.height = (parseInt(which.style.height) + clientRects[0].bottom - clientRects[0].top + 2) + "px";
	        }
		    which.style.width = (which.offsetWidth + 10) + "px";
		}
	}
}

function autoChangeAllTextAreaSize() {
	var listTextArea = document.getElementsByTagName("TEXTAREA");
	for (var idx = 0; idx < listTextArea.length; idx++) {
		autoChangeTextAreaSize(listTextArea[idx]);
	}
}

var checkLength = function(which, event)
{
    hasChange = 1;
	if($("#mirror_text_area").style.width)
		$("#mirror_text_area").style.removeAttribute("width");
	var oTarget = event.srcElement?event.srcElement:event.target;
	var setup = function(event)
    {
		var activeSwitch = which;
		//获得目标单位值
		var oTextContent = which.value;
		//获得目标框字符数
		//var iCount = which.value.replace(/[^\u0000-\u00ff]/g,"aa").length;
		//input框随字符宽度增长
		var __checkLength = function(event)
        {
			var mirrorObj = $("#mirror_text_area");
			//IE浏览器下字符间距和字体bug
			if(!!document.all)
			{
				if(parseInt(which.style.fontSize) < 14)
					which.style.letterSpacing = "0px";
			}
			if (which.tagName == "INPUT") {
			    if (which.readOnly) {
			        return;
			    }

				mirrorObj.innerText = oTextContent;
				//复制style
				mirrorObj.style.fontSize = which.style.fontSize;
				which.style.width =(parseInt(mirrorObj.offsetWidth) > 35) ? mirrorObj.offsetWidth + "px" : "35px";
				//解决输入后文字前面显示不全的问题（让光标始终在最后字符上）
				//try{
				//	var textRange = oTarget.createTextRange();
				//	textRange.move('character', which.value.length);
				//	textRange.select();
				//}catch(err){};
			}
			else if (which.tagName == "TEXTAREA")
			{
				var sKeyCode = event.keyCode;
				autoTextarea(sKeyCode);
			}
			else
			{ 
				return;
			}		
		}
		
		//自动改变宽度高度的Textarea
		var autoTextarea = function(sKeyCode) {
	        autoChangeTextAreaSize(which);
		}
		__checkLength(event);
	}
	//get KeyCode
	//when get Enter than add a character instand
	function dispatchEvent(e)
	{
        try{
            var code;
            if (!e)
            {
                var e = window.event;
            }
            if (!document.all)
            {
                code = e.keyCode;
            }
            else
            {
                code = e.which;
            }
            if(code==13)
            {
                return code;
            }
        }
        catch(err){}
		//var character = String.fromCharCode(code);  //getKey mean
		//alert('Character was ' + character);
	}
	//wait patse data load
	try{
		setTimeout(setup(event),"5");
	}catch(err){}
}

//屏蔽对页面进行刷新，跳转，新建的快捷键
document.onkeydown = function(event)
{
	var event = window.event?window.event:event;
	var oTarget = event.srcElement?window.event:event.target;
	function oStop(){
		if(window.event)
		{
			event.keyCode=0;  
			event.returnValue=false; 
			return   false;
		}
		else
			event.preventDefault();
	}
    if((event.altKey)&&((event.keyCode==37)||(event.keyCode==39)))   
    {       
        oStop();   
    }
    if((event.keyCode==116)||(event.ctrlKey   &&   event.keyCode==82))   
    {     
        oStop();   
    }
    //屏蔽   Ctrl+n   
    if   ((event.ctrlKey)&&(event.keyCode==78))   
    {       
        oStop();   
    }   

    //屏蔽   shift+F10   
    if   ((event.shiftKey)&&(event.keyCode==121))   
    {     
        oStop();   
    }   

    //屏蔽   shift   加鼠标左键新开一网页   
    if   (oTarget.tagName   ==   "A"   &&   event.shiftKey)     
    {   
		oStop();   
    }   
            
    //屏蔽Alt+F4   
    if   ((event.altKey)&&(event.keyCode==115))   
    {   
    window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");   
    return   false;   
    }   

    //屏蔽Ctrl+A   
    if((event.ctrlKey)&&(event.keyCode==65))   
    {   
    return   false;   
    } 
}
	
//start GetFocus function

var hisRecord = [];	// 第一个为id,第二个为背景颜色
function GetFocus(which)
{
	var activeSwitch = which.id;
	if(hisRecord[0] === undefined)
	{
		hisRecord[0] = which.id;
		hisRecord[1] = which.currentStyle.backgroundColor;
	}
	$('#'+hisRecord[0]).style.backgroundColor = hisRecord[1];
	hisRecord[0] = which.id;
	hisRecord[1] = which.currentStyle.backgroundColor;
	which.style.backgroundColor = "#B2D3FF";
}

var RightMenu = function(event)
{
	activeSwitch = event.srcElement || event.target;
	var sMenuHTML = "<p id='copyNode'>复制<\/p><p id='pasteNode'>粘贴<\/p>";
	var oDiv = document.createElement('div');
	oDiv.id = "popup_menu";
	document.body.appendChild(oDiv);
	document.getElementById('popup_menu').innerHTML = sMenuHTML;
	oDiv = document.getElementById('popup_menu');
	oDiv.style.position = "absolute";
	oDiv.style.border = "1px solid #ccc";
	oDiv.style.left = event.clientX+"px";
	oDiv.style.top = document.documentElement.scrollTop+event.clientY+"px";
	//关闭弹出菜单
 	var CloseMenu = function()
	{
		if(oDiv.parentNode)
		oDiv.parentNode.removeChild(oDiv);
		//focus一下存在的目标
		//以解决ie7下面右键在textarea目标下找不到光标的bug
		document.getElementsByTagName("body")[0].focus();
	}
	var Copy = function()
	{
		if(document.selection.createRange().text)
		{
			var sText = document.selection.createRange();
			//IE下面复制选中的数据部分
			window.clipboardData.setData('text', sText.text);
		}
		else
		alert('未选中文字');
	}
	var Paste = function(event)
	{
		var oSrc = activeSwitch;
		if((oSrc.tagName === "INPUT")||(oSrc.tagName === "TEXTAREA"))
		{
			if(!oSrc.disabled && !oSrc.readOnly)
			{
			setTimeout("function(){oSrc.focus()}", 0);
			sText = document.selection.createRange();
			sText.text = window.clipboardData.getData('text');
			sText.select();
			oSrc.click();
			}
			else{alert('未知粘贴区域')}
		}
		else{alert('未知粘贴区域')}
	}
	//添加关闭事件监听
	addEvent(document,'mousedown',CloseMenu);
	addEvent(document.getElementById('copyNode'),'mousedown',Copy);
	addEvent(document.getElementById('pasteNode'),'mousedown',Paste);
}

//阻止浏览器默认右键菜单并运行RightMenu
var UMenu = function(event)
{
	if(document.all)
		event.returnValue=false;
	else
		event.preventDefault();
	RightMenu(event);
}

var rightMenu = function(event)
{
	if(event.button === 2)
	{
		addEvent(document,'contextmenu',UMenu)
	}
}

//调用Gprun函数
//
function invokeGprun(id)
{
    Gprun(document.getElementById(id));
}

//静止页面所有操作
//显示与不显示 sw = "on" or "off"
//
//function TopDiv(sw)
//{
//	if(sw === "on")
//	{
//		var oDiv = document.createElement('div');
//		oDiv.id = 'topdiv';
//		oDiv.style.width = document.getElementsByTagName('html')[0].clientWidth + "px";
//		oDiv.style.height = document.getElementsByTagName('html')[0].clientHeight + "px";
//		oDiv.style.position = "absolute";
//		oDiv.style.backgroundColor = "#FFFFFF";
//		oDiv.style.zIndex = "999";
//		oDiv.style.left = 0;
//		oDiv.style.top = 0;
//		document.body.appendChild(oDiv);
//		window.onscroll = function(){
//			document.getElementById('topdiv').style.top = document.documentElement.scrollTop + "px";
//		}
//	}
//	else if(sw === "off")
//	{
//		var oDiv = document.getElementById('topdiv');
//		document.body.removeChild(oDiv);
//		window.onSrcoll = function(){
//			//
//		}
//	}
//	else
//		alert('TopDiv 参数不正确')
//}

//屏蔽或开启input，textarea输入行为
//method = "on" | "off"
//aID为数组，内容为id名称字符串
//aID为空时该函数面向所有可输入对象
function writeSwitch(method, aID)
{
	var sMethod = method === "on" ? false: true;
	if(aID[0] && typeof(aID)!=="string")
	{
		for(var i=0; i<aID.length; i++)
		{
			if(aID[i].type === "checkbox")
			{
				aID[i].disabled = sMethod;
			}
			else
			{
			  $('#'+aID[i]).readOnly = sMethod;
		  }
		}
	}
	else
	{	
		var Org = $('input');
		var Org2 = $('textarea');
		for(var i=0; i<Org.length; i++)
		{
			if(Org[i].type === "checkbox")
			{
				Org[i].disabled = sMethod;
			}
			else
			{
			  Org[i].readOnly = sMethod;
		  }
		}
		for(var i=0; i<Org2.length; i++)
		{
			Org2[i].readOnly = sMethod;
		}
	}
}

//字体色以及背景色红蓝切换
//method = "red" || "reset" || "Bred"
//
function Sw_Color(method, id)
{
    var org = OperateFile.sNode;
    if (method == "red")
    {
        document.getElementById(id).style.color = "red";
    }
    else if(method == "reset")
    {
        document.getElementById(id).style.color = "";
        document.getElementById(id).className += " font_black";
    }
    else if(method == "Bred")
    {
        if(document.getElementById(id).tagName == "INPUT")
        {
            document.getElementById(id).className += " bored";
        }
        else
        {
            document.getElementById(id).className += " bkred";
        }
    }
    else if(method == "Breset")
    {
        document.getElementById(id).className = "";
    }
}

/*修改Span的innerText属性
* added by chenxiang
* 2009-11-04
*/
function modifySpan(spanId, spanText)
{
    hasChange = 1;
    document.getElementById(spanId).innerText = spanText;
}

/*在Table中添加行
* added by chenxiang
* 2009-11-04
*/
function addRow(tableId, row, columnCount)
{
    hasChange = 1;
    
    var tb = document.getElementById(tableId);
    var tdy = tb.getElementsByTagName("tbody")[0];
    var newRow;
    
    if(columnCount == null)
    {
        if(tdy.lastChild == tdy.rows[row])
        {
           newRow = tdy.appendChild(tdy.rows[0].cloneNode(true)); //如果是table的最后一个行，插入newRow
        }
        else
        {
           newRow = tdy.insertBefore(tdy.rows[0].cloneNode(true), tb.rows[row + 1]);//如果不是，插入到下一行的前面
        }
    }
    else
    {
        newRow = tdy.insertRow(row);
        for(var idx = 0; idx < columnCount; idx++)
        {
            var cell = newRow.insertCell(0);
            cell.className = tdy.rows[0].cells[0].className;
        }
        
        return newRow;
    }
    
    for(var i = 0; i < newRow.cells.length; i++)
    {
        clearChildNode(newRow.cells[i]);
        
        var cell;
        
        if(newRow.cells[i].children[0].children[0] != null)
        {
            cell = newRow.cells[i].children[0].children[0];
        }
        else
        {
            cell = newRow.cells[i];
        }
        
        cell.innerText = "";
    }
    
    return newRow;
}

/*在Table中删除多余的子节点
* added by chenxiang
* 2009-11-05
*/
function clearChildNode(childNode)
{
    childNode.style.fontWeight = "lighter";    
    if(childNode.children.length > 1)
    {
        childNode.removeChild(childNode.children[1]);
        clearChildNode(childNode);
    }
    else if(childNode.children.length == 1)
    {
        clearChildNode(childNode.children[0]);
    }
}

/*在Table中删除行
* added by chenxiang
* 2009-11-05
*/
function deleteRow(tableId, row)
{
    hasChange = 1;
    var tb = document.getElementById(tableId);
    tb.deleteRow(row);
}

/*设置Table中单元格的显示文本
* added by chenxiang
* 2009-11-05
*/
function setCellText(tableId, row, cell, text)
{
    hasChange = 1;
    var tb = document.getElementById(tableId);
    if(tb.rows[row].cells[cell].children.length == 0)
    {
        var objCell = tb.rows[1].cells[0].cloneNode(true);
        clearChildNode(objCell);
        tb.rows[row].cells[cell].innerHTML = objCell.innerHTML;
    }
    
    tb.rows[row].cells[cell].children[0].children[0].innerText = text;
}

/*载入XML模版数据
* added by chenxiang
* tableId:
* xmlModule: xml文件名称
* startRow：起始行，从该行开始编辑
* columnCount：列数
* delRowCount：删除所有行时保留的行数，并从倒数的第几行（delRowCount）开始删除
* MultTableHeader：多表头标志
* 2009-11-06
*/
function menuItemLoadModule(tableId, xmlModule, startRow, columnCount, delRowCount, MultTableHeader)
{
    hasChange = 1;
    
    var xdoc = new ActiveXObject("Microsoft.XMLDOM");
    xdoc.async = "true";
    xdoc.load(xmlModule);
    nodes = xdoc.documentElement.childNodes;
    
    if(nodes.length > 0)
    {
        clearTableRow(tableId, delRowCount, MultTableHeader);
        for(var i = 0; i < nodes.length; i++)
        {
            loadNewRow(tableId, startRow, nodes[i], columnCount);
            startRow++;
            var childNode = nodes[i].childNodes;
            if(childNode.length > 0)
            {                
                for(var j = 0; j < childNode.length; j++)
                {
                    loadNewRow(tableId, startRow, childNode[j], columnCount);
                    startRow++;
                }
            }
        }
    }
}

/*读取Xml的数据到Table行的单元格
* added by chenxiang
* 2009-11-06
*/
function loadNewRow(tableId, row, node, columnCount)
{
    var newRow = addRow(tableId, row, columnCount);
    
    if(columnCount == null)
    {        
        newRow.cells[0].children[0].children[0].innerText = node.getAttribute("Sequence");
        newRow.cells[1].children[0].children[0].innerText = node.getAttribute("Item");
        newRow.cells[2].children[0].children[0].innerText = node.getAttribute("Content");
    
        switch(tableId)
        {
            case "tpPrecept":            
                newRow.cells[3].children[0].children[0].innerText = node.getAttribute("Score");
                newRow.cells[4].children[0].children[0].innerText = node.getAttribute("VoteValue");
                break;
            case "tpQualify":
                newRow.cells[3].children[0].children[0].innerText = node.getAttribute("Score");
                newRow.cells[4].children[0].children[0].innerText = node.getAttribute("VoteValue");
                break;
            case "tpTechBid":
                newRow.cells[3].children[0].children[0].innerText = node.getAttribute("Qualified") != null ? (node.getAttribute("Qualified") == "True" ? "是" : "否") : node.getAttribute("Score");
            case "tpProject":
                newRow.cells[3].children[0].children[0].innerText = node.getAttribute("Score");
                break;
        }
    }
    else
    {
	    for(var i = 0; i < newRow.cells.length; i++)
        {
            var cell;
        
            if(newRow.cells[i].children[0] != null && newRow.cells[i].children[0].children[0] != null)
            {
                cell = newRow.cells[i].children[0].children[0];
            }
            else
            {
                cell = newRow.cells[i];
            }
            if(node.attributes[i] != null)    //wuyl+,2009.12.19
            {
              cell.innerText = node.attributes[i].nodeValue;
            }
        }
    }
}

/*删除Table行
* added by chenxiang
* 2009-11-06
*/
function clearTableRow(tableId, delRowCount, MultTableHeader)
{
    var tb = document.getElementById(tableId);
    if(MultTableHeader == null || MultTableHeader == 1) 
    {
      while(tb.rows.length > delRowCount)
      {
        tb.deleteRow(tb.rows.length - delRowCount);
      }
    }
    else       //表头多行的情况
    {
      while(tb.rows.length > delRowCount + 1)
      {
        tb.deleteRow(tb.rows.length - MultTableHeader);
      }
    }    
}

function getHasChange()
{
    return hasChange;
}

function setHasChange(changeValue)
{
    if (changeValue == null)
    {
        hasChange = 0;
    }
    else
    {
        hasChange = changeValue;
    }
}

/*
*定位光标到控件
*chenxiang 2009-12-22
*/
function goFocus(inputId)
{
    $('#' + inputId).focus();
}

/*
 *
 * 模拟键盘tab和shift+tab切换
 * @XiongTao
 * 2009-12-2
 */

//tabCount = input中的数字
var tabCount=1;
//包括在外的input
function tabMethod()
{
	if(hisRecord[0])
	{
		var sR = /\d+/;
		var iID = parseInt(hisRecord[0].match(sR));
		var iRel = parseInt(document.body.rel);
		tabCount = (tabCount < iRel) ? iID+1 : iID;
	}
	try{
		$('#input'+tabCount).focus();
	}catch(err){
		hisRecord[0] = 'input'+tabCount;
		arguments.callee();
	}
}
function shiftTabMethod()
{	
	if(hisRecord[0])
	{	
		var sR = /\d+/;
		var iID = parseInt(hisRecord[0].match(sR));
		tabCount = (tabCount > 1) ? iID-1 : iID;
	}
	try{
		$('#input'+tabCount).focus();
	}catch(err){
		hisRecord[0] = 'input'+tabCount;
		arguments.callee();
	}
}


//
//页面加载后的初始化操作
//
//oEle 为目标节点name
function SwEle(zbfs, pbff, psfs)
{
    $("#sc1").style.display = zbfs == "1" ? "block" : "none";
    $("#sc2").style.display = zbfs == "2" ? "block" : "none";

    $("#sc31").style.display = pbff == "经评审的最低投标价法" ? "block" : "none";
    $("#sc32").style.display = pbff == "综合评估法" ? "block" : "none";

    $("#div最低价定量").style.display = psfs == "定量" ? "block" : "none";
    $("#div最低价定性").style.display = psfs == "定性" ? "block" : "none";

    $("#input174").checked = pbff == "综合评估法";
    $("#input173").checked = pbff == "经评审的最低投标价法";
}

/*
*隐藏或显示某个DIV控件
*chenxiang 2009-12-24
*/
function showDiv(tbId)
{
    var target = $('#' + tbId);
    if(target.style.display == "block")
    {
        target.style.display = "none";
    }
    else
    {
        target.style.display = "block";
    }
}


//
//模拟点击某个input以执行事件目标函数
//
//id为String
//@xiongtao
//2009-12-21
//
function clickInput(id)
{
	$('#'+id).click();
}

//
//页面是否被加载切程序运行完成
//@xiongtao
//2009-12-21
//
function isPageComplete()
{
	return pageComplete;
}

/*
*chenxiang+ 2009-12-25
*/
function setCheckBox(inputId, checked)
{
    $('#' + inputId).checked = checked;
    invokeGprun(inputId);
}

/*
*chenxiang+ 2009-12-25
*/
function getCheckBox(inputId)
{
    return $('#' + inputId).checked;
}

//
//判断同一个分组中对象是否被选择
//全未选返回false,否则为true
//[str]为标签name字符串
//@xiongtao
//2009-12-28
//
function groupSelect(str){
	var oObj = $("@"+str);
	for(var i=0,iLength = oObj.length; i<iLength; i++)
	{
		if(oObj[i].checked === true)
		{
			return oObj[i].id;
		}
	}
	return "";
}

function loadXml2Table(tableId, xmlFile, startRow)
{
    hasChange = 1;

    var xdoc = new ActiveXObject("Microsoft.XMLDOM");
    xdoc.async = "true";
    try{
        xdoc.load(xmlFile);
        nodes = xdoc.documentElement.childNodes;
    }
    catch(ex)
    {
        return "";
    }
    
    try
    {
        var tb = document.getElementById(tableId);
        while(tb.rows.length > startRow)
        {
            tb.deleteRow(startRow);
        }
        
        if(nodes.length > 0)
        {
            var cellCount = tb.getElementsByTagName("tbody")[0].rows[0].cells.length;
            loadXmlNode2Row(tb, cellCount, nodes);
        }

        hasChange = 1;

        return "";
    }
    catch(ex)
    {
        return "保存数据到HTML失败";
    }
}

function loadXmlNode2Row(tb, cellCount, nodes)
{
    for(var i = 0; i < nodes.length; i++)
    {
        var newRow = tb.insertRow();
        newRow.vAlign = "middle";
        var childNode = nodes[i];
        for(var idx = 0; idx < cellCount; idx++)
        {
            var newCell = newRow.insertCell();
            newCell.className = idx == 0 ? "TD1" : "TD2";
            newCell.innerHTML = "<p></p>";
            if(childNode.attributes[idx] != null)
            {
                newCell.children[0].innerText = TransToHtmlEntity(childNode.attributes[idx].nodeValue);
            }
        }

        if(childNode.childNodes.length > 0)
        {
            loadXmlNode2Row(tb, cellCount, childNode.childNodes);
        }
    }
}

function TransToHtmlEntity(str)
{
	var newStr = str;
	
	newStr = newStr.replace(/&amp;/g, "&");
	
	newStr = newStr.replace(/&lt;/g, "<");
	
	newStr = newStr.replace(/&gt;/g, ">");
	
	newStr = newStr.replace(/&apos;/g, "'");
	
	newStr = newStr.replace(/&quot;/g, "\"");
	
	return newStr;
}

//检查Div是否超过参照Div的宽度
//referId:参照Div的Id属性
//id:目标Div的Id属性
//2010-12-04 Youker
function checkIsOverWidth(referId, id)
{
	var obj = $("#" + referId);
	var referWidth = obj.clientWidth || obj.offsetWidth;
	obj = $("#" + id);
	var width = obj.clientWidth || obj.offsetWidth;
	
	if(width > referWidth)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}


//iframeName:框架ID
function SetIframeSize(iframe) {
	//var iframe = document.getElementById(iframeName);
	try {
		var bHeight = iframe.contentWindow.document.body.scrollHeight;
		//var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
		//据说这两个高 度可能不一样
		//var height = Math.max(bHeight, dHeight) + 30;
		//alert("bHeight"+ bHeight+",dHeight"+dHeight);
		iframe.height = bHeight;                
	}catch (ex) {}
}

function iframeReload(id)
{
    try
    {
        var iframe = document.getElementById(id);
        iframe.contentWindow.document.execCommand('Refresh');
        SetIframeSize(iframe);
    }
    catch (ex) { }
}

function checkBoxClick()
{
    var isChecked = event.srcElement.checked;

    switch (event.srcElement.id)
    {
        //不接受联合体投标 
        case "input25":
        case "input63":
        case "input123":
            clearTextAreaValue("input26", isChecked);
            clearTextAreaValue("input64", isChecked);
            clearTextAreaValue("input125", isChecked);
            if (!isChecked)
            {
                switch (event.srcElement.id)
                {
                    case "input25":
                        $("#input26").focus();
                        break;
                    case "input63":
                        $("#input64").focus();
                        break;
                    case "input123":
                        $("#input125").focus();
                        break;
                }
            }
            break;
        //接受联合体投标 
        case "input24":
        case "input62":
        case "input124":
            clearTextAreaValue("input26", !isChecked);
            clearTextAreaValue("input64", !isChecked);
            clearTextAreaValue("input125", !isChecked);
            if (isChecked)
            {
                switch (event.srcElement.id)
                {
                    case "input24":
                        $("#input26").focus();
                        break;
                    case "input62":
                        $("#input64").focus();
                        break;
                    case "input124":
                        $("#input125").focus();
                        break;
                }
            }
            break;
        //不允许分包 
        case "input130":
            if (isChecked)
            {
                clearTextAreaValue("input132", isChecked);
                clearTextAreaValue("input133", isChecked);
                clearTextAreaValue("input134", isChecked);
            }
            break;
        //允许分包 
        case "input131":
            clearTextAreaValue("input132", !isChecked);
            clearTextAreaValue("input133", !isChecked);
            clearTextAreaValue("input134", !isChecked);
            if (isChecked)
            {
                $("#input132").focus();
            }
            break;
        //不允许偏离 
        case "input135":
            if (isChecked)
            {
                clearTextAreaValue("input137", isChecked);
                clearTextAreaValue("input138", isChecked);
            }
            break;
        //允许偏离 
        case "input136":
            clearTextAreaValue("input137", !isChecked);
            clearTextAreaValue("input138", !isChecked);
            if (isChecked)
            {
                $("#input137").focus();
            }
            break;
        //是否授权评标委员会确定中标人-是 
        case "input175":
            if (isChecked)
            {
                //clearTextAreaValue("input177", true);
            }
            break;
        //是否授权评标委员会确定中标人-否 
        case "input176":
            //clearTextAreaValue("input177", !isChecked);
            if (isChecked)
            {
                //$("#input177").focus();
            }
            break;
        //最高投标限价-不设招标控制价; 详见电子招标商务标文件 
        case "input181":
        case "input184":
            if (isChecked)
            {
                clearTextAreaValue("input183", isChecked);
            }
            break;
        //最高投标限价-设招标控制价  
        case "input182":
            clearTextAreaValue("input183", !isChecked);
            if (isChecked)
            {
                $("#input183").focus();
            }
            break;
        case "input207": //评标价计算方法一
        	clearTextAreaValue("input209", !isChecked);
        	clearTextAreaValue("input212", isChecked);
        	clearTextAreaValue("input214", isChecked);
        	if (isChecked)
            {
                $("#input209").focus();
            }
            else
            {
            	$("#input212").focus();
            }
        	break;
        case "input210": //评标价计算方法二
        	clearTextAreaValue("input209", isChecked);
        	clearTextAreaValue("input212", !isChecked);
        	clearTextAreaValue("input214", !isChecked);
        	if (isChecked)
            {
                $("#input212").focus();
            }
            else
            {
                $("#input209").focus();
            }
        	break;
        case "input230": // 分值构成-其他因素
            clearTextAreaValue("input203", !isChecked);
            $("#btnOther_ZHPG").disabled = !isChecked;
            var tr = $("#tr2243_ZHPG");
            var table = document.getElementById("tabZHPG")
            var itemCount = tr.getAttribute("itemCount");
            var rowCount = tr.cells[0].rowSpan;
            var delRow = parseInt(rowCount) - parseInt(itemCount) + parseInt(tr.rowIndex);
            while (parseInt(itemCount) > 0) {
                table.deleteRow(delRow);
                tr.cells[0].rowSpan--;
                tr.cells[1].rowSpan--;
                itemCount--;
                rowCount--;
            }
            tr.setAttribute("itemCount", "0");

            if (isChecked) {
                $("#input203").focus();
            }
            break;
    }
}

function clearTextAreaValue(id, readOnly)
{
    var oEle = $("#" + id);
    if (readOnly)
    {
        oEle.value = "";
    }
    oEle.readOnly = readOnly;
}

// 2013-05-25 Chenx+ 绑定Xml数据到评标办法前附表中。
function loadXml2PBBFQFB(tableId, ctlId, xmlFile)
{
    hasChange = 1;

    var xdoc = new ActiveXObject("Microsoft.XMLDOM");
    xdoc.async = "true";
    try
    {
        xdoc.load(xmlFile);
        nodes = xdoc.documentElement.childNodes;
    }
    catch (ex)
    {
        return "";
    }

    try
    {
        var table = document.getElementById(tableId);
        var tr = document.getElementById(ctlId);
        var itemCount = tr.getAttribute("itemCount");
        var rowCount = tr.cells[0].rowSpan;
        var delRow = parseInt(rowCount) - parseInt(itemCount) + parseInt(tr.rowIndex);
        while (parseInt(itemCount) > 0)
        {
            table.deleteRow(delRow);
            tr.cells[0].rowSpan--;
            tr.cells[1].rowSpan--;
            itemCount--;
            rowCount--;
        }

        var childNode;
        for (var i = 0; i < nodes.length; i++)
        {
            childNode = nodes[i];
            var newRow = table.insertRow(tr.rowIndex + rowCount + i);
            newRow.style.backgroundColor = "#FFFF00";
            var newCell = newRow.insertCell();
            newCell.className = "TD6";
            newCell.vAlign = "center";        
            newCell.innerText = TransToHtmlEntity(childNode.attributes[1].nodeValue);

            if (tableId == "tabZHPG" || ctlId.indexOf("定量") != -1)
            {
                newCell.colSpan = 2;
            }

            if (childNode.attributes[3].nodeName == "分值")
            {
                newCell.colSpan = 1;
                newCell = newRow.insertCell();
                newCell.className = "TD5";
                newCell.vAlign = "center";
                newCell.innerText = TransToHtmlEntity(childNode.attributes[3].nodeValue) + "分"; 
            }

            newCell = newRow.insertCell();
            newCell.className = "TD6";
            newCell.vAlign = "center";
            newCell.innerText = TransToHtmlEntity(childNode.attributes[2].nodeValue);

            newRow.className += " inputFontColor";

            tr.cells[0].rowSpan += 1;
            tr.cells[1].rowSpan += 1;
        }

        tr.setAttribute("itemCount", nodes.length);

        return "";
    }
    catch (ex)
    {
        return "保存数据到HTML失败";
    }
}

function delete评审项目() {
    var arrTable = ["tabZHPG", "tabZDTBJF_定量", "tabZDTBJF_定性"];
    for (var i = 0; i < arrTable.length; i++) {
        var arrTR;
        switch (arrTable[i]) {
            case "tabZHPG":
                arrTR = ["tr211_ZHPG", "tr2241_ZHPG", "tr2242_ZHPG", "tr2243_ZHPG"];
                break;
            case "tabZDTBJF_定量":
                arrTR = ["tr211_ZDTBJF_定量", "tr213_ZDTBJF_定量", "tr214_ZDTBJF_定量"];
                break;
            case "tabZDTBJF_定性":
                arrTR = ["tr211_ZDTBJF_定性", "tr213_ZDTBJF_定性", "tr214_ZDTBJF_定性"];
                break;
        }

        var table = document.getElementById(arrTable[i]);
        for (var j = 0; j < arrTR.length; j++) {
            var tr = document.getElementById(arrTR[j]);
            var itemCount = tr.getAttribute("itemCount");
            if (itemCount == 0) continue;
            var rowCount = tr.cells[0].rowSpan;
            var delRow = parseInt(rowCount) - parseInt(itemCount) + parseInt(tr.rowIndex);
            while (parseInt(itemCount) > 0) {
                table.deleteRow(delRow);
                tr.cells[0].rowSpan--;
                tr.cells[1].rowSpan--;
                itemCount--;
                rowCount--;
            }
            tr.setAttribute("itemCount", "0");
        }
    }
}

//设置页面所有input是否可编辑
//Method = 1 || 0
//1为不可编辑0为可编辑
function lockSet(Method) {
    var zbInput = document.getElementsByTagName("input");
    var zbText = document.getElementsByTagName("textarea");
    var zbSelect = document.getElementsByTagName("select");
    if (Method == 1) {
        for (var i = 0; i < zbInput.length; i++) {
            zbInput[i].disabled = true;
        }

        for (var i = 0; i < zbText.length; i++) {
            zbText[i].disabled = true;
        }

        for (var i = 0; i < zbSelect.length; i++) {
            zbSelect[i].disabled = true;
        }
    }
    else if (Method == 0) {
        for (var i = 0; i < zbInput.length; i++) {
            zbInput[i].disabled = false;
        }

        for (var i = 0; i < zbText.length; i++) {
            zbText[i].disabled = false;
        }

        for (var i = 0; i < zbSelect.length; i++) {
            zbSelect[i].disabled = false;
        }
    }
}