
// ÃÖ»óÀ§ Ã¼Å© ·ÎÁ÷(chars·Î ³Ñ±ä °ªÀÌ ÀÖ´Ù¸é true)

    function containsCharsOnly(input,chars) {
        for (var inx = 0; inx < input.length; inx++) {

            if (chars.indexOf(input.charAt(inx)) == -1)

                return false;

        }

        return true;

    }

// ¶óµð¿À¹öÆ°,Ã¼Å©¹Ú½º Àû¾îµµ ÇÑ°³ ÀÌ»ó ¼±ÅÃÇß´ÂÁö °Ë»ç(Ã¼Å©¹Ú½ºÀÏ¶§´Â elemÀ» ³Ñ±æ¶§ []¹è¿­·Î ³Ñ±â°í ¹è¿­·Î ¹Þ°í Ã¼Å©¹Ú½º´Â ¾Æ´Ï´ç)
function isCheckAtLeastOne (elem)
{
	if (elem != null)	// Ç×¸ñÀÌ ÇÏ³ªÀÌ»ó Á¸Àç ÇÒ¶§
	{
		if (elem.length == null)	// Ç×¸ñÀÌ ÇÏ³ª¸¸ ÀÖÀ»¶§
		{
			if (elem.checked == true)
				return true;
		}
		else	// Ç×¸ñÀÌ µÎ°³ ÀÌ»óÀÏ ¶§
		{
			for(index = 0; index < elem.length; index++)
				if(elem[index].checked == true)
					return true;
		}
	}

	return false;
}

//È¸¿ø°¡ÀÔ¹× Á¶Á÷±¸¼º¿ø¿¡ °üÇÑ ÀÚ¹Ù½ºÅ©¸³Æ®


function chk_member() {
	
	var theform=document.join_form;

	if (theform.fname.value==false) {
	alert("Input the First Name!");
	theform.fname.focus();
	return false;
	}

	if (theform.lname.value==false) {
	alert("Input the Last Name!");
	theform.lname.focus();
	return false;
	}

	if (theform.id.value==false) {
	alert("Input the ID!");
	theform.id.focus();
	return false;
	}

	if (theform.id.value.length<6 || theform.id.value.length>12) {
	alert("ID:Type 6~12 characters!");
	theform.id.focus();
	return false;
	}

	if (theform.pwd1.value==false) {
	alert("Input the password!");
	theform.pwd1.focus();
	return false;
	}

	if (theform.pwd1.value.length<6 || theform.pwd1.value.length>12) {
	alert("Password:Type 6~12 characters!");
	theform.pwd1.focus(); 
	theform.pwd1.select();
	return false;
	}

	if (theform.pwd2.value==false) {
	alert("Input the re-type password!");
	theform.pwd2.focus();
	return false;
	}

	if (theform.pwd2.value != theform.pwd1.value) {
	alert("Discordance between password  and re-type password!");
	theform.pwd2.focus();
	theform.pwd2.select();
	return false;
	}

	
	if (theform.email.value==false) {
	alert("Input the email address!");
	theform.email.focus();
	return false;
	}

	if(theform.email.value!= false){
	 var objEmail = theform.email; //eval(FromAddr) ;
	 var szEmail = objEmail.value ;
	 var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	 var regMust = /^[a-zA-Z0-9\-\.\_]+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;

		 if ( !regDoNot.test(szEmail) && regMust.test(szEmail) ){
		}else{
		alert('Email address error!');
		objEmail.focus() ;
		return false;
		}
	}

	if (theform.company.value==false) {
	alert("Input the company name!");
	theform.company.focus();
	return false;
	}


	if (theform.country.value==false) {
	alert("Input the country!");
	theform.country.focus();
	return false;
	}


	if (theform.tel.value==false) {
	alert("Input the phone number!");
	theform.tel.focus();
	return false;
	}
	
 theform.submit();
}




