

document.title = "골프버디 - 휴대용 GPS 골프거리측정기";




//=============================================================================
//오른쪽 마우스 막기 
//=============================================================================

/*
if (navigator.appName != "Netscape") {
	document.onselectstart=new Function ("return false");
	document.oncontextmenu=new Function ("return false");
	document.ondragstart=new Function ("return false");
} else {
	if (window.sidebar) {
		document.onmousedown=disableselect;
		document.onclick=reEnable;
	}
} 
*/


/*
function PrintScreen_Check() {
	if (window.clipboardData) {
		window.clipboardData.setData("Text","test");
		window.clipboardData.setData("Text","");
	}
}

setInterval("PrintScreen_Check()",100);
*/


//프레임 방지 태그
/*
if (opener) {
} else {
	if(parent.frames.length <= 0) { 
		top.location.href="http://golfbuddy.co.kr"; 
	}
}
*/
//==============================================================================





theFeats = "height=120,width=500,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
theUniqueID = (new Date()).getTime() % 1000000000;


//일설정 
function month_check(mFrom, yFrom, targetForm) {
  var index = mFrom.selectedIndex;
  var month = mFrom.value;
  var year = yFrom.value;

  if (year % 4 != 0) {
    YoonYear = 0;
  } else if (year % 100 != 0) {
    YoonYear = 1;
  } else if (year % 400 != 0) {
    YoonYear = 0;
  } else {
    YoonYear = 1;
  }
  
  if (month == "02") {
    if (YoonYear == 1) {          
      var cArray = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29');
      var cArraycd = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29');
    } else if (YoonYear == 0) {
      var cArray = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28');
      var cArraycd = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28');
    }
  } else if (month == "04" || month == "06" || month == "09" || month == "11") { 
    var cArray = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30');
    var cArraycd = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30');
  } else {
    var cArray = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31');
    var cArraycd = new initArray('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31');  
  }
  
  changeCategory( targetForm, cArray, cArraycd );
}


function initArray() {
  this.length = initArray.arguments.length
  for (var i = 0; i < this.length; i++)
    this[i+1] = initArray.arguments[i];
}


function changeCategory( targetForm, categoryArray , categoryArraycd ) {
  var targetLength = targetForm.options.length;

  for (var i=0; i<targetLength; i++)
    targetForm.options[0] = null;

  for (i=1; i<=categoryArray.length ;i++) {
    var e1 = document.createElement("OPTION");
    
    e1.text = categoryArray[i];
    e1.value = categoryArraycd[i];
    
    targetForm.options.add(e1);
  }

  targetForm.options.selectedIndex = 0;
}


// 이메일 주소 직접입력 interface 조정
function email_select(e) {
  if (e.value=="-1") {
    document.form1.txtemail3.style.display = "inline";
    document.form1.txtemail3.focus();
  }
  else {
    document.form1.txtemail3.value = "";
    document.form1.txtemail3.style.display = "none";
  }
}



//숫자만 입력할수 있게
function num_check(field) {

	if((event.keyCode==8) || (event.keyCode==9) || (event.keyCode==13) || (event.keyCode==16) 
		|| (event.keyCode==17)|| (event.keyCode==25)|| (event.keyCode==35)|| (event.keyCode==36)|| (event.keyCode==45)|| (event.keyCode==86)
		|| (event.keyCode==46) || (event.keyCode>36 && event.keyCode<41) 
		|| (event.keyCode>47 && event.keyCode<58) || (event.keyCode>95 && event.keyCode<106)
	) {
		//통과
	} else {			
		alert("숫자만 입력가능합니다.");
		event.returnValue = false;
		field.focus();
		return;
	}
}





//금액만 입력할수 있게
function money_num_check(field) {
	if((event.keyCode==8) || (event.keyCode==9) || (event.keyCode==16) 
		|| (event.keyCode==17)|| (event.keyCode==25)|| (event.keyCode==35)|| (event.keyCode==36)|| (event.keyCode==45)|| (event.keyCode==86)
		|| (event.keyCode==46) || (event.keyCode>36 && event.keyCode<41) 
		|| (event.keyCode>47 && event.keyCode<58) || (event.keyCode>95 && event.keyCode<106)
	) {
		//통과
		formatnumber_value = field.value.replace(",","");
		//alert(formatnumber_value);
		field.value = formatnumber(formatnumber_value,3); //3자리마다 콤마
	} else {			
		alert("숫자만 입력가능합니다.");  
		event.returnValue = false;
		field.focus();
		return;
	}
}



