// ==============================================
// ÀÚµ¿ Æû °Ë»ç±â
// ==============================================

function isValidDate( oInput, oType, oMsg ) {

	switch( oType.toLowerCase() ) {

		case 'select':		// Âü°í:Á÷¾÷Á¾·ù/ÇÐ·Â/°ÅÁÖÁö´Â Ã¹¹øÂ° value °ªÀÌ 99·Î µÇ¾î ÀÖÀ½...
			if(oInput.selectedIndex == 0){
				alert(oMsg);
				oInput.selectedIndex = 0;
				return false;
			}
			return true;

		case 'number':
			if( !oInput.value ) {
				//alert ("°ø¶õÀÔ´Ï´Ù.");
				alert(oMsg);
				oInput.focus();
				return false; 
			}
			for( var mXi = 0; mXi < oInput.value.length; mXi++ ) {
				if( oInput.value.charAt( mXi ) != '' + parseInt( oInput.value.charAt( mXi ) ) + '' ) {
					alert ("¼ýÀÚ·Î¸¸ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.");
					oInput.select();
					oInput.focus();
					return false;
				}
			}
			return true;

		case 'email':

			if(oInput.value == ""){
				alert(oMsg);
				oInput.focus();
				return false;
			}
			var mail_num = oInput.value.length;
			for (var l = 0; l <= (mail_num - 1); l++)
			{
				if (oInput.value.indexOf(" ") >= 0 ) 
				{
					alert ("E-Mail ÁÖ¼Ò¿¡¼­ °ø¶õÀ» »©ÁÖ½Ê½Ã¿À");
					oInput.focus();
					return false;
				}
			}
			var str_mail = oInput.value;
			if ((str_mail.indexOf("/")) == -1){
			}else {
				alert("E-MailÇü½ÄÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\n  ´Ù½ÃÇÑ¹ø È®ÀÎ¹Ù¶ø´Ï´Ù.");
				oInput.focus();
				return false;
			}
			if ((str_mail.indexOf(";")) == -1){
			}else {
				alert("E-MailÇü½ÄÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\n  ´Ù½ÃÇÑ¹ø È®ÀÎ¹Ù¶ø´Ï´Ù.");
				oInput.focus();
				return false;
			}
			
			if ((oInput.value.length != 0) && (str_mail.search(/(\S+)@(\S+)\.(\S+)/) == -1)) {
				alert("E-MailÇü½ÄÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\n  ´Ù½ÃÇÑ¹ø È®ÀÎ¹Ù¶ø´Ï´Ù.");
				oInput.focus();
				return false;
			}	
			s_str1 = oInput.value;
			
			if ( s_str1.match(/\S/)==null ) {
				alert("°ø¹é¸¸ ÀÔ·ÂÇÏ¸é ¾ÈµË´Ï´Ù. E-MailÀ» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿ä.");
				oInput.focus();
				return false;
			}


			return true;

		case 'jumin1':
			if (int_check(oInput) != true || oInput.value.length != 6) { 
				alert(oMsg); 
				oInput.select();			 
				oInput.focus(); 
				return false; 
			}
			
			/*¿ÀÀÛµ¿
			strdate = new Date();
			strdate = strdate.getYear();

			r_age = strdate - parseInt('19'+oInput.value.substring(0,2));
			if(r_age < 20){
				alert(r_age + "20¼¼ ¹Ì¸¸Àº ÀÔ·ÂÇÏ½Ç¼ö ¾ø½À´Ï´Ù.");
				return false;
			}
			*/

			return true;

		case 'jumin2':
			if (int_check(oInput) != true || oInput.value.length != 7 ) { 
				alert(oMsg); 
				oInput.select();			 
				oInput.focus(); 
				return false; 
			}

			return true;

		case 'text':
			if(oInput.value == ""){
				alert(oMsg);
				oInput.focus();
				return false;
			}
			return true;

		case 'password':
			if(oInput.value == ""){
				alert(oMsg);
				oInput.focus();
				return false;
			}
			if(oInput.value.length < 4){
				alert("ºñ¹Ð¹øÈ£´Â 4ÀÚ ÀÌ»ó ÀÔ·ÂÇØÁÖ¼¼¿ä.");
				oInput.focus();
				return false;
			}
			return true;

		case 'check':
			var count = 0;
			//alert(oInput.length);
			for(i = 0; i < oInput.length; i++){
				if(oInput[i].checked == true){
					count += 1;
				}
			}
			if(count == 0){
				alert(oMsg);
				oInput[0].focus();
				return false;
			}

			return true;

		case 'agree':
			if(oInput.checked == false){
				alert(oMsg);
				oInput.focus();
				return false;
			}
			return true;

		case 'image':
			var arr = ("file:///"+oInput.value.replace(/ /gi,"%20").replace(/\\/gi,"/")).split("/");
			var fname = arr[arr.length-1];
			var e = fname.length;
			var m = fname.lastIndexOf(".");
			var filename = fname.substring(0,m);	//ÆÄÀÏ¸í
            var extname = fname.substring(m+1,e);	//È®ÀåÀÚ¸í

            if(extname.toUpperCase()=="JPG" || extname.toUpperCase()=="GIF" || extname.toUpperCase()=="BMP" || extname.toUpperCase()=="PPT" || extname.toUpperCase()=="PSD" || extname.toUpperCase()=="DOC" || extname.toUpperCase()=="AI" || extname.toUpperCase()=="XLS" || extname.toUpperCase()=="HWP" || extname.toUpperCase()=="PPTX" || extname.toUpperCase()=="PDF" || extname.toUpperCase()=="ZIP"){
				return true;
            }else{
				
				if(oInput.value == ""){
					alert(oMsg);
				}else{
					alert("ÀÌ¹ÌÁö(JPG/GIF/BMP) È¤Àº ¹®¼­ Çü½ÄÀÇ ÆÄÀÏÀÌ ¾Æ´Õ´Ï´Ù.");
				}
				oInput.focus();
				return false;
            }
	}
}

