//¸¶¿ì½ºµå·¡±×


//if(getCookie('memID') != "detong47"){
//document.onkeydown=EnterCheck;
//document.oncontextmenu = ReturnFalse;
//document.ondragstart=ReturnFalse;
//document.onselectstart=ReturnFalse;
//}





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.01
  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 && d.getElementById) x=d.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_showHideLayers() { //v6.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; }
}

var DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];		// Non-Leap year Month days.. 
var lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];	// Leap year Month days.. 


function dayChange(year, month, day){
	var thisYear = year.options[year.selectedIndex].value;
	var thisMon = month.options[month.selectedIndex].value;
	
	
	var endDay = getDaysOfMonth(thisYear,thisMon-1);
	for(var i=day.length;i>0;i--){
		day.options[i] =null;
	}
	
	for(var i=0;i<endDay;i++){
		day.options[i] = new Option(i+1,i+1);
	}
}


function getDaysOfMonth(year,month){
	if ((year % 4) == 0) { 
		if ((year % 100) == 0 && (year % 400) != 0) 
			return DOMonth[month]; 
			
			return lDOMonth[month]; 
	} else 
		return DOMonth[month];
}

function IsNumeric(){
	var tmp=event.keyCode;
	if(!((48 <= tmp && tmp<=57) || (96<= tmp && tmp<=105) || (tmp==8) || (tmp==9) || (tmp==13) || (tmp==46))){
			event.returnValue = false;
	}
}

// ¹®ÀÚ¿­ÀÌ °ø¹é¸¸ÀÖ´ÂÁö È®ÀÎÇÑ´Ù.
function checkBlank(str){
	for(var i=0; i<str.length; i++){
		if(str.charCodeAt(i) != 32){
			return false;
			break;
		}
	}
	return true;
}

function formatCurrency(v){
	var orin = new String(v)
	var len = orin.length

	if(len<4){
		return orin;
	}else if(len<7){
		var tmp1 = orin.substring(0,len-3);
		var tmp2 = orin.substring(len-3,len);
		return tmp1+","+tmp2;
	}else if(len<10){
		var tmp1 = orin.substring(0,len-6);
		var tmp2 = formatCurrency(orin.substring(len-6,len));
		return tmp1+","+tmp2;
	}
}

// ÁÖ¹Î¹øÈ£ Ã¼Å©
function checkJumin(v){
	var rn = new String(v);
		
	if(rn.length<13) return false;
	
	
	
	var chk = rn.charAt(6);
	if(!(chk==1 || chk==2 || chk==3 || chk==4)){
		return false;
	}
	
	var sum=0;
	for(i=0;i<8;i++) { sum+=rn.substring(i,i+1)*(i+2); }
	for(i=8;i<12;i++) { sum+=rn.substring(i,i+1)*(i-6); }
	sum=11-(sum%11);
		
	if (sum>=10) { sum-=10; }
	if (rn.substring(12,13) != sum || (rn.substring(6,7) !=1 && rn.substring(6,7) != 2)) {
		return false;
	}
	
	return true;
}