function formatnumber(v1,v2){ //숫자와 콤마를 찍을자리수를 매개변수로 받음
 var str=new Array(); //콤마스트링을 조합할 배열

 //v1 = v1.replace(",","");
 v1=String(v1); //숫자를 스트링으로 변환
 for(var i=1;i<=v1.length;i++){ //숫자의 길이만큼 반복
  if(i%v2) str[v1.length-i]=v1.charAt(v1.length-i); //자리수가 아니면 숫자만삽입
  else  str[v1.length-i]=','+v1.charAt(v1.length-i); //자리수 이면 콤마까지 삽입
 }
 return str.join('').replace(/^,/,''); //스트링을 조합하여 반환
}






//주민번호 체크
function chkJumin(str, str2) {
	var chk=0;
	var jumin = str.value + str2.value;
	for (var i=0; i<=5; i++) {
		chk += ((i%8+2) * parseInt(jumin.substring(i,i+1)));
	}
	for (var i=6; i<=11; i++) {
		chk += ((i%8+2) * parseInt(jumin.substring(i,i+1)));
	}
	chk = 11 - (chk %11);
	chk = chk % 10;


	if (chk != jumin.substring(12,13)){
		 return false;
	}
	
	return true;
}

// 사업자번호 체크 형식
function chkBizNum(str, str2, str3) {
	var chkRule = "137137135";
	var ThisVal1 = str.value;
	var ThisVal2 = str2.value;
	var ThisVal3 = str3.value;

	var strCorpNum = ThisVal1 + ThisVal2 + ThisVal3; // 사업자번호 10자리
	var step1, step2, step3, step4, step5, step6, step7;


	step1 = 0;			// 초기화

	for (i=0; i<7; i++) {
		step1 = step1 + (strCorpNum.substring(i, i+1) *chkRule.substring(i, i+1));
	}

	step2 = step1 % 10;
	step3 = (strCorpNum.substring(7, 8) * chkRule.substring(7, 8))% 10;
	step4 = strCorpNum.substring(8, 9) * chkRule.substring(8, 9);
	step5 = Math.round(step4 / 10 - 0.5);
	step6 = step4 - (step5 * 10);
	step7 = (10 - ((step2 + step3 + step5 + step6) % 10)) % 10;

	if (strCorpNum.substring(9, 10) != step7) {   // 결 과 비교 판단
		return false;
	}
	return true;
}



//외국인 등록번호 체크
//내국거주 외국인 주민번호 유효성 체크 생략 
function fgn_no_chksum(reg_no) {
   /* var sum = 0;
    var odd = 0;
    
    buf = new Array(13);
    for (i = 0; i < 13; i++) buf[i] = parseInt(reg_no.charAt(i));

    odd = buf[7]*10 + buf[8];
    
    if (odd%2 != 0) {
      return false;
    }

    if ((buf[11] != 6)&&(buf[11] != 7)&&(buf[11] != 8)&&(buf[11] != 9)) {
      return false;
    }
     
    multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
    for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);


    sum=11-(sum%11);
    
    if (sum>=10) sum-=10;

    sum += 2;

    if (sum>=10) sum-=10;

    if ( sum != buf[12]) {
        return false;
    }
    else {
        return true;
    } */
     return true;
}



//E-Mail check
function chkEmail(chkMail) {
 emailEx1 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z]+/;
 emailEx2 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;
 emailEx3 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;

 if(emailEx1.test(chkMail)) return true;
 if(emailEx2.test(chkMail)) return true;
 if(emailEx3.test(chkMail)) return true;

 return false;
}



//길이 체크
function chkLen(obj, minSize, maxSize) {
	if (minSize > maxSize) {
		alert(obj.name + '에 대한 길이 체크에 잘못된 범위를 사용했습니다.');
		return false;
	}

	var objval_len = obj.value.length;
	var temp;

	for(i = 0; i < objval_len; i++) {
		temp = obj.value.charAt(i);
		if(escape(temp).length > 4)
			objval_len++;
	}

	if ((objval_len < minSize) || (objval_len > maxSize)){
		return false;
	}else{
		return true;
	}
}




//자동 커서 이동
function jump(str, nextstr, strlen) {	
	if(str.value.length == strlen) {
    nextstr.focus();
	}
} 



