function GoWrite()
{
	var string = document.form.title ;
	if(string.value=="")
	{

		string.focus() ;
		return;
	}

	var string = document.form.contents ;
	if(string.value=="")
	{

		string.focus() ;
		return;
	}
	
	document.form.action="write_ok.php";
	document.form.submit();
}

function GoEDITWrite(elClicked)
{
	var string = document.form.title ;
	if(string.value=="")
	{		
		string.focus() ;
		return;
	}

	oEditors.getById["contents"].exec("UPDATE_IR_FIELD", []);
	
	var string = document.getElementById("contents");
	if(string.value=="")
	{		
		oEditors.getById["contents"].exec("FOCUS");
		return;
	}

	try{
		document.form.action="_write_ok.php";
		elClicked.form.submit();
	}catch(e){}	
	
}

function GoImgWrite()
{
	var string = document.form.title ;
	if(string.value=="")
	{
		
		string.focus() ;
		return;
	}

	var string = document.form.files;
	if(string.value=="")
	{
		
		string.focus() ;
		return;
	}
	
	var string = document.form.files1;
	if(string.value=="")
	{

		string.focus() ;
		return;
	}

	document.form.action="write_ok.php";
	document.form.submit();
}

function GoImgEdit()
{
	var string = document.form.title ;
	if(string.value=="")
	{
		
		string.focus() ;
		return;
	}

	document.form.action="edit_ok.php";
	document.form.submit();
}


function GoEdit(mode,menu,idx,hfile)
{
	document.form.action="main.html?mode="+mode+"&menu="+menu+"&idx="+idx+"&hfile="+hfile;
	document.form.submit();
}

function GoEdit1(mode,menu,idx,hfile)
{
	//alert(mode);
	document.form.action="main.html?mode="+mode+"&menu="+menu+"&idx="+idx+"&hfile="+hfile;
	document.form.submit();
}


function GoUpdate()
{
	document.form.action="edit_ok.php";
	document.form.submit();
}

function GoEDITUpdate(elClicked)
{
	oEditors.getById["contents"].exec("UPDATE_IR_FIELD", []);

	try{
		document.form.action="_edit_ok.php";
		elClicked.form.submit();
	}catch(e){}	
}

function GoDelete()
{
	//if (confirm('Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
	//{
		document.form.action="delete_ok.php";
		document.form.submit();
	//}
}

function memo_write(dy,dm,dd,memu,viewtime)
{	
	location.href = "main.html?menu="+memu+"&dy="+dy+"&dm="+dm+"&dd="+dd+"&mode=write&viewtime="+viewtime;
	//document.form.action="main.html?menu="+memu+"&dy="+dy+"&dm="+dm+"&dd="+dd+"&mode=write";
	//document.form.submit();
}

function GoMemoWrite()
{
	if(form.name.value == ""){
		form.name.focus();
		return false;
	}
	if(form.pwd.value == ""){
		form.pwd.focus();
		return false;
	}
	if (form.memo.value == ""){
		form.memo.focus();
		return false;
	}

	document.form.action="write_ok.php";
	document.form.submit();
}	

function GoMemoDelete(idx,page)
{
	//if (confirm('Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
	//{
		document.form.action="delete_ok.php?idx="+idx+"&page="+page;
		document.form.submit();
	//}
}

function GoAdminEdit()
{

	var string = document.form.adminid ;
	if(string.value=="")
	{

		string.focus() ;
		return;
	}

	var string = document.form.adminpwd ;
	if(string.value=="")
	{
		string.focus() ;
		return;
	}
	document.form.action="admin.php";
	document.form.submit() ;
	
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers(l,i,m,idx) { //v6.0
	

  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { 
	obj=obj.style; 
	v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
	}
				
		if (v == 'visible')
		{
			obj.visibility=v;			
			startRequest(idx);
			obj.left=700;
			obj.top=400;
		}
	
		else if (v == 'show')
		{
			if(document.getElementById('Layer1').style.display == " ")
			{
				document.getElementById('Layer1').style.display = "none";
			}

			obj.visibility='visible'; 		
			startRequest(idx);
			obj.left=event.x;
			obj.top=event.y;
			
		}

		else
		{			
			delTable()
		}
	
	}
	
}

var xmlHttp;

function createXMLHttpRequest() {
    if(window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else if(window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function startRequest(idx) {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", "memo.html?idx="+idx, true);
    xmlHttp.send(null);
}

function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			
			var addStr = xmlHttp.responseText;
			var table = document.getElementById("tblmemo");
			var newRow = table.insertRow();
			var newCell = newRow.insertCell();
			newCell.innerHTML = addStr;
			
        }
    }
}


function delTable()
{
	 
	var table = document.getElementById("tblmemo");
	for( var i=0; i< table.rows.length; i++ ) {			
		 table.deleteRow(i);		
	}
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit){ 		
	form.memo.focus();
	document.getElementById("memo").readOnly = true;	
	//field.value = field.value.substring(0,maxlimit);
// ³²Àº±ÛÀÚ¼ö  Ä«¿îÅÍ ºÎºÐ
}
else {
	countfield.value = maxlimit - field.value.length;
	}
}


function GoScheduleWrite()
{
	var conLen = document.form.contents1.value.length + document.form.contents2.value.length + document.form.contents3.value.length + document.form.contents4.value.length + document.form.contents5.value.length + document.form.contents6.value.length;
	
	if(conLen < 1 )
	{
		//alert("ÇÏ³ª ÀÌ»óÀÇ ÀÏÁ¤À» ÀÔ·ÂÇØÁÖ½Ê½Ã¿À.");
		document.form.contents1.focus() ;
		return;
	}	
	
	document.form.action="write_ok.php";
	document.form.submit();
}



function  banner_pop()
{
	/*
	var url = "pop.html"; // ÆË¾÷Ã¢ ÁÖ¼Ò
	window.open(url,'banner','left=0,top=0,width=200,height=300');
	*/
}

function open_layer(idx, viewtime)
{
	//alert(viewtime);
	location.href="schedule.html?midx="+idx+"&viewtime="+viewtime;
}

function close_layer(viewtime)
{
	location.href="schedule.html?viewtime="+viewtime;
}

function OpenReplyPwd(idx, ridx, page, mode, grp, lev)
{
	var url = "../admin/password_check.html?idx="+idx+"&ridx="+ridx+"&page="+page+"&mode="+mode+"&grp="+grp+"&lev="+lev;
	window.open(url, "reply", "width=450, height=120, top=700, left=500");

}

function OpenReply(grp, idx, page)
{
	var url = "../admin/reply.php?idx="+idx+"&grp="+grp+"&page="+page;
	window.open(url, "reply", "width=450, height=120, top=700, left=500");
}

function account_term()
{
	document.form.action = "term_ok.php";
	document.form.submit();
}
