function introIframeResize(h){	
	IframeResize('intro_iframe', h);
}

function menuIframeResize(h){
	IframeResize('menu_iframe', h);
}

function IframeResize(obj, h){
	document.getElementById(obj).height = h;
}

function allCheck(obj, target){
	var flag = ''
	if (obj.checked)
	{
		flag = true;
	}
	else
	{
		flag = false;
	}


	if (target)
	{
		
		if (isNaN(target.length))
		{
			if (!target.disabled)
			{
				target.checked = flag;
			}			
		}
		else
		{
			for (var i = 0; i < target.length;i++ )
			{
				if (!target[i].disabled)
				{
					target[i].checked = flag;
				}				
			}
		}
	}	
}

function getUniqueKey( pLength ){   
var arrStringTable    = new Array ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0');  
var intTableLen       = arrStringTable.length;  
var strMakedString  = "";  
var intLoop             = 0;   
for (intLoop = 0; intLoop < pLength  ; intLoop++)    
	strMakedString += arrStringTable[ Math.round( ( intTableLen-1 ) *Math.random() ) ];   	
	

	return strMakedString;
}

function nextFocus(obj, next_obj){
	if (parseInt($("#"+obj).val().length) == parseInt($("#"+obj).attr("maxlength")))
	{
	
		$("#"+next_obj).focus();
	}
	
}

function enters(func){
	if (event.keyCode == 13)
	{
		func();
	}
}

function isValidJumin(el1,el2) {

    var pattern = /^([0-9]{6})-?([0-9]{7})$/;
	var num = el1.value + el2.value;
    if (!pattern.test(num)) return false;
    num = RegExp.$1 + RegExp.$2;

	var sum = 0;
	var last = num.charCodeAt(12) - 0x30;
	var bases = "234567892345";
	for (i=0; i<12; i++) {
		if (isNaN(num.substring(i,i+1))) return false;
		sum += (num.charCodeAt(i) - 0x30) * (bases.charCodeAt(i) - 0x30);
	}
	var mod = sum % 11;
	return ((11 - mod) % 10 == last) ? true : false;
}

function mainGateFunction(startFunc, cbFunc){
	startFunc();

	$("#list_pwd_chk").unbind("keypress").keypress(function(){
		if (event.keyCode == 13)
		{
			mainPwdCheckGo(cbFunc);
		}
	});

	$("#list_pwd_chk_img").unbind("click").css("cursor", "pointer").click(function(){
		mainPwdCheckGo(cbFunc);
	});

	$("#list_pwd_hide_img").unbind("click").css("cursor", "pointer").click(function(){
		$('#list_pwd_div').slideUp('fast');
	});
}

function mainPwdCheckGo(func){	
	var h = new clsJsHelper();

	if (!h.checkValNLen('list_pwd_chk', 4, 16, "ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.", "Y"))	return;

	$.ajax({
		url: "/_module/bbs/type/A/pwd_chk.asp",
		type: 'get',
		data: {pwd_chk:$("#list_pwd_chk").val(), idx:$("#list_idx").val(), bbs_code:$("#list_bbs_code").val()},
		dataType: 'text',
		error: function(xhr){
			alert('¼­¹öÀÀ´ä ¿À·ùÀÔ´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
		},
		success: function(data){
			if (data == "pwd_chk_ok")
			{				
				func();
			}
			else
			{
				alert('ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ ÇÏÁö ¾Ê½À´Ï´Ù.');
				$("#list_pwd_chk").attr("value", "").focus();
			}

		}
	});
}

function mainViewGo(idx, secret, level, url, bbs_code, bbs_kind){	

	if (level == 99)
	{
		location.href= url + "?idx=" + idx + "&bbs_code=" + bbs_code;	
	}		
	else if (secret == "Y")
	{
		if (!document.getElementById("list_pwd_div"))
		{		
			
			/**/
			var t = '<table width="230" height="100" border="0" cellpadding="0" cellspacing="3" bgcolor="#D2D2D2">'+
						'<form name="pwdFrm" id="pwdFrm" method="get" onsubmit="return false;">'+
						'<input type="hidden" name="list_bbs_code" id="list_bbs_code" value="'+bbs_code+'">'+
						'<input type="hidden" name="list_idx" id="list_idx" value="">'+
						'	<tr>'+
						'		<td bgcolor="#FFFFFF">'+
						'			<table width="100%" border="0" cellpadding="0" cellspacing="0">'+
						'				<tr>'+
						'					<td align="center" colspan="2" height="24" valign="bottom"><img src="/_module/bbs/skin/default/txt_pw.gif"></td>'+
						'				</tr>'+
						'				<tr height="34">'+
						'					<td width="60" align="right" style="padding:0 8px 0 0;"><img src="/_module/bbs/skin/default/title_txt_pw.gif"></td>'+
						'					<td><input type="password" class="input_a" style="width:136px;" name="list_pwd_chk" id="list_pwd_chk"></td>'+
						'				</tr>'+
						'				<tr>'+
						'					<td>&nbsp;</td>'+
						'					<td valign="top"><img src="/_module/bbs/skin/default/but_confirm2.gif" id="list_pwd_chk_img" alt="È®ÀÎ"><img src="/_module/bbs/skin/default/but_close.gif" alt="´Ý±â" id="list_pwd_hide_img"></td>'+
						'				</tr>'+
						'			</table>'+
						'		</td>'+
						'	</tr>'+
						'</form>'+
						'</table>';		
			
			$(document.body).append($("<div></div>").attr({"name":"list_pwd_div", "id":"list_pwd_div"}).css({"position":"absolute", "z-index":"9999","width":"200px", "height":"100px", "display":"none", "background-color":"white"}).html(t));

		}

		$("#list_idx").attr("value", idx);
		$("#list_pwd_div").css("left", event.x + document.body.scrollLeft).css("top", event.y + document.body.scrollTop-50).slideDown('fast', function(){$("#list_pwd_chk").focus();});
	}
	else
	{
		$.get("/_module/bbs/type/" + bbs_kind + "/hit_update.asp", {bbs_code:bbs_code, submit_idx:idx}, function(data){});
		location.href= url + "?idx=" + idx + "&bbs_code=" + bbs_code;	
	}
}

//A ÅÂ±× Á¡¼± Á¦°Å
function blurDocumentATag(){
	var tag_a = document.getElementsByTagName("A");

	for (var i = 0;i < tag_a.length; i++)
	{
		tag_a[i].onfocus = function(){this.blur()};
	}
}

$(function(){
	blurDocumentATag();
});
