var index = -1;
var XML_ZIPCODE;
var queryStr; // »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ Å°¿öµå
var selectedQueryStr; // ¸¶¿ì½º·Î Å¬¸¯ÇÑ Å°¿öµå

function setListBox(e, str) {
	box = document.getElementById("list_a");
	text = document.frm1.SearchWord;
	list_div = box.contentWindow.document.getElementById("list_div");
	if(str) {
		if(!(e.keyCode == 38 || e.keyCode == 40)) {
			queryStr = text.value;
			index = -1;
			xmlhttp = XMLHTTP();
			with(xmlhttp) {
				open("POST", "../v2005/ajax_Search/search.php", false);
				setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				send("SearchWord=" + encodeURIComponent(str));
				xml = responseXML;
			}
			XML_ZIPCODE = xml.getElementsByTagName("ZIPCODE");
			html = new String;
			for(i = 0; i < XML_ZIPCODE.length; i++) {
				html += "<div id='no_" + i + "' style='width:100%; height:15px; cursor:pointer'";
				html += "onmouseover=\"if(parent.index>-1&&parent.index!=" + i + "){document.getElementById('no_' + parent.index).style.backgroundColor='';} parent.index=" + i + ";this.style.backgroundColor='#EEEEEE';parent.selectedQueryStr='" + XML_ZIPCODE.item(i).getAttribute('ADDR') + "';\" ";
				html += "onmouseout=\"parent.index=-1;this.style.backgroundColor=''\" "; 
				html += "onclick=\"parent.document.frm1.SearchWord.value='" + XML_ZIPCODE.item(i).getAttribute("ADDR") + "'\">¡¤ ";				
				//html += "<font color='#A4A4D2'>[" + XML_ZIPCODE.item(i).getAttribute("CODE") + "]</font> ";//ÁÖ¼®urung^C
				html += XML_ZIPCODE.item(i).getAttribute("ADDR").replace(str, "<font color='blue'>" + str + "</font>") + "</div>";
				//html += XML_ZIPCODE.item(i).getAttribute("ADDR").toUpperCase().replace(str.toUpperCase(), "<font color='red'>" + str.toUpperCase() + "</font>") + "</div>";
				//ÁÖ¼®µÈ°É·ç ÇÏ¸é ÀÚ¹Ù½ºÅ©¸³Æ® ¿À·ù ¾È³ª³×..
			}
			list_div.innerHTML = html;
			if(index == -1) box.style.display = "inline";
		}
		else {
			if(e.keyCode == 40 && index < XML_ZIPCODE.length - 1) {
				with(box.contentWindow.document) {
					if(index > -1) getElementById("no_" + index).style.backgroundColor = "";
					getElementById("no_" + ++index).style.backgroundColor = "#EEEEEE";
					text.value = XML_ZIPCODE.item(index).getAttribute("ADDR");
					body.scrollTop = Math.floor(index / 5) * 75;
				}
				box.style.display = "inline";
			}
			else if(e.keyCode == 38) {
				if(index > 0) {
					with(box.contentWindow.document) {
						getElementById("no_" + index).style.backgroundColor = "";
						getElementById("no_" + --index).style.backgroundColor = "#EEEEEE";
						text.value = XML_ZIPCODE.item(index).getAttribute("ADDR");
						body.scrollTop = Math.floor(index / 5) * 75;
					}
				}
				else {
					index = -1;
					box.style.display = "none";
					text.value = queryStr;
				}
			}
		}
	}
	else box.style.display = "none";
}

function removeListBox() {
	box = document.getElementById("list_a");
	box.style.display = "none";
}