//엔터키 체크
function keycheck(nextstr) {
	if(event.keyCode == 13){
		nextstr();
	}
}





//영문과 숫자 체크
function is_AlpaNum(strAlphaNum) {
	var stTmp = "";
	for( i=0 ; i < strAlphaNum.length ; i++ ) {
	    stTmp = strAlphaNum.charAt(i);
		if ( (( stTmp >= "0") && (stTmp <= "9")) || ((stTmp >= "A") && (stTmp <= "Z")) || ((stTmp >= "a") && (stTmp <= "z")) )	{
		} else return false;
	}
	return	true;
}



//숫자 체크
function chkNumber(str) {	
	for (i = 0; i < str.value.length; i++) {
		if (str.value.charAt(i) >= '0' && str.value.charAt(i) <= '9')
			continue;
		else {
			return false;
		}
	}
	return true;
}


//영문과 숫자 체크
function chkEngNumber(str) {	
	for (i = 0; i < str.value.length; i++) {
		if ((str.value.charAt(i) >= '0' && str.value.charAt(i) <= '9') || (str.value.charAt(i) >= 'A' && str.value.charAt(i) <= 'Z') || (str.value.charAt(i) >= 'a' && str.value.charAt(i) <= 'z'))
			continue;
		else {
			return false;
		}
	}
	return true;
}



//영문과 숫자 체크
function chkSpecialChar(str) {
	var str2 = str.value.split(" ").join("");
	l = str2.length;
	t8 =  -1;
	
	for (i=0; i<l ; i++){
		if (str2.charCodeAt(i) == 34)
			t8 = 1;
	}

	// 이름에 특수문자 체크....
	var special_char;	
	var name_error = 0;
	for (i=0; i<l ; i++) {					// 2Bytes 캐릭터값이 0FFF 이상인것중 알파벳외
		if (str2.charCodeAt(i) < 4096) {		
			if (!( ((str2.charCodeAt(i)>=97) && (str2.charCodeAt(i)<=122)) || ((str2.charCodeAt(i)>=65) && (str2.charCodeAt(i)<=90)) || ((str2.charCodeAt(i)>=48) && (str2.charCodeAt(i)<=57)) ))
				name_error = 1;
		} else {
			if (str2.charCodeAt(i) >= 9424 && str2.charCodeAt(i) <= 9449) name_error = 1;
			if (str2.charCodeAt(i) >= 9312 && str2.charCodeAt(i) <= 9326) name_error = 1;
			if (str2.charCodeAt(i) >= 12896 && str2.charCodeAt(i) <= 12923) name_error = 1;
			if (str2.charCodeAt(i) >= 8544 && str2.charCodeAt(i) <= 8553) name_error = 1;
			if (str2.charCodeAt(i) >= 8560 && str2.charCodeAt(i) <= 8569) name_error = 1;
			if (str2.charCodeAt(i) >= 12296 && str2.charCodeAt(i) <= 12309) name_error = 1;
		}
	}
	
	if (name_error == 1) {
		return false;
	}

	var special_char = "[]<>‥…〃―∥＼∼‘’“”′″※℃Å￠￡￥。‰℉∀∃∏∂∇∮≠≤≥∞∴≡≒√∽∝∵∫∬∈∋⊆⊇⊂⊃∪∩∧∨∑∠⊥→←↑↓↔⇒⇔↕↗↙↖↘♭♩♪♬♂♀†‡☆★○●◎◇◆□■△▲▽▼♨☏☎☜☞㉿㈜◁◀▷▶♤♠♡♥♧～⌒♣⊙◈▣◐◑▒▤▥▨▧▦▩㎕㎖㎗ℓ㎘㏄㎣㎤㎥㎦㎛㎟㎠㎡㎢㏊㎍㏈㎧㎨㎰㎶Ω㎮㎯㏆⅓⅔⅛⅜⅝⅞⁴ⁿ₁₂₃";
	for (i=0; i<special_char.length; i++) {
		var t1 = str2.indexOf(special_char.charAt(i));			
		if(t1 != -1) {			
			return false;
		} else {
			continue;
		}
	}

	return true;
}



//한글체크
function chkKoreanChar(chStr) {
	if (chStr.substring(0,2)=='%u') {
		if (chStr.substring(2,4)=='00') {
			return 1;
		} else {
			return 2;
		}
	} else if (chStr.substring(0,1)=='%') {
		if (parseInt(chStr.substring(1,3),16) > 127) {
			return 2;
		} else {
			return 1;
		}
	} else {
		return 1;
	}
}



