//******************************************************************************************************
// Eexplanation : DIV OPEN & CLOSE
// Input Value  : DIV's ID
// by Kim BK
// Date: 2006-05-11
//******************************************************************************************************

function open_div(showID){
	if(showID.style.display == 'none') {		
		showID.style.display = 'block'; 
	}else {
		showID.style.display = 'none';
	}
}
var prevID="";
function only_open(showID,showID2,showID3,showID4,showID5){
	if(showID.style.display == 'none') 
		showID.style.display = 'block'; 
	else
		showID.style.display = 'none';	
		
	if(showID2.style.display == 'none')
		showID2.style.display = 'block'; 
	else
		showID2.style.display = 'none';	
		
	if(showID3.style.display == 'block')
		showID3.style.display = 'none';
	if(showID4.style.display == 'block')
		showID4.style.display = 'none';
	
	if(showID5.style.display == 'block')
		showID5.style.display = 'none';
		
		
}
//******************************************************************************************************
// Eexplanation : a number of DIV OPEN & CLOSE
// Input Value  : DIV's ID
// by Kim BK
// Date: 2006-05-11
//******************************************************************************************************


function open_div_1(showID,form){
	if(form!=null)	form.reset();
		if(prevID != ""){
			prevID.style.display='none';
			showID.style.display='block';
		}else{
			showID.style.display='block';
		}
		prevID = showID;
}

//******************************************************************************************************
// Eexplanation : An Form's input value checking
// Input Value  : Chekced Form's Name and Input's Name
// Return Value : insertted dada
// Sample : returned data is... value1,value2,value3,value4
// by Kim BK
// Date: 2006-05-11
//******************************************************************************************************

function item_check(form,category){
	
	var data = '';	
	var length = eval(form+"."+category+".length");
	for(i=0;i<length;i++){
 		if(eval(form+"."+category+"["+i+"].checked")){
					data += eval(form+"."+category+"["+i+"].value")+',';
		}
	}
	return data;
}






//******************************************************************************************************
// Eexplanation : ???????? ???? ??????
//******************************************************************************************************

function findZipcode(form, str) {
	formName = form.name;
	newURL = "/member/zipcodeSearch.php?sort=" + str + "&formName=" + formName;
	searchWindow=window.open(newURL, 'zipcodeSearch', 'width=468,height=245,left=200,top=100, toolbar=no,scrollbars=yes,resizable=no');
}


//******************************************************************************************************
// Eexplanation : ???????? ???????? ???? ????????.
// Input Value  : msg(?????? ??????)
//******************************************************************************************************

function message(msg) {
	alert(msg);
}


//******************************************************************************************************
// Eexplanation : ?????????? ?????? ???? ???????? ??????.
// Input Value  : msg(?????? ??????)
//******************************************************************************************************

function errmsg(msg) {
	if(msg == "") {
		msg = "???????? ???? ????????!!";
	}
	alert(msg);
	history.go(-1);
}


//******************************************************************************************************
// Eexplanation : ?????????? ?????? ???? ???????? ??????.
// Input Value  :$msg(?????? ??????)
//******************************************************************************************************

function msgClose(msg) {
	alert(msg);
	window.close();
}


//******************************************************************************************************
// Eexplanation : ?????????? ?????? ???? ???????? ??????.
// Input Value  : msg(?????? ??????), url(?????? ????)
//******************************************************************************************************

function msgMove(msg, url) {
	alert(msg);
	location.href = url;
}


//******************************************************************************************************
// Eexplanation : ?????????? ?????? ???? ???????? ??????.
// Input Value  : url(?????? ????)
//******************************************************************************************************

function openerCM(url) {
	window.close();
	opener.location.href = url;
}


//******************************************************************************************************
// Eexplanation : ?????????? ?????? ???? ???????? ??????.
// Input Value  : url(?????? ????)
// Sample		: openWindow('??????','????','scrollbars=yes,width=900,height=660,left=0,top=0')
//******************************************************************************************************

function openWindow(url,target,option) {
	window.open(url,target,option);
}


//******************************************************************************************************
// Eexplanation : ?????????? ?????? ??????.
// Input Value  : url(?????? ????)
// Sample		: openWindow("??????", "????", "dialogWidth:400px; dialogHeight:250px;status:no; help:no; scroll:no")
//******************************************************************************************************