function XMLHTTP() {
	try	{
		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
	}
	catch(e) {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}


function deleteComfirm(readdir,mode,dir1,dir2,dir3){
	if(window.confirm("Á¤¸» »èÁ¦ÇÏ¼¼°Ú½À´Ï±î?")){
		location.replace("/v2005/upload.php?upMode=fileDelete&mode="+ mode +"&readdir=" + readdir +"&dir1="+dir1+"&dir2="+dir2+"&dir3="+dir3);
	}
}

function dirIn(dir1,dir2,dir3){
	location.replace("/v2005/upload.php?dir1="+dir1+"&dir2="+dir2+"&dir3="+dir3);
}

function noticeQuestion(board_id,board_num,user_id){
	if(window.confirm("ÇØ´ç °Ô½Ã¹°ÀÌ 3¹øÀÌ»ó ½Å°í Á¢¼ö°¡ µÈ´Ù¸é °Ô½Ã¹°Àº °­Á¦ »èÁ¦ µË´Ï´Ù.\n¸¸¾à ÇãÀ§·Î ÆÇ¸íµÈ´Ù¸é ÇØ´ç °Ô½Ã¹°ÀÇ ½Å°íÀÚ ¾ÆÀÌµð ¹× ¾ÆÀÌÇÇ´Â Â÷´Ü ÇÒ ¿¹Á¤ÀÔ´Ï´Ù.\n\nÁ¤¸» ÀúÀÛ±Ç °ü·ÃÀ¸·Î ½Å°í¸¦ ÇÏ½Ã°Ú½À´Ï±î?")){
		copyRight.location.replace("/zzboard/copyRightProc.php?nMode=insert&board_id=" + board_id + "&board_num=" + board_num + "&user_id=" + user_id);
	}
}

function noticePrompt(board_id,board_num,user_id){
	var content = prompt("½Å°í³»¿ëÀÌ »ç½ÇÀÏ¶© °Ô½Ã¹°Àº »èÁ¦µË´Ï´Ù.\n½Å°í³»¿ëÀ» °£·«È÷ ¾Ë·ÁÁÖ¼¼¿ä~.","½Å°í³»¿ë : ");
	if(content != null){
		copyRight.location.replace("/zzboard/copyRightProc.php?nMode=insert&board_id=" + board_id + "&board_num=" + board_num + "&user_id=" + user_id + "&content=" + content);
	}
}

//object È¸ÇÇ...
function viewObject(name,type,width,height){

	type = type.toLowerCase();

	var valueFile = "";
	var widthV = "";
	var heightV = "";

	(width=="0") ? widthV = "" : widthV = "width=" + width;
	(height=="0") ? heightV = "" : heightV = "height=" + height;
	
	//ÇÃ·¡½¬...
	if(type == "flash"){
		valueFile = "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" "+widthV+" "+heightV+">	 <PARAM NAME=movie VALUE=\"" + name + "\"> <PARAM NAME=quality VALUE=high>  <PARAM NAME=wmode VALUE=transparent><PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src=\"" + name + "\" quality=high wmode=transparent bgcolor='#FFFFFF' "+ widthV +" " + heightV + " TYPE=\" application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED></OBJECT>";
	}else if(type == "movie"){				
		valueFile = "<object id=\"Player\" classid=\"CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95\" "+ widthV +" " + heightV + "> <param name=\"AutoStart\" value=\"False\"> <param name=\"TransparentAtStart\" value=\"false\"> <param name=\"ShowControls\" value=\"1\"> <param name=\"ShowDisplay\" value=\"0\"> <param name=\"ShowStatusBar\" value=\"0\"> <param name=\"AutoSize\" value=\"1\"> <param name=\"AnimationAtStart\" value=\"false\"> <param name=\"FileName\" value=\""+ name +"\"> </object>";
	}else{
		document.write("AppletÀº ³ªÁß¿¡ Ãß°¡ ÇÏ°Ú½À´Ï´Ù..±×°Íµµ ¾Æ´Ï¶ó¸é ¤Ñ¤Ñ;;");
	}

	document.write(valueFile);
}


//top5....
function SearchTop5(v){		
	document.frm1.SearchMode.value="SubNMemo";
	document.frm1.SearchWord.value=v;
	document.frm1.submit();
}


 // ±ÝÁö´Ü¾î ÇÊÅÍ¸µ
function word_filter_check(v){
	var filter = "<embed,<EMBED";

	var s = filter.split(",");

	for (i=0; i<s.length; i++) 
	{
		if (v.indexOf(s[i]) != -1)
			return s[i];
	}
	return "";
}

//gnuboard ..... Âü°í..
function comFun(){
	var s;
	var lower=document.getElementById('memo_id').value;
	
	if (s = word_filter_check(lower.toLowerCase()))
	{
		alert("'"+s+"' ÅÂ±×´Â »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù.\n\n¸¸¾à <embed ÅÂ±×¸¦ »ç¿ëÇÏ½Ç °ÍÀÌ¶ó¸é ¿¹Á¦ÀÇ [embed] ½ºÅ©¸³Æ®¸¦ »ç¿ëÇØÁÖ¼¼¿ä.");

		var objStrip = new RegExp();
		objStrip = /[<][e][m][b][e][d]/gi; //´ë¼Ò¹®ÀÚ »ó°ü¾øÀÌ <embed »èÁ¦..Á¤±Ô½Ä.
		var replace_word = lower.replace(objStrip,"--[IE ÆÐÄ¡·Î EMBED ÅÂ±×´Â Á÷Á¢ È£ÃâÇÒ ¼ö ¾ø½À´Ï´Ù]--\n\n");
		document.getElementById('memo_id').value = replace_word; //±³Ã¼

		document.getElementById('memo_id').focus();
		
		return false;
	}		
}

function insert_movie(){
	var movie="\n<embed src=\"µ¿¿µ»ó ÁÖ¼Ò\" autostart=0 />\n";
	//var movie="\n<script language=\"javascript\">viewObject(\"µ¿¿µ»ó¸µÅ©ÁÖ¼Ò\",\"movie\",\"0\",\"0\");</script>\n¢ºÇÃ·¹ÀÌ¹öÆ°À» ´­·¯ÁÖ¼¼¿ä \n";//¹ÝÀÀÀÌ¿µ~~ ¾ÈÁÁ¾Æ.
	document.write.memo.value = document.write.memo.value + movie;
}

//´ÜÃàÅ° F7À» ÀÌ¿ëÇÑ viewObject ºÒ·¯¿À±â.
function CheckKeyPress() { 
	var EventStatus = event.srcElement.tagName; 
	var ekey = event.keyCode; 
	if(ekey=='118') { 
		event.keyCode=0; 
		insert_movie();
		return false; 
	}
} 
//document.onkeydown = CheckKeyPress; 


