
// 덧글 비번 확인 창 숨기기
function hideDel(article)
{
	theDiv = eval("document.getElementById('div_del_" + article + "')");
	theDiv.style.display = "none";
	return false;
}

// 덧글 비번 확인 창
//function showDel(b_seq, board_seq, article_seq, talk_seq) {
//	CheckPass = window.open("/common/blog/talkback/talkback_delete.asp?b_seq=" + b_seq + "&board_seq=" + board_seq + "&article_seq=" + article_seq + "&talk_seq=" + talk_seq, "CheckPass","width=400,height=170,left=" + (screen.availWidth - 400) / 2 + ",top=" + (screen.availHeight - 182) / 2);
//	CheckPass.focus();
//}
function showDel(article, talk_seq)
{
	theDiv = eval("document.getElementById('div_del_" + article + "')");
	eval("document.getElementById('talk_seq_" + article + "')").value = talk_seq;
	var IE = document.all?true:false;
	
	if (IE) {
	theDiv.style.pixelLeft = wx - 190;
	theDiv.style.pixelTop  = wy - 50;
	theDiv.style.pixelLeft += document.body.scrollLeft;
	theDiv.style.pixelTop  += document.body.scrollTop;
	} else {
	theDiv.style.left = wx - 440 +"px";
	theDiv.style.top = wy - 200 +"px";
	}
	theDiv.style.display = '';
	
	eval("document.getElementById('talk_passwd_" + article + "')").focus();
	return;
}

// 덧글 비번 확인
function checkDel(article)
{
	if (eval("document.getElementById('talk_passwd_" + article + "')").value == "")
	{
		alert('Fill in the password');
		eval("document.getElementById('talk_passwd_" + article + "')").focus();
	}
	else
		eval("document.talk_del_" + article).submit();
}

// 엮인글 URL 복사하기
//function copyUrl(url){
//	window.clipboardData.setData('Text',url);
//	window.alert("엮인글 주소가 복사되었습니다.");
//}

function copyUrl(meintext)
{
  if (window.clipboardData) 
  {
  // the IE-manier

  window.clipboardData.setData("Text", meintext);
  
  // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
  // het is mij echter onbekend vanaf welke versie dit precies werkt:

  }
  else if (window.netscape) 
  { 
  
  // dit is belangrijk maar staat nergens duidelijk vermeld:
  // you have to sign the code to enable this, or see notes below 

  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  
  // maak een interface naar het clipboard

  var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
  if (!clip) return;
  
  // maak een transferable

  var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
  if (!trans) return;
  
  // specificeer wat voor soort data we op willen halen; text in dit geval

  trans.addDataFlavor('text/unicode');
  

  // om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig  om het in op te slaan

  var str = new Object();
  var len = new Object();
  
  var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
  
  var copytext=meintext;
  
  str.data=copytext;
  
  trans.setTransferData("text/unicode",str,copytext.length*2);
  
  var clipid=Components.interfaces.nsIClipboard;
  
  if (!clip) return false;
  
  clip.setData(trans,null,clipid.kGlobalClipboard);
  
  }
  window.alert('copy to trackback address');
  return false;
}


// 엮인글 삭제
function TrackDelete(article, b_idx){
	if (confirm('Are you sure to delete?')){
			theForm = eval('document.track_delete_' + article);
			 theForm.b_idx.value = b_idx;
			 theForm.submit();
	}
}

// 덧글 삭제
function TalkDelete(article, talk_seq){
	if (confirm('Are you sure to delete?')){
			eval("document.getElementById('talk_seq_" + article + "')").value = talk_seq;
			 eval("document.talk_del_" + article).submit();
	}
}


// 포스트 삭제
function PostDelete(board, article){
	if (confirm('Are you sure to delete?')){
			document.getElementById("board_seq_p").value = board;
			document.getElementById("article_seq_p").value = article;
			document.post_status.action = "./board_delete_post.asp";
			document.post_status.submit();
	}
}


// 포스트 수정
function PostModify(board, article){
			document.getElementById("board_seq_p").value = board;
			document.getElementById("article_seq_p").value = article;
			document.post_status.action = "./board_modify.asp";
			document.post_status.submit();
}


