var Msg = new Object();
Msg.show = new Array();
Msg.show['make'] = 'The Guest it produces with accounts.\n\n     It moves with a login page?';

var Btn = {
	login: function(event){
		var id = $F("email");
		var passwd = $F("passwd");
		
		if(!id){
			alert('Input the mail address!');		//메일주소를 입력하세요!
			$("email").focus();
			return false;
		}
		if(!passwd){
			alert('Input the Password!');		//패스워드를 입력하세요!
			$("passwd").focus();
			return false;
		}

		var URL = "login_end.php"; 
		new Ajax.Request(URL, { 
			parameters: {"id":id,"passwd":passwd}, 
			onSuccess: function(xmlHttp){      
				var response = xmlHttp.responseText; 
				if(response == 'Y'){
					aLink.index();
				}
				else{
					alert('Information which it inputs is incorrect.');	//입력하신 정보가 틀립니다.
				}
			}
		});
	},
	join: function(event){
		var name = $F("name");
		var id = $F("email");
		var passwd = $F("passwd");
		
		if(!name){
			alert('Input tye name!!');		//이름을 입력하세요
			$("name").focus();
			return false;
		}
		if(!id){
			alert('Input the mail address!');		//메일주소를 입력하세요!
			$("email").focus();
			return false;
		}
		if(!passwd){
			alert('Input the Password!');		//패스워드를 입력하세요!
			$("passwd").focus();
			return false;
		}

		if(ck_str(passwd) == false){
			alert('The letter it will not be able to use was included.');		//사용할수 없는 문자가 들어있습니다.
			$("passwd").select();
			return false;
		}
	
		$("btnJoin").disabled = true;
		var URL = "join_end.php"; 
		new Ajax.Request(URL, { 
			parameters: {"id":id,"name":name,"passwd":passwd}, 
			onSuccess: function(xmlHttp){      
				var response = xmlHttp.responseText;
				if(response == 'Y'){
					alert("It welcomes joining in the YOUCC.\n\n[Joining guidance]\n ID : "+id+"\n Password : "+passwd);		//YouCC에 가입을 환영합니다.[가입내역] 아이디 비밀번호
					aLink.index();
				}
				else if(response == 'N'){
					alert('The id the ['+id+'] already is in the process of using.');		//아이디 ['+id+']는 이미 사용중입니다
					$("btnJoin").disabled = false;
				}
				else{
					alert('It is this mail address which is not.');			//없는 이메일 주소입니다.
					$("btnJoin").disabled = false;
				}
			}
		});
	},
	search: function(){
		var q = $F("q");
		if(!q){
			alert('Input search!');		//검색어를 입력하세요!
			$("q").focus();
		}
		else
		{
			q = encodeURIComponent(q);
			//document.f.action = "/r7web/r7Search.php?searchTxt="+q;
			document.f.action = "/r7web/rise7Search.php?q="+q;
			document.f.submit();
		}
	}
}

var aLink = {
	index: function(event){
		location.replace("/index.php");
	},
	join: function(event){
		location.replace("/member/join_ucc.php");
	},
	allUCC: function(event){
		location.replace("/section/allContents_ucc.php");
	},
	make: function(event){
		location.replace("http://maker.youcc.co.kr");
	}
}

function ck_str(poi1)
{
	ck_word = "0123456789";
	ck_word += "abcdefghijklmnopqrstuvwxyz";
	ck_word += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	ck_word += "~`!@#$%^&*()_+-=:?><|][{}";

	poi1_length = poi1.length;
	for(i = 0 ; i < poi1_length ; i ++)
	{
		ck_result = ck_word.indexOf(poi1.charAt(i));
		if(ck_result < 0 )
		{
			return false;
		}
	}
	return true;
}
function LinkInfo(guid){
	var status = "width=400,height=300,screenX=0,left=0,screenY=0,top=0,resizable=yes,toolbar=no,status=false,menubar=no,scrollbars=no";
	var info = window.open('/r7web/linkInfo.php?guid='+guid,'info',status);
	info.focus();
}
function EditEBook(guid,id){
	var status = "width=100,height=100,screenX=0,left=0,screenY=0,top=0,resizable=yes,toolbar=no,status=false,menubar=no,scrollbars=no";
	var edit = window.open('/r7web/r7EditApp.php?guid='+guid+'&id='+id,'edit',status);
	//edit.focus();
}
function setColor(obj, color) { 
	obj.setAttribute('backup', obj.getAttribute('backgroundColor')); 
	obj.setAttribute('backgroundColor', color); 
	obj.onmouseout = new Function("this.setAttribute('backgroundColor', this.getAttribute('backup'));"); 
}
Event.observe(window,"load",function(){
	if($("Logo") != null) Event.observe("Logo","click",aLink.index);
	if($("btnSearch") != null) Event.observe("btnSearch","click",Btn.search);
	if($("allUCC") != null) Event.observe("allUCC","click",aLink.allUCC);	
	if($("btnLogin") != null) Event.observe("btnLogin", "click" , Btn.login);
	if($("join") != null) Event.observe("join", "click" , aLink.join);
	if($("btnJoin") != null) Event.observe("btnJoin", "click" , Btn.join);
	if($("LinkInfo") != null) Event.observe("LinkInfo", "click" , aLink.LinkInfo);
});
