function RollOver(FSimg, mode) {
	var devide = FSimg.src.lastIndexOf("/");
	var head = FSimg.src.substring(0, devide);
	var foot = FSimg.src.substring(devide + 1);
	if (mode == "over" && !foot.substring(0, 2).match("o_")) FSimg.src = head + "/o_" + foot;
	else if (mode == "out" && foot.substring(0, 2).match("o_")) FSimg.src = head + "/" + foot.substring(2);
}

function swapLayers(no, display) {
	var i, obj;
	for (i = 1; i <= main_count; i++) {
		obj = document.getElementById("Layer" + i);
		if (obj != null) {
			if (obj.style && i == no && obj.style.visibility != display) obj.style.visibility = display;
			else if (obj.style.visibility != "hidden") obj.style.visibility = "hidden";
		}
	}
	obj = document.getElementById("Layer" + main_index);
	if (obj != null) {
		if (no != main_index && display == "hidden") obj.style.visibility = "visible";
		else if (no == main_index) obj.style.visibility = "visible";
	}
}

function swapMenu(id, mode) {
	var main_obj, sub_obj, page_obj, etc_obj, layer_obj, obj = document.getElementById(id);
	if (id.match("main_menu")) {
		for (i = 1; i <= main_count; i++) {
			main_obj = document.getElementById("main_menu" + i);
			if (main_obj != null && main_obj.src.match("o_")) main_obj.src = main_obj.src.replace("o_", "");
		}
	}
	if (id.match("sub_menu") || id.match("page_menu")) {
		for (i = 1; i <= sub_count; i++) {
			sub_obj = document.getElementById("sub_menu" + main_index + "_" + i);
			if (sub_obj != null && sub_obj.src.match("o_")) sub_obj.src = sub_obj.src.replace("o_", "");
			if (main_index) page_obj = document.getElementById("page_menu" + main_index + "_" + i);
			else page_obj = document.getElementById("page_menu0" + "_" + (i + 3));
			if (page_obj != null && page_obj.src.match("o_")) page_obj.src = page_obj.src.replace("o_", "");
		}
	}
	if (id.match("etc_menu")) {
		for (i = 1; i <= etc_count; i++) {
			etc_obj = document.getElementById("etc_menu" + i);
			if (etc_obj != null && etc_obj.src.match("o_")) etc_obj.src = etc_obj.src.replace("o_", "");
		}
	}
	if (obj != null) RollOver(obj, mode);
	if (mode == "out") {
		main_obj = document.getElementById("main_menu" + main_index);
		if (main_obj != null) RollOver(main_obj, "over");
		layer_obj = document.getElementById("Layer" + main_index);
		if (layer_obj != null) layer_obj.style.visibility = "visible";
		sub_obj = document.getElementById("sub_menu" + main_index + "_" + sub_index);
		if (sub_obj != null) RollOver(sub_obj, "over");
		if (main_index) page_obj = document.getElementById("page_menu" + main_index + "_" + sub_index);
		else page_obj = document.getElementById("page_menu0_" + etc_index);
		if (page_obj != null) RollOver(page_obj, "over");
		etc_obj = document.getElementById("etc_menu" + etc_index);
		if (etc_obj != null) RollOver(etc_obj, "over");
	}
}

function previewUpload(attach) {
	if (!checkPhoto(attach)) return;
	var img_url = getImagePath(attach.value);
	if (popup != null && !popup.closed) popup.close();
	var URL = "../../src/popup/preview.php?url=" + img_url;
  popup = window.open(URL, '_View', 'resizable=yes,scrollbars=no,width=400,height=400');
}

function previewImage(img_url) {
	if (img_url.trim() != "") {
		if (popup != null && !popup.closed) popup.close();
		var URL = "../../src/popup/preview.php?url=" + img_url;
  	popup = window.open(URL, '_View', 'resizable=yes,scrollbars=yes,width=400,height=400');
  }
}

function getCookieVal(cookieName) {
	var thisCookie = document.cookie.split("; ");
	for (i = 0; i < thisCookie.length; i++) {
		if (cookieName == thisCookie[i].split("=")[0]) return thisCookie[i].split("=")[1];
	}
	return "";
}

function openPopup(no, left, top, width, height) {
	if (getCookieVal("popup" + no) != "1" && no.trim() != "") {
		link = "../../src/popup/popup.php?no=" + no;
		style = "resizable=no,scrollbars=no,left=" + left + ",top=" + top + ",width=" + width + ",height=" + height;
		window.open(link, '_Popup'+no, style);
  }
}

function checkQuickSearchInfo(Form) {
	if (Form.s_title.value.trim() == "") {
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		Form.s_title.focus();
		Form.s_title.select();
		return false;
	}
	//alert("ÁØºñÁßÀÔ´Ï´Ù.");
	return true;
}

function checkLoginInfo(id, pw) {
	if (!checkID(id)) return false;
	if (!checkPassword(pw, pw)) return false;
	return true;
}

function logout() {
	var ans = confirm("·Î±×¾Æ¿ô ÇÏ½Ã°Ú½À´Ï±î?");
	if (ans == true) top.location = "../../src/main/logout.php";
	else return;
}

function openFlash(w, h, c, src) {
	var flash;
	flash = "<object width=\"" + w + "\" height=\"" + h + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\">\n";
	flash += "<param name=\"movie\" value=\"" + src + "\">\n";
	flash += "<param name=\"menu\" value=\"false\">\n";
	flash += "<param name=\"quality\" value=\"high\">\n";
	flash += "<param name=\"bgcolor\" value=\"" + c + "\">\n";
	//flash += "<param name=\"wmode\" value=\"transparent\">\n";
	flash += "<embed src=\"" + src + "\" width=\"" + w + "\" height=\"" + h + "\" menu=\"false\" quality=\"high\" bgcolor=\"#FFFFFF\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>\n";
	flash += "</object>\n";
	document.write(flash);
}

function findZipcode(type) {
	if (popup != null && !popup.closed) popup.close();
	var URL = "../../src/popup/find_zipcode.php?type=" + type;
	popup = window.open(URL, '_zipcode','resizable=no,scrollbars=yes,status=no,width=500,height=300');
}