function infoWindow(URL){
	window.showModalDialog(URL, "", "dialogWidth:400px; dialogHeight:250px;status:no; help:no; scroll:no"); 
}


//******************************************************************************************************
// Eexplanation : ???? ??????
//******************************************************************************************************

function closeWindow() {
	window.close();
}


//******************************************************************************************************
// Eexplanation : ?????? ?????? ???????? ????????.
// Input Value  : form(??????), fn(??????), url(????????)
// Sample		: <select name=field_name onchange="Quick_Link(this.form, 'field_name', '/sample/sample.php?sample_id=');">
//******************************************************************************************************

function Jump_Category(form, fn, url) {
	var select = form.fn.selectedIndex;

	if(form.fn.options[select].value != "") {
		location=url + form.fn.options[select].value;
	}
}


//******************************************************************************************************
// Eexplanation : ???? ???? ??????.
// Input Value  : msg, url, val
//******************************************************************************************************

function msgConfirm(msg, url, val) {
	var val;
	ans = confirm(msg)
	if ( ans== true){
		str = url + val
		location.href = str;
	} 
}



//******************************************************************************************************
// Eexplanation : ?????? ?????? ???????? ????????
// Input Value  : form(this.form), fieldName
//******************************************************************************************************

function selectFocus(form, fieldName) {
	form.recom_id.focus();
	return;
}


//******************************************************************************************************
//******************************************************************************************************
//******************************************************************************************************
//****************************   ???????????? ???????? ???? ???? ???? ???????? ???? **************************
//******************************************************************************************************
//******************************************************************************************************
//******************************************************************************************************
//******************************************************************************************************
// Eexplanation : E-mail Checking
//******************************************************************************************************

function isEmail(str) { 

var supported = 0; 

if (window.RegExp) { 
	var tempStr = "a"; 
	var tempReg = new RegExp(tempStr); 
	
	if (tempReg.test(tempStr)) supported = 1; 
} 

if (!supported)  
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); 

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"); 
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); 

	return (!r1.test(str) && r2.test(str)); 
}



//******************************************************************************************************
// Eexplanation : ?????? ???? ?????? ???????? ??????.
// Input Value  : class_id, item_id, type(insert, modify)
//******************************************************************************************************

function docClassOpen(class_id, item_id, type) {
	if(item_id == 0) {
		mode = "insert";
	} else {
		mode = "modify";
	}
	url = "write.php?class_id=" + class_id + "&item_id=" + item_id + "&type=" + type + "&mode=" + mode;
	window.open(url, 'write', 'scrollbars=no,width=400,height=650,left=600,top=0');
}


//******************************************************************************************************
// Eexplanation : ???????? ???????? ????????.
// Input Value  : str(form.name.value??)
//******************************************************************************************************

function isEmpty(str) {

	for ( var i = 0 ; i < str.length ; i++ ) {
		if ( str.substring(i, i+1) != " " ) {
			return false;
		}
	}

	return true;

}


//******************************************************************************************************
// Eexplanation : ???????? ????, ?????? ???? ?????????? ????????.
// Input Value  : str(form.name.value??), minlen, maxlen
//******************************************************************************************************

function checkLength(str, minlen, maxlen) {

	if (str.length < minlen || str.length > maxlen) {
		return false;
	}		
		
	return true;

}


//******************************************************************************************************
// Eexplanation : ???????? ????????.
// Input Value  : str(form.name.value??)
//******************************************************************************************************

