//document.domain = "www.sonokong.co.kr";

// 링크 점선 테두리 한번에 없애기
function bluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;

function SetNum(obj){
	val=obj.value;
	re=/[^0-9]/gi;
	obj.value=val.replace(re,"");
}

// Trim
function Trim(obj1){
	obj1 = obj1.replace(/^(\s+)|(\s+)$/g, "")
	return obj1;
}

// Input String null checking
function validFieldText(objInput, msgStr){
	if(Trim(objInput.value) == "") {
		alert("" + msgStr + "를 입력해주세요.");
		objInput.focus();
		return false;
	}

	return true;
}

// Input String null checking (for English)
function validFieldTextEng(objInput, msgStr){
	if(Trim(objInput.value) == "") {
		alert("Please enter a " + msgStr + "");
		objInput.focus();
		return false;
	}

	return true;
}


// 포뱃 체크
function isValidFormat(input, format) {
    if (input.value.search(format) != -1) {
        return true;
    }
    return false;
}
//숫자입력 체크(onblur)
function  number_validate(theForm, firstNum) {
	if (theForm.value != "") {
		var str=theForm.value;
		for (var i = 0; i< str.length; i++) {
			var ch = str.substring(i, i + 1);

			if ( (ch<"0" || ch>"9") ) {
				alert("\n숫자만 입력해주세요");
				theForm.value=firstNum;
				theForm.focus();
				return false;
			}
		}
	}

	return true;
}
// 이메일 형식 체크
function CheckEmail(strEmail){
	var format = /^((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidFormat(strEmail, format);
}

function WindowOpen(Url, popName, popwidth, popheight){
	var height = screen.height;
	var width = screen.width;
	var left = 0;
	var top = 0;
	popheight = popheight + 27;
	window.open(Url, popName, "width="+popwidth+",height="+popheight+",scrollbars=no,toolbar=no,left="+left+",top="+top+"")
}

function WindowOpenNomargin(Url, popName, popwidth, popheight){
	var height = screen.height;
	var width = screen.width;
	popheight = popheight + 27;
	window.open(Url, popName, "width="+popwidth+",height="+popheight+",scrollbars=yes,toolbar=no,left=0,top=0")
}

function IDCheck(value)
{
	WindowOpen("/Popup/IDDupCheck.asp?UserID="+value, "IDCheck", 407, 180)
}

// 주민등록번호 체크
function jumin_check(o, registNum1, registNum2 ){
	var chk =0;
	var yy = registNum1.value.substring(0,2);
	var mm = registNum1.value.substring(2,4);
	var dd = registNum1.value.substring(4,6);
	var sex = registNum2.value.substring(0,1);


	if( (registNum1.value.length!=6)||(yy <25||mm <1||mm>12||dd<1) ){
		o.msg.value = "주민등록번호를 바로 입력하여 주십시오.";
		registNum1.value="";
		registNum2.value="";
		registNum1.focus();
		return true;
	}

	if( (sex != 1 && sex !=2 && sex != 3 && sex != 4)||(registNum2.value.length!= 7 ) ){
		o.msg.value = "주민등록번호를 바로 입력하여 주십시오.";
		registNum1.value="";
		registNum2.value="";
		registNum1.focus();
		return true;
	}

	for (var i = 0; i <=5 ; i++){
		chk = chk + ((i%8+2) * parseInt(eval(registNum1.value.substring(i,(i+1)))));
	}
	for (var i = 6; i <=11 ; i++){
		chk = chk + ((i%8+2) * parseInt(eval(registNum2.value.substring((i-6),(i-5)))));
	}

	chk = 11 - (chk %11);
	chk = chk % 10;

	if (chk != registNum2.value.substring(6,7))	{
			o.msg.value = "유효하지 않는 주민등록번호입니다.\n\n타인의 주민등록번호를 도용하거나 허위 기제할 경우 회원가입이 취소됩니다.";
			registNum1.value="";
			registNum2.value="";
			registNum1.focus();
			return true;
	}

}

// ActiveX Start //

function flashMovie(fid,src,wid,hei,fvs,wmd) {
  this.fPrint = '';
  this.Id = document.getElementById(fid);
  this.Src = src;
  if(wid == 0){
    this.Width = '100%';
  }
  else{
    this.Width = wid;
  }
  if(hei == 0){
    this.Height = '100%';
  }
  else{
    this.Height = hei;
  }
  this.FlashVars = (fvs != undefined)? fvs :'';
  this.Wmod = (wmd != undefined)? wmd :'';
  if(isObject(Id)) {
    fPrint = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"';
    fPrint += ' width="'+Width+'"';
    fPrint += ' height="'+Height+'">';
    fPrint += '<param name="allowScriptAccess" value="always">';
    fPrint += '<param name="movie" value="'+Src+'">';
    fPrint += '<param name="menu" value="false" />';
    fPrint += '<param name="quality" value="high">';
    fPrint += (FlashVars != null) ? '<param name="FlashVars" value="'+FlashVars+'">' : '';
    fPrint += '<param name="wmode" value="Transparent">';
    fPrint += '<embed';
    fPrint += ' src="'+Src+'"';
    fPrint += (FlashVars != null) ? ' FlashVars="'+FlashVars+'"' : '';
    fPrint += ' wmode="Transparent"' ;
    fPrint += ' quality="high"';
    fPrint += ' allowScriptAccess="always"';
    fPrint += ' pluginspage="http://www.macromedia.com/go/getflashplayer"';
    fPrint += ' type="application/x-shockwave-flash"';
    fPrint += ' width="'+Width+'"';
    fPrint += ' height="'+Height+'"';
    fPrint += '></embed>';
    fPrint += '</object>';
    Id.innerHTML = fPrint;
  }
}

function isObject(a) {
    return (a && typeof a == 'object');
}

// ActiveX End //


//DIV 슬라이드
function slideDiv(val, divName, movenumname, maxnum)
{
	movenum = eval(movenumname+"movenum");

	//alert("1 : "+ movenum);

	for (var i = 1; i <= maxnum; i++) {
		document.getElementById(divName+i).style.display = "none";
	}


	if(val == "next"){
		movenum++;
	}else{
		movenum--;
		if(movenum >maxnum)
			movenum = 1;
	}

	if(movenum <1)
		movenum = maxnum;
	if(movenum >maxnum)
		movenum = 1;

	document.getElementById(divName+movenum).style.display = "block";
	return movenum;
}

function slideDiv2(kindval, divName, movenumname, maxnum)
{
	movenum = eval(movenumname+"movenum");

	if (kindval == "next")
	{
		movenum++;
	} else
	{
		movenum--;
		if(movenum > maxnum)
			movenum = 1;
	}

	if(movenum < 1)
		movenum = maxnum;
	if(movenum > maxnum)
		movenum = 1;

	for (var i = 1; i <= maxnum; i++)
	{
		if (i == movenum)
		{
			document.getElementById(divName+i).style.display = "block";
			document.getElementById("img"+i).src = "/images/ToyWorld/icn/icn_num0"+i+".gif"
			document.getElementById("txt"+i).className = "FRedB"
		} else
		{
			document.getElementById(divName+i).style.display = "none";
			document.getElementById("img"+i).src = "/images/ToyWorld/icn/icn_num0"+i+"off.gif"
			document.getElementById("txt"+i).className = ""
		}
	}

	Hotmovenum = movenum;
	return;
}

/**************************
*   토이, 애니, VOD  찜하기
*************************/
function Scrap(codeVal, FkVal){
	loadAjaxXML("/share/proc/ScrapProc.asp", "Code="+codeVal+"&NoPkid="+FkVal, ScrapSuccess, AjaxFail);
}

function ScrapSuccess(originalRequest)
{
	var MsgStr, strCode, ScrapCount;

	var docXML = originalRequest.responseXML;
	if(docXML.getElementsByTagName("Contents").length > 0) {
			MsgStr = docXML.getElementsByTagName("MsgStr").item(0).firstChild.nodeValue;
			strCode = docXML.getElementsByTagName("strCode").item(0).firstChild.nodeValue;
			ScrapCount = docXML.getElementsByTagName("ScrapCount").item(0).firstChild.nodeValue;
			alert(MsgStr);
	}else{
		MsgStr = "";
	 	strCode = "";
	 	ScrapCount = "";
	}

	document.getElementById(strCode+"_Scrap").innerHTML = ScrapCount;
}

/**************************
*   토이, 애니, VOD 추천하기
*************************/
function contentsRecom(val, NoPkid, tblCode)
{
	loadAjaxXML("/share/proc/RecommendProc.asp", "FlagUD="+val+"&NoPkid="+NoPkid+"&tblCode="+tblCode, RecomSuccess, AjaxFail);
}

function RecomSuccess(originalRequest)
{
	var docXML = originalRequest.responseXML;
	var UTotal = 0;
	var DTotal = 0;
	var UPercent = 0;
	var DPercent = 0;
	var Ucnt = 0;
	var Dcnt = 0;

	var innerText = innerText = "<table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
	innerText = innerText + "												<tr>";	

	if(docXML.getElementsByTagName("Contents").length > 0) {
			Ucnt = docXML.getElementsByTagName("ucnt").item(0).firstChild.nodeValue;
			Dcnt = docXML.getElementsByTagName("dcnt").item(0).firstChild.nodeValue;
			UTotal = parseInt(Ucnt)+parseInt(Dcnt);
			DTotal = parseInt(Dcnt)+parseInt(Ucnt);
			UPercent = Math.round(100*(parseInt(Ucnt)/UTotal));
			DPercent = Math.round(100*(parseInt(Dcnt)/DTotal));

	}else{
		UPercent = 0;
	 	Ucnt = 0;
	 	Dcnt = 0;
	}

	innerText = innerText + "													<td style=\"font-size:11px; width:105px; text-align:left;\">"+Ucnt+"</td>";
	innerText = innerText + "													<td style=\"font-size:11px; width:105px; text-align:right;\">"+Dcnt+"</td>";
	innerText = innerText + "												</tr>";
	innerText = innerText + "											</table>";
	innerText = innerText + "											<table>";
	innerText = innerText + "											<tr>";
	innerText = innerText + "												<td class=\"CharBg\">";
	innerText = innerText + "													<table width=\"210\" align=\"center\">";
	innerText = innerText + "														<tr>";
	innerText = innerText + "															<td width=\""+UPercent+"%\" height=\"13\" background=\"/images/ToyWorld/char_linebg.gif\"></td>";
	innerText = innerText + "															<td width=\""+DPercent+"%\" align=\"right\"></td>";
	innerText = innerText + "														</tr>";
	innerText = innerText + "													</table>";
	innerText = innerText + "												</td>";
	innerText = innerText + "											</tr>";
	innerText = innerText + "										 	</table>";

	document.getElementById("tblRecom").innerHTML = innerText;

}

//이메일 형식 체크
function mailVal_ck(o, val)
{
	if(val.indexOf("@") +""=="-1" ||
		val.indexOf(".") +""=="-1")
	{
		alert("잘못된 이메일 형식입니다.")
		o.focus();
		return false;
	}else{
		return true;
	}
}
//이메일 형식 체크 ENGLISH
function mailVal_ENG_ck(o, val)
{
	if(val.indexOf("@") +""=="-1" ||
		val.indexOf(".") +""=="-1")
	{
		alert("Invalid email format!")
		o.focus();
		return false;
	}else{
		return true;
	}
}

function FindZip()
{
	window.open("/Popup/FindZip.asp", "zip", "width="+437+",height="+280+",scrollbars=yes,toolbar=no")

}

//Member Login
function LoginCheck(theForm) {
	if (!validFieldText(theForm.id, "아이디")){
		return ;
	}
	if (!validFieldText(theForm.pass1, "비밀번호")){
		return ;
	}

	theForm.submit();
}

//encodeURIComponent 함수 정의
if (typeof(encodeURIComponent) != "function")
{
	encodeURIComponent = function (s)
	{
		function toHex (n)
		{
			var hexchars = "0123456789ABCDEF" ;
			return  "%" + hexchars.charAt(n>>4) + hexchars.charAt(n&0xF) ;
		}
		var es  = "" ;
		for (var i = 0; i < s.length;)
		{
			var c = s.charCodeAt(i++) ;
			if ((c&0xF800) == 0xD800)
			{
				var sc = s.charCodeAt(i++) ;
				c = ((c-0xD800)<<10) + (sc-0xDC00) + 0x10000 ;
			}
			if (!(c&~0x7F))
			{
				if ((c>=65&&c<=90) || (c>=97&&c<=122) || (c>=48&&c<=57) || (c>=45&&c<=46) || c==95 || c==33 || c==126 || (c>=39&&c<=42))
					es += String.fromCharCode(c) ;
				else
					es += toHex(c) ;
			}
			else if (!(c&~0x7FF))
				es += toHex(0xC0+(c>>6)) + toHex(c&0x3F) ;
			else if (!(c&~0xFFFF))
				es += toHex(0xE0+(c>>12)) + toHex(0x80+(c>>6&0x3F)) + toHex(0x80+(c&0x3F)) ;
			else es += toHex(0xF0+(c>>18)) + toHex(0x80+(c>>12&0x3F)) + toHex(0x80+(c>>6&0x3F)) + toHex(0x80+(c&0x3F)) ;
		}
		return  es ;
	}
}

String.prototype.trim2 = function()
{
   return this.replace(/(^\s*)|(\s*$)/gi, "");
}


String.prototype.replaceAll = function(str1, str2)
{
   var temp_str = "";
   if (this.trim2() != "" && str1 != str2)
   {
       temp_str = this.trim2();
       while (temp_str.indexOf(str1) > -1)
       {
           temp_str = temp_str.replace(str1, str2);
       }
   }
   return temp_str;
}

//==============================================================
//Prototype Base Function Lib
function loadAjaxXML(url, pars, fncSuccess, fncFailure){
	var myAjax = new Ajax.Request(
					url,
					{
							method: 'get',
							parameters: pars,
							onSuccess: fncSuccess,
							onFailure: fncFailure
					});
}
//==============================================================
//==============================================================

// Ajax Process Function
// url = Call Page Full URL INCOUDE PARAMITER
function AjaxProc(url)
{
	loadAjaxXML(url, '', AjaxSuc, AjaxFail);
}
// Ajax Process Success Function
// originalRequest = Ajax Request
function AjaxSuc(originalRequest)
{
	var objXML;
	objXML = new JSONParser(originalRequest);
	var json = objXML.data;


	if ( json.Content.IsAlert != "" && json.Content.IsAlert != null && json.Content.IsAlert == "1" ) {
		alert(json.Content.Message);
	}

	if ( json.Content.IsFunction != "" && json.Content.IsFunction != null && json.Content.IsFunction == "1" ) {
		eval(json.Content.FunctionName);
	}
}
// Ajax Process Fail Function
function AjaxFail()
{
	alert("처리에 실패하였습니다.");
}
 function QuickMenu(){
	var a=document.body.scrollTop+292;
	 document.all.quick.style.top = a;
 }
 //display설정 변경
function changeTb(tbName, tbCount, tbNum) {
	var a;
	for(i=1;i<=tbCount;i++){

		a = eval("document.all."+tbName+i);

		if(i != tbNum) {
			a.style.display = 'none';
		}
		else {
			a.style.display = 'block';
		}
	}
}
//--아이프레임 자동 길이 조절 스크립트-----------------------------------------------------------------------------
function resizeFrame(iframeObj){
        var innerBody = iframeObj.contentWindow.document.body;
        oldEvent = innerBody.onclick;
        innerBody.onclick = function(){ resizeFrame(iframeObj, 1);oldEvent; };
        var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight) + 5;
        iframeObj.style.height = innerHeight;
        var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
        iframeObj.style.width = innerWidth;
        if( !arguments[1] )        /* 특정 이벤트로 인한 호출시 스크롤을 그냥 둔다. */
                this.scrollTo(1,1);
}
//--------------------------------------------------------------------------------------------------
function clrImg(obj){
    obj.style.backgroundImage="";obj.onkeydown=obj.onmousedown=null;
}
//동영상 보기
function viewMovie(intWidth, intHeight){
	var htmltext = "";
	try{
		var linktext = document.all["vodlink"].value;

		if(linktext == "http://" || linktext == ""){
			alert("링크를 입력해 주세요.");
			return;
		}

		if(linktext.indexOf("<") >= 0){
			alert("허용하지 않는 링크주소입니다.");
			return;
		}

		if(linktext.indexOf(".asx") >= 0 || linktext.indexOf(".ASX") >= 0){
			alert("asx파일은 링크할 수 없습니다.");
			return;
		}

		var ext = linktext.slice(linktext.lastIndexOf(".")+1).toLowerCase();
		if  (ext == "gif" || ext == "jpg" || ext == "png"){
			img = new Image();
			img.src = linktext;
			linktext = linktext.replace(/'/g, "\'");
			if (img.width > intWidth)
				document.all["vodcontents"].innerHTML = "<img src=\"" + img.src + "\"  width=\""+intWidth+"\" heigth=\""+intHeight+"\">";
			else
				document.all["vodcontents"].innerHTML = "<img src=\"" + img.src + "\"  >";
		}
		// if (ext == "wma" || ext == "wmv" || ext == "asf" || ext == "asx" || ext == "swf" || ext == "mp3"){
		else
		{
			linktext = linktext.replace(/'/g, "\'");
			//document.all["vodcontents"].innerHTML = "<embed width=\""+intWidth+"\" heigth=\""+intHeight+"\" src=\"" + linktext + "\"  >";
			htmltext = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+intWidth+"\" heigth=\""+intHeight+"\" id=\"V402923\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"always\" /> <param name=\"movie\" value=\"" + linktext + "\" /> <param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" /><embed src=\"" + linktext + "\" quality=\"high\" bgcolor=\"#000000\" width=\""+intWidth+"\" heigth=\""+intHeight+"\" name=\"V402923\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>";
			document.all["vodcontents"].innerHTML = htmltext;
		}
	} catch(e) {
		alert(e);
	}
}

/**************************
*   댓글
*************************/

//댓글입력
function insertTail()
{
	var f = document.frmTail;
	if (!validFieldText(f.tailContents, "내용을")){
		return false;
	}
	if (f.tailContents.length <= 0 || f.tailContents.value == "30자까지만 쓸 수 있어요" ) {
		alert("내용을 입력하세요.");
		f.tailContents.focus();
		f.tailContents.value = "";
		return false;
	}
	loadAjaxXML("/share/proc/TailProc.asp", "Code="+tblCode+"&NoPkid="+NoPkid+"&TailContents="+escape(f.tailContents.value), TailWriteSuccess, AjaxFail);
	return false;
}

function TailWriteSuccess(originalRequest)
{
	var f = document.frmTail;
	alert(originalRequest.responseText)	;
	getTailList(1);
	f.tailContents.value = "";
}


//댓글삭제
function deleteTail(TailPkid)
{
	var Return;

	Return = confirm("삭제 하시겠습니까?");
	if(Return == true)
	{
		loadAjaxXML("/share/proc/TailDelProc.asp", "Code="+tblCode+"&TailPkid="+TailPkid, TailDeleteSuccess, AjaxFail);
	}
}

function TailDeleteSuccess(originalRequest)
{
	alert(originalRequest.responseText)	;
	getTailList(1);
}

//댓글 목록
function getTailList(page)
{
	loadAjaxXML("/share/proc/TailList.asp", "Code="+tblCode+"&NoPkid="+NoPkid+"&Page="+page, TailListSuccess, AjaxFail);
}

function TailListSuccess(originalRequest)
{
	var docXML = originalRequest.responseXML;


	var totalCount = 0;
	var rnowPage = 1;

	var innerText = innerText = "<table width=\"100%\"  style=\"margin-top:13px;\">";
	innerText = innerText + "	<tr>";
	innerText = innerText + "	<td colspan=\"3\" height=\"1\" bgcolor=\"#C04148\"></td>";
	innerText = innerText + "	</tr>";

	if(docXML.getElementsByTagName("list").length > 0) {
		totalCount = docXML.getElementsByTagName("totalCount").item(i).firstChild.nodeValue;
		rnowPage = docXML.getElementsByTagName("nowPage").item(i).firstChild.nodeValue;
		for (var i = 0; i < docXML.getElementsByTagName("list").length; i++) {
			innerText = innerText + "	<tr>";
			innerText = innerText + "	<td width=\"473\" height=\"24\" class=\"ComLont\" >"+docXML.getElementsByTagName("TailContents").item(i).firstChild.nodeValue;

			if(UserSNO == docXML.getElementsByTagName("FKMember").item(i).firstChild.nodeValue)
				innerText = innerText + " <a href=\"javascript:deleteTail('"+docXML.getElementsByTagName("Pkid").item(i).firstChild.nodeValue+"')\"><img src=\"/images/icn/icn_x.gif\" align=\"absmiddle\"></a>";

			innerText = innerText + "</td>";
			innerText = innerText + "	<td width=\"140\" class=\"ComCont\">"+docXML.getElementsByTagName("UserID").item(i).firstChild.nodeValue+"</td>";
			innerText = innerText + "	<td width=\"73\" class=\"ComCont\">"+docXML.getElementsByTagName("RegDate").item(i).firstChild.nodeValue+"</td>";
			innerText = innerText + "	</tr>";
			innerText = innerText + "	<tr><td class=\"ComLine\" colspan=\"3\"></td></tr>";
		}
	}else{
		innerText = innerText + "	<tr>";
		innerText = innerText + "		<td height=\"24\" class=\"ComLont\" colspan=\"3\" align=\"center\">등록된 글이 없습니다.</td>";
		innerText = innerText + "		</tr>";
		innerText = innerText + "	<tr><td class=\"ComLine\" colspan=\"3\"></td></tr>";
	}

	innerText = innerText + "</table>";

	document.getElementById("TailList").innerHTML = innerText;
	mkPage(parseInt(rnowPage), parseInt(totalCount));
}

/**************************
*   댓글페이징
*************************/
function mkPage(nowPage, totalRecords) {
	tableLimit = 5;
	pageList = document.all.paging; // 페이지 목록이 뿌려질 곳 <td>
    pageList.innerHTML = '';

     totalPages = Math.ceil(totalRecords/tableLimit); // 총페이지수


     blockPage = 0; // 1,11,21,...각 블럭 들의 첫페이지 1~10 까지가 한블럭
     blockSize = 10; // 보여줄 페이지 갯수, 이전 x개, 다음 x개

     //블럭의 첫번째 페이지 구하기
     blockPage = Math.floor((nowPage-1)/blockSize);
     blockPage = blockPage * blockSize + 1;


	 link=window.location.href
	 if(!window.location.search) link+="?"
	 else link=link.replace(/&pg=([0-9]*)/,'')


	 var pagestr = "";
	 var l_iStartPage = "";

    //이전 10개구문
	l_iStartPage = parseInt((nowPage)/blockSize)*blockSize + 1
	if(l_iStartPage == 1 || l_iStartPage == "")
		pagestr += "<img src=\"/images/btn/btn_prev02.gif\" width=\"16\" height=\"17\" hspace=\"2\" align=\"absmiddle\" />";
	else
		pagestr += "<a href=\"javascript:getTailList("+(l_iStartPage-1)+");\"><img src=\"/images/btn/btn_prev02.gif\" width=\"16\" height=\"17\" hspace=\"2\" align=\"absmiddle\" /></a>";

	//이전글
	if(nowPage <= 1)
		pagestr += "<img src=\"/images/btn/btn_prev.gif\" width=\"35\" height=\"17\" align=\"absmiddle\"/>&nbsp;";
	else
		pagestr += "<a href=\"javascript:getTailList("+(nowPage-1)+");\"><img src=\"/images/btn/btn_prev.gif\" width=\"35\" height=\"17\" align=\"absmiddle\"/></a>&nbsp;";

     //페이지리스트, blockPage++
     for(i=1; i<=blockSize; i++, blockPage++){
          // 마지막 페이지와 같다면..
          if(blockPage == totalPages || totalPages ==0)
          i = blockSize+1; // 이러면 다음차례에는 for문을 빠져나가겠져?

          // 블럭페이지와 현재페이지가 같으면 링크없다.
          if(blockPage == nowPage){
			pagestr += "<span class=\"a_o\">" + blockPage + "</span>";
		  }
          else{
            pagestr += "<a href=\"javascript:getTailList("+blockPage+");\" >";
            pagestr += blockPage;
            pagestr += "</a>";
		  }

          // 마지막 페이지와 같다면..
          if(i < blockSize)
		  	pagestr += " | ";
     }


    l_iPageCount = parseInt(totalRecords/ tableLimit)

	 //다음글
	 if(nowPage > l_iPageCount)
		pagestr += "&nbsp;<img src=\"/images/btn/btn_next.gif\" width=\"35\" height=\"17\" hspace=\"2\" align=\"absmiddle\"/>";
	 else
		pagestr += "&nbsp;<a href=\"javascript:getTailList("+(nowPage+1)+");\"><img src=\"/images/btn/btn_next.gif\" width=\"35\" height=\"17\" hspace=\"2\" align=\"absmiddle\"/></a>";

	 //다음 10개구문
	l_iLastPage = l_iStartPage + blockSize - 1
	if(l_iLastPage >= l_iPageCount)
		l_iLastPage = l_iPageCount


	if(l_iLastPage >= l_iPageCount)
		pagestr += "<img src=\"/images/btn/btn_next02.gif\" width=\"16\" height=\"17\" align=\"absmiddle\" />";
	else
		pagestr += "<a href=\"javascript:getTailList("+(l_iStartPage+blockSize)+");\"><img src=\"/images/btn/btn_next02.gif\" width=\"16\" height=\"17\" align=\"absmiddle\" /></a>";

	pageList.insertAdjacentHTML("beforeEnd",pagestr);
	document.getElementById("closebtn").style.visibility = "visible";
}

/**************************
*   BBS 댓글
*************************/

//BBS 댓글입력
function insertBBSTail()
{
	var f = document.frmTail;
	if (!validFieldText(f.tailContents, "내용을")){
		return false;
	}
	if (f.tailContents.length <= 0 || f.tailContents.value == "30자까지만 쓸 수 있어요" ) {
		alert("내용을 입력하세요.");
		f.tailContents.focus();
		f.tailContents.value = "";
		return false;
	}
	loadAjaxXML("/share/proc/TailProc.asp", "Code="+tblCode+"&NoPkid="+NoPkid+"&TailContents="+escape(f.tailContents.value), BBSTailWriteSuccess, AjaxFail);
	return false;
}

function BBSTailWriteSuccess(originalRequest)
{
	var f = document.frmTail;
	alert(originalRequest.responseText);
	getBBSTailList()
	f.tailContents.value = "";
}

//BBS 댓글삭제
function deleteBBSTail(TailPkid)
{
	var Return;

	Return = confirm("삭제 하시겠습니까?");
	if(Return == true)
	{
		loadAjaxXML("/share/proc/TailDelProc.asp", "Code="+tblCode+"&TailPkid="+TailPkid, BBSTailDeleteSuccess, AjaxFail);
	}
}

function BBSTailDeleteSuccess(originalRequest)
{
	alert(originalRequest.responseText)	;
	getBBSTailList();
}

//BBS 댓글 목록
function getBBSTailList()
{
	loadAjaxXML("/share/proc/BBSTailList.asp", "Code="+tblCode+"&NoPkid="+NoPkid, BBSTailListSuccess, AjaxFail);
}

function BBSTailListSuccess(originalRequest)
{
	var docXML = originalRequest.responseXML;
	var totalCount = 0;

	var innerText = "";

	if(docXML.getElementsByTagName("list").length > 0) {
		totalCount = docXML.getElementsByTagName("totalCount").item(i).firstChild.nodeValue;

		innerText = innerText + "	<table width=\"100%\"  style=\"margin-top:13px; background-color:#F8F3EF\">\n";
		innerText = innerText + "		<tr>\n";
		innerText = innerText + "			<td colspan=\"3\" height=\"22\" class=\"FBrowB11\" style=\"padding-left:10px;\">덧글 : "+ totalCount +"건</td>\n";
		innerText = innerText + "		</tr>\n";
		innerText = innerText + "		<tr>\n";
		innerText = innerText + "			<td colspan=\"3\" height=\"2\" bgcolor=\"#BCA290\"></td>\n";
		innerText = innerText + "		</tr>\n";

		for (var i = 0; i < docXML.getElementsByTagName("list").length; i++) {
			innerText = innerText + "	<tr>\n";
			innerText = innerText + "		<td width=\"473\" height=\"24\" class=\"ComLont\" >"+docXML.getElementsByTagName("TailContents").item(i).firstChild.nodeValue;

			if(UserSNO == docXML.getElementsByTagName("FKMember").item(i).firstChild.nodeValue)
				innerText = innerText + " <a href=\"javascript:deleteBBSTail('"+docXML.getElementsByTagName("Pkid").item(i).firstChild.nodeValue+"')\"><img src=\"/images/icn/icn_x.gif\" align=\"absmiddle\"></a>\n";

			innerText = innerText + "		</td>\n";
			innerText = innerText + "		<td width=\"140\" class=\"ComCont\">"+docXML.getElementsByTagName("UserID").item(i).firstChild.nodeValue+"</td>\n";
			innerText = innerText + "		<td width=\"73\" class=\"ComCont\">"+docXML.getElementsByTagName("RegDate").item(i).firstChild.nodeValue+"</td>\n";
			innerText = innerText + "	</tr>\n";
			innerText = innerText + "	<tr><td class=\"ComLine\" colspan=\"3\"></td></tr>\n";
		}

	}else{
		innerText = innerText + "	<table width=\"100%\"  style=\"margin-top:13px; background-color:#F8F3EF\">\n";
		innerText = innerText + "		<tr>\n";
		innerText = innerText + "			<td colspan=\"3\" height=\"22\" class=\"FBrowB11\" style=\"padding-left:10px;\">덧글 : 0건</td>\n";
		innerText = innerText + "		</tr>\n";
		innerText = innerText + "		<tr>\n";
		innerText = innerText + "			<td colspan=\"3\" height=\"2\" bgcolor=\"#BCA290\"></td>\n";
		innerText = innerText + "		</tr>\n";
		innerText = innerText + "		<tr>\n";
		innerText = innerText + "			<td height=\"24\" colspan=\"3\" align=\"center\">등록된 글이 없습니다.</td>\n";
		innerText = innerText + "				</tr>\n";
		innerText = innerText + "		<tr><td class=\"ComLine\" colspan=\"3\"></td></tr>\n";
	}
		innerText = innerText + "	</table>\n";

	document.getElementById("TailList").innerHTML = innerText;
}
//---드롭 메뉴-----
var lmn='';
function menu(name){
	submenu=eval("Funy"+name+".style");

	if(lmn!=submenu)
	{
		if(lmn!='')
		{
			lmn.display='none';
		}
		submenu.display='block';
		lmn=submenu;
	}
	else
	{
		submenu.display='none';
		lmn='';
	}
}
//--로그인 여부 체크
function PollPkidCheck(val, obj)
{

	if (val == ""){
		alert("로그인을 해주세요");
		return;
	}
	eval("document."+obj).submit();
}

function clrImg(obj){
    obj.style.backgroundImage="";obj.onkeydown=obj.onmousedown=null;
}
function isEng(str)
{

	for(var i=0; i < str.length; i++){
		 achar = str.charCodeAt(i);
		if(achar > 255){
			return false;
		}
	}
	return true;
}

function MoviePlayer(movieurl){
	document.write("<object classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' id='MediaPlayer1' width='400' height='300' border='0'>");
	document.write("<param name='Filename' value='"+ movieurl +"'>");
	document.write("<param name='loop' value='1'>");
	document.write("<param name='mute' value='0'>");
	document.write("<param name='AutoStart' value='0'>");
	document.write("<param name='AutoSize' value='0'>");
	document.write("<param name='AutoResize' value='0'>");
	document.write("<param name='TransparentAtStart' value='1'>");
	document.write("<param name='AutoRewind' value='1'>");
	document.write("<param name='ShowDisplay' value='0'>");
	document.write("<param name='ClickToPlay' value='1'>");
	document.write("<param name='EnableContextMenu' value='0'>");
	document.write("<param name='ShowPositionControls' value='1'>");
	document.write("<param name='ShowStatusBar' value='0'>");
	document.write("<param name='ShowControls' value='1'>");
	document.write("<param name='EnableTracker' value='1'>");
	document.write("<param name='Volume' value='0'>");
	document.write("</object>");
}

function MoviePlayer2(movieurl, mwidth, mheight){
	document.write("<object classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' id='MediaPlayer1' width='"+mwidth+"' height='"+mheight+"' border='0'>");
	document.write("<param name='Filename' value='"+ movieurl +"'>");
	document.write("<param name='loop' value='1'>");
	document.write("<param name='mute' value='0'>");
	document.write("<param name='AutoStart' value='1'>");
	document.write("<param name='AutoSize' value='0'>");
	document.write("<param name='AutoResize' value='0'>");
	document.write("<param name='TransparentAtStart' value='1'>");
	document.write("<param name='AutoRewind' value='1'>");
	document.write("<param name='ShowDisplay' value='0'>");
	document.write("<param name='ClickToPlay' value='1'>");
	document.write("<param name='EnableContextMenu' value='0'>");
	document.write("<param name='ShowPositionControls' value='1'>");
	document.write("<param name='ShowStatusBar' value='0'>");
	document.write("<param name='ShowControls' value='1'>");
	document.write("<param name='EnableTracker' value='1'>");
	document.write("<param name='Volume' value='0'>");
	document.write("</object>");
}

function MoviePlayer3(movieurl, mwidth, mheight){
	document.write("<object classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715' width='"+mwidth+"' height='"+mheight+"' id='MediaPlayer1' type='application/x-oleobject' standby='Loading Microsoft Windows Media Player components...'>");
	document.write("<param name='URL' value='"+movieurl+"'>");
	document.write("<param name='AutoStart' value='0'>");
	document.write("<param name='TransparentAtStart' value='1'>");
	document.write("<param name='DisplaySize' value='4'>");
	document.write("<param name='PlayCount' value='1'>");
	document.write("<param name='ShowDisplay' value='0'>");
	document.write("</object>");
}

function ShowFlash(name,Width,Height) {
  document.writeln("<object name=flashgame id=FG classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + Width + "' height='" + Height + "'>");
  document.writeln("<param name='movie' value='"+name+"'>");
  document.writeln("<param name='quality' value='high' />");
  document.writeln("<embed src='"+name+".swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + Width + "'  height='" + Height + "'>");
  document.writeln("</object>");
}
function ErrorCash(Type)
{
	if(Type == "2")
	{
		if(confirm("부모님동의를 해주세요. 동의센터로 이동하시겠습니까?"))
		{
			location.href="/HelpDesk/ParentsAgree.asp";
		}
	}
	else if(Type == "3")
	{
		if(confirm("가동의 상태입니다. 회원정보 수정페이지로 이동하시겠습니까?"))
		{
			location.href="/HelpDesk/Indivicheck.asp";
		}
	}
	else
	{
		if(confirm("결제동의를 해주세요. 동의센터로 이동하시겠습니까?"))
		{
			location.href="/HelpDesk/PayAgree.asp";
		}
	}
}

function mail_check(str) {
	emailEx1 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z]+/;
	emailEx2 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;
	emailEx3 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;
	if(emailEx1.test(str)){ return true; };
	if(emailEx2.test(str)){ return true; };
	if(emailEx3.test(str)){ return true; };
	return false;
}

// 금지어 체크
// by ywkwon 2007.4.11
function fnCheckAbuse(str){
 var fucks;
 var fuck;
 fuck = abuseword;
 fucks = fuck.toLowerCase();
 fucks = fucks.split(",");
 str = str.toLowerCase();
 var strTempString = ' ' + str;

 for(var i=0; i <fucks.length; i++)
 {
  if(strTempString.indexOf(fucks[i]) > 0)
  {
   return false;
  }
 }
 return true;
}

//SELECT -> LAYER변환
function getSelectToLayer(obj,lwidth,href)
{
    if(navigator.userAgent.indexOf('Opera') != -1 || navigator.userAgent.indexOf('MSIE') == -1) { return false; }

    obj.style.display = 'none';
    var newsb = obj.id + "_sbj";
    var newid = obj.id + "_tmp";
    var newim = obj.id + "_img";
    var LayerTag = "";

    LayerTag += "<TABLE WIDTH='"+lwidth+"' CELLSPACING=0 CELLPADDING=0 STYLE='position:absolute;cursor:default;'>";
    LayerTag += "<TR HEIGHT=1><TD></TD></TR><TR><TD>";
    LayerTag += "<TABLE BGCOLOR='#FFFFFF' HEIGHT=15 WIDTH=100% CELLSPACING=1 CELLPADDING=0 STYLE='border:1 solid #C0C0C0;line-height:117%;' onmouseover=\"getSelectLayerOver(this,document.getElementById('"+newim+"'),document.getElementById('"+newid+"'));\" onmouseout=\"getSelectLayerOut(this,document.getElementById('"+newim+"'),document.getElementById('"+newid+"'));\">";

    LayerTag += "<TR WIDTH=100% onclick=\"getSelectSubLayer(document.getElementById('"+newid+"'),document.getElementById('"+newsb+"'));\">";
    LayerTag += "<TD ID='"+newsb+"' WIDTH=95% onblur='getSelectLayerBlur(this);'>&nbsp;" + obj.options[obj.selectedIndex].text + "</TD>";
    LayerTag += "<TD ALIGN=RIGHT><IMG ID='"+newim+"' SRC='http://www.blueb.co.kr/image/ico/dot_select.gif' ALIGN=absmiddle STYLE='filter:gray();'></TD></TR>";

    LayerTag += "</TABLE>";

    LayerTag += "<TABLE onblur='getSubLayerClose(this);' ID='"+newid+"' WIDTH=100% CELLSPACING=0 CELLPADDING=0 STYLE='display:none;border:1 solid #C0C0C0;' BGCOLOR='#FFFFFF'>";
    for (var i = 0 ; i < obj.length; i++)
    {
        LayerTag += "<TR onmouseover='getSelectMoveLayer(this);' onmouseout='getSelectMoveLayer1(this);' onclick=\"getSelectChangeLayer(document.getElementById('"+obj.id+"'),document.getElementById('"+newid+"'),document.getElementById('"+newsb+"'),'"+obj.options[i].text+"','"+obj.options[i].value+"','"+href+"');\" ";

        if (obj.value == obj.options[i].value)
        {
            LayerTag += "STYLE='background:#efefef;color:#FFFFFF;'><TD>&nbsp;";
        }
        else {
            LayerTag += "STYLE='background:#FFFFFF;color:#000000;'><TD>&nbsp;";
        }

        LayerTag += obj.options[i].text;
        LayerTag += "</TD></TR>";
    }
    LayerTag += "</TABLE>";
    LayerTag += "</TD></TR></TABLE><IMG SRC='' WIDTH='"+lwidth+"' HEIGHT=0>";

    document.write(LayerTag);
}

//서브레이어보이기
function getSelectSubLayer(obj,sobj)
{
    if(obj.style.display == 'none')
    {
        sobj.style.background = '#FFFFFF';
        sobj.style.color = '#000000';
        obj.style.display = 'block';
        NowSelectedLayer = obj;

        obj.focus();
    }
    else {
        sobj.style.background = '#efefef';
        sobj.style.color = '#FFFFFF';
        obj.style.display = 'none';
    }
}

//서브레이어체크
function getSelectSubLayer1(obj)
{
    if(obj.style.display != 'none')
    {
        obj.style.display = 'none';
    }
}

//타이틀레이어 MouseOver
function getSelectLayerOver(obj,img,nobj)
{
    if (nobj.style.display == 'none')
    {
        obj.style.border = '1 solid #efefef';
        img.style.filter = '';
    }
}

//타이틀레이어 MouseOut
function getSelectLayerOut(obj,img)
{
    obj.style.border = '1 solid #C0C0C0';
    img.style.filter = 'gray()';
}


//서브레이어 MouseOver
function getSelectMoveLayer(obj)
{
    if (obj.style.color == '#000000')
    {
        obj.style.background = '#efefef';
        obj.style.color = '#FFFFFF';
    }
}
//서브레이어 MouseOut
function getSelectMoveLayer1(obj)
{
    obj.style.background = '#FFFFFF';
    obj.style.color = '#000000';
}

//새레이어선택
function getSelectChangeLayer(obj,fobj,sobj,text,value,href)
{
    if (href)
    {
        eval("document.DataForm." + href).value = value;
        location.href = getThisUrl();
        return false;
    }
    else {
        fobj.style.display = 'none';
        sobj.innerHTML = '&nbsp;' + text;
        sobj.style.background = '#efefef';
        sobj.style.color = '#666666';
        sobj.focus();
        obj.value = value;
    }
}

//타이틀레이어 blur
function getSelectLayerBlur(obj)
{
    obj.style.background = '#FFFFFF';
    obj.style.color = '#666666';
}

//서브레이어 닫기
function getSubLayerClose(obj)
{
    if (obj.style.display != 'none')
    {
        setTimeout("document.getElementById('" + obj.id + "').style.display = 'none';" , 150);
    }
}

//플래시
	function flashTrace(url,id,w,h,bg,vars,win){
		var flashStr=
		"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
		"<param name='allowScriptAccess' value='always' />"+
		"<param name='movie' value='"+url+"' />"+
		"<param name='base' value='swf' />"+
		"<param name='FlashVars' value='"+vars+"' />"+
		"<param name='wmode' value='"+win+"' />"+
		"<param name='quality' value='high' />"+
		"<param name='bgcolor' value='"+bg+"' />"+
		"<embed src='"+url+"' base='swf' FlashVars='"+vars+"' wmode='"+win+"' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
		"</object>";
		document.write(flashStr);
	}

