function SetBarShow(num)
{
	var tr = document.activeElement.parentElement.parentElement;
	for(i=0;i<num;i++)
	{
		tr = tr.nextSibling;
		if(tr.style.display == "")
		{
			tr.style.display = "none";
			document.activeElement.children(0).src="../images/bbs/exp_plus.gif";
		}
		else
		{
			tr.style.display = "";
			document.activeElement.children(0).src="../images/bbs/exp_minus.gif";
			tr.scrollIntoView(true);
		}
	}
}
function showmsg(Div)
{
    document.getElementById(Div).style.display="none";
   
    var objdiv=document.getElementById(Div);
    objdiv.style.display='';
}
function EnableEdit()
{	
	try
	{
		document.frames(1).document.designMode = "on";	
	}
	catch(e)
	{
	}
}

function SaveState()
{
	var ifm = document.all("editpan");
	document.all("ctl00$ContentPlaceHolder1$msgbody").value = ifm.contentWindow.document.body.innerHTML;
}	
function newks(num)
{
//    //window.parent.document.frames(1).document.designMode = "on";	
//      var ifm =  window.parent.document.all("msgbody");
//      alert('10');
//      ifm.value=strHTML;
//       alert('20');
    if(num==0)
    {
        document.all("tbxTitle").value="";
    }
    else
    {
        document.all("tbxTitle").value =document.all("ctl00$ContentPlaceHolder1$msgbody").value
    }
}
function GetTextRange()
{
	var ifm = document.getElementById("editpan");
	var sel = ifm.contentWindow.document.selection;
	var rng = sel.createRange();
	return rng;	
}

function CleanFontStyle()
{
	var ifm = document.getElementById("editpan");
	ifm.contentWindow.document.body.innerHTML = ifm.contentWindow.document.body.innerText;
}

function ChangeFontStyle(style)
{
	var rng = GetTextRange();	
	rng.execCommand(style);
}

function ChangeFont(style,item)
{
	var rng = GetTextRange();
	var option = document.all(item);
	var value = option.options(option.selectedIndex).value;
	rng.execCommand(style,false,value);
}
function InsertPic(filename)
{
	var doc = window.parent.document.all("editpan").contentWindow.document;
	var img = doc.createElement("img");
	img.src = filename;
	img.border = "0";
	doc.body.appendChild(img);
}
function InsertHref()
{
	var doc = document.all("editpan").contentWindow.document;
	var link=document.all("txtlink");
	var linkhref=document.all("txtlinkhref");
	var a=doc.createElement("a");
	a.href=linkhref.value;
    a.innerText=link.value;
	doc.body.appendChild(a);
}
function InsertEmotion(filename)
{
	var doc = document.all("editpan").contentWindow.document;	
	var img = doc.createElement("img");
	img.src = "../images/bbs/emoticons/" + filename;
	img.border = "0";
	doc.body.appendChild(img);
}

function InitAttach(filename,value)
{
	var doc = window.parent.document;	
	var td = doc.all("uploaded");			
	var span = doc.createElement("span");
	
	var img = doc.createElement("img");
	img.src = "../images/bbs/sefans/f_norm.gif";
	img.border = "0";
	span.appendChild(img);
	
	var alink = doc.createElement("a");
	alink.href = "attachs/" + filename;
	alink.innerText = filename;	
	alink.target = "_blank";
	span.appendChild(alink);
	
	var del = doc.createElement("input type=button");
	del.onclick = "DelAttachs('" + filename + "')";
	del.value = value;	
	span.appendChild(del);
	
	td.appendChild(span);
	
	td.innerHTML += "<br>";	
}

function InitEditPan()
{	
    var s = document.getElementById("ctl00$ContentPlaceHolder1$DropDownList1");
    if(s.selectedIndex==0)
    {
        document.all("tbxTitle").value="";
    }
    else
    {
        document.all("tbxTitle").value=s.options[s.selectedIndex].text;
    }
	document.frames(1).document.write(GetIFrameValue());
	document.frames(1).document.designMode = "on";	
}
function InitEditPanRead()
{	
	document.frames(1).document.write(GetIFrameValue());
	document.frames(1).document.designMode = "on";	
}
function InitEditPanReadSendMSG()
{	
	document.frames(1).document.write(GetIFrameValueSendMSG());
	document.frames(1).document.designMode = "on";	
}
function InitEditPanQuery()
{	
//    var s = document.getElementById("ctl00$ContentPlaceHolder1$DropDownList1");
//    if(s.selectedIndex==0)
//    {
        document.all("tbxTitle").value="";
//    }
//    else
//    {
//        document.all("tbxTitle").value=s.options[s.selectedIndex].text;
//    }
	document.frames(1).document.write(GetIFrameValue());
	document.frames(1).document.designMode = "on";	
}

