
function mailSend()
{	
	if (loginChk())
	{
		sendcnt = document.getElementById("sendcnt").value;

		for (var i = 1; i <= sendcnt; i++) 
		{
			sendname = document.getElementById("sendname"+i);
			sendemail = document.getElementById("sendemail"+i);

			if (sendname.value == "")
			{
				alert("받는 사람 이름을 입력해주세요.");
				sendname.focus();
				return;
			}

			if (sendemail.value == "")
			{
				alert("받는 사람 이메일을 입력해주세요.");
				sendemail.focus();
				return;
			}

			if (sendemail.value.indexOf("@") == -1 || sendemail.value.indexOf(".") == -1 || sendemail.value.length <= 5)
			{
				alert("받는 사람 이메일을 제대로 입력하세요.\r\n");
				sendemail.value = "";		
				sendemail.focus();
				return;
			}		
		}
		
		document.frmMain.action="sendmail.asp";
		document.frmMain.target="blank";
		document.frmMain.submit();
	}
}

//로그인체크

function loginChk()
{
	if (document.getElementById("mcode").value == "")
	{	
		alert("로그인 후 이용해 주세요.");
		location.href="http://www.chocopie.co.kr/member/login.asp?retURL=http://www.chocopie.co.kr/community/comm_point.asp";
		return;
		
	}

	return true;
}

//태그 복사
function tagCopy(gubun)
{	
	tag = "http://www.chocopie.co.kr/community/pevent.asp?gubun="+gubun;
	if (loginChk())
	{
		tag = tag + "&mcode=" + document.getElementById("mcode").value + "&num=" + document.getElementById("num").value;

		if (gubun == 3)
		{
			tag = '<a href="http://www.chocopie.co.kr/community/comm_point_t.asp?num=' + document.getElementById("num").value + '" target="_blank"><img src="' + tag + '" border="0"></a>';
		}
		
		window.clipboardData.setData("Text",tag);

		if (gubun == 2)
		{
			alert("주소가 복사되었습니다.\n메신저를 통해 친구들에게 알려주세요.");
		}
		if (gubun == 3)
		{
			alert("태그가 복사되었습니다.\n카페나 블로그를 통해 친구들에게 알려주세요.");
		}
	}
}

function myPoint()
{
	if (loginChk())
	{
		getHttprequest();
	}
}

function useInfo()
{
	window.open("info.html", "useInfo", "width=483, height=345, top=50, left=400");
}

function pointInfo()
{
	window.open("point.html", "pointInfo", "width=507, height=578, top=50, left=400");
}

var xmlhttp = null;
function getHttprequest() 
{
	if(window.XMLHttpRequest) {

	//파어이 폭스는 아래값으로 셋팅됨.
	xmlhttp = new XMLHttpRequest();
	} else {
	//인터넷 익스플로어는 아래값으로 셋팅됨.
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}	//브라우져 셋팅 끝.

	xmlhttp.open('get',"point.asp?mcode="+document.getElementById("mcode").value+"&num="+document.getElementById("num").value,true);

	xmlhttp.onreadystatechange = function(){
	if(xmlhttp.readyState == '4'){	//readyState 4는 로딩된후, 값을 모두 받았음을 의미함.
	  if(xmlhttp.status == 200) {

		var data=xmlhttp.responseText;
		//alert(data);
		point = data.split("|");

		document.getElementById("mpoint").value = point[0];
		document.getElementById("tpoint").value = point[1];

		//utf 설정 헤더를 넣을때 아래 추가
		//xmlhttp.setRequestHeader("Content-type", "application/x-www-urlencoded; charset=UTF-8");
	  } //End of 200
	} //End of 4
	} 

	xmlhttp.send(null);
}

//동적 텍스트 박스 생성
var num = 1; 
function add_Form() {

if (num >= 10)
{
	alert("10명이상 보내실 수 없습니다.");
	return;
}

if (num == 1)
{
	eval('send').innerHTML = ""
}

eval('send').innerHTML += ""

+ "<table width='448' height='28'border='0' align='center' cellpadding='0' cellspacing='0'>"
+ "	<tr>"
+ "		<th width='89' scope='col'><img src='/images/community/bottom_text1.jpg' width='89' height='28' /></th>"
+ "		<th width='60' height='28' align='center' valign='top' background='/images/community/bottom_text1_2.jpg' scope='col'><input name='sendname"+(num+1)+"' style='width:58px;height:18px;border:solid 0px #666666' maxlength='10' onclick='loginChk();' /></th>"
+ "		<th width='56' scope='col'><img src='/images/community/bottom_text1_3.jpg' width='56' height='28' /></th>"
+ "		<th width='120' height='28' align='left' valign='top' background='/images/community/bottom_text1_4.jpg' scope='col'><input name='sendemail"+(num+1)+"' style='width:113px;height:18px;border:solid 0px #666666;ime-mode:disabled;' maxlength='100' onclick='loginChk();' /></th>"
+ "		<th width='37' scope='col'>&nbsp;</th>"
+ "		<th width='86' scope='col'>&nbsp;</th>"
+ "	</tr>"
+ "</table>";


document.getElementById("sendcnt").value = num+1;
//alert(document.getElementById("sendcnt").value);
num++; 
}

function img_Chanage(num)
{
	document.getElementById("diary").src = "/images/community/top_diary_"+num+".jpg";
	document.getElementById("num").value = num;
}