//È¸¿ø ¼öÁ¤Æû °ü·Ã ½ºÅ©¸³Æ®
function edit_chk_member() {
	var theform=document.join_form;

	if (theform.fname.value==false) {
	alert("Input the First Name!");
	theform.fname.focus();
	return false;
	}

	if (theform.lname.value==false) {
	alert("Input the Last Name!");
	theform.lname.focus();
	return false;
	}

	
	if (theform.email.value==false) {
	alert("Input the email address!");
	theform.email.focus();
	return false;
	}

		if(theform.email.value!= false){
	 var objEmail = theform.email; //eval(FromAddr) ;
	 var szEmail = objEmail.value ;
	 var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	 var regMust = /^[a-zA-Z0-9\-\.\_]+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;

		 if ( !regDoNot.test(szEmail) && regMust.test(szEmail) ){
		}else{
		alert('Email address error!');
		objEmail.focus() ;
		return false;
		}
	}

	if (theform.company.value==false) {
	alert("Input the company name!");
	theform.company.focus();
	return false;
	}

	if (theform.country.value==false) {
	alert("Input the country!");
	theform.country.focus();
	return false;
	}

	if (theform.tel.value==false) {
	alert("Input the phone number!");
	theform.tel.focus();
	return false;
	}
	
 theform.submit();
}


//---- enterÅ°¸¦ ´©¸£¸é ´ÙÀ½Ä­À¸·Î ³Ñ¾î°¡°Ô ÇÏ´Â ÇÔ¼ö
var parameter;
function enterNext(parameter){
if(event.keyCode==13)
parameter.focus();
}

//----------------------------------------------------------------------------------------
function onlyNumber()  //¼ýÀÚ¸¸À» ±âÀÔ¹Þ°Ô ÇÏ´Â ¹æ¹ý
{
	//alert("¼ýÀÚ·Î ÀÔ·ÂÇÏ¼¼¿ä");
   if((event.keyCode<48)||(event.keyCode>57))
      event.returnValue=true;
}

//----------------------------------------------------------------------------------------

//email ÀÔ·ÂÀÌ À¯È¿ÇÑÁö °Ë»ç
function check_email(theform)
{
emailStr=theform.email.value
if(emailStr != "") {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var firstChars=validChars
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom="(" + firstChars + validChars + "*" + ")"
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("E-mail ÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù.\n @ ¿Í . À» È®ÀÎÇÏ¼¼¿ä!");
		theform.email.select();
		
		return false;
		}
	}
}
//----------------------------------------------------------------------------------------


//----------------------------------------------------------------------------------------
//¾ÆÀÌµð Áßº¹½Ã ´Ù½Ã °Ë»öÇÏ´Â ÇÔ¼ö
function id_again() {
		theform=document.form;
		if (theform.id.value=="") {
			alert ("ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
			theform.id.focus();
			return;
			}
		if (theform.id.value.length<4) {
			alert ("4ÀÚ¸® ÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä!");
			theform.id.select();
			return;		
			}
		theform.submit();
	}


	function id_apply() {
		opener.document.join_form.id.value = document.form.id.value;
		self.close();
	}


///////////////////////////
	//Ã¼Å©¹Ú½º ¼±ÅÃ ÇÏ±â
//////////////////////////
function allcheck(theform)
{
	var check_box=theform["check[]"]; 
	if(!check_box)
	{
	alert('°ªÀÌ ¾ø½À´Ï´Ù.');
	    return false;
	}
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == false)
		{
			ele.checked = true;
		}	
	}
	return;
}

///////////////////////////
	//Ã¼Å©¹Ú½º ¼±ÅÃ ÇÏ±â image ÀÏ¶§
//////////////////////////
function allcheck1()
{
	theform=document.form;
	var check_box=theform["check[]"]; 
	if(!check_box)
	{
	alert('°ªÀÌ ¾ø½À´Ï´Ù.');
	    return false;
	}
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == false)
		{
			ele.checked = true;
		}	
	}
	return;
}

//¼±ÅÃÃë¼Ò
function discheck(theform)
{
	for( var i=0; i<theform.elements.length; i++) 
	{
		var ele = theform.elements[i];
		if(ele.name == 'check[]')
			ele.checked = false;
	}
	return;
}

//¼±ÅÃÃë¼Ò image ÀÏ¶§
function discheck1()
{
	theform=document.form;
	for( var i=0; i<theform.elements.length; i++) 
	{
		var ele = theform.elements[i];
		if(ele.name == 'check[]')
			ele.checked = false;
	}
	return;
}