function TextBoxError(obj,msg){
	if(checkBlank(obj.value)){
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}

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 FindZipCode(frm, zipcode, addr1, addr2){
	window.open("/Member/SearchZip.aspx?formName="+frm+"&zipcode="+zipcode+"&addr1="+addr1+"&addr2="+addr2,"findZipcode","width=518,height=350,scrollbars=yes");
}

function CheckID(form, idField, memberID){
	window.open("/Member/CheckID.aspx?formName="+form+"&idField="+idField+"&memberID="+memberID,"checkID","width=323,height=270,scrollbars=no");
}

function setHome()
{
	var Massage = confirm("È¨ÆäÀÌÁö¸¦ www.dang119.com/(À¸)·Î ¼³Á¤ÇÏ½Ã°Ú½À´Ï±î?");

	if (Massage == true) 
	{
		if (document.all)
		{
			document.links[0].style.behavior="url(#default#homepage)"; 
			document.links[0].setHomePage("www.dang119.com")
		}
	}
	else
	{
		str = "";
	}
}

function AddDang119()
{
	var Massage = confirm("Áñ°ÜÃ£±â¿¡ www.dang119.com/À» Ãß°¡ÇÏ½Ã°Ú½À´Ï±î?");

	if (Massage == true) 
	{
		bookmarkurl="http://www.dang119.com/" 
		bookmarktitle="´ç119´åÄÄ" 
		if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
	}
	else
	{
		str = ""
	}
}


function EnterCheck(e){
	var e  = (e) ? e : ((event) ? event : null);
	var node = (e.target) ? e.target : ((e.srcElement) ? e.srcElement : null);
	
	if(e.keyCode == 116){
		e.returnValue = false;
	}else if(e.keyCode==13){
		if(node.type=="undefined" || node.type=="file")
			e.returnValue = false;
		else if(node.type=="image" || node.type=="textarea")
			e.keyCode = 13;
		else
			e.keyCode = 9;
	}
}


function checkValidMember(id, pwd){
	var f = document.serverForm;
	if(checkBlank(eval("f."+id).value)){
		alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		eval("f."+id).focus();
		return false;
	}
	if(checkBlank(eval("f."+pwd).value)){
		alert('¾ÏÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		eval("f."+pwd).focus();
		return false;
	}
	if(f.idSave != null){
		if(f.idSave.checked == true){
			setCookie("saveID",eval("f."+id).value,365);
		}
	}else{
		setCookie("saveID",eval("f."+id).value,365);
	}
	return true;
}

function initID(id){
	var saveID = getCookie("saveID");
	if(saveID != ""){
		eval("document.serverForm."+id).value = saveID;
	}
}

function IDPWDSearch(){
	var w=window.open('/member/IdPwdSearch.aspx','','width=310,height=180');
	w.focus();
}

function RequestWrite(){
     popup = window.open( "https://www.dang119.com/common/mail.asp", "mail", "menubar=0, toolbar=0,location=0,directory=0,scrollbars=0,resizable=0, width=600,height=447, left=200, top=100");
     popup.focus();        
}

function FindZipCode(frm, zipcode, addr1, addr2){
	window.open("/Common/FindZipcode.aspx?formName="+frm+"&zipcode="+zipcode+"&addr1="+addr1+"&addr2="+addr2,"findZipcode","width=518,height=350,scrollbars=yes");
}



function checkLoginASP(frm){
	if(checkBlank(frm.memID.value)){
		alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä');
		frm.memID.focus();
		return false;
	}
	if(checkBlank(frm.memPwd.value)){
		alert('¾ÏÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		frm.memPwd.focus();
		return false;
	}
	frm.submit();
}

function checkLoginEnter(){
	if(event.keyCode==13){
		checkLoginASP(document.frmLogin);
	}
}		
	
	
function checkValidAllSearch(f){	
	if(checkBlank(eval(f).value)){
		alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		eval(f).focus();
		return false;
	}
	return true;
}

function goPrint(contentFlag){
	var path = new String(location.pathname);
	var fileName = path.substring(path.lastIndexOf("/")+1,path.length);
	
	if(fileName == "print.aspx"){
		window.print();
	}else{
		window.open("print.aspx?contentFlag="+contentFlag,"printPage","width=585,height=500,scrollbars=yes");
	}
}
function changeLayerImage(o,s){
		
	for(var i=0;i<document.images.length;i++){
		if(document.images[i].name.indexOf("ImageL") > -1){
			if(document.images[i].name==o){
				document.images[i].src="/Layer/img/"+s+"-1.gif";
			}else{
				var tmp="";
				switch(document.images[i].name){
					case "ImageL2" :
						tmp = "/Layer/img/2.gif";
						break;
					case "ImageL3" :
						tmp = "/Layer/img/3.gif";
						break;
					case "ImageL4" :
						tmp = "/Layer/img/4.gif";
						break;
				}
				document.images[i].src=tmp;
			}
		}
	}
}
function checkEmail(input) {
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    if (input.search(format) == -1) {
        return true;
    }
	else if (input.charAt(input.indexOf('@')+1)=='.')
		return true;
    return false;
}

function SplitToNull(obj){
	var v = new String(obj.value);
	var nV="";
	for(var i=0;i<v.length;i++){
		if(v.charCodeAt(i)!=32){
			nV += v.charAt(i);
		}
	}
	obj.value = nV;
}



//Ç÷´çÃøÁ¤±â ¼±ÅÃ°ü·Ã
function openSelectMachine(){
	var p=window.open('/member/selectCheckMachine.aspx','selectMachine','top=0,left=0,width=800, height=580, scrollbars=0')
	p.focus();
}
function clearCheckMachine(){
	for(var i=document.serverForm.glucoseCheckmachine.options.length-1;i>0;i--){
		document.serverForm.glucoseCheckmachine.options[i] = null;
	}
}
function appendCheckMachine(v){
	var isDup = false;
	for(var i=0;i<document.serverForm.glucoseCheckmachine.options.length;i++){
		if(document.serverForm.glucoseCheckmachine.options[i].value == v){
			isDup = true;
			break;
		}
	}
	if(!isDup)
		document.serverForm.glucoseCheckmachine.options[document.serverForm.glucoseCheckmachine.options.length] = new Option(v,v);
}
function delCheckMachine(){
	for(var i=document.serverForm.glucoseCheckmachine.options.length-1;i>0;i--){
		if(document.serverForm.glucoseCheckmachine.options[i].selected==true)
		{
			document.serverForm.glucoseCheckmachine.options[i] = null;
		}
	}
}

function checkImage(v)
{
	var regImage = /\.(gif|jpg|jpeg|bmp)$/i;

	if (v.match(regImage)) 
		return true;
	else 
		return false;
}

function closeFrame(name){
	var obj = document.getElementById(name);
	obj.style.visibility = "hidden";
}

function shop()
{
	var url = "/member/shop_jung.asp"
	popup = window.open(url, "shop", "menubar=0, toolbar=0,location=0,directory=0,scrollbars=yes,resizable=0, left=300,top=0,width=615,height=673");
	popup.focus();
}	
function gaein_jung(){
	var f = window.open('/member/gaein_jung_new.asp','',',scrollbars=1,resizable=0, width=620,height=673');
	f.focus();
}
function ReturnFalse()
{
	var loc = new String(location.href);
	var pos = loc.indexOf("/", 8);
	
	loc = loc.substring(pos+1, loc.length-1);
	pos = loc.indexOf("/", 0);

	loc = loc.substring(0, pos);
	
	if(loc.toLowerCase() == "join_in")
	{
		return true;
	}
	return false;
}