function containChars(input,chars) {
	for(var i=0;i<input.length;i++) {
		if(chars.indexOf(input.charAt(i))!=-1) {
			return true;
		}
	}
	return false;
}



/***********************************************************************************
  Pop-up (무조건 가운데 뜸)
***********************************************************************************/
var win= null;
function NewWindow(mypage,myname,w,h,scroll,resize){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable='+resize+',';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


/***********************************************************************************
  Pop-up (무조건 Top의 레프트에 뜸)
***********************************************************************************/
var winTop= null;
function NewWindowTop(mypage,myname,w,h, L, scroll,resize){
//  var winl = (screen.width-w)/2;
//  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top=0,';
      settings +='left='+L+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable='+resize+',';
  winTop=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){winTop.window.focus();}
}





function pop_login(opentype) {
	NewWindow("/popup/login.asp?opentype="+opentype,"pop_login","400","300","NO");
}

function pop_login_shop(opentype) {
	NewWindow("/popup/login_shop.asp?opentype="+opentype,"pop_login","400","300","NO");
}


function post_search() {
	NewWindow("/popup/postSearch.asp","postSearch","500","500","NO");
}


function pop_image(filename){
	window.open("/popup/popup_image.asp?filename="+filename, "popup_image","directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=467,height=600,top=10,left=10");		
}


function file_dn(mode, strFile) {
	if (strFile != "") {
		document.downform.mode.value = mode;
		document.downform.downfile.value = strFile;		

		document.downform.target = "_new";
		document.downform.action = "/common/popup_download.asp";
		document.downform.submit();
	}
}


function send_email(to_name, to_email) {
	NewWindow("/common/popup_email.asp?to_name="+to_name+"&to_email="+to_email,"send_email","450","450","NO");
}


function join_check() {
	//if (confirm("로그인을 하거나 회원 가입을 하세요!\n회원가입 하시겠습니까?")) {
		popup_login();
	//}
}


//메뉴 보이기
function leftmenu_open(leftmenu) { 
  if (leftmenu.style.display == 'none') {
    leftmenu.style.display = '';
  } else {
    leftmenu.style.display = 'none';
  }
}



//이미지 리사이즈
function resizeImgSub(img) {
 if ( (img.width / img.visibleImgObj.width) > (img.height / img.visibleImgObj.height) )
  img.visibleImgObj.height = Math.round(img.height * (img.visibleImgObj.width / img.width));
 else
  img.visibleImgObj.width = Math.round(img.width * (img.visibleImgObj.height / img.height));
}
function resizeImg(imgObj) {
 var imgOriginal = new Image();
 imgOriginal.visibleImgObj = imgObj;
 imgOriginal.onload = function() { resizeImgSub(this); }  
 imgOriginal.src = imgObj.src;
}




//이미지 리사이즈
function Image_resize(img, w, h) {
	imgFile = new Image(); 

	imgFile.src = img; 

	var x1 = imgFile.width; 
	var y1 = imgFile.height; 

	var x2 = w; 
	var y2 = h; 

alert(x1+"/"+y1);
	if (x1 >= y1){ 
		y2 = parseInt((y1 * x2) / x1); 
	}else{ 
		x2 = parseInt((x1 * y2) / y1); 
	} 
alert(x2+"/"+y2);

	document.write ("<img src='" +img+ "' width='" +x2+ "' height='" +y2+ "'>");
}

function startResize(imgObj) {
 if(viewImage.complete == false) {
  setTimeout("resizeImg(imgObj)", 2000);
 } else {
  resizeImg(imgObj);
 }
}



//iframe 사이즈 조절
function iframe_resizeIt(f_height,f_iframe){
  thisMenu = eval("document.all." + f_iframe + ".style")
  thisMenu.height = f_height;
}


//FAQ사용
var prevFaqID = '';

function SwitchMenu(showFaqID) {

	if(prevFaqID == showFaqID) {

		//내용 본것을 다시 클릭시 본문내용을 감춘다.
		eval(showFaqID).style.display = 'none';
		prevFaqID = '';

	} else {

		//내용 클릭시 본문내용을 보여준다.
		if(prevFaqID != '') {
			eval(prevFaqID).style.display = 'none';
		}
		eval(showFaqID).style.display = 'block';
		prevFaqID = showFaqID;
	}
}

function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 

document.onfocusin=bluring;