//¼±ÅÃºÎºÐ ¹ÝÀü
function invert_check(theform)
{
	for( var i=0; i<theform.elements.length; i++) 
	{
		var ele1 = theform.elements[i];
		if(ele1.name == 'check[]')
		{
			if(ele1.checked == true)
			{
				ele1.checked = false;
			} 
			else 
			{
				ele1.checked = true;
			}
		}
		
	}
	return;
}
//¼±ÅÃºÎºÐ ¹ÝÀü image ÀÏ¶§
function invert_check1()
{theform=document.form;
	for( var i=0; i<theform.elements.length; i++) 
	{
		var ele1 = theform.elements[i];
		if(ele1.name == 'check[]')
		{
			if(ele1.checked == true)
			{
				ele1.checked = false;
			} 
			else 
			{
				ele1.checked = true;
			}
		}
		
	}
	return;
}

/////////////¼±ÅÃ±Û »èÁ¦

function delall(theform)
 { 
var check_box=theform["check[]"]; 
	
		for(var i=0; i<check_box.length;i++)
		{
			var ele = check_box[i];
			if(ele.checked == true)	break;		
		}
	if(i==check_box.length)
		{
			alert('¼±ÅÃÀ» ÇÏÁö ¾ÊÀ¸¼Ì½À´Ï´Ù.');
			return;
		}
 else 
   {
     if(confirm("¼±ÅÃµÈ ¸ðµç È¸¿øÀÌ Áö¿öÁý´Ï´Ù."))
	  {
	  theform.action="select_all_del_ok.php";
      theform.submit();
	  }
	 else
	  {
		
     location.href="#";  
	  }
   }
 } 
 function CkImageVal() {
	var oInput = event.srcElement;
	var fname = oInput.value;
	//alert(fname);
	if((/(.jpg|.jpeg|.gif|.png|.JPG|.JEPG|.GIF|.PNG|.bmp|.BMP )$/i).test(fname)){
		oInput.parentElement.children[0].src = fname;
	}else{
		alert('ÀÌ¹ÌÁö´Â gif, jpg, png, bmp ÆÄÀÏ¸¸ °¡´ÉÇÕ´Ï´Ù.');
	//return false;
	}
	}

/////////////¼±ÅÃ±Û »èÁ¦

function i_delall()
 { 
	 theform=document.form;
var check_box=theform["check[]"]; 
	
		for(var i=0; i<check_box.length;i++)
		{
			var ele = check_box[i];
			if(ele.checked == true)	break;		
		}
	if(i==check_box.length)
		{
			alert('¼±ÅÃÀ» ÇÏÁö ¾ÊÀ¸¼Ì½À´Ï´Ù.');
			return;
		}
 else 
   {
     if(confirm("¼±ÅÃµÈ ¸ðµç ¹®ÀÇ°¡ Áö¿öÁý´Ï´Ù."))
	  {
	  theform.action="select_all_del_ok.php";
      theform.submit();
	  }
	 
   }
 } 

//¼öÁ¤°ü·Ã ÆäÀÌÁöÀÌµ¿µî..
function go_modify(idx){
	location.href="info.php?mode=edit&idx="+idx;    
}

function pwd_chg(idx){
	window.open('../member/pwd_chg.php?idx='+idx,'pwd_chg','width=250 height=179') 
}

//inquiry Ã¼Å© ÇÔ¼ö
function inq_chk(){
theform=document.inq_form;

if(theform.title.value==false){
alert("Input the title!");
theform.title.focus();
return false;
}

if(theform.fname.value==false){
alert("Input the first name!");
theform.fname.focus();
return false;
}

if(theform.lname.value==false){
alert("Input the last name!");
theform.lname.focus();
return false;
}

if (theform.email.value==false) {
	alert("Input the email address!");
	theform.email.focus();
	return false;
}

		if(theform.email.value!= false){
	 var objEmail = theform.email; //eval(FromAddr) ;
	 var szEmail = objEmail.value ;
	 var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	 var regMust = /^[a-zA-Z0-9\-\.\_]+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;

		 if ( !regDoNot.test(szEmail) && regMust.test(szEmail) ){
		}else{
		alert('Email address error!');
		objEmail.focus() ;
		return false;
		}
	}

if(!isCheckAtLeastOne (theform["lcate"]))
	{
	elem=theform["lcate"];
	alert("Check the product category.");
	elem[0].focus();
	return false;
}

/*if (theform.lcate.checked==false) {
	alert("Check the product category!");
	theform.lcate.focus();
	return false;
}*/

if (theform.content.value==false) {
	alert("Input your message!");
	theform.content.focus();
	return false;
}

theform.submit();
}


