$(document).ready(function() {	
	
	if (getCookie("saveid").length > 0)
	{
		$("#id_save").attr("checked",true);
		$("#id_input").removeClass("no_id");
		$("#id_input").val(getCookie("saveid"));
	}

	$(":text[name=q]").bind("click", function(){
		$(this).css("background", "url('') no-repeat");
	});

	$(":text[name=q]").bind("blur", function(){ 
		if ($(this).val()=="") $(this).css("background", "url('/images/index/bg_input.gif') no-repeat scroll 2px 3px transparent");
	});

	REMOVE_BG("no_id", "#id_input");
	REMOVE_BG("no_pw", "#pw_input");

	/* tab01 */
	//TOGGLE_ON_OFF( ".right_menu a", 30);	
	
	/* tab02 */
	$("#tabs02_01").bind("click focus", function() {
		$("#tabs02_01 img").attr("src", "/images/index/tab02_01_on.gif");
		$("#tabs02_02 img").attr("src", "/images/index/tab02_02_off.gif");
		$("#tabs02_02").parent().css("left","240px");	
		$("#content_02").hide();	
		$("#content_01").show();
		return false;
	});
	$("#tabs02_02").bind("click focus", function() {
		$("#tabs02_01 img").attr("src", "/images/index/tab02_01_off.gif");
		$("#tabs02_02 img").attr("src", "/images/index/tab02_02_on.gif");
		$(this).parent().css("left","246px");
		$("#content_01").hide();	
		$("#content_02").show();
		return false;
	});

	/* 셀렉트 - 플러그인 jquery.stylish.select.js */
	$('#index .row_02 .col_02 .tab_Style .select01, #index .row_02 .col_02 .tab_Style .select02').sSelect();	

	/* tab03 */
	$("#tabs03_01").bind("click focus", function() {		
		$(this).removeClass("off").addClass("on");
		$("#tabs03_02").removeClass("on").addClass("off");
		$("#content03_02").hide();	
		$("#content03_01").show();
		return false;
	});
	$("#tabs03_02").bind("click focus", function() {
		$(this).removeClass("off").addClass("on");
		$("#tabs03_01").removeClass("on").addClass("off");
		$("#content03_01").hide();	
		$("#content03_02").show();	
		return false;
	});

	/* row_04 tabs */
	$(".row_04 .right_menu li a").click(function() {
		var THIS_CLASS = $(this).parent().attr("class");
		if ( THIS_CLASS == "order01" )
		{
			$(".row_04 .right_menu .order01 img").attr("src", "/images/index/index0401_tab01_on.gif");
			$(".row_04 .right_menu .order02 img").attr("src", "/images/index/index0401_tab02_off.gif");
			$(".row_04 .right_menu .order03 img").attr("src", "/images/index/index0401_tab03_off.gif");
			$(".row_04 .right_menu .order04 img").attr("src", "/images/index/index0401_tab04_off.gif");
			$(".row_04 .right_menu .order05 img").attr("src", "/images/index/index0401_tab05_off.gif");
			$(".row_04 .left_area .lists").hide();
			$(".row_04 .left_area .list01").show();
		} else if ( THIS_CLASS == "order02" )
		{
			$(".row_04 .right_menu .order01 img").attr("src", "/images/index/index0401_tab01_off.gif");
			$(".row_04 .right_menu .order02 img").attr("src", "/images/index/index0401_tab02_on.gif");
			$(".row_04 .right_menu .order03 img").attr("src", "/images/index/index0401_tab03_off.gif");
			$(".row_04 .right_menu .order04 img").attr("src", "/images/index/index0401_tab04_off.gif");
			$(".row_04 .right_menu .order05 img").attr("src", "/images/index/index0401_tab05_off.gif");
			$(".row_04 .left_area .lists").hide();
			$(".row_04 .left_area .list02").show();
		} else if ( THIS_CLASS == "order03" )
		{
			$(".row_04 .right_menu .order01 img").attr("src", "/images/index/index0401_tab01_off.gif");
			$(".row_04 .right_menu .order02 img").attr("src", "/images/index/index0401_tab02_off.gif");
			$(".row_04 .right_menu .order03 img").attr("src", "/images/index/index0401_tab03_on.gif");
			$(".row_04 .right_menu .order04 img").attr("src", "/images/index/index0401_tab04_off.gif");
			$(".row_04 .right_menu .order05 img").attr("src", "/images/index/index0401_tab05_off.gif");
			$(".row_04 .left_area .lists").hide();
			$(".row_04 .left_area .list03").show();
		} else if ( THIS_CLASS == "order04" )
		{
			$(".row_04 .right_menu .order01 img").attr("src", "/images/index/index0401_tab01_off.gif");
			$(".row_04 .right_menu .order02 img").attr("src", "/images/index/index0401_tab02_off.gif");
			$(".row_04 .right_menu .order03 img").attr("src", "/images/index/index0401_tab03_off.gif");
			$(".row_04 .right_menu .order04 img").attr("src", "/images/index/index0401_tab04_on.gif");
			$(".row_04 .right_menu .order05 img").attr("src", "/images/index/index0401_tab05_off.gif");
			$(".row_04 .left_area .lists").hide();
			$(".row_04 .left_area .list04").show();
		} else if ( THIS_CLASS == "order05" )
		{
			$(".row_04 .right_menu .order01 img").attr("src", "/images/index/index0401_tab01_off.gif");
			$(".row_04 .right_menu .order02 img").attr("src", "/images/index/index0401_tab02_off.gif");
			$(".row_04 .right_menu .order03 img").attr("src", "/images/index/index0401_tab03_off.gif");
			$(".row_04 .right_menu .order04 img").attr("src", "/images/index/index0401_tab04_off.gif");
			$(".row_04 .right_menu .order05 img").attr("src", "/images/index/index0401_tab05_on.gif");
			$(".row_04 .left_area .lists").hide();
			$(".row_04 .left_area .list05").show();
		}
		return false;
	});

	/* tab04 */
//	TOGGLE_ON_OFF( ".service_manual a", 30);

	$("input:checkbox.ess_d").each(function() {
		$(this).attr("checked",true);
	});

	/* 메인 도메인 검색 */
	$("#dom_chk_all").click(function() {

		$("input.dom").attr("checked", $(this).attr("checked"));

	});
	
	$("#sel_kr_dom").click(function() {

		if ( $(this).attr("checked") == false )
		{
			$(this).val("");
		}

	});
	$("select.domain_select").change(function() {

		$("#sel_kr_dom").val( $(this).val());
		$("#sel_kr_dom").attr("checked",true);

	});

	$("#frm_domain_search").submit(function() {

		if ( $("input[name=q]").val() == "" )
		{
			alert("검색할 도메인을 입력해 주세요.");
			$("input[name=q]").focus();
			return false;
		}

		if ( $("input[name='dom[]']:checked").length == 0 )
		{
			alert("검색할 도메인 종류를 선택해 주세요.");
			return false;
		}

	});
});