//ÀÌ¸ÞÀÏ Ã¼Å© ( ¾ÆÀÌµð +"@"+ µµ¸ÞÀÎ¼±ÅÃ ¹æ½Ä)  / ÀÚ±â¹ß°ßÅ×½ºÆ®¿Ü ´Ù¼ö °³ÀÎÁ¤º¸ ÀÔ·Â ÆäÀÌÁö¿¡ Àû¿ë
function checkEmail(oInput1,oInput2,oInput3) {

	if (oInput1.value == "") { 
		alert("ÀÌ¸ÞÀÏ ¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿À ..");
		oInput1.focus(); 
		return false;
	}
	if (oInput1.value.indexOf("@") != -1 ){		// "@" ¹®ÀÚ¿­ÀÌ Æ÷ÇÔµÆÀ»°æ¿ì
		var s_email = oInput1.value.split("@");
		oInput1.value = s_email[0];				//ÀÌ¸ÞÀÏ ¾ÆÀÌµð¸¸ °­Á¦ ÀÔ·Â
	}
	
	if(oInput3.selectedIndex == 0){
		alert("ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÇ µµ¸ÞÀÎÀÌ ¼±ÅÃµÇÁö ¾Ê¾Ò½À´Ï´Ù.");
		oInput3.selectedIndex = 0;
		return false;
	}

	if (oInput3.value == "input") {
		var txt = oInput1.value+"@"+oInput2.value;	// ¾ÆÀÌµð + µµ¸ÞÀÎÁ÷Á¢ÀÔ·Â
	} else {
		var txt = oInput1.value+"@"+oInput3.value;	// ¾ÆÀÌµð + µµ¸ÞÀÎ¼±ÅÃ
	}

	for (i = 0; i < txt.length; i++) { 
		if (txt.charCodeAt(i) > 127) { 
			alert("ÀÌ¸ÞÀÏÀº ÇÑ±ÛÀ» »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù."); 
			return false; 
		} 
	} 

	if (txt.indexOf("@") < 2){ 
		alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ Àß¸ø µÇ¾ú°Å³ª µµ¸ÞÀÎ ÀÔ·ÂÀÌ ¾ÈµÇ¾ú½À´Ï´Ù.");
		oInput1.focus();
		return false;
	}

	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)&&(txt.indexOf(".kr")<4)&&(txt.indexOf(".st")<4)&&(txt.indexOf(".tv")<4)&&(txt.indexOf(".ro")<4)&&(txt.indexOf(".arpa")<6)&&(txt.indexOf(".biz")<5)&&(txt.indexOf(".aero")<6)&&(txt.indexOf(".name")<6)&&(txt.indexOf(".coop")<6)&&(txt.indexOf(".info")<6)&&(txt.indexOf(".pro")<5)&&(txt.indexOf(".museum")<7))
	{ 
		alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ Àß¸øµÈ ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÔ´Ï´Ù.");
		return false;
	}

	return true;
}

//ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
function ju_check(ju_text){
	var num = ju_text, num_div =new Array(), mul_num =new Array(2,3,4,5,6,7,8,9,2,3,4,5), sum = 0, sum_div;
	for(var i=0; i < 13; i++){num_div[i] =num.charAt(i)}
	for(var i=0; i < 12; i++){sum += (num_div[i] * mul_num[i])}
	sum_div = (11 - (sum % 11)) % 10;
	             
	if ((sum_div == num_div[12] && (num_div[6]== 1 || num_div[6] == 2 )) ||  ju_text == '6789999996789'){
	 	return true
	}else {
		return false
	}
}

// ¼ýÀÚ Ã¼Å©   
function int_check(textObj) {	
	var newValue = textObj.value ;
	var newLength = newValue.length ;
	
	for (var i=0; i < newLength; i++) {
		aChar = newValue.substring(i, i + 1);
		bChar = newValue.charAt(0);
	
		if (aChar < "0" || aChar > "9") {
			return false
		}
	}
	return true ;
}

// ÀÌ¸ÞÀÏ µµ¸ÞÀÎ ºÎºÐ º¯°æ Ã¼Å©
function chgEmail(form,val) {
	if (val=="input") {
		form.u_email_domain.value = "";
		form.u_email_domain_select.style.display = "none";
		form.u_email_domain.style.display = "";
		form.u_email_domain.focus();
	} else {
		form.u_email_domain.value = val;
	}
}