function isHangul(str) {

	var re = /[a-zA-Z0-9\s~!@#\$%\^&\*\(\)_\+\{\}|:"<>\?`\-=\[\]\\;',\.\/]/; // matches a alphanumeric character or space

	if (re.test(str)) {
		return false;
	}

	return true;

}


//******************************************************************************************************
// Eexplanation : ???????? ????????.
// Input Value  : str(form.name.value??)
//******************************************************************************************************

function isNumber(str, allowable) {

	valid = true;
	cmp = "0123456789" + allowable;

	for (i=0; i<str.length; i++) {
		if (cmp.indexOf(str.charAt(i)) < 0) {
			valid = false;
			break;
		}
	}

	return valid;

}


//******************************************************************************************************
// Eexplanation : ???????? ????????.
// Input Value  : str(form.name.value??)
//******************************************************************************************************

function checkName(str) {

	if (!checkLength(str, 2, 80, false) || !isHangul(str)) {
		return false;
	}

	return true;

}



//******************************************************************************************************
// Eexplanation : ?????????????? ????????.
// Input Value  : str(form.name.value??)
//******************************************************************************************************

function checkEmail(str) {

	valid = false;

	if (str == "")
		valid = false;
		//alert("EmailÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À!!");
	else if (str.indexOf(" ") != -1)
		valid = false;
		//alert("EmailÁÖ¼Ò¿¡ °ø¹éÀº Çã¿?µÇÁ? ¾Ê½À´Ï´Ù!!");
	else if (str.indexOf("@") < 1)
		valid = false;
		//alert("EmailÁÖ¼Ò ÁöÁ¤ÀÌ Àß¸øµÇ¾ú½À´Ï´Ù. '@'ÀÌ ´©¶ôµÇ¾ú½À´Ï´Ù!!");
	else if (str.indexOf(".") == -1)
		valid = false;
		//alert("EmailÁÖ¼Ò ÁöÁ¤ÀÌ Àß¸øµÇ¾ú½À´Ï´Ù. '.'ÀÌ ´©¶ôµÇ¾ú½À´Ï´Ù!!");
	else if (str.indexOf(".") - str.indexOf("@") == 1)
		valid = false;
		//alert("EmailÁÖ¼Ò ÁöÁ¤ÀÌ Àß¸øµÇ¾ú½À´Ï´Ù. '@' ´ÙÀ½¿¡ ¹Ù·Î '.'ÀÌ ¿Ã ¼? ¾ø½À´Ï´Ù!!");
	else if (str.charAt(str.length-1) == '.')
		valid = false;
		//alert("EmailÁÖ¼Ò ÁöÁ¤ÀÌ Àß¸øµÇ¾ú½À´Ï´Ù. '.'Àº EmailÁÖ¼Ò ³¡¿¡ ¿Ã ¼? ¾ø½À´Ï´Ù!!");
	else
		valid = true;

	return valid;

}


//******************************************************************************************************
// Eexplanation : ???????????? ?????? ????????.
//******************************************************************************************************
/*
function pollCheck(form){

	var pollChecked = '';

	if(form.pollUsed.value == "Y") {

		alert("???? ?????? ??????????!!");
		return false;

	} else {

		for(var i =0 ; i < form.poll.length; i ++){
			if(form.poll[i].checked == true){
				pollChecked = 'OK';
			}
		}
		
		if(pollChecked != 'OK') {
			alert ('???? ?????? ???????????? ??????????.');
			return false;
		}

	}

}
*/

//******************************************************************************************************
// Eexplanation : ?? ?????? 3???????? ???? ????
//******************************************************************************************************

function commaSplit(str) { 
	
	if(str.value.charAt(0) == 0 && str.value != "0") {
		str.value = "";
	}

	txtNumber = str.value;
	txtNumber = txtNumber.replace(/,/gi, "");

	if(txtNumber >= 1000000000000) {
		alert("?????? ?????? 1???????? ???????? ??????????!!");
	}

	if (isNaN(txtNumber)) { 
		alert("?????? ???? ??????"); 
		str.value = '';
		str.focus();
	} else { 

		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])'); 
		var arrNumber = txtNumber.split('.'); 

		arrNumber[0] += '.'; 
		do { 
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2'); 
		} while (rxSplit.test(arrNumber[0]));
		
		if (arrNumber.length > 1) { 
			str.value = arrNumber.join(''); 
		} else { 
			str.value = arrNumber[0].split('.')[0]; 
		} 

	} 

} 


//******************************************************************************************************
// Eexplanation : id???? ???????? ????????.
//******************************************************************************************************
function showmenu(str) {
	str.style.display = "";
}

function hidemenu(str) {
	str.style.display = "none";
}
function openFormWindow()
{
	var width = 640;
	var height = 480;
	var left = window.screen.width / 2 - width / 2;
	var top = window.screen.height / 2 - height / 2;
	var resize = "no"; //yes
	var scrollbars = "yes"; //no
	var filename = "http://www.helms.co.jp/form/gnet.html";
	var windowname = "_new";
	var style = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",scrollbars=" + scrollbars + ",resizable=" + resize;
	window.open(filename, windowname, style);
}
//******************************************************************************************************
// Eexplanation : RollOver ????
//******************************************************************************************************
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