//È¸¿ø°ü¸®ÀÚ¿ë
function aedit_go(){
document.join_form.action="member_edit.php";
document.join_form.submit();
}

function alist_go(){
document.join_form.action="member_list.php";
document.join_form.submit();
}

function awrite_go() {
	
	var theform=document.join_form;

	if (theform.fname.value==false) {
	alert("First NameÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.fname.focus();
	return false;
	}

	if (theform.lname.value==false) {
	alert("Last NameÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.lname.focus();
	return false;
	}

	if (theform.id.value==false) {
	alert("ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.id.focus();
	return false;
	}

	if (theform.id.value.length<6 || theform.id.value.length>12) {
	alert("ID´Â 6~12ÀÚ »çÀÌ·Î ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.id.focus();
	return false;
	}

	if (theform.pwd1.value==false) {
	alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.pwd1.focus();
	return false;
	}

	if (theform.pwd1.value.length<6 || theform.pwd1.value.length>12) {
	alert("ºñ¹Ð¹øÈ£´Â 6~12ÀÚ »çÀÌ·Î ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.pwd1.focus(); 
	theform.pwd1.select();
	return false;
	}

	if (theform.pwd2.value==false) {
	alert("ºñ¹Ð¹øÈ£ È®ÀÎÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.pwd2.focus();
	return false;
	}

	if (theform.pwd2.value != theform.pwd1.value) {
	alert("ÀÔ·ÂÇÏ½Å ºñ¹Ð¹øÈ£¿Í È®ÀÎ ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù!");
	theform.pwd2.focus();
	theform.pwd2.select();
	return false;
	}

	
	if (theform.email.value==false) {
	alert("ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.email.focus();
	return false;
	}

		if(theform.email.value!= false){
	 var objEmail = theform.email; //eval(FromAddr) ;
	 var szEmail = objEmail.value ;
	 var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	 var regMust = /^[a-zA-Z0-9\-\.\_]+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;

		 if ( !regDoNot.test(szEmail) && regMust.test(szEmail) ){
		}else{
		alert('ÀÌ¸ÞÀÏÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù!');
		objEmail.focus() ;
		return false;
		}
	}


	if (theform.country.value==false) {
	alert("±¹°¡¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.country.focus();
	return false;
	}


	if (theform.tel.value==false) {
	alert("ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.tel.focus();
	return false;
	}
	
 theform.submit();
}

function aedit_gogo() {
	
	var theform=document.join_form;

	if (theform.fname.value==false) {
	alert("First NameÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.fname.focus();
	return false;
	}

	if (theform.lname.value==false) {
	alert("Last NameÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.lname.focus();
	return false;
	}

	if (theform.id.value==false) {
	alert("ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.id.focus();
	return false;
	}

	if (theform.id.value.length<6 || theform.id.value.length>12) {
	alert("ID´Â 6~12ÀÚ »çÀÌ·Î ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.id.focus();
	return false;
	}

	if (theform.email.value==false) {
	alert("ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.email.focus();
	return false;
	}

	if(theform.email.value!= false){
	 var objEmail = theform.email; //eval(FromAddr) ;
	 var szEmail = objEmail.value ;
	 var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	 var regMust = /^[a-zA-Z0-9\-\.\_]+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;

		 if ( !regDoNot.test(szEmail) && regMust.test(szEmail) ){
		}else{
		alert('ÀÌ¸ÞÀÏÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù!');
		objEmail.focus() ;
		return false;
		}
	}

	if (theform.country.value==false) {
	alert("±¹°¡¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.country.focus();
	return false;
	}


	if (theform.tel.value==false) {
	alert("ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!");
	theform.tel.focus();
	return false;
	}
	
 theform.submit();
}
