function approve_item(av_form)
{
	var i, av_element;

	for(i = 0; i < av_form.elements.length; i++)
	{
		av_element = av_form.elements[i];

		if(av_element.required != null)
		{
			if(av_element.type == "text" || av_element.type == "TEXT" ||
				av_element.type == "password" || av_element.type == "PASSWORD" ||
				av_element.type == "file" || av_element.type == "FILE" ||
				av_element.tagName == "select" || av_element.tagName == "SELECT" || 
				av_element.tagName == "textarea" || av_element.tagName == "TEXTAREA")
			{
				if(!avcheck_text(av_element)) 
					return false;
			}
			else if(av_element.type == "checkbox" || av_element.type == "CHECKBOX")
			{
				if(!avcheck_checkbox(av_element)) 
					return false;
			}
			else if(av_element.type == "radio" || av_element.type == "RADIO")
			{
				if(!avcheck_radio(av_element)) 
					return false;
			}
		}

		if(av_element.pattern != null && av_element.value.length > 0)
		{
			if(!avcheck_pattern(av_element))
				return false;
		}

		var av_len = 0;

		if(av_element.maxbytes != null && av_element.value.length > 0)
		{
			for(var j = 0; j < av_element.value.length; j++)
				av_len += (av_element.value.charAt(j).charCodeAt() > 128) ? 2 : 1;
			
			if(av_len > av_element.maxbytes)
			{
				alert("[" + av_element.iname + "] Ç×¸ñÀÇ ±æÀÌ°¡ ³Ê¹« ±é´Ï´Ù.");
				av_element.focus();
				return false;
			}
		}
		
		if(av_element.minbytes != null && av_element.value.length > 0)
		{
			if(av_len < av_element.minbytes)
			{
				alert("[" + av_element.iname + "] Ç×¸ñÀÇ ±æÀÌ°¡ ³Ê¹« Âª½À´Ï´Ù.");
				av_element.focus();
				return false;
			}
		}			
	}

	return true;
}

function approve_oneitem(av_element)
{
	var i;

	if(av_element.required != null)
	{
		if(av_element.type == "text" || av_element.type == "TEXT" ||
			av_element.type == "password" || av_element.type == "PASSWORD" ||
			av_element.type == "file" || av_element.type == "FILE" ||
			av_element.tagName == "select" || av_element.tagName == "SELECT" || 
			av_element.tagName == "textarea" || av_element.tagName == "TEXTAREA")
		{
			if(!avcheck_text(av_element)) 
				return false;
		}
		else if(av_element.type == "checkbox" || av_element.type == "CHECKBOX")
		{
			if(!avcheck_checkbox(av_element)) 
				return false;
		}
		else if(av_element.type == "radio" || av_element.type == "RADIO")
		{
			if(!avcheck_radio(av_element)) 
				return false;
		}
	}

	if(av_element.pattern != null && av_element.value.length > 0)
	{
		if(!avcheck_pattern(av_element))
			return false;
	}

	var av_len = 0;

	if(av_element.maxbytes != null && av_element.value.length > 0)
	{
		for(var j = 0; j < av_element.value.length; j++)
			av_len += (av_element.value.charAt(j).charCodeAt() > 128) ? 2 : 1;
		
		if(av_len > av_element.maxbytes)
		{
			alert("[" + av_element.iname + "] Ç×¸ñÀÇ ±æÀÌ°¡ ³Ê¹« ±é´Ï´Ù.");
			av_element.focus();
			return false;
		}
	}
	
	if(av_element.minbytes != null && av_element.value.length > 0)
	{
		if(av_len < av_element.minbytes)
		{
			alert("[" + av_element.iname + "] Ç×¸ñÀÇ ±æÀÌ°¡ ³Ê¹« Âª½À´Ï´Ù.");
			av_element.focus();
			return false;
		}
	}			

	return true;
}

function avcheck_text(av_element)
{
	if(String(av_element.value).length < 1)
	{
		alert("[" + av_element.iname + "] Ç×¸ñÀ» ÀÔ·ÂÇØÁÖ½Ê½Ã¿ä.");
		av_element.focus();
		return false;
	}

	return true;

}

function avcheck_checkbox(av_element)
{
	if(!av_element.checked)
	{
		alert("[" + av_element.iname + "] Ç×¸ñÀ» ¼±ÅÃÇØÁÖ½Ê½Ã¿ä.");
		return false;
	}

	return true;
}

function avcheck_radio(av_element)
{
	for(var i = 0; i < av_element.length; i++)
	{
		if(av_element[i].checked)
			return true;
	}

	alert("[" + av_element.iname + "] Ç×¸ñÀ» ¼±ÅÃÇØÁÖ½Ê½Ã¿ä.");
	return false;
}