// 포스트 쓰기
function PostWrite(board){
			document.getElementById("board_seq_p").value = board;
			document.post_status.action = "./board_write.asp";
			document.post_status.submit();
}


// 방명록 비번 확인 창 숨기기
function hideGuestDel()
{
	document.getElementById("div_guest_del").style.display = "none";
	return false;
}

// 방명록 비번 확인 창
function showGuestDel(article)
{
	theDiv = eval('document.getElementById("div_guest_del")');
	document.getElementById("guest_del_article_seq").value = article;
	theDiv.style.pixelLeft = wx - 190;
	theDiv.style.pixelTop  = wy - 50;
	theDiv.style.pixelLeft += document.body.scrollLeft;
	theDiv.style.pixelTop  += document.body.scrollTop;
	theDiv.style.display = '';
	document.getElementById("guest_del_passwd").focus();
	
	return false;
}

// 방명록 비번 확인
function checkGuestDel(article)
{
	theForm = eval('document.guest_del');
	if (document.getElementById("guest_del_passwd").value == "")
	{
		alert('Fill in the password');
		document.getElementById("guest_del_passwd").focus();
		return;
	}
	else
		document.guest_del.submit();
}

// 블로그 등록관련
var blnUploading = false;
var blnDeleting = false;

function AttachFile() {
	var strFilePath = 'File attaching...';
	var intFileCnt = document.getElementById("file_list").length;

	if (Len(document.getElementById("file_path").value) == 0) {
		alert('To select the file which it will attach.');
		return;
	}

	if (blnUploading) {
		alert('File attaching.');
		return;
	}

	if (blnDeleting) {
		alert('File attaching.');
		return;
	}

	if (intFileCnt >= 5) {
		alert('Until the maximum 5 it is possible');
		return;
	}

	blnUploading = true;

	var nIndex = strFilePath.lastIndexOf('\\');
	if (nIndex > 0)	strFilePath = strFilePath.substr(nIndex + 1);

	var option = new Option(strFilePath, strFilePath, true);
	document.frm_attach_file.file_list.options[intFileCnt] = option;
	
	document.frm_attach_file.submit();
}

function UploadComplete(FilePath, FileName) {
	var intFileCnt = document.getElementById("file_list").length;
	blnUploading = false;

	var nListIndex = intFileCnt - 1;
	document.getElementById("file_list").options[nListIndex].value = FilePath;
	document.getElementById("file_list").options[nListIndex].text = FileName;
}

function UploadCancel() {
	var intFileCnt = document.getElementById("file_list").length;
	blnUploading = false;
	
	var nListIndex = intFileCnt - 1;
	document.getElementById("file_list").options[nListIndex] = null;

	parent.main.ifrm_area.location.href = "about:blank";	
}

function DeleteFile() {
	var FileList = document.getElementById("file_list");

	if (blnUploading) {
		alert('File attaching.');
		return;
	}
	if (blnDeleting) {
		alert('File eliminating.');
		return;
	}
	
	if (FileList.length == 0) {
		alert('There is no file.');
		return;
	}
	
	if (FileList.selectedIndex < 0 || FileList.selectedIndex == null) {
		alert('To select the file which it will eliminate.');
		return;
	}
	
	blnDeleting = true;

	FileList.options[FileList.selectedIndex].text = FileList.options[FileList.selectedIndex].text + ' File remove...';

	var nIndex, strFilePath, strFileName;

	strFilePath = FileList.options[FileList.selectedIndex].value;
	nIndex = strFilePath.lastIndexOf('/');
	strFileName = strFilePath.substr(nIndex + 1);
	strFilePath = strFilePath.substr(0, nIndex);

	if (strFilePath.toLowerCase( ).indexOf('/data/temp') >= 0) {
		document.frm_delete_file.delete_file_index.value = FileList.selectedIndex;
		document.frm_delete_file.delete_file_path.value = FileList.options[FileList.selectedIndex].value;
		
		document.frm_delete_file.submit();
	} else {
		if (Len(document.getElementById("delete_file_list").value) > 0) document.getElementById("delete_file_list").value = document.getElementById("delete_file_list").value + ',';
		document.getElementById("delete_file_list").value = document.getElementById("delete_file_list").value + FileList.options[FileList.selectedIndex].value;
		
		DeleteComplete(FileList.selectedIndex);
	}
}

