	var CURR_PAGE_URL = "";

	//쿠키정보가져오기
	function getCookie( name ){
		var nameOfCookie = name + "=";
		var x = 0;
		while ( x <= document.cookie.length ) {
			var y = (x+nameOfCookie.length);
			if ( document.cookie.substring( x, y ) == nameOfCookie ) {
				if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
					endOfCookie = document.cookie.length;
				return unescape( document.cookie.substring(y, endOfCookie) );
			}
			x = document.cookie.indexOf( " ", x ) + 1;
			if ( x == 0 )break;
		}
		return "";
	}
	
	//쿠키정보세팅
	function setCookie( name, value, expiredays ) {
		var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	}
	
	// 트위터 로그인
	function fnTwLogin(l){
		if(!l)l="y";
		window.open("/signin.do?l="+l,"TwitterLogin","width=500,height=800");
	}
	
	//페이스북 로그인
	function fnFBLogin(l){
		if(!l)l="y";
		var url = "https://www.facebook.com/dialog/oauth?client_id=180191022037945&redirect_uri=http://www.teejay.co.kr/login/fb_login_result.jsp?l="+l+"&scope=email,user_birthday,publish_stream&response_type=token";
		window.open(url,"FaceBookLogin","width=900,height=500");
	}
	
	//TeeJay 로그인
	function fnLogin(){
		if($("#userId").val() == "" ) {
			alert("Input ID");
			$("#userId").focus();
			return;
		}
		if( $("#userPw").val() == "") {
			alert("Input Password");
			$("#userPw").focus();
			return;
		}
		/*
		if($("userId_save").checked == true) {
			setCookie("userID", $("#userID").val(), 30);
		}
		*/
		$.ajax({
			type:"POST",
			url: "data/data.xml.jsp",
			data: {type:'login',userId:$("#userId").val(),userPw:$("#userPw").val()},
			dataType:"xml",
			success: function(xml) {
				if($(xml).find("login").length > 0 ){
					$(xml).find("login").each(function (){
						$("#user_name").val($(this).find("name").text());
						$("#user_id").val($(this).find("email").text());
						$("#user_email").val($(this).find("email").text());
						$("#user_active").val($(this).find("active").text());
						$("#user_type").val("default");
						$("#act_email").val($(this).find("email").text());
						$("#act_uid").val($(this).find("seq").text());
						$("#act_sid").val($(this).find("sessionId").text());
					});
					$("#loginfrm").submit();
				}else{
					alert("로그인에 실패하였습니다.");
				}
			},
			error:function(xml){
				//alert("error")
			}
		});	
	}

	function fnAdmin(){
		window.open("admin/admin.jsp", "", "menubar = no, resizable = no, width = 1024, height = 800");
	}
	
	function fnLoginProcess(userName){
		//alert("어서 오십시오");
		$("#loginInfo_userName").html(userName);
		$("#loginfrm").hide();
		$("#noLogin_ul").hide();
		$("#login_ul").show();
		if($("#user_type").val() == "default"){
			$("#myPageBtn").show();
		}else{
			$("#myPageBtn").hide();
		}
		if($("#h_fbLogin").val() == "true"){
			$("#user_active").val("y")
		}
		if($("#h_twLogin").val() == "true"){
			$("#user_active").val("y")
		}
		if($("#user_active").val() != "y"){
			$("#ContentsArea").load("login/activation.jsp");
		}else{
			if(CURR_PAGE_URL != ""){
				fnLoginCallBack();	
			}
		}
	}

	function fnLoginCallBack(){
		if(CURR_PAGE_URL != "_index.jsp"){
			$("#ContentsArea").load(CURR_PAGE_URL);
		}else{
			document.href = "/_index.jsp";
		}
	}