function avcheck_pattern(av_element)
{
	var av_pattern;

	switch(av_element.pattern)
	{
		case "number":
			av_pattern = /^[0-9]+$/;
			break;
		case "phone":
			av_pattern = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;
			break;
		case "email":
			av_pattern = /^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/;
			break;
		case "domain":
			av_pattern = /^[.a-zA-Z0-9-]+.[a-zA-Z]+$/;
			break;
		case "alpha":
			av_pattern = /^[a-zA-Z]+$/;
			break;
		case "alphanum":
			av_pattern = /^[a-zA-Z0-9]+$/;
			break;
		case "host":
			av_pattern = /^[a-zA-Z-]+$/;
			break;
		case "notkor":
			av_pattern = /[°¡-ÆR]/;
			break;
		case "koreng":
			av_pattern = /^[°¡-ÆRa-zA-Z]*$/;
			break;
		case "koronly":
			av_pattern = /^[°¡-ÆR]*$/;
			break;
		case "alphanum_-":
			av_pattern = /^[_0-9a-zA-Z-]+$/;
			break;
		case "korengnum":
			av_pattern = /^[°¡-ÆR0-9a-zA-Z]+$/;
			break;
		case "korengnum_-":
			av_pattern = /^[_°¡-ÆR0-9a-zA-Z-]+$/;
			break;
	}

	if(!av_pattern.test(av_element.value))
	{
		alert("[" + av_element.iname + "] Ç×¸ñÀÇ Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
		av_element.focus();
		return false;
	}

	return true;
}

function avcheck_residentnum(av_resnum) 
{
	var idtot = 0;
	var idadd = "234567892345";

	for(var i = 0; i < 12; i++)
		idtot = idtot + parseInt(av_resnum.substring(i, i+1)) * parseInt(idadd.substring(i, i+1));
	
	idtot = 11 - (idtot % 11);

	if(idtot == 10)
		idtot = 0;		
	else if(idtot == 11)
		idtot = 1;

	if(parseInt(av_resnum.substring(12,13)) != idtot)
	{
		alert("ÁÖ¹Îµî·Ï¹øÈ£°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù.");
		return false;
	}

	return true;
}

function zoomimage(art_img) 
{
	var win = window.open("/includes/zoomimage.asp?art_img=" + art_img, "zoomimage", "resizable=no,scrollbars=no,status=no,width=10,height=10,left=0,top=0");
	win.focus();
}

function search_school()
{
	window.open('/includes/schoolsearch.asp', 'schoolnm', 'scrollbars=yes,copyhistory=no,top=300,left=400,width=366,height=250');
}

function search_lecturer()
{
	window.open('/includes/lecturersearch.asp', 'lecturer', 'scrollbars=yes,copyhistory=no,top=300,left=400,width=366,height=250');
}

function check_userid()
{
	if(!approve_oneitem(document.frm.userid))
		return;

	window.open('/includes/useridcheck.asp?userid=' + document.frm.userid.value, 'userid', 'scrollbars=no,copyhistory=no,resizable=no,top=200,left=300,width=350,height=150');
}

function check_recomendid()
{
	window.open('/includes/useridcheck_t.asp', 'recomendid', 'scrollbars=no,copyhistory=no,resizable=no,top=200,left=300,width=350,height=150');
}

//function check_usernic(userid)
//{
//	if(!approve_oneitem(document.frm.usernic))
//		return;
//
//	window.open('/includes/userniccheck.asp?userid=' + userid + '&usernic=' + document.frm.usernic.value, 'usernic', 'scrollbars=no,copyhistory=no,resizable=no,top=200,left=300,width=350,height=150');
//}

function search_zipcode()
{
	window.open('/includes/zipsearch.asp', 'zipcode', 'scrollbars=yes,copyhistory=no,top=300,left=400,width=366,height=250');
}

function show_lyric(artno)
{
	window.open('/includes/lyric.asp?artno=' + artno, 'lyric', 'scrollbars=yes,copyhistory=no,resizable=no,top=300,left=400,width=420,height=500');
}

function show_card(artno)
{
	window.open('/includes/card.asp?artno=' + artno, 'card', 'scrollbars=no,copyhistory=no,resizable=no,top=300,left=400,width=536,height=484');
}

function show_losesearch()
{
	window.open('/includes/losesearch_fm.asp', 'losesearch', 'scrollbars=no,copyhistory=no,top=300,left=400,width=350,height=150');
}

function show_memberout()
{
	window.open('/includes/memberout_fm.asp', 'memberout', 'scrollbars=no,copyhistory=no,top=300,left=400,width=350,height=300');
}


function login_alert()
{
	alert('·Î±×ÀÎÀ» ¸ÕÀú ÇØÁÖ½Ê½Ã¿ä.');
	document.frm_login.userid.focus();
}

function noauth_alert()
{
	alert('±ÇÇÑÀÌ ¾ø½À´Ï´Ù.');
}

function showhp_op_mod(BBSID, ARTNO, OPNO, ILIST_PAGE, SLIST_SEARCHITEM, SLIST_SEARCHVALUE, ITEM_FLAG)
{	
	window.open('/includes/openhp_op_mod.asp?bbsid=' + BBSID + '&artno=' + ARTNO + '&opno=' + OPNO + '&ilist_page=' + ILIST_PAGE + '&slist_searchitem=' + SLIST_SEARCHITEM
		+ '&slist_searchvalue=' + escape(SLIST_SEARCHVALUE) + '&item_flag=' + ITEM_FLAG, 'op_mod', 'scrollbars=no,copyhistory=no,top=400,left=300,width=570,height=120');	
}

function spd_viplayer(TIM, FIM, SIM)
{
	var windowW = 400;
	var windowH = 457;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 3);
	var windowY = Math.ceil( (window.screen.height - windowH) / 3);

	window.open("/viplayer/viplayer.asp?tim=" + TIM + "&fim=" + FIM + "&sim=" + SIM, "VIPlayer", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=" + windowY + ",left=" + windowX + ",width=" + windowW + ",height=" + windowH);
}
function change_view(){
if (document.all["smalltype"].length > 0) {
	if (btn.value == "ÀÛÀº»çÁøº¸±â") {
		for(i=0;i<document.all["smalltype"].length;i++){
			document.all["smalltype"][i].style.visibility="visible";
			document.all["smalltype"][i].style.display="block";
			document.all["bigtype"][i].style.visibility="hidden";
			document.all["bigtype"][i].style.display="none";
		}
		btn.value = "Å«»çÁøº¸±â";
	}
	else {
		for(i=0;i<document.all["smalltype"].length;i++){
			document.all["smalltype"][i].style.visibility="hidden";
			document.all["smalltype"][i].style.display="none";
			document.all["bigtype"][i].style.visibility="visible";
			document.all["bigtype"][i].style.display="block";
		}
		btn.value = "ÀÛÀº»çÁøº¸±â";
	}
}
else {
	if (btn.value == "ÀÛÀº»çÁøº¸±â") {
		smalltype.style.visibility="visible";
		smalltype.style.display="block";
		bigtype.style.visibility="hidden";
		bigtype.style.display="none";
		btn.value = "Å«»çÁøº¸±â";
	}
	else {
		smalltype.style.visibility="hidden";
		smalltype.style.display="none";
		bigtype.style.visibility="visible";
		bigtype.style.display="block";
		btn.value = "ÀÛÀº»çÁøº¸±â";
	}
}
}

function adjustImage(target_img)
{
    var newWidth;
	var newHeight;
    var newImg;
    var maxWidth = 550;
	var maxHeight = 450;
	var temp_h;
	var temp_w;
	var Wpercent;
	var Hpercent;


    newImg = new Image();
    newImg.src = target_img.src;
    imgw = newImg.width;
	imgh = newImg.height;
	

	if(imgw > maxWidth && imgh > maxHeight)
	{	
		
		target_img.onload = null;

		temp_w = imgw - maxWidth

		Wpercent =  temp_w / imgw

		temp_h = imgh - maxHeight

		Hpercent =  temp_h / imgh

		if(Wpercent >= Hpercent)
		{
			temp_h = newImg.height * Wpercent

			target_img.src = newImg.src;
			target_img.width = maxWidth;
			target_img.height = newImg.height - temp_h;
		}
		else
		{
			
			temp_w = newImg.width * Hpercent

			target_img.src = newImg.src;
			target_img.height = maxHeight;
			target_img.width = newImg.width - temp_w;
		}

	}
    else if (imgw > maxWidth && imgh < maxHeight) 
	{    
		target_img.onload = null;

		temp_w = imgw - maxWidth

		Wpercent =  temp_w / imgw

		temp_h = newImg.height * Wpercent

		

		target_img.src = newImg.src;
		target_img.width = maxWidth;
		target_img.height = newImg.height - temp_h;
	}
	else if(imgh > maxHeight && imgw < maxWidth)
	{
		target_img.onload = null;

		temp_h = imgh - maxHeight

		Hpercent =  temp_h / imgh

		temp_w = newImg.width * Hpercent

		

		target_img.src = newImg.src;
		target_img.height = maxHeight;
		target_img.width = newImg.width - temp_w;

	}		
}