function loginConfirm(perURL) {
		//location.href='/mall/logon/login.php?path='+perURL;

	popupwidth = 400;
	popupheight = 830;
	LeftPosition = (screen.width) ? (screen.width-popupwidth)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-popupheight)/2 : 0;
	settings = 'height='+ popupheight +',width='+popupwidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no, resizable=no, location=no';
	if(confirm('로그인 후 사용하실 수 있습니다.\n\n로그인 하시겠습니까?')) 
		window.open('/pages/etc/popup_login.php?path=' + encodeURIComponent(perURL),'',settings);
}

function bookMark() {
	var title = document.title;
	var url = "http://www.dchoney.co.kr"; //window.location.href;

    //파이어폭스~! 
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	}

    //익스플로어
    else if( window.external ) {
		window.external.AddFavorite( url, title);
    }   

}

function idpwsearch()
{
	
	popupwidth = 400;
	popupheight = 830;
	LeftPosition = (screen.width) ? (screen.width-popupwidth)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-popupheight)/2 : 0;
	settings = 'height='+ popupheight +',width='+popupwidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no, resizable=no, location=no';
	//if(confirm('로그인 후 사용하실 수 있습니다.\n\n로그인 하시겠습니까?')) 
		window.open('/mall/members/membersearch.php','',settings);
	
}



function ChangeImg(img)
{
	$('#big_img').attr('src', img);
}

function imgOpen(imgPath)
{
	var winHandle = window.open("" ,"KG옐로우캡몰","toolbar=no,scrollbars=no,resizable=no, top=200, left=200, width=100, height=85");

	if(winHandle != null) {
		var htmlString = "<script language='javascript'>\n";
		htmlString += "<!--\n";
		htmlString += "function resize() {\n";
		htmlString += "window.resizeTo(document.popup.width, document.popup.height);\n}\n";
		htmlString += "//-->\n";
		htmlString += "</script>\n";
		htmlString += "<html><head><title>KG옐로우캡몰</title></head>\n";
		htmlString += "<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>\n";
		htmlString += "<a href=javascript:window.close()><img src=" + imgPath + " name='popup' border=0 alt=이미지클릭:화면닫기 onload='resize();'></a>\n";
		htmlString += "</body></html>";
		winHandle.document.open();
		winHandle.document.write(htmlString);
		winHandle.document.close();
	} 

	if(winHandle != null) winHandle.focus();
	return winHandle;
}

function showPayPopup(code)
{
	popupwidth = 417;
	popupheight = 632;
	LeftPosition = (screen.width) ? (screen.width-popupwidth)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-popupheight)/2 : 0;
	settings = 'height='+ popupheight +',width='+popupwidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no, toolbar=no, menubar=no,resizable=no, location=no';

	window.open('/mall/products/order_pop.php?code=' + code,'_blank',settings);
}

function showFreeEventPopup()
{
	popupwidth = 400;
	popupheight = 660;
	LeftPosition = (screen.width) ? (screen.width-popupwidth)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-popupheight)/2 : 0;
	settings = 'height='+ popupheight +',width='+popupwidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no, resizable=no, location=no';

	window.open('/pages/etc/event_myhoney.php','',settings);
}

//김인곤 수정(type 추가)
function showlogin(targeturl,type)
{
	popupwidth = 400;
	popupheight = 830;
	LeftPosition = (screen.width) ? (screen.width-popupwidth)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-popupheight)/2 : 0;
	settings = 'height='+ popupheight +',width='+popupwidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no, resizable=no, location=no';

	window.open('/pages/etc/popup_login.php?path=' + targeturl + '&type=' + type,'',settings);
}


function showlogin2(targeturl,code,type)
{
	popupwidth = 400;
	popupheight = 830;
	LeftPosition = (screen.width) ? (screen.width-popupwidth)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-popupheight)/2 : 0;
	settings = 'height='+ popupheight +',width='+popupwidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no, toolbar=no, menubar=no, resizable=no, location=no';

	window.open('/pages/etc/popup_login.php?path=' + targeturl + '&code=' + code + '&type=' + type,'_blank',settings);
}
//김인곤 수정 끝(type 추가)

function sendTwitter(title,url) {
	var wp = window.open("http://twitter.com/home?status=" + encodeURIComponent(title) + " " + encodeURIComponent(url), 'twitter', '');
	if ( wp ) {
		wp.focus();
	}
}
function sendMe2Day(title,url,tag) {
	title = "\""+title+"\":"+url;
	var wp = window.open("http://me2day.net/posts/new?new_post[body]=" + encodeURIComponent(title) + "&new_post[tags]=" + encodeURIComponent(tag), 'me2Day', '');
	if ( wp ) {
		wp.focus();
	}
}
function sendFaceBook(title,url) {
	var wp = window.open("http://www.facebook.com/sharer.php?u=" + url + "&t=" + encodeURIComponent(title), 'facebook', '');
	if ( wp ) {
		wp.focus();
	}
}
function sendCyWorld(no) {
	
}
function sendSms(title,code,id) {
	if(id == ""){
		var wp = window.open("/pages/etc/tosms_logout.php?code="+code+"&title="+encodeURIComponent(title),"","width=400px,height=345px")
	}else{
		var wp = window.open("/pages/etc/tosms.php?code="+code+"&title="+encodeURIComponent(title),"","width=400px,height=340px")
	}
	if ( wp ) {
		wp.focus();
	}
}

function sendMail(title,code) {

	var wp = window.open("/pages/etc/tomail.php?code="+code+"&title="+encodeURIComponent(title),"","width=445px,height=420px")
	if ( wp ) {
		wp.focus();
	}
}

