var targetURL = "/center/popup/card_layer.asp";
function $(element){return document.getElementById(element);}
function visible(element){return element.style.display != 'none';}
function toggle(element){return visible($(element))?hide($(element)):show($(element));}
function hide(element){return element.style.display='none';}
function show(element){return element.style.display = 'inline';}
function toggle_btn(obj,element){return visible($(element))?obj.src=obj.src.replace(/show/g,'hide'):obj.src=obj.src.replace(/hide/g,'show');}
function gotoCard() {window.open('/center/popup/card.asp','card','width=466,height=532,left='+((screen.width-817)/2)+',top='+((screen.height-750)/2)+',menubar=no,scrollbars=no');}
function view_card(id) {
	var viewLayer = $('i_card_layer');
	var mouse_x, mouse_y, posX, posY;
	var objWinBody;
	var ev=window.event || e ;
	var tgt=ev.srcElement;

	mouse_x = ev.pageX || ( ev.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
	mouse_y = ev.pageY || ( ev.clientY + (document.documentElement.scrollTop || document.body.scrollTop));

	posX = (mouse_x-150);
	posY = (mouse_y-150);

	if (visible(viewLayer))
	{
		viewLayer.innerHTML = '';
		hide(viewLayer);
	}
	else
	{
		viewLayer.style.left = posX;
		viewLayer.style.top = posY;
		$('i_card_layer_proc').src = targetURL + '?id='+id;
	}
	return;
}
function view_card_popup(id) {
	var viewLayer = $('i_card_layer');
	var mouse_x, mouse_y, posX, posY;
	var objWinBody;
	var ev=window.event || e ;
	var tgt=ev.srcElement;
	
	mouse_x = ev.pageX || ( ev.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
	mouse_y = ev.pageY || ( ev.clientY + (document.documentElement.scrollTop || document.body.scrollTop));

	posX = (mouse_x-150);
	posY = (mouse_y-150);

	if (visible(viewLayer))
	{
		viewLayer.innerHTML = '';
		hide(viewLayer);
	}
	else
	{
		viewLayer.style.left = posX;
		viewLayer.style.top = posY;
		$('i_card_layer_proc').src = targetURL + '?id='+id;
	}
	return;
}
function isEmpty( ddata ) {
   for ( var i = 0 ; i < ddata.length ; i++ ) {
	  if ( ddata.substring( i, i+1 ) != " " )
		 return false;
   }
   return true;
}
function isEmail(s)
{
	return s.search(/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g) >= 0;
}
function resultcheck(form, message) {
	alert(message);
	form.focus();
	return false;
}

function cfNumeric(sOrg) {
 var nm;
 sOrg = sOrg.replace(/,/g,""); 
 nm = parseFloat(sOrg).toString();
 return (isNaN(nm)?0:nm);
} 

function number_format(num) {
 num = num.replace(/,/g, "");
 var num_str = num.toString();
 var result = '';

	for(var i=0; i<num_str.length; i++) {
		var tmp = num_str.length-(i+1);
		if(i%3==0 && i!=0) result = ',' + result;
		result = num_str.charAt(tmp) + result;
	}

	return result;
}
function checkRegistBoardForm(form, type) {

	var cnt = 0;
	if (type == 0){
		if (isEmpty(form.title.value))
			return resultcheck(form.title, "Please enter the title.");
		if (isEmpty(form.contents.value))
			return resultcheck(form.contents, "Please enter the contents.");
	}else if (type == 2){
		if (isEmpty(form.title.value))
			return resultcheck(form.title, "Please enter the title.");
		if (isEmpty(form.contents.value))
			return resultcheck(form.contents, "Please enter the contents.");
		if (form.upfile.length > 0)
		{
			cnt = 0;
			for (var i=0;form.upfile.length-1;i++)
			{
				if (!(isEmpty(form.upfile[i].value))){
					if (!(form.upfile[i].value.match(/\.(gif|jpg|jpeg|png)$/i)))
						return resultcheck(form.upfile[i], "Please enter the Image.");				
				}else{cnt = cnt + 1;}

				if (form.upfile.length==cnt)
				{
					return resultcheck(form.upfile[i], "Please enter the Image.");				
				}
			}
		}else{
			if (isEmpty(form.upfile.value))
				return resultcheck(form.upfile, "Please enter the Files.");
			if (!(form.upfile.value.match(/\.(gif|jpg|jpeg|png)$/i)))
				return resultcheck(form.upfile, "Please enter the Image.");
		}
	}else if (type == 3){
		if (isEmpty(form.title.value))
			return resultcheck(form.title, "Please enter the title.");
		if (isEmpty(form.contents.value))
			return resultcheck(form.contents, "Please enter the contents.");

		if (form.upfile.length > 0)
		{
			for (var i=0;form.upfile.length-1;i++)
			{
				if (!(isEmpty(form.upfile[i].value))){
					if (!(form.upfile[i].value.match(/\.(gif|jpg|jpeg|png)$/i)))
						return resultcheck(form.upfile[i], "Please enter the Image.");				
				}
			}
		}else{
			if (!(isEmpty(form.upfile.value))){
				if (!(form.upfile.value.match(/\.(gif|jpg|jpeg|png)$/i)))
					return resultcheck(form.upfile, "Please enter the Image.");
			}
		}
	}else{
		if (isEmpty(form.contents.value))
			return resultcheck(form.contents, "Please enter the contents.");
	}return true;
}
String.prototype.trim = function(){return this.replace(/(^[ \f\n\r\t]*)|([ \f\n\r\t]*$)/g, "");}
function checkSearchBoardForm(form) {
	if (isEmpty(form.search_text.value.trim()))
		return resultcheck(form.search_text, "Input search.");
	else if(form.search_text.value.trim().length <= 1)
		return resultcheck(form.search_text, "Above of minimum 2 letters input.");
	else
		return true;
}
function checkRegistCommentForm() {
	var form = document.registCommentForm;
	if (isEmpty(form.contents.value)) {	
		return resultcheck(form.contents, "Input the contents.");
	} else if (form.contents.value.length > 200) {
		return resultcheck(form.contents, "Until the maximum 200 letter registration is possible");
	} else {
		return true;
	}
}
function deletecomment(idx, chk) {
	var form = document.deletecommentform;
	var confirm_msg = "Do you delete the reply?";
	if (chk == "1")
		confirm_msg = "If you delete the above reply, it will be deleted all the following replies below. Do you delete the reply?"
	if (confirm(confirm_msg)) {
		form.comment_seq.value = idx;
		form.submit();
	} else {
		return;	
	}
}

function canceltheplelayer() {
	var form = document.registthepleform;
	var thepleLayer = $('thepleLayer');
	hide(thepleLayer);
	form.reset();
	$('textlimit').innerHTML = "0";
	return;
}

function checkregistthepleform() {
	var form = document.registthepleform;
	if (isEmpty(form.contents.value)) {
		return resultcheck(form.contents, "Input the contents.");
	} else if (form.contents.value.length > 200) {
		return resultcheck(form.contents, "Until the maximum 200 letter registration is possible");
	} else {
		return true;
	}
}

function textcounter() {
	var form = document.registthepleform;
	var maxlimit = 200;
	if (form.contents.value.length > maxlimit) {			
		form.contents.value = form.contents.value.substring(0, maxlimit);
		alert("Reply Avaiable within 200 letters.");
	} else {
		$('textlimit').innerHTML = form.contents.value.length;
	}
	return;
}


function registtheple(idx) {
	var form = document.registthepleform;
	var thepleLayer = $('thepleLayer');
	var mouse_x, mouse_y, posX, posY;
	var ev=window.event || e ;
	mouse_x = ev.pageX || ( ev.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
	mouse_y = ev.pageY || ( ev.clientY + (document.documentElement.scrollTop || document.body.scrollTop));

	posX = (mouse_x-150);
	posY = (mouse_y-700);

	thepleLayer.style.left = posX;
	thepleLayer.style.top = posY;
	show(thepleLayer);

	form.comment_seq.value = idx;
	return;
}

function down_bittorrent()
{
	window.open("/center/pds/download_bittorrent.asp", "down_bittorrent", "width=669, height=487, status=yes");
}
function item_info(){
	alert('Now in Preparation.');
	return;
}
function npc_info(){
	alert('Now in Preparation.');
	return;
}
function choboguide(){
	window.open('/center/guide/guidefla.asp','guide_pop','width=800,height=600,top=100,left=300,scrollbars=no');
}
function inviteFriend(){
	window.open('/center/popup/cbt_friend/invite.asp','inviteFriendpop','width=450,height=602,top=50,left=150,scrollbars=no'); 
}
function inviteFriend1(uid) {
	window.open('/center/popup/cbt_friend/invite.asp?friend_id='+uid,'inviteFriendpop','width=450,height=602,top=50,left=150,scrollbars=no'); 
/*	if(confirm("Would you like to invite " + nic + "?"))
		{
			document.friendFrm.target="i_friendFrm_proc"
			document.friendFrm.action = "/center/news/friend_inviteok.asp";
			document.friendFrm.submit();
		}*/
}
function applyfriend(){
window.open('/center/popup/cbt_friend/apply.asp','applyfriendpop','width=450,height=340,top=0,left=150');
}

//셀렉트박스 꾸미기 v1.2 
//================================================ JS 
var zindex = 10000; 
select_count = new Array(); 
ev_click     = new Array(); 

function insert_select (sn,w,f,b,g,fc,c,img,event) { 
ev_click[sn]    = event; 
select_count[sn] = 0; 
zindex--; 
document.write("<input type=hidden name="+sn+" id="+sn+" value=''>"); 
document.write("    <table border='0' cellspacing='1' cellpadding='1' width='"+w+"' style='table-layout:fixed;width:"+w+";' ' bgcolor='"+b+"' onclick='select_click(\""+sn+"\");' >"); 
document.write("    <tr>"); 
document.write("        <td bgcolor='"+g+"' align='absmiddle'>"); 
document.write("            <input type='text' id='"+sn+"_select_name' name='"+sn+"_select_name' style='border:none;background-color: "+g+";cursor:hand;width:100%;height:11px;color:"+fc+";font-size:"+f+"pt' onselectstart=\"return false\" readonly> "); 
document.write("        </td>"); 
if(img != "") { 
document.write("    <td width=18 bgcolor='"+g+"' align=center valign=middle style='cursor:hand'><img src='"+img+"' align='absmiddle'></td>");         
} else { 
document.write("    <td width=18 bgcolor='"+g+"' align=center valign=middle style='cursor:hand'>v</td>"); 
} 
document.write("    </tr>"); 
document.write("    </table>"); 

document.write("<div id='"+sn+"_select_div' name='"+sn+"_select_div'  style='display:none;z-index:"+zindex+";position:absolute;cursor:hand' onmouseover='"+sn+"_select_div.style.display=\"\";' onmouseout='"+sn+"_select_div.style.display=\"none\";'>"); 
document.write("        <table border='0' cellspacing='1' cellpadding='1' bgcolor='"+b+"' width="+w+" onmouseover='"+sn+"_select_div.style.display=\"\";'>"); 
document.write("        <tr><td bgcolor='"+g+"' style='line-height:1.3em;' id='"+sn+"_select_span'></td></tr>"); 
document.write("        </table>"); 
document.write("    </div>"); 
} 

function insert_select_option(sn,f,b,g,fc,c,v,vv,chk)     {     
select_count[sn] ++;     
option_html = "<span style='width:100%;color:"+fc+";font-size:"+f+"pt' onclick='"+sn+"_select_name.value=\""+vv+"\";"+sn+".value=\""+v+"\";"+sn+"_select_div.style.display=\"none\";"+ev_click[sn]+";' onmouseover='this.style.background=\""+c+"\"' onmouseout='this.style.background=\""+g+"\"'>"+vv+"</span><br>"; 

if(select_count[sn] == 1 || chk == "Y" ) { 
document.getElementById( sn+"_select_name" ).value = vv 
document.getElementById( sn).value = v 
} 
document.getElementById( sn+"_select_span").innerHTML += option_html; 
} 

function  select_click(sn)     {     
if ( document.getElementById( sn+"_select_div").style.display == "none") { 
document.getElementById( sn+"_select_div").style.display = ""; 
} else { 
document.getElementById( sn+"_select_div").style.display = "none"; 
} 
}
//셀렉트박스 꾸미기 끝 v1.2 
//================================================ JS 