var signed;
var oform;
var oHttp, oPageNavigator;
var iPage;
var returnFunction = "";	
var product_idx = 1;
var embed; //scrap embed tag

/* left */
function leftMenu(setNum1, setNum2){
	if ( setNum1 == 3){
		if (setNum2 > 0)
			products_flash_change(setNum2,0);
		else
			products_flash_change(1,0);
	}
	
	switch (setNum1){
		case 1:
			self.location.href = "./beauty2_beauty.asp";
			break;
		case 2:
			self.location.href = "./beauty2_food.asp";
			break;
		case 4:
			self.location.href = "./beauty2_event.asp";
			break;
	}
}

/* comment */
function getCommentList(page){
	iPage = page;
	oHttp.sendRequest("./behind_codes/getCommentList.asp?page=" + iPage + "&product=" + product_idx, null, "showCommentList");
}

function showCommentList(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	
	if( txtJSON.length > 10 ){
		var oDATA = txtJSON.parseJSON();
		var list = document.createDocumentFragment();
		
		if( oDATA.dataList ){	
			var oCell = new Array();
			var i, j;

			for(i=0; i<oDATA.dataList.length; i++){
				for(j=0; j<2; j++){
					oCell[j] = document.createElement("div");
					if (j == 0)
						oCell[j].className = "comment_text";
					else
						oCell[j].className = "comment_name";
					list.appendChild( oCell[j] );
				}
				
				var removeImg = new Image();
				removeImg.src = "/event/20090204/img/btn_del.jpg";
				removeImg.className = "hand";
				removeImg.style.paddingLeft = "5px";
				removeImg.uid = oDATA.dataList[i].uid;
				removeImg.account = oDATA.dataList[i].account;
				removeImg.align = "absmiddle";
				removeImg.onclick = function(){
					removeComment(this.uid, this.account);
				}
				var point = parseInt(oDATA.dataList[i].point);
				
				for(k=0;k<point;k++){
					var heartImg = new Image();
					heartImg.src = "/event/20090204/img/point.jpg";
					heartImg.align = "absmiddle";
					oCell[1].appendChild( heartImg );
				}

				oCell[0].appendChild( document.createTextNode( oDATA.dataList[i].comment ) );
				oCell[0].appendChild( removeImg );
				oCell[1].appendChild( document.createTextNode( " " + oDATA.dataList[i].name ) );
			}
		}

		removeAllChildNodes( $("commentList") );
		$("commentList").appendChild( list );
		oPageNavigator.Render(oDATA.pageInfo.page, oDATA.pageInfo.recordCnt);
	}
}

function commentText_onFocus(obj){
	if (obj.value == "»óÇ°ÆòÀ» Àû¾îÁÖ¼¼¿ä(ÃÖ´ë20ÀÚ)")
		obj.value = ""
}

function commentText_onBlur(obj){
	if (obj.value == "")
		obj.value = "»óÇ°ÆòÀ» Àû¾îÁÖ¼¼¿ä(ÃÖ´ë20ÀÚ)"
}

function pointSelect(selectPoint){
	removeAllChildNodes( $("pointValue") );
	oform.point.value = selectPoint;
	
	for(i=0;i<selectPoint;i++){
		var pointimg = new Image();
		pointimg.src = "./img/s_point.jpg";
		$("pointValue").appendChild(pointimg);
	}
	
	for(i=0;i<5-selectPoint;i++){
		var dis_pointimg = new Image();
		dis_pointimg.src = "./img/s_point_dis.jpg";
		$("pointValue").appendChild(dis_pointimg);
	}
	
	$("heartPoint").style.display = "none";
}