//¼ýÀÚÃ¼Å©
function checkNumber(checkNum) {
	t = checkNum.value ;

	for(i = 0; i < t.length; i++) {
		if (t.charAt(i) < '0' || t.charAt(i) > '9') {
			alert("¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			checkNum.value = "";
			checkNum.focus();
			return false;
		}
	}
}


// input text ÀÌµ¿
function auto_fs(item, next_item, num)    {
	 bName = navigator.appName;
	 if (bName == "Netscape") return;
	 if (item.value.length == num       )
	 {
		next_item.select();
		next_item.focus();
	}
	return;
}

// ajax °´Ã¼ »ý¼º ÇÔ¼ö
var xmlHttp;
function createXMLHttpRequest(){
	if(window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
	}else if(window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();
	}
}

//ÆË¾÷Ã¢ ÄíÅ° ±â°£ ¼³Á¤ ÇÔ¼ö
function setCookie( name, value, expiredays ){
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

//ÆË¾÷Ã¢ ÄíÅ°°ª °¡Á®¿À±â
function getCookie( name ) {
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ) {
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;

			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
  
		x = document.cookie.indexOf( " ", x ) + 1;
		
		if ( x == 0 ) 
			break;
	}

	return "";
}

//ÆË¾÷Ã¢ ´Ý±â
function closeWin(idx) { 
	if( eval("document.popup_"+ idx +".notice.checked") ) {
 		setCookie( "popupview_"+idx, "view" , 7); 
	}
	self.close(); 
}

// goto url È£Ãâ / ÆË¾÷ÆäÀÌÁö
function goto_url(linkPage){
	var linkPage;
	//opener.location.href=linkPage;
	window.open(linkPage, '', '');
	this.close();
}

// ÀÚ½Å ÆäÀÌÁö ÀÌµ¿ / Layer ÆË¾÷ÆäÀÌÁö
function goto_url_self(linkPage){
	var linkPage;
	location.href=linkPage;
}

//Layer ÆË¾÷ ¹æ½Ä È£Ãâ ÇÔ¼ö
function popup_close(onOrOff,idx) {

	var popupid = document.getElementById('popupview_'+idx);
	popupid.style.display="none";

	if ( eval("document.popup_"+ idx +".notice.checked") ){ 
		setCookie("popupview_"+idx, "view" , 7);
	}
} 

//Layer ÆË¾÷ ¹æ½Ä È£Ãâ ÇÔ¼ö // ¸®´º¾ó ÇÏ¸é¼­ close ¹æ½Ä º¯°æ
function popup_close11(onOrOff,idx) {

	var popupid = document.getElementById('popupview_'+idx);

	if (onOrOff == 1) {
		popupid.mouseIn = 1;
		timer = window.setTimeout("movepopup(1,'"+idx+"');", 0, "JavaScript");
	} else {

		popupid.mouseIn = 0;
		timer = window.setTimeout("movepopup(0,'"+idx+"');", 0, "JavaScript");

		if ( document.popup.notice.checked ){ 
				setCookie( "popupview_"+idx, "view" , 7);
		}
	}
} 


//Layer ÆË¾÷ ¹æ½Ä È£Ãâ ÇÔ¼ö
function movepopup(onOrOff,idx) {
	var popupid = document.getElementById("popupview_"+idx);
	if (onOrOff == 1 && popupid.mouseIn == 1) {
			if (popupid.style.posTop < 0) {
			popupid.style.posTop = popupid.style.posTop + 20;
			timer = window.setTimeout("movepopup(1,'"+idx+"');", 0, "JavaScript");
		}
	} else {
			if (popupid.mouseIn == 0 && popupid.style.posTop > -550) {
			popupid.style.posTop = popupid.style.posTop - 20;
			timer = window.setTimeout("movepopup(0,'"+idx+"');", 0, "JavaScript");
		}
	}
}

//DB ÀÌ¹ÌÁö È£ÃâÈÄ ÀÌ¹ÌÁö »çÀÌÁî Á¶Àý
function img_resize(imgid,nWidth){

	var idvalue = document.getElementById(imgid);
	oWidth = idvalue.width;

	if(oWidth > nWidth){
		idvalue.width = nWidth;
	}
}


// input ¹Ú½º Å¬¸¯½Ã ³»¿ë »èÁ¦
//====================================================
var ccc = false;
var cccc = false;

function duo_ac1(param,flag) {

	duoMain_setTextBox(param,flag);
	if ( ccc ) return;
	param.value = "" ;
	ccc = true;
}

function duo_ac2(param,flag) {

	duoMain_setTextBox(param,flag);
	if ( cccc ) return;
	param.value = "" ;
	cccc = true;
}

var duoMain_keystatus = 1; // keysatus 1 : No Input, 2 : Start Input
function duoMain_setTextBox(cname,flag) {
	var textbox = cname;
	var _event;
	switch ( duoMain_getNavigatorType() ) {
		case 1 : // IE
			_event = window.event;
			nodeName = _event.srcElement.nodeName;
			break;
		case 2 : // Netscape
			_event = event;
			nodeName = _event.target.nodeName;
			break;
		default :
			nodeName = "None";
			break;
	}
	key = _event.keyCode;
	if ( duoMain_keystatus == 1 && flag && key != 13) { // keyCode : Enter
		textbox.value = "";
		duoMain_keystatus = 2;
	}
}

function duoMain_getNavigatorType() {
	if ( navigator.appName == "Microsoft Internet Explorer" )
		return 1;
	else if ( navigator.appName == "Netscape" )
		return 2;	
	else
		return 0;
}

// ÇÑ±Û¸¸ ÀÔ·ÂÇÏ°Ô ÇÏ´Â Æã¼Ç
function checkKor(){
	if(event.keyCode>=33 && event.keyCode<=126){
		alert("ÇÑ±Û¸¸ ÀÔ·ÂÇÏ½Ç¼ö ÀÖ½À´Ï´Ù.");
		return false;
	}
}

//Á¤±ÔÈ­ Ç¥Çö ÇÔ¼ö
function checkValue(theObj,regExp,errSpan,errMsg){
	if(theObj.search(regExp) == -1){
		errSpan.innerHTML = errMsg;
		return false;
	}else{
		return true;
	}
}

// °¢Á¾ ÆäÀÌÁö¿¡¼­ ¿ìÆí¹øÈ£ ÆäÀÌÁö È£Ãâ
function findpost_member(){
	window.open("/join/pop_address.asp?flag=member","zipcode","width=458,height=465,resizable=no,scrollbars=yes");
}

function findpost2(dong, form_zip_id, form_addr1_id, form_addr2_id){
	window.open("/include/popup/popup_zipsearch.red?dong=" + dong + "form_zip_id=" + form_zip_id + "&form_addr1_id=" + form_addr1_id + "&form_addr2_id=" + form_addr2_id,"","width=458,height=465,resizable=no,scrollbars=yes");
}