// image roll
function imgOver(imgEl) {
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function imgOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}



// Flash ¸Þ´º
function FlashMain(vUrl,obj,wid,hei) {
	var viewObj = '' +
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,22,0" width="' + wid + '" height="' + hei + '" id="' + obj + '" align="middle">' +
	'<param name="allowScriptAccess" value="always">' +
	'<param name="FlashVars" value="" domain=/img/flash/">' +
	'<param name="movie" value="' + vUrl + '" />' +
	'<param name="wmode" value="transparent" />' +
	'<param name="menu" value="false" />' +
	'<param name="quality" value="high" />' +
	'<embed src="' + vUrl + '" wmode="transparent" menu="false" quality="high" width="' + wid + '" height="' + hei + '" name="' + obj + '" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
	'</object>';
	document.write(viewObj);
}


/* ###########################################
                    Menu RollOver
########################################### */
/*subMenu*/
function subMenu() {
	subMenuEl = document.getElementById("Menu").getElementsByTagName("li");
	for (i=0; i<subMenuEl.length; i++) {
		var menuAnchor = subMenuEl[i].getElementsByTagName("a")[0];
		menuAnchor.onmouseover = subMenuOver;
		menuAnchor.onmouseout = subMenuOut;
	}
}
var subCurrentOn;
function subMenuOver() {
	subMenuIMG = this.getElementsByTagName("img").item(0);
	name = subMenuIMG.src;
	if( name.indexOf("_on.gif") <= 0 ) {
		this.className = "subon";
		subMenuIMG.src = name.replace(".gif", "_on.gif");
	} else {
		subCurrentOn = subMenuIMG;
	}
}
function subMenuOut() {
	subMenuIMG = this.getElementsByTagName("img").item(0);
	if( subCurrentOn != subMenuIMG ) {
		this.className = "";
		subMenuIMG.src = subMenuIMG.src.replace("_on.gif", ".gif");
	}
}



/* ###########################################
                     link selectBox
########################################### */
function viewSelLink() {
	target = this.href;
	linkEl = document.getElementById(target.split("#")[1]);
	if (linkEl.style.display == "block") {
		linkEl.style.display = "none";
	} else {
		linkEl.style.display = "block";
	}
	siteLinkEl = linkEl.getElementsByTagName("li");
	for(j=0; j<siteLinkEl.length; j++) {
		siteLinkEl[j].getElementsByTagName("a")[0].onclick = hideSelLink;
	}
	return false;
}
function hideSelLink() {
	linkEl.style.display = "none";
}

function initSelLink(linkElld) {
	selLinkEl = document.getElementById(linkElld);
	selLinkElH2 = selLinkEl.getElementsByTagName("h4");
	for(i=0; i<selLinkElH2.length; i++) {
		selLinkElH2[i].getElementsByTagName("a")[0].onclick = viewSelLink;
	}
}


/* #################################################
                    »çÀÌµå µû¶ó´Ù´Ï´Â ¹è³Ê¹× Å¾¹öÆ°
################################################# */
function IEZN_quick_menu_simple(input_obj,move_top){
    this.timeId     = new Array();
    this.div_obj = new Array();
    try{
        this.input_obj = input_obj;
        this.input_obj.style.display = 'none';
    }catch(e){}
    var IEZN_quick_menu_counter;
    IEZN_quick_menu_counter = (typeof(IEZN_quick_menu_counter)=='undefined')? 0:IEZN_quick_menu_counter++;
    this.counter = IEZN_quick_menu_counter;
    this.div_obj_top = parseInt(this.input_obj.style.top);
    this.div_obj_left = parseInt(this.input_obj.style.left);    
    this.div_obj_max_move_top = (move_top)? move_top:this.div_obj_top;//browser top offset 
    this.move();
}