function Js_mainlogin() {
	if ($("#id_input").val() == "")
	{
		alert("아이디를 입력해주세요.");
		$("#id_input").focus();
		return false;
	}
	if ($("#pw_input").val() == "")
	{
		alert("비밀번호를 입력해주세요.");
		$("#pw_input").focus();
		return false;
	}
	$.post("login_ajax.php"
			, {
				"memid" : $("#id_input").val()
				,"mempw" : $("#pw_input").val()
				,"id_save" : $("#id_save").val()
				,"geturl" : $("#geturl").val()
			}
			, function(res){
				if (res == 1)
				{
					alert("로그인에 실패하였습니다. 관리자에게 문의하세요.");
				}
				else if(res == 2){
					alert("일치하는 회원정보가 없습니다");
				}
				else if(res == 3){
					alert("탈퇴한 회원 아이디입니다.");
				}
				else {
					if ($("#id_save").is(":checked") == true)
					{
						setCookie2("saveid",$("#id_input").val(),30);
					}
					else {
						deleteCookie("saveid");
					}

					location.reload();

				}
			}
		);
		return false;
}
// 검색하기
function js_listSearch(str) 
{
	str = (str)?str:"frmSearch"; // 기본 검색 폼 이름
	$("form[name=" + str + "]").submit();
}

// 페이지 이동
function js_goPage(vlu, tg) 
{
	var trgt = (tg)?tg:"#page";
	$(trgt).val(vlu);
	$("#pageSize2").val($("#pageSize").val());
	js_listSearch();
}

// 카테고리 페이지 이동
function js_goPage2(dvn, vlu) 
{
	$("[name^=cate_]").val("");
	$("[name=cate_" + dvn + "]").val(vlu);
	$("#page").val(1);
	$("#pageSize2").val($("#pageSize").val());
	js_listSearch();
}