function goCyWorld(title,url,thumb,textrecomm) {
	/*
	var href = "http://api.cyworld.com/openscrap/post/v1/?xu=http://<?=$_SERVER[HTTP_HOST]?>/cyworldApi.php?code=" + code +"&sid=s0300011";
	var a = window.open(href, 'cyworld', 'width=450,height=410');
	if ( a ) {
		a.focus();
	}
	*/
	//alert('test');
	//window.open('http://csp.cyworld.com/bi/bi_recommend_pop.php?url=http://dchoney.co.kr&area=28&title=&thumbnail=http://tmon.co.kr/prodimg/mainimg/Title_img%5B446%5D.jpg&summary=W%2By9lOyXkeyKpF0g66Gv642w7L2U7JeR7Iqk66m07IS47KCQ7JeQ7IScIOyCrOyaqe2VoCDsiJgg7J6I64qUIO2YhOq4iOydtCA0MCUg7ZWg7J2465CcIOqwgOqyqeyXkCDrgrQg7IaQ7Jy866GcIOuTpOyWtOyYqOuLpH4hISEg66Gv642w7L2U7JeR7Iqk66m07IS47KCQIDUwLjasdfasdfAwMOybkasdfasdfasdfasdfasdfasdfasdfCA0MCXtlaDsnbg%3D&writer=');
	window.open('http://csp.cyworld.com/bi/bi_recommend_pop.php?url=' + encodeURIComponent(url) + '&title=&thumbnail='+encodeURIComponent(thumb)+'&summary='+encodeURIComponent(textrecomm), 'recom_icon_pop', 'width=400,height=364,scrollbars=no,resizable=no');
}
function goYozmDaum(link,prefix,parameter) {
				var href = "http://yozm.daum.net/api/popup/prePost?link=" + encodeURIComponent(link) + "&prefix=" + encodeURIComponent(prefix) + "&parameter=" + encodeURIComponent(parameter);
				var a = window.open(href, 'yozmSend', 'width=466, height=356');
				if ( a ) {
					a.focus();
				}
}
function myHoney(title,code,id) {
	if(id == ""){
		var wp = window.open("/pages/etc/myhoney_logout.php?code="+code+"&title="+encodeURIComponent(title),"","width=400px,height=360px")
	}else{
		var wp = window.open("/pages/etc/myhoney_login.php?code="+code+"&title="+encodeURIComponent(title),"","width=400px,height=360px")
	}
	if ( wp ) {
		wp.focus();
	}
}

function feedFunc(frm) {

	if(!frm.emailCheck.checked && !frm.smsCheck.checked) {
		alert('이메일과 핸드폰중 구독을 원하시는 항목을 선택하여주세요');
		return false;
	}

	if(frm.emailCheck.checked) {
		if(!frm.feedEmail.value) {
			alert('받으실 이메일을 입력해주시기 바랍니다.');
			frm.feedEmail.focus();
			return false;
		} else {
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

			if (!filter.test(frm.feedEmail.value)) { 
				alert('잘못된 이메일 입니다.');
				frm.feedEmail.focus();
				return false; 
			}
		}
	} 

	if(frm.smsCheck.checked) {
		if(!frm.feedSms.value) {
			alert('받으실 핸드폰번호를 입력해주시기 바랍니다.');
			frm.feedSms.focus();
			return false;
		} else {

			if(frm.feedSms.value.length > 3) {
				head = frm.feedSms.value.substr(0,3);
				if(head != "010" && head != "011" && head != "016" && head != "017" && head != "018" && head != "019") {
					alert('핸드폰구독은 010, 011, 016, 017, 018, 019만 서비스가 가능합니다.');
					frm.feedSms.focus();
					return false;
				}
			}
		}
	}			

	if(!confirm('구독신청을 하시겠습니까?')) return false;

	return true;
	
}
function toCheck(obj) {
	if(!obj.value) return;

	var printStr = "";
	var isAlert = "";
	strlen = obj.value.length;
	for(i=0;i<strlen;i++) {
		strTmp = obj.value.substr(i,1);
		if((isNaN(strTmp) && strTmp != "-") || strTmp == " ") {
			if(!isAlert) alert('숫자와 대시(-) 만 입력할수 있습니다.');
			isAlert = "1";
		} else {
			printStr = printStr + String(strTmp);
		}
	}
	
	if(isAlert) obj.value = printStr;

	return;
}

// request 객체 생성
var req = null;
function create_request() {
		var request = null;
		try {
				request = new XMLHttpRequest();
		} catch (trymicrosoft) {
				try {
						request = new ActiveXObject("Msxml12.XMLHTTP");
				} catch (othermicrosoft) {
						try {
								request = new ActiveXObject("Microsoft.XMLHTTP");
						} catch (failed) {
								request = null;
						}
				}
		}
		if (request == null)
				alert("Error creating request object!");
		else
				return request;
}



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_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}


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; }
}

function Error_Func() {
	alert('로그인 후 사용하실 수 있습니다.   ');
}

function openwindow(name,url,width,height,scrollbar) {
	scrollbar_str = scrollbar ? 'yes' : 'no';
	window.open(url,name,'width='+width+',height='+height+',scrollbars='+scrollbar_str);
}

function authFunction() {
	alert('해당 게시판에 대한 권한이 없습니다.   ');
}

// 금액에 세자리마다 콤마를 적어준다.
String.prototype.comma=function() 
{ 

var l_text=this; 
var l_pattern=/^(-?\d+)(\d{3})($|\..*$)/; 

  if(l_pattern.test(l_text)){ 
    l_text=l_text.replace(l_pattern,function(str,p1,p2,p3) 
    { 
      return p1.comma() + ("," + p2 + p3); 
    }); 
  } 

  return l_text; 

} 
