var lastPicID="";
var lastSeID="";

function onc_pic(id){
  	if(lastPicID != "" && lastPicID != id) {
  		try {
	  		var lastImg=document.getElementById(lastPicID);
	  		lastImg.setAttribute("src", "images/" + lastPicID + ".gif");
  		}catch(e){}
  	}
  	try {
		var img=document.getElementById(id);
	  	img.setAttribute("src", "images/" + id + "_1.gif");
	}catch(e){}
  	lastPicID=id;
}
function onc_se_bg(id){
  	if(lastSeID != "" && lastSeID != id) {
  		try {
	  		var setup_id=document.getElementById(lastSeID);
	  		setup_id.style.backgroundColor="#E3EFF9";
  		}catch(e){}
  	}
  	try {
		var setup_id_=document.getElementById(id);
	  	setup_id_.style.backgroundColor="#FFFFFF";
	}catch(e){}
  	lastSeID=id;
}
function findObj(theObj, theDoc){ 
	var p, i, foundObj; 
	if(!theDoc)
		theDoc = document; 
	if((p = theObj.indexOf("?")) > 0 && parent.frames.length){
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
	if(!(foundObj = theDoc[theObj]) && theDoc.all)
		foundObj = theDoc.all[theObj];
	for(i=0; !foundObj && i < theDoc.forms.length; i++)
		foundObj = theDoc.forms[i][theObj];
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
		foundObj = findObj(theObj,theDoc.layers[i].document);
	if(!foundObj && document.getElementById)
		foundObj = document.getElementById(theObj);
	return foundObj;
}
function addSignRow(frameName, text, trLastName){ //读取最后一行的行号，存放在txtTRLastIndex文本框中 
	var txtTRLastIndex = findObj(trLastName,document);
	var rowID = parseInt(txtTRLastIndex.value);
	var signFrame = findObj(frameName, document);

	//添加行
	var newTR = signFrame.insertRow(signFrame.rows.length);
	newTR.id = "SignItem" + rowID;

	//添加列:序号
	var newNameTD = newTR.insertCell(0);

	//添加列内容
	newNameTD.innerHTML = text;
	txtTRLastIndex.value = (rowID + 1).toString();
}
function clearEdit(){
	var editor = document.getElementById("webEditor").contentWindow.document.getElementById("HtmlEditor").contentWindow;
	dwr.util.setValue('content_','');
	editor.document.open();
	editor.document.writeln('<HTML><HEAD><TITLE> New Document </TITLE><style>body{font-size:14px;padding-top:5px;padding-left:5px;padding-right:0px;margin:0px}</style></HEAD><BODY></BODY></HTML>');
	editor.document.close();
}
function insertLeaveword(html){
	var editor = document.getElementById("webEditor").contentWindow.document.getElementById("HtmlEditor").contentWindow;
	editor.focus();
	if (editor.document.selection.type.toLowerCase() != "none"){
		editor.document.selection.clear();
	}
	editor.document.selection.createRange().pasteHTML(html);
}