IEZN_quick_menu_simple.prototype = {    
    move : function(){
        this.div_obj = document.createElement("div");
        this.div_obj.id='izqm1'+this.counter;
        this.div_obj.style.position = 'absolute';
        this.div_obj.style.top=this.div_obj_top+'px';
        this.div_obj.style.padding='0px';
        this.div_obj.style.left=this.div_obj_left+'px';
        this.div_obj.style.backgroundColor=(this.input_obj.style.backgroundColor)? this.input_obj.style.backgroundColor:'transparent';
        this.div_obj.style.overflow='hidden';
        this.div_obj.style.textOverflow='ellipsis';
        this.div_obj.style.width=this.input_obj.style.width;
        this.div_obj.style.border=this.input_obj.style.border;
        this.div_obj.style.padding=this.input_obj.style.padding;
        try{
            document.body.appendChild(this.div_obj);            
            this.div_obj.innerHTML = this.input_obj.innerHTML;
            this.move_menu();
        }catch(e){alert(e)}
    },
    move_menu : function (){
        var obj = this;
        this.div_obj_start = parseInt(this.div_obj.style.top,10);
        this.div_obj_end = parseInt(this.scrollTop()) + parseInt(this.div_obj_max_move_top,10);
        if (this.div_obj_end < parseInt(this.div_obj_top,10)) this.div_obj_end = parseInt(this.div_obj_top,10);
        if (this.div_obj_start != this.div_obj_end ) {
            this.div_obj_offset = Math.ceil(Math.abs( this.div_obj_end - this.div_obj_start ) / 15 );
            t = parseInt(this.div_obj.style.top, 10) + ((this.div_obj_end<this.div_obj_start)? this.div_obj_offset*-1:this.div_obj_offset);
            this.div_obj.style.top = t+'px';
            this.slide_time = 10;
        }
        this.timeId[this.div_obj.id] = window.setTimeout(function(){obj.move_menu()},this.slide_time);
    },
    scrollTop : function (){//xhtml doctype patch
        if (window.pageYOffset){
            scroll_top = window.pageYOffset
        }else if (document.documentElement && document.documentElement.scrollTop){
            scroll_top = document.documentElement.scrollTop
        }else if (document.body){
            scroll_top = document.body.scrollTop
        }
        return scroll_top;
    }
}



function allcheck(theform , name)	{
	for( var i=0; i<theform.elements.length; i++) {
		var ele = theform.elements[i];
		if( ele.name == name )
			ele.checked = true;
	}
	return;
}

function discheck(theform , name){
	for( var i=0; i<theform.elements.length; i++) {
		var ele = theform.elements[i];
		if( ele.name == name )
			ele.checked = false;
	}
	return;
}

function revcheck(theform , name) {
	for( var i=0; i<theform.elements.length; i++) {
		var ele = theform.elements[i];
		if(ele.name == name )
			ele.checked = !ele.checked;
	}
	return;
}

function revcheck(theform , name , src) {
	for( var i=0; i<theform.elements.length; i++) {
		var ele = theform.elements[i];
		if(ele.name == name )
			ele.checked = !ele.checked;
	}
	return;
}

function checkcount(theform , name) {
	var cnt=0;
	if( theform.elements == null || theform.elements.length == null ) {
		return 0;
	}

	for( var i=0; i<theform.elements.length; i++) {
		var ele = theform.elements[i];
		if(ele.name == name )
			if( ele.checked == true ){
				cnt++;
			}
	}
	return cnt;
}