function addComment(){
	if (signed == ""){
		alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ß¸¸ ÀÀ¸ð°¡ °¡´ÉÇÕ´Ï´Ù.");
		login_layer();
		return;
	}
	oform.product.value = product_idx;
	if (chkNull(oform.comment, "´ñ±ÛÀ»")) { return; }
	
	if (oform.comment.value == "»óÇ°ÆòÀ» Àû¾îÁÖ¼¼¿ä(ÃÖ´ë20ÀÚ)"){
		alert("´ñ±ÛÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
		oform.comment.focus();
		return;
	}
	
	oHttp.sendRequest("./behind_codes/addComment.asp", oform, "resultComment");
}

function removeComment(uid, account){
	var cookie = 0;
	
	if (signed != "")
		cookie = parseInt(signed);
	
	if (account != cookie){
		alert("ÀÚ½ÅÀÌ ÀÛ¼ºÇÑ ´ñ±Û¸¸ »èÁ¦ °¡´ÉÇÕ´Ï´Ù");
		return;
	}
	oHttp.sendRequest("./behind_codes/removeComment.asp?uid=" + uid + "&product=" + product_idx, null, "resultComment");
}

function getAverage(){
	oHttp.sendRequest("./behind_codes/getAverage.asp?product=" + product_idx, null, "resultComment");
}

function resultComment(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	$("productAverage").innerText = oDATA.average;
	
	var avg = parseFloat(oDATA.average);
	
	if (avg > 4.8)
		$("average_heart").src = "./img/b_point5.jpg";
	else if (avg > 4)
		$("average_heart").src = "./img/b_point4.jpg";
	else if (avg > 3)
		$("average_heart").src = "./img/b_point3.jpg";
	else if (avg > 2)
		$("average_heart").src = "./img/b_point2.jpg";
	else
		$("average_heart").src = "./img/b_point1.jpg";
	
	oform.comment.value = "»óÇ°ÆòÀ» Àû¾îÁÖ¼¼¿ä(ÃÖ´ë20ÀÚ)";
	pointSelect(5);
	getCommentList(0);
}

function enterComment(){
	addComment();
	return false;
}

function showPoint(){
	if ($("heartPoint").style.display == "none" || $("heartPoint").style.display == "")
		$("heartPoint").style.display = "block";
	else
		$("heartPoint").style.display = "none";
}

function getFlashObjectReturnTag(flashSrc, objWidth, objHeight, etcParam, flaName) {
	var tag = "";
	var baseFlashDir="";
	flashSrc = baseFlashDir + flashSrc;

	if ( etcParam != "" || etcParam != null ) {
		if ( etcParam.substr(0, 1) == "?" )
			flashSrc += etcParam;
		else
			flashSrc += "?" + etcParam;
	}

	tag += "<object id=\"" + flaName + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
	tag += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" ";
	tag += "width=\"" + objWidth + "\" height=\"" + objHeight + "\">";
	tag += "<param name=\"movie\" value=\"" + flashSrc + "\">";
	tag += "<param name=\"menu\" value=\"true\">";
	tag += "<param name=\"quality\" value=\"high\">";
	tag += "<param name=\"wmode\" value=\"transparent\">";
	tag += "<param name=\"allowScriptAccess\" value=\"sameDomain\">";
	tag += "<embed name=\"" + flaName + "\" src=\"" + flashSrc + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
	tag += "type=\"application/x-shockwave-flash\" width=\"" + objWidth + "\" height=\"" + objHeight + "\" ";
	tag += "wmode=\"transparent\" allowScriptAccess=\"sameDomain\"></embed>";
	tag += "</object>";

	return tag;
}
			
function product_change(idx){
	$("snap").src = "./img/superfood_snap" + idx + ".jpg";
	$("note").src = "./img/superfood_note" + idx + ".jpg";
	product_idx = idx;
	getAverage();
}

function products_flash_change(idx, subidx){
	var url = location.toString();
	
	if (url.indexOf("beauty2_info.asp") > 0)
		switch (idx){
			case 1:
				if (subidx > 0)
					product_idx = subidx
				else
					product_idx = 1;
				product_change(product_idx);
				$("products").innerHTML = getFlashObjectReturnTag("./flash/product_biscuit.swf", 515, 82, 'sidx=' + product_idx, 'product');
				break;
			case 2:
				if (subidx > 0)
					product_idx = subidx
				else
					product_idx = 7;
				product_change(product_idx);
				$("products").innerHTML = getFlashObjectReturnTag("./flash/product_choco.swf", 515, 82, 'sidx=' + product_idx, 'product');
				break;
			case 3:
				if (subidx > 0)
					product_idx = subidx
				else
					product_idx = 12;
				product_change(product_idx);
				$("products").innerHTML = getFlashObjectReturnTag("./flash/product_icecream.swf", 515, 82, 'sidx=' + product_idx, 'product');
				break;
		}
	else {
		self.location.href = "./beauty2_info.asp?fidx=" + idx + "&sidx=" + subidx;
	}
}

/* login */
function login_layer(){
	if (!$("loginBg") != null){
		$("loginBg").style.display = "block";
		$("login").style.display = "block";
		
		$("loginForm").name.focus();
	}
}
		
function loginbox_reset(key){
	if (key == 1){
		var loginform = $("loginForm");
		loginform.name.value = "";
		loginform.phone1.value = "010"
		loginform.phone2.value = "";
		loginform.phone3.value = "";
		loginform.name.focus()
	} else {
		var detailForm = $("detailForm");
		detailForm.name.value = "";
		detailForm.phone1.value = "010"
		detailForm.phone2.value = "";
		detailForm.phone3.value = "";
		
		detailForm.zip.value = "";
		detailForm.addr1.value = "";
		detailForm.addr2.value = "";
		detailForm.email.value = "";
		detailForm.name.focus()
	}
}

function goLogin(){
	var loginform = $("loginForm");
	
	if (chkNull(loginform.name, "ÀÌ¸§À»")) { return; }
	if (chkNull(loginform.phone2, "ÈÞ´ëÆù¹øÈ£¸¦")) { return; }
	if (chkNull(loginform.phone3, "ÈÞ´ëÆù¹øÈ£¸¦")) { return; }
	
	var oHttp = new oXMLHttp();
	oHttp.sendRequest("./behind_codes/login_reg.asp", loginform, "loginResult");
}

function loginResult(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var result = parseInt(oDATA.result);
	
	switch (result){
		case -1:
			alert("µ¥ÀÌÅÍ ÀÔ·Â½Ã ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. Àá½ÃÈÄ ´Ù½Ã ÀÌ¿ëÇØ ÁÖ¼¼¿ä");
			break;
		case 0:
			$("loginBox").style.display = "none";
			$("detailBox").style.display = "block";
			var df = $("detailForm");
			var lf = $("loginForm");
			df.name.value = lf.name.value;
			df.phone1.value = lf.phone1.value;
			df.phone2.value = lf.phone2.value;
			df.phone3.value = lf.phone3.value;
			break;
		default :
			$("loginBg").style.display = "none";
			$("login").style.display = "none";
			signed = result;
			
			if (returnFunction != "")
				eval(returnFunction);
			break;
	}
}

function addAccount(){
	var detailForm = $("detailForm");
	
	if (chkNull(detailForm.name, "ÀÌ¸§À»")) { return; }
	if (chkNull(detailForm.phone2, "ÈÞ´ëÆù¹øÈ£¸¦")) { return; }
	if (chkNull(detailForm.phone3, "ÈÞ´ëÆù¹øÈ£¸¦")) { return; }
	
	
	if (chkNull(detailForm.zip, "¿ìÆí¹øÈ£¸¦")) { return; }
	if (chkNull(detailForm.addr2, "³ª¸ÓÁö ÁÖ¼Ò¸¦")) { return; }
	
	if (chkNull(detailForm.email, "ÀÌ¸ÞÀÏÁÖ¼Ò¸¦")) { return; }
	
	if (!detailForm.email.value.isEmail()){
		alert("ÀÌ¸ÞÀÏÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù. ÀÌ¸ÞÀÏ ÁÖ¼Ò¸¦ ´Ù½Ã ÀÛ¼ºÇØ ÁÖ¼¼¿ä");
		detailForm.email.focus();
		return;
	}
	
	var oHttp = new oXMLHttp();
	oHttp.sendRequest("./behind_codes/addAccount.asp", detailForm, "addResult");
}

function addResult(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var result = parseInt(oDATA.result);
	
	if (result == -1){
		alert("µ¥ÀÌÅÍ ÀÔ·Â½Ã ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. Àá½ÃÈÄ ´Ù½Ã ÀÌ¿ëÇØ ÁÖ¼¼¿ä");
	} else {
		signed = result;
		$("loginBg").style.display = "none";
		$("login").style.display = "none";
		$("detailBox").style.display = "none";
		
		if (returnFunction != "")
			eval(returnFunction);
	}
}

function open_zip_window(){
	var win = window.open("./zipcode.asp","zipWin","width=50,height=50");
	win.focus();
}

function enterSubmit(){
	if(window.event.keyCode == 13)
		addAccount();
}

function multi_onkeyup(obj){
	onlyNumber(obj);
	if(window.event.keyCode == 13)
		goLogin();
}

function loginbox_close(){
	$("loginBg").style.display = "none";
	$("login").style.display = "none";
}

/* quiz */
var prize_name = new Array();
prize_name[1] = "¹Ì´Ï³ëÆ®ºÏ";
prize_name[2] = "Wii Fit ¼¼Æ®";
prize_name[3] = "5¸¸¿ø »óÇ°±Ç";
prize_name[4] = "½´ÆÛÇªµå °úÀÚ¼¼Æ®";
prize_name[5] = "È­ÀåÇ° ¼¼Æ®";
prize_name[6] = "Çâ¼ö ¼¼Æ®";
prize_name[7] = "¿µÈ­¿¹¸Å±Ç";

function quiz_event(){
	if (signed == ""){
		alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ß¸¸ ÀÀ¸ð°¡ °¡´ÉÇÕ´Ï´Ù.");
		login_layer();
		return;
	}

	if (chkNull(oform.word1, "Á¤´äÀ»")) { return; }
	if (chkNull(oform.word2, "Á¤´äÀ»")) { return; }
	if (chkNull(oform.word3, "Á¤´äÀ»")) { return; }
	if (chkNull(oform.word4, "Á¤´äÀ»")) { return; }
	
	if (checkedIndex(oform.prize) == -1){
		alert("ÀÀ¸ðÇÏ½Ç °æÇ°À» ¼±ÅÃÇØ ÁÖ¼¼¿ä");
		oform.prize[0].focus();
		return;
	}
	
	var bingo = oform.word1.value + oform.word2.value + oform.word3.value + oform.word4.value
	
	if (bingo == "½´ÆÛÇªµå"){
		var oHttp = new oXMLHttp();
		oHttp.sendRequest("./behind_codes/quiz_reg.asp", oform, "resultQuiz");
	} else {
		alert("Á¤´äÀÌ ¾Æ´Õ´Ï´Ù. ´Ù½ÃÇÑ¹ø µµÀüÇØ ÁÖ¼¼¿ä");
		oform.word1.focus();
	}
}

function resultQuiz(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var index = checkedIndex(oform.prize);
	var result = parseInt(oDATA.result);
	
	switch (result){
		case -1:
			alert("µ¥ÀÌÅÍ ÀÔ·Â½Ã ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. Àá½ÃÈÄ ´Ù½Ã ÀÌ¿ëÇØ ÁÖ¼¼¿ä");
			break;
		case 0:
			alert("¿À´ÃÀº ÀÌ¹Ì ÀÀ¸ðÇÏ¼Ì½À´Ï´Ù. ³»ÀÏ ´Ù½Ã ÀÀ¸ðÇØ ÁÖ¼¼¿ä");
			break;
		case 1:
			alert("Â¦Â¦Â¦!! Á¤´äÀÔ´Ï´Ù. [" + prize_name[oform.prize[index].value] + "]¿¡ ÀÀ¸ðµÇ¼Ì½À´Ï´Ù. \nÇÏ·ç¿¡ ÇÑ¹ø¾¿ ÀÀ¸ð°¡ °¡´ÉÇÏ´Ï ³»ÀÏ ¶Ç Âü¿©ÇØ ÁÖ¼¼¿ä");
			self.location.href = "http://www.ht.co.kr/event/20090204/beauty2_event.asp";
			break;
	}
}

function one_word(obj, next){
	var focus;
	switch (obj.name){
		case "word1":
			if (obj.value == "½´"){
				focus = eval("oform." + next)
				focus.focus();
			}
			break;
		case "word2":
			if (obj.value == "ÆÛ"){
				focus = eval("oform." + next)
				focus.focus();
			}
			break;
		case "word3":
			if (obj.value == "Çª"){
				focus = eval("oform." + next)
				focus.focus();
			}
			break;
	}
}

/* event */
function more_present(mode){
	var layer = $("quiz_event_p").style
	
	if (mode == 0)
		$("quiz_event_p").className = "quiz_event_p";
	else
		$("quiz_event_p").className = "chef_event_p";
	
	if (layer.display != "block")
		layer.display = "block";
	else 
		layer.display = "none";
}

function getEventInfo(){
	if (signed != ""){
		oHttp = new oXMLHttp();
		oHttp.sendRequest("./behind_codes/getEventinfo.asp", null, "showEventinfo");
	}
}

function showEventinfo(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var quiz = parseInt(oDATA.quiz);
	var comment = parseInt(oDATA.comment);
	var chef = parseInt(oDATA.chef);
	var blog = parseInt(oDATA.blog);
	
	if (quiz > 0)
		$("Myquiz").innerHTML = "<a href=\"javascript:getMyEvent(1);\"> Âü¿© / " + quiz.toString() + "È¸</a>";
	else 
		$("Myquiz").innerText = "¹ÌÂü¿©";
	
	if (comment > 0)
		$("myComment").innerText = "Âü¿© / " + comment.toString() + "È¸";
	else
		$("myComment").innerText = "¹ÌÂü¿©";
	
	if (chef > 0)
		$("myChef").innerHTML = "<a href=\"javascript:getMyEvent(0);\"> Âü¿© / " + chef.toString() + "È¸</a>";
	else
		$("myChef").innerText = "¹ÌÂü¿©";
	
	if (blog > 0)
		$("myBlog").innerText = "Âü¿© / " + blog.toString() + "È¸";
	else
		$("myBlog").innerText = "¹ÌÂü¿©";
}

function getMyEvent(e){
	if (signed != ""){
		oHttp = new oXMLHttp();
		oHttp.sendRequest("./behind_codes/getMyEvent.asp?event=" + e, null, "showMyEvent");
	}
}

function showMyEvent(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	removeAllChildNodes( $("prize_list") );
	
	for(i=0;i<oDATA.prizeData.length;i++){
		var div = document.createElement("div");
		div.className = "eventBox";
		div.appendChild( document.createTextNode( oDATA.prizeData[i].prize + " È¸" ))
		$("prize_list").appendChild(div);
	}
	$("myEventBox").style.display = "block";
}

function myEventList_Hidden(){
	$("myEventBox").style.display = "none";
}

/* ani_chef */
function getChefAniFlash(flashSrc, objWidth, objHeight, etcParam, flaName) {
	var tag = "";
	var baseFlashDir="";
	flashSrc = baseFlashDir + flashSrc;

	if ( etcParam != "" || etcParam != null ) {
		if ( etcParam.substr(0, 1) == "?" )
			flashSrc += etcParam;
		else
			flashSrc += "?" + etcParam;
	}

	tag += "<object id=\"" + flaName + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
	tag += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" ";
	tag += "width=\"" + objWidth + "\" height=\"" + objHeight + "\">";
	tag += "<param name=\"movie\" value=\"" + flashSrc + "\">";
	tag += "<param name=\"menu\" value=\"true\">";
	tag += "<param name=\"quality\" value=\"high\">";
	tag += "<param name=\"wmode\" value=\"transparent\">";
	tag += "<param name=\"allowScriptAccess\" value=\"sameDomain\">";
	tag += "<embed name=\"" + flaName + "\" src=\"" + flashSrc + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
	tag += "type=\"application/x-shockwave-flash\" width=\"" + objWidth + "\" height=\"" + objHeight + "\" ";
	tag += "wmode=\"transparent\" allowScriptAccess=\"sameDomain\"></embed>";
	tag += "</object>";
	
	return tag;
}

function flashPlay_End(){
	alert("µ¿È­¸¦ ¸ðµÎ ÀÐÀ¸¼Ì½À´Ï´Ù. \nÀÌÁ¦, ¿øÇÏ½Ã´Â °æÇ°À» ¼±ÅÃÇØÁÖ¼¼¿ä");
	removeAllChildNodes( $("chefAnimation") );
	$("anithumb").src = "./img/event2_img2.jpg";
	$("chefAnimation").style.display = "none";
	playEnd = true;
}

function flash_animatin_view(){
	$("chefAnimation").style.display = "block";
	$("chefAnimation").innerHTML = getChefAniFlash("./flash/index.swf", 767, 534, "", "chefAni");
}

function animation_event(){
	if (signed == ""){
		alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ß¸¸ ÀÀ¸ð°¡ °¡´ÉÇÕ´Ï´Ù.");
		login_layer();
		return;
	}

	if (!playEnd){
		alert("Çàº¹ÇÑ ¸¶À»ÀÇ ¿ä¸®»ç µ¿È­¸¦ ¸ÕÀú °¨»óÇÏ¼Å¾ß¸¸ ÀÌº¥Æ® ÀÀ¸ð°¡ °¡´ÉÇÕ´Ï´Ù.");
		return;
	}
	
	if (checkedIndex(oform.prize) == -1){
		alert("ÀÀ¸ðÇÏ½Ç °æÇ°À» ¼±ÅÃÇØ ÁÖ¼¼¿ä");
		oform.prize[0].focus();
		return;
	}
	
	var oHttp = new oXMLHttp();
	oHttp.sendRequest("./behind_codes/chef_reg.asp", oform, "resultAnimation");
}

function resultAnimation(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var index = checkedIndex(oform.prize);
	var result = parseInt(oDATA.result);
	
	switch (result){
		case -1:
			alert("µ¥ÀÌÅÍ ÀÔ·Â½Ã ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. Àá½ÃÈÄ ´Ù½Ã ÀÌ¿ëÇØ ÁÖ¼¼¿ä");
			break;
		case 0:
			alert("¿À´ÃÀº ÀÌ¹Ì ÀÀ¸ðÇÏ¼Ì½À´Ï´Ù. ³»ÀÏ ´Ù½Ã ÀÀ¸ðÇØ ÁÖ¼¼¿ä");
			break;
		case 1:
			alert(" [" + prize_name[oform.prize[index].value] + "]¿¡ ÀÀ¸ðµÇ¼Ì½À´Ï´Ù. \nÇÏ·ç¿¡ ÇÑ¹ø¾¿ ÀÀ¸ð°¡ °¡´ÉÇÏ´Ï ³»ÀÏ ¶Ç Âü¿©ÇØ ÁÖ¼¼¿ä");
			self.location.href = "/event/20090204/beauty2_event.asp";
			break;
	}
}

/* scrap */
function onlyNotKorean() {
	var oElement = (arguments[0] != null) ? arguments[0] : this;
	var charChk;

	for(var i=0; i<oElement.value.length; i++){
		charChk = oElement.value.charCodeAt(i);

		if(charChk <= 31 || charChk >= 127) {
			alert("ÇÑ±ÛÀº »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
			oElement.value = oElement.value.substring(0, i);
			oElement.focus();
			return;
		}
	}
}

function getScrapList(page){
	iPage = page;
	oHttp.sendRequest("./behind_codes/getScrapList.asp?page=" + iPage, null, "showScrapList");
}

function showScrapList(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	
	if( txtJSON.length > 10 ){
		var oDATA = txtJSON.parseJSON();
		var list = document.createDocumentFragment();
		
		if( oDATA.dataList ){	
			var oCell = new Array();
			var i,j;

			for(i=0; i<oDATA.dataList.length; i++){
				for(j=0; j<3; j++){
					oCell[j] = document.createElement("div");
					list.appendChild( oCell[j] );
				}
			
				oCell[0].appendChild( document.createTextNode( oDATA.dataList[i].num + "." ) );
				oCell[0].className = "comment_num";
				oCell[1].appendChild( document.createTextNode( cutTitle(oDATA.dataList[i].blogURL,35) ) );
				oCell[1].className = "comment_text";
				oCell[2].appendChild( document.createTextNode( oDATA.dataList[i].name ) );
				oCell[2].className = "comment_name";
			}
		}

		removeAllChildNodes( $("scrapList") );
		$("scrapList").appendChild( list );
		oPageNavigator.Render(oDATA.pageInfo.page, oDATA.pageInfo.recordCnt);
	}
}

function addScrap(){
	if (signed == ""){
		alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ß¸¸ ÀÀ¸ð°¡ °¡´ÉÇÕ´Ï´Ù.");
		login_layer();
		return;
	}
	
	var blogURL = oform.blogURL;
	if (blogURL.value == "") {
		alert("CF µ¿¿µ»óÀ» ½ºÅ©·¦ÇÑ ÁÖ¼Ò¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä");
		blogURL.focus();
		return;
	}
	
	if (blogURL.value.length < 15){
		alert("ÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù.");
		blogURL.focus();
		return;
	}
	
	if (blogURL.value.indexOf("http://", 0) < 0){
		alert("ÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù.");
		blogURL.focus();
		return;
	}
	
	oHttp.sendRequest("./behind_codes/addScrap_reg.asp", oform, "resultScrap");
}

function enterAddURL(){
	addScrap();
	return false;
}

function resultScrap(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var result = parseInt(oDATA.result);
	
	switch (result){
		case -1:
			alert("µ¥ÀÌÅÍ ÀÔ·Â½Ã ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. Àá½ÃÈÄ ´Ù½Ã ÀÌ¿ëÇØ ÁÖ¼¼¿ä");
			break;
		case -2:
			alert("ÀÌ¹Ì µî·ÏÇÑ ÁÖ¼ÒÀÔ´Ï´Ù. ´Ù¸¥ ÁÖ¼Ò¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä. ");
			oform.blogURL.value = "";
			oform.blogURL.focus();
			break;
		case 0:
			alert("ÀÌ¹Ì 3°³ÀÇ ÁÖ¼Ò¸¦ ¸ðµÎ µî·ÏÇÏ¼Ì½À´Ï´Ù.");
			oform.blogURL.value = "";
			break;
		default :
			alert("URLÀ» µî·ÏÇÏ¿´½À´Ï´Ù.");
			oform.blogURL.value = "";
			oform.blogURL.focus();
			getScrapList(0);
			break;
	}
}

function CopyToClipboard(selector) { 
	var object = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"308\" height=\"204\" id=\"CF\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"allowFullScreen\" value=\"false\" /><param name=\"movie\" value=\"http://www.ht.co.kr/event/20090204/flash/player.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" /> <param name=\"flashvars\" value=\"file=http://www.ht.co.kr/event/20090204/flash/beauty2_cf.flv&image=http://www.ht.co.kr/event/20090204/flash/beauty2_cf_thumb.jpg&autostart=true&repeat=always\" /></object>";
	var link = "http://www.ht.co.kr/event/20090204/beauty2_scrap.asp";
	var cb = "";
	
	switch (selector){
		case "embed":
			cb = embed;
			break;
		case "object":
			cb = object;
			break;
		case "link":
			cb = link;
			break;
	}
	
	window.clipboardData.setData('Text', cb);
	alert('º¹»çµÇ¾ú½À´Ï´Ù.\n\n¿øÇÏ´Â ºÎºÐ¿¡¼­ Ctrl + V·Î ºÙÇô³Ö±â ÇÏ½Ã¸é µË´Ï´Ù.');
}

function cutTitle(str, strLen){
	var s = str;
	var len = 0;
	
	for(i=0; i<s.length; i++) {
		if(s.charCodeAt(i)>=0 && s.charCodeAt(i)<=127)
			len++;
		else 
			len += 2;
		
		if (strLen < len){
			s = s.substring(0,i) + "..";
			break;
		}
	}
	return s;
}

function flv_player(){
	var s1 = new SWFObject('./flash/player.swf','ply','308','251','9','#FFFFFF');
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("wmode","opaque");
	s1.addParam("flashvars","file=http://www.ht.co.kr/event/20090204/flash/beauty2_cf.flv&image=beauty2_cf_thumb.jpg&autostart=true&repeat=always");
	s1.write("container");
}

/* winner */
function goWinnerReg(winner){
	if (signed == ""){
		alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ß¸¸ µî·ÏÀÌ °¡´ÉÇÕ´Ï´Ù.");
		login_layer();
		return;
	}
	
	oHttp.sendRequest("./behind_codes/getWinner.asp", oform, "resultWinner");
}

function resultWinner(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var prize = parseInt(oDATA.prize);
	
	if (!prize){
		alert("¾ÈÅ¸±õ°Ôµµ ´çÃ·µÇÁö ¾ÊÀ¸¼Ì³×¿ä. \nÇöÀç 2Â÷ÀÌº¥Æ®°¡ ÁøÇàÁßÀÌ¿À´Ï ´Ù½ÃÇÑ¹ø µµÀüÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù.^^");
		return;
	} else {
		alert("ÃàÇÏµå¸³´Ï´Ù. [" + returnPresend(prize) + "]¿¡ ´çÃ·µÇ¼Ì½À´Ï´Ù. ´çÃ·ÀÚ µî·ÏÀ» ÇØÁÖ¼¼¿ä");
		self.location.href = "./beauty2_winner_reg.asp";
	}
}

function returnPresend(p){
	var p_name = "";
	switch (p){
		case 1:
			p_name = "¹Ì´Ï ³ëÆ®ºÏ";
			break;
		case 2:
			p_name = "Wii Fit ¼¼Æ®";
			break;
		case 3:
			p_name = "¹éÈ­Á¡ »óÇ°";
			break;
		case 4:
			p_name = "½´ÆÛÇªµå °úÀÚ¼¼";
			break;
		case 5:
			p_name = "È­ÀåÇ° ¼¼Æ®";
			break;
		case 6:
			p_name = "Çâ¼ö ¼¼Æ®";
			break;
		case 7:
			p_name = "¿µÈ­¿¹¸Å±Ç";
			break;
	}
	return p_name;
}

/* winner reg */
function haitai_idCheck(){
	var form = $("detailForm");
	if (chkNull(form.haitai_id, "ÇØÅÂÁ¦°ú ID¸¦")) { return; }
	
	oHttp.sendRequest("./behind_codes/idcheck.asp?uid=" + form.haitai_id.value, null,"idChkResult")
}

function idChkResult(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var result = parseInt(oDATA.result);
	
	switch (result){
		case 0:
			alert("µî·ÏµÈ ¾ÆÀÌµð°¡ ¾Æ´Õ´Ï´Ù. È¸¿ø°¡ÀÔ ÈÄ ´Ù½Ã µî·ÏÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.");
			break;
		case 1:
			alert("ID¸¦ È®ÀÎ ÇÏ¿´½À´Ï´Ù.");
			idChk = true;
			break;
	}
}

function winner_reg(){
	var form = $("detailForm");
	if (chkNull(form.phone2, "ÈÞ´ëÆù¹øÈ£¸¦")) { return; }
	if (chkNull(form.phone3, "ÈÞ´ëÆù¹øÈ£¸¦")) { return; }
	if (chkNull(form.zip, "¿ìÆí¹øÈ£¸¦")) { return; }
	if (chkNull(form.addr1, "ÁÖ¼Ò¸¦")) { return; }
	if (chkNull(form.addr2, "³ª¸ÓÁö ÁÖ¼Ò¸¦")) { return; }
	if (chkNull(form.haitai_id, "ÇØÅÂÁ¦°ú ID¸¦")) { return; }
	
	if (!idChk){
		alert("¾ÆÀÌµð Ã¼Å©¸¦ ÇÏ¼Å¾ß¸¸ ´çÃ·ÀÚ µî·ÏÀÌ °¡´ÉÇÕ´Ï´Ù.");
		return;
	}
	
	oHttp.sendRequest("./behind_codes/winner_reg.asp", form,"winnerRegResult")
}

function winnerRegResult(xmlHttp){
	var txtJSON = xmlHttp.responseText;
	var oDATA = txtJSON.parseJSON();
	var result = parseInt(oDATA.result);
	
	switch (result){
		case 0:
			alert("µî·ÏµÈ ¾ÆÀÌµð°¡ ¾Æ´Õ´Ï´Ù. È¸¿ø°¡ÀÔ ÈÄ ´Ù½Ã µî·ÏÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.");
			idChk = false;
			break;
		case 1:
			alert("´çÃ·ÀÚ µî·ÏÀÌ ¿Ï·áµÇ¾ú½À´Ï´Ù. ´Ù½ÃÇÑ¹ø ´çÃ·À» ÃàÇÏµå¸³´Ï´Ù.");
			break;
	}
}

function Enter_winner_reg(){
	winner_reg();
	return false;
}