function DeleteComplete(ListIndex) {
	blnDeleting = false;
	
	document.getElementById("file_list").options[ListIndex] = null;
}

function DeleteCancel() {
	blnDeleting = false;
	
	var FileList = document.getElementById("file_list");

	var strFilePath = FileList.options[FileList.selectedIndex].value;
	var nIndex = strFilePath.lastIndexOf('/');
	var strFileName = strFilePath.substr(nIndex + 1);

	FileList.options[FileList.selectedIndex].text = strFileName;
}

function KeyDeleteFile() {
	if (window.event.keyCode == 46) DeleteFile();
}

function SetImageInfo() {
	for (var i, i = document.getElementById("img_list_1").length - 1; i >= 0; i--)
		document.getElementById("img_list_1").options[i] = null;

	for (var i, i = document.getElementById("img_list_2").length - 1; i >= 0; i--)
		document.getElementById("img_list_2").options[i] = null;
	
	var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

	parent.main.ifrm_area.document.open();
	parent.main.ifrm_area.document.write(document.getElementById("org_content").innerHTML);
	parent.main.ifrm_area.document.close();

	if (parent.main.ifrm_area.document.getElementsByTagName("img").length) {
		var intImgIndex = parent.main.ifrm_area.document.getElementsByTagName("img").length

		for (var i, i = 0; i < intImgIndex; i++) {
			var option = new Option(parent.main.ifrm_area.document.getElementsByTagName("img")[i].src, parent.main.ifrm_area.document.getElementsByTagName("img")[i].src, true);
			document.getElementById("img_list_1").options[i] = option;
			document.getElementById("img_list_1").options[i].selected = true;
		}
	}

	parent.main.ifrm_area.document.open();
	parent.main.ifrm_area.document.write(oEditor.GetXHTML());
	parent.main.ifrm_area.document.close();

	if (parent.main.ifrm_area.document.getElementsByTagName("img").length) {
		var intImgIndex = parent.main.ifrm_area.document.getElementsByTagName("img").length

		for (var i, i = 0; i < intImgIndex; i++) {
			var option = new Option(parent.main.ifrm_area.document.getElementsByTagName("img")[i].src, parent.main.ifrm_area.document.getElementsByTagName("img")[i].src, true);
			document.getElementById("img_list_2").options[i] = option;
			document.getElementById("img_list_2").options[i].selected = true;
		}
	}
}

function SetFileInfo () {
	for (var i, i = 0; i < document.getElementById("file_list").length; i++) {
		var option = new Option(document.getElementById("file_list").options[i].text, document.getElementById("file_list").options[i].value, true);

		document.getElementById("file_list_1").options[i] = option;
		document.getElementById("file_list_1").options[i].selected = true;
	}
}

function CheckForm() {
	if (document.getElementById("topic")) {
		if (Len(document.getElementById("topic").value) == 0) {
			alert('Fill in the subject.');
			document.getElementById("topic").focus();
			return;
		}
	}

	var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

	if (Len(oEditor.GetXHTML()) == 0) {
		alert('Fill in the content.');
		return;
	}

	SetImageInfo();
	if (document.getElementById("frm_attach_file")) {
		SetFileInfo();
	}

	document.frm_article_info.submit();
}

function CheckPhotoForm() {
	if (document.getElementById("topic")) {
		if (Len(document.getElementById("topic").value) == 0) {
			alert('Fill in the subject.');
			document.getElementById("topic").focus();
			return;
		}
	}

	var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

	if (Len(oEditor.GetXHTML()) == 0) {
		alert('Fill in the content.');
		return;
	}

	SetImageInfo();
	if (document.getElementById("file_list").length == 0) {
		alert('Upload more than one image file Please.');
		return;
	} else {
		SetFileInfo();
	}

	document.frm_article_info.submit();
}