var num = 2;
//Ã·ºÎÆÄÀÏ Ãß°¡
function add_file(){
	var num2 = (num - 1);

	if (document.all["files"+num2].value != null && document.all["files"+num2].value != "") {

			var oOption = document.createElement("OPTION");
			var fileName = document.all["files"+num2].value;
			oOption.text = fileName;
			oOption.value = num2;
			document.all.oSelect.add(oOption);
			var newDivTag1 = document.createElement("<div>");
			var newDivTag2 = document.createElement("<div>");
			var temp = "<input width=1 type='file' id ='files" + num + "' onKeydown='event.returnValue=false;' onpropertychange='add_file()'  name='attachfile" + num +"'  class='txt01' style='width: 471px; margin: 0; height: 19px;'>";
			var newFileObject = document.createElement(temp);
			
			var filenum = "files" +num2;
			
			document.all[filenum].onpropertychange = null;
			document.all[filenum].style.display = "none";

			document.all.filetd.insertBefore(newDivTag1, document.all.oSelect);
			document.all.filetd.insertBefore(newFileObject, document.all.oSelect);
			document.all.filetd.insertBefore(newDivTag2, document.all.oSelect);        

			if (document.all.oSelect.length >= (500 * 1024 * 1024)) {
				document.all["files"+num].onpropertychange = null;
				document.all["files"+num].style.display = "none";
			}
			num++; 
	} 
}
function add_file2(){
	var num2 = (num - 1);

	if (document.all["files"+num2].value != null && document.all["files"+num2].value != "") {

			var oOption = document.createElement("OPTION");
			var fileName = document.all["files"+num2].value;

			if ( fileName.indexOf(".PNG") != -1 ||
				 fileName.indexOf(".JPG") != -1 ||
				 fileName.indexOf(".GIF") != -1 ||
				 fileName.indexOf(".png") != -1 ||
				 fileName.indexOf(".gif") != -1 ||
				 fileName.indexOf(".jpg") != -1 ){
			}else{
				if ( fileName != "" ){
					alert("ÀÌ¹ÌÁöÆÄÀÏÀÌ ¾Æ´Õ´Ï´Ù.");
					return false;
				}
				return false;
			}

			oOption.text = fileName;
			oOption.value = num2;
			document.all.oSelect.add(oOption);
			var newDivTag1 = document.createElement("<div>");
			var newDivTag2 = document.createElement("<div>");
			var temp = "<input width=1 type='file' id ='files" + num + "' onKeydown='event.returnValue=false;' onpropertychange='add_file()'  name='attachfile" + num +"'  class='txt01' style='width: 471px; margin: 0; height: 19px;'>";
			var newFileObject = document.createElement(temp);
			
			var filenum = "files" +num2;
			
			document.all[filenum].onpropertychange = null;
			document.all[filenum].style.display = "none";

			document.all.filetd.insertBefore(newDivTag1, document.all.oSelect);
			document.all.filetd.insertBefore(newFileObject, document.all.oSelect);
			document.all.filetd.insertBefore(newDivTag2, document.all.oSelect);        

			if (document.all.oSelect.length >= (500 * 1024 * 1024)) {
				document.all["files"+num].onpropertychange = null;
				document.all["files"+num].style.display = "none";
			}
			num++; 
	} 

}
//Ã·ºÎÆÄÀÏ »èÁ¦
function del_list() {
	if (document.frm.oSelect.selectedIndex != -1 ) {
			var str = document.frm.oSelect.options[document.frm.oSelect.selectedIndex].text;
			document.frm.oSelect.options[document.frm.oSelect.selectedIndex]=null;
			var i =0;
			for ( i=1; i < num; i++ ) {
					if (document.all["files"+i] != null) {
							var filename = document.all["files"+i].value;
							if ( filename == str ) {
									document.all["files"+i].removeNode(true);
							}
					}
			}
			
if (document.all.oSelect.length < (500 * 1024 * 1024)) {
	var num2 = num -1;
				document.all["files"+num2].onpropertychange = null;
				document.all["files"+num2].style.display = "";
				document.all["files"+num2].onpropertychange = add_file;
			}
	} else {
			alert("»èÁ¦ÇÒ ÆÄÀÏÀ» ¼±ÅÃÇØÁÖ½Ê½Ã¿À.");
	}
}
//±Û¾²±â
function submitFrm() {
	var frm = document.frm;

	if( frm.TITLE.value == "" ) {
		alert("Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		frm.TITLE.focus();
		return;
	}
	
	if( frm.CONTENT.value == "" ) {
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		frm.CONTENT.focus();
		return;
	}

	frm.action = './do-write.csp';
	frm.submit();
}


//°Ô½Ã¹°À» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î? »èÁ¦
function doDelete(idx){
	var delchk = confirm("°Ô½Ã¹°À» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?");
	if(delchk){
		location.href = "do-delete.csp?idx=" + idx;
	}
	return;
}