function InitShowPan()
{
	document.frames(0).document.write(GetIFrameValue());	
}

function GetIFrameValue()
{
	var hidden = document.all("ctl00$ContentPlaceHolder1$msgbody");
	var ht = "";//"<html><head><title></title>"
//	ht += "<style type='text/css' media='all'>@import url( ../style/blankpage.css ); </style>";
//	ht += "<script>function GoHere(url){parent.focus();parent.moveTo(0,0);";
//	ht += "parent.resizeTo(screen.availWidth,screen.availHeight);parent.location=url;}</script>";
//	ht += "</head><body>";
	var he = "";//"</body></html>";
	return 	ht + hidden.value + he ;
}
function GetIFrameValueSendMSG()
{
	var hidden = document.all("msgbody");
	var ht = "";//"<html><head><title></title>"
//	ht += "<style type='text/css' media='all'>@import url( ../style/blankpage.css ); </style>";
//	ht += "<script>function GoHere(url){parent.focus();parent.moveTo(0,0);";
//	ht += "parent.resizeTo(screen.availWidth,screen.availHeight);parent.location=url;}</script>";
//	ht += "</head><body>";
	var he = "";//"</body></html>";
	return 	ht + hidden.value + he ;
}

function InsertAttach(time,filename,value)
{
	var doc = window.parent.document;	
	var hidden = doc.all("attachs");
	hidden.value += time + filename + ";";
	
	var td = doc.all("uploaded");			
	var span = doc.createElement("span");
	
	var img = doc.createElement("img");
	img.src = "../images/bbs/sefans/f_norm.gif";
	img.border = "0";
	span.appendChild(img);
	
	var alink = doc.createElement("a");
	alink.href = "attachs/" + time + filename;
	alink.target = "_blank";
	alink.innerText = filename;	
	span.appendChild(alink);
	
	var del = doc.createElement("input type=button");
	del.onclick = "DelAttachs('" + time + filename + "')";
	del.value = value;	
	span.appendChild(del);
	
	td.appendChild(span);
	
	td.innerHTML += "<br>";
}

function DelAttachs(filename)
{
	var hidden = document.all("attachs");
	hidden.value = hidden.value.replace(filename + ";","");

	document.attach.location = "uploadattach.aspx?exec=del&fn=" + filename;
	var span = document.activeElement.parentElement
	var br = span.nextSibling;
	span.removeNode(true);
	br.removeNode(true);
}

function ShowMessage(boxIn,time)
{
	OpenScrollWindow("ShowMessage.aspx?box=" + boxIn + "&time=" + time ,600,250);
}

function ShowSendMessage(receiver,time)
{
	OpenScrollWindow("ShowMessage.aspx?box=Send&recid=" + receiver + "&time=" + time ,600,250);
}

function MoveAllMessage(box)
{
	var ifm = CreateIFrame("frmExec","MessageExeCmd.aspx?exec=move&param=all&box=" + box,"0","100%");
	document.body.appendChild(ifm);
}

function DeleteAllMessage(box,msg)
{	
	if(window.confirm(msg))
	{
		var ifm = CreateIFrame("frmExec","MessageExeCmd.aspx?exec=del&param=all&box=" + box ,"0","100%");
		document.body.appendChild(ifm);
	}
}

function MoveMessage(box,time)
{
	var ifm = CreateIFrame("frmExec","MessageExeCmd.aspx?exec=move&box=" + box + "&time=" + time ,"0","100%");
	document.body.appendChild(ifm);
}

function EditMessage(boxIn,time)
{
	OpenScrollWindow("EditMessage.aspx?box=" + boxIn + "&time=" + time ,600,507);
}

function DeleteMessage(box,time)
{
	var ifm = CreateIFrame("frmExec","MessageExeCmd.aspx?exec=del&box=" + box + "&time=" + time ,"0","100%");
	document.body.appendChild(ifm);
}

function DeleteSendMessage(recid,time)
{
	var ifm = CreateIFrame("frmExec","MessageExeCmd.aspx?exec=del&recid=" + recid + "&time=" + time ,"0","100%");
	document.body.appendChild(ifm);
}

function DeleteReadMessage()
{
	var ifm = CreateIFrame("frmExec","MessageExeCmd.aspx?exec=del&param=read","0","100%");
	document.body.appendChild(ifm);
}

function MoveReadMessage()
{
	var ifm = CreateIFrame("frmExec","MessageExeCmd.aspx?exec=move&param=read" ,"0","100%");
	document.body.appendChild(ifm);
}