// Àü¿ª º¯¼ö
var errmsg = "";
var errfld;

// ÇÊµå °Ë»ç
function check_field(fld, msg) {
    if ((fld.value = trim(fld.value)) == "") 			   
        error_field(fld, msg);
    else
        clear_field(fld);
    return;
}

// ÇÊµå ¿À·ù Ç¥½Ã
function error_field(fld, msg) {
    if (msg != "")
        errmsg += msg + "\n";
    if (!errfld) errfld = fld;
    fld.style.background = "#EEEEEE";
}

// ÇÊµå¸¦ ±ú²ýÇÏ°Ô
function clear_field(fld) {
    fld.style.background = "#FFFFFF";
}

function trim(s){
	var t = "";
	var from_pos = to_pos = 0;

	for (i=0; i<s.length; i++)	{
		if (s.charAt(i) == ' ')
			continue;
		else 	{
			from_pos = i;
			break;
		}
	}

	for (i=s.length; i>=0; i--)	{
		if (s.charAt(i-1) == ' ')
			continue;
		else 	{
			to_pos = i;
			break;
		}
	}	

	t = s.substring(from_pos, to_pos);
	//				alert(from_pos + ',' + to_pos + ',' + t+'.');
	return t;
}

// ÀÚ¹Ù½ºÅ©¸³Æ®·Î PHPÀÇ number_format Èä³»¸¦ ³¿
// ¼ýÀÚ¿¡ , ¸¦ Ãâ·Â
function number_format(data) {
    var tmp = '';
    var number = '';
    var cutlen = 3;
    var comma = ',';
    var i;

    len = data.length;
    mod = (len % cutlen);
    k = cutlen - mod;
    for (i=0; i<data.length; i++) 	{
        number = number + data.charAt(i);
        if (i < data.length - 1) {
            k++;
            if ((k % cutlen) == 0) 	{
                number = number + comma;
                k = 0;
            }
        }
    }

    return number;
}

// E-Mail °Ë»ç
function email_check(email) {
    if (email.value.search(/(\S+)@(\S+)\.(\S+)/) == -1)
        return false;
    else
        return true;
}

// ÁÖ¹Îµî·Ï¹øÈ£ °Ë»ç
function jumin_check(j1, j2) {
    if (j1.value.length<6 || j2.value.length<7)
        return false;

    var sum_1 = 0;
    var sum_2 = 0;
    var at=0;
    var juminno= j1.value + j2.value;
    sum_1 = (juminno.charAt(0)*2)+
            (juminno.charAt(1)*3)+
            (juminno.charAt(2)*4)+
            (juminno.charAt(3)*5)+
            (juminno.charAt(4)*6)+
            (juminno.charAt(5)*7)+
            (juminno.charAt(6)*8)+
            (juminno.charAt(7)*9)+
            (juminno.charAt(8)*2)+
            (juminno.charAt(9)*3)+
            (juminno.charAt(10)*4)+
            (juminno.charAt(11)*5);
    sum_2=sum_1%11;

    if (sum_2 == 0) 	{
        at = 10;
    } 
	else 	{
        if (sum_2 == 1) 
            at = 11;
		else 
            at = sum_2;
    }
    att = 11 - at;
    if (juminno.charAt(12) != att) 	{
        return false;
    }

    return true
}

// »õ Ã¢
function popup_window(url, winname, opt){
    window.open(url, winname, opt);
}

// ¿ìÆí¹øÈ£ Ã¢
function popup_zip(frm_name, frm_zip1, frm_zip2, frm_addr, rel_dir, top, left){
	url = rel_dir+'/zip.php?frm_name='+frm_name+'&frm_zip1='+frm_zip1+'&frm_zip2='+frm_zip2+'&frm_addr='+frm_addr;
	opt = 'scrollbars=yes,width=513, height=400,top='+top+',left='+left;
	popup_window(url, "winzip", opt);
}


// Æû¸ÞÀÏ Ã¢
function popup_formmail(url){
	opt = 'scrollbars=yes,width=417,height=385,top=10,left=20';
	popup_window(url, "wformmail", opt);
}

// Å«ÀÌ¹ÌÁö Ã¢
function popup_large_image(it_id, width, height){
	var top = 10;
	var left = 10;
	url = "large_image.php?it_id=" + it_id;
	width = width;
	height = height;
	opt = 'scrollbars=no,width='+width+',height='+height+',top='+top+',left='+left;
	popup_window(url, "largeimage", opt);
}

// , ¸¦ ¾ø¾Ø´Ù.
function no_comma(data){
	var tmp = '';
    var comma = ',';
    var i;

	for (i=0; i<data.length; i++)	{
		if (data.charAt(i) != comma)
		    tmp += data.charAt(i);
	}
	return tmp;
}

// »èÁ¦ °Ë»ç È®ÀÎ
function del(href) {
    if(confirm("Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) 
        document.location.href = href;
}
function del_item(href) {
	if(confirm("ÇØ´ç»óÇ°ÀÇ ÁÖ¹®³»¿ª¿¡ »ó°ü¾øÀÌ »óÇ°ÀÌ »èÁ¦µË´Ï´Ù. \n»óÇ° »èÁ¦ÈÄ¿¡´Â ¿¹±âÄ¡ ¾ÊÀº ¿À·ù°¡ ¹ß»ýÇÒ¼ö ÀÖ½À´Ï´Ù\n\n±×·¡µµ Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) 
	        document.location.href = href;
}
// ÄíÅ° ÀÔ·Â
function set_cookie(name, value, expirehours) {
	var today = new Date();
	today.setTime(today.getTime() + (60*60*1000*expirehours));
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
}

// ÄíÅ° ¾òÀ½
function get_cookie(name) {
    var find_sw = false;
    var start, end;
    var i = 0;

	for (i=0; i<= document.cookie.length; i++)	{
		start = i;
		end = start + name.length;

		if(document.cookie.substring(start, end) == name) 		{
			find_sw = true
			break
		}
	}

    if (find_sw == true) 	{
        start = end + 1;
        end = document.cookie.indexOf(";", start);

        if(end < start)
            end = document.cookie.length;

        return document.cookie.substring(start, end);
    }
    return "";
}

// ÄíÅ° Áö¿ò
function delete_cookie(name) {
	var today = new Date();

	today.setTime(today.getTime() - 1);
	var value = getCookie(name);
	if(value != "")
		document.cookie = name + "=" + value + "; path=/; expires=" + today.toGMTString();
}

function receipt_apply(od_id, od_uid,width,height) {
	var top = 10;
	var left = 10;
	var od_id, od_uid;
	url = "card/INIreceipt/INIreceipt_apply.php?od_id=" + od_id+"&od_uid="+od_uid;
	opt = 'scrollbars=no,width='+width+',height='+height+',top='+top+',left='+left;
	window.open(url, "receipt_apply", opt);
}

function reciept_view(receipt_id) {// Çö±Ý ¿µ¼öÁõ Ãâ·Â
	var showreceiptUrl = "https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid="+receipt_id+ "&clpaymethod=22";
	window.open(showreceiptUrl,"showreceipt","width=380,height=540, scrollbars=no,resizable=no");
}

// ¶óÀÎ »ö±ò...
function setPointer(theRow, thePointerColor){
	if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
       return false;
    }

    var row_cells_cnt = theRow.cells.length;
    for (var c = 0; c < row_cells_cnt; c++) {
        theRow.cells[c].bgColor = thePointerColor;
    }
}