function GoBlogCatW(return_url, b_seq, board_seq) {
	location.href='/blog/' + return_url + '/board_write.asp?b_seq=' + b_seq + '&board_seq=' + board_seq;
}

function ToggleDelAll(theForm, theID) {
	if (eval('theForm.' + theID).length) {
		for (var i, i = 0; i < eval('theForm.' + theID).length; i++) {
			eval('theForm.' + theID)[i].checked = eval('theForm.' + theID + '_all').checked;
		}
	} else {		
		if (eval('theForm.' + theID).checked) {
			eval('theForm.' + theID).checked = eval('theForm.' + theID + '_all').checked;
		} else {
			eval('theForm.' + theID).checked = eval('theForm.' + theID + '_all').checked;
		}
	}
}

function ToggleGuestDelAll() {
	alert(getElementByName("guest_del_seq").length);
	if (getElementByName(theID).length) {
		for (var i, i = 0; i < getElementByName(theID).length; i++) {
			getElementByName(theID)[i].checked = getElementByName(theID).checked;
		}
	} else {		
		if (eval('theForm.' + theID).checked) {
			eval('theForm.' + theID).checked = eval('theForm.' + theID + '_all').checked;
		} else {
			eval('theForm.' + theID).checked = eval('theForm.' + theID + '_all').checked;
		}
	}
}

function DeleteBatch(theForm, theID) {	
	if (eval(theForm + '.' + theID).length) {
		for (var i, i = 1; i < eval(theForm + '.' + theID).length; i++) {
			if (eval(theForm + '.' + theID + '[i]').checked) break;
		}
		if (i == eval(theForm + '.' + theID).length) {
			alert('To select the article which it will eliminate');
			return;
		}

		if (confirm('Under eliminating route it wishes the article?')) {
			eval(theForm).action = '/common/blog/talkback/talkback_delete_batch.asp';
			eval(theForm).submit();
		}
		else {
			return;
		}
	} else {
		if (eval(theForm + '.' + theID).checked) {
			if (confirm('Under eliminating route it wishes the article?')) {
				eval(theForm).action = '/common/blog/talkback/talkback_delete_batch.asp';
				eval(theForm).submit();
			}
			else {
				return;
			}
		} else {
			alert('To select the article which it will eliminate');
			return;
		}
	}
}

function DeleteTrackBatch(theForm, theID) {	
	if (eval(theForm + '.' + theID).length) {
		for (var i, i = 1; i < eval(theForm + '.' + theID).length; i++) {
			if (eval(theForm + '.' + theID + '[i]').checked) break;
		}
		if (i == eval(theForm + '.' + theID).length) {
			alert('To select the article which it will eliminate');
			return;
		}

		if (confirm('Under eliminating route it wishes the article?')) {
			eval(theForm).action = '/common/blog/trackback/trackback_delete_batch.asp';
			eval(theForm).submit();
		}
		else {
			return;
		}
	} else {
		if (eval(theForm + '.' + theID).checked) {
			if (confirm('Under eliminating route it wishes the article?')) {
				eval(theForm).action = '/common/blog/trackback/trackback_delete_batch.asp';
				eval(theForm).submit();
			}
			else {
				return;
			}
		} else {
			alert('To select the article which it will eliminate');
			return;
		}
	}
}

function DeleteGuestBatch(theForm, theID) {	
	if (eval(theForm + '.' + theID).length) {
		for (var i, i = 1; i < eval(theForm + '.' + theID).length; i++) {
			if (eval(theForm + '.' + theID + '[i]').checked) break;
		}
		if (i == eval(theForm + '.' + theID).length) {
			alert('To select the article which it will eliminate');
			return;
		}

		if (confirm('Under eliminating route it wishes the article?')) {
			eval(theForm).action = '/common/blog/guest/board_delete_batch.asp';
			eval(theForm).submit();
		}
		else {
			return;
		}
	} else {
		if (eval(theForm + '.' + theID).checked) {
			if (confirm('Under eliminating route it wishes the article?')) {
				eval(theForm).action = '/common/blog/guest/board_delete_batch.asp';
				eval(theForm).submit();
			}
			else {
				return;
			}
		} else {
			alert('To select the article which it will eliminate');
			return;
		}
	}
}
