﻿// 쿠키 받기 함수
function getCookie(strname)
{
	var nameOfCookie = strname + "=";
	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 setCookie(name, value, expire)
{
	var tDate = new Date();
	tDate.setDate(tDate.getDate() + expire);
	document.cookie = name + "=" + escape(value) + ";path=/;expires="+tDate.toGMTString()+";"
}

                                       
function sendfocuscolor(objname)
{
	objname.style.backgroundColor = "#F5F5F5";
}

                                    
function sendblurcolor(objname)
{
	objname.style.backgroundColor = "#FFFFFF";
}

                             
function sendlistfocuscolor(objname)
{
	objname.style.background = "#F5F5F5";
}

                           
function sendlistblurcolor(objname)
{
	objname.style.background = "#FFFFFF";
}

                     
function checkkorean(strvalue)
{
	var i = 0;
	var str = /[가-힣]/;
	while(i < strvalue.length)
	{
		if(!str.test(strvalue.charAt(i)))
			return true;
		i++;
	}
	return false;
}

                  
function checkid(strvalue)
{
	var str = /[A-Za-z0-9]/;
	var i = 0
	while(i < strvalue.length)
	{
		if(!str.test(strvalue.charAt(i)))
		{
			return true;
			break;
		}
		i++;
	}
	if(strvalue.length < 4)
		return true;
	return false;
}

                       
function checkpwd(strvalue)
{
	if(checkspace(strvalue))
		return true;
	if(strvalue.length < 4)
		return true;
	return false;
}

                           
function checkresidentno(strvalue)
{
	var str = /\d{6}[1-4]\d{6}/;
	if(str.test(strvalue))
	{
		var check = new Array(13);
		var key = new Array(2,3,4,5,6,7,8,9,2,3,4,5);
		var sum = 0;
		for(var i=0; i<13; i++)
			check[i] = parseInt(strvalue.charAt(i),10);
		for(var i=0; i<12; i++)
			sum += check[i] * key[i];
		var rs = (11-(sum%11)) % 10
		if(rs != check[12])
			return true;
		return false;
	}
	return true;
}

                     
function checkspace(strvalue)
{
	var str = /[ \n\r]/;
	var i = 0;
	var count = 0;
	while(i < strvalue.length)
	{
		if(str.test(strvalue.charAt(i)))
			count++;
		i++;
	}
	if(count == strvalue.length)
		return true;
	else
		return false;
}

                     
function checkdigit(strvalue, size)
{
	var str = /[0-9]/;
	for(var i=0; i<strvalue.length; i++)
	{
		if(!str.test(strvalue.charAt(i)))
			return true;
	}
	if(strvalue.length < size)
		return true;
	return false;
}

                     
function checkdigit1(strvalue)
{
	var str = /[0-9]/;
	for(var i=0; i<strvalue.length; i++)
	{
		if(!str.test(strvalue.charAt(i)))
			return true;
	}
	return false;
}

                     
function checkfloat(strvalue)
{
    var str = /[0-9\.]/;
	for(var i=0; i<strvalue.length; i++)
	{
		if(!str.test(strvalue.charAt(i)))
			return true;
	}
	return false;
}
                     
function checkmail(strvalue)
{
	var str = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	if(!str.test(strvalue))
		return true;
	return false;
}

                     
function checkphoneddd(strvalue)
{
	var str = /02|031|032|033|041|042|043|051|052|053|054|055|061|062|063|064/;
	if(str.test(strvalue))
		return false;
	else
		return true;
}

                  
function checkmobileddd(strvalue)
{
	var str = /010|011|012|015|016|017|018|019/;
	if(str.test(strvalue))
		return false;
	else
		return true;
}

             
function checkurl(strvalue)
{
	var str = /http:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/;
	if(str.test(strvalue))
		return false;
	else
		return true;
}

                                 
function checkimage(strvalue)
{
	var str = /gif|jpg|jpeg|png/;
	if(strvalue.lastIndexOf(".") > -1)
	{
		strvalue = strvalue.substr(strvalue.lastIndexOf(".") + 1,strvalue.length - strvalue.lastIndexOf(".") - 1).toLowerCase();
		if(str.test(strvalue))
			return false;
		else
			return true;
	}
	else
		return true;
}

                               
function checkcurrency(intvalue)
{
	var strvalue = intvalue.toString();
	var commalocation = strvalue.length % 3;
	if(commalocation > 0)
	{
		var returnvalue = strvalue.substring(0,commalocation);
		if(strvalue.length > 3)
			returnvalue += ",";
	}
	else
		returnvalue = "";
	for(var i=commalocation; i < strvalue.length; i+=3)
	{
		returnvalue += strvalue.substring(i, i+3);
		if(i < strvalue.length - 3)
			returnvalue += ",";
	}
	return returnvalue;
}

                          
function sendclose()
{
	window.close(this);
	return false;
}

                                        
function sendpopupclose(strname,strdays)
{ 
    setCookie( strname, "done" , strdays);                                           
    window.close();
}

                       
function sendback()
{
	window.history.back();
	return false;
}

                                           
function sendkeypress(value)
{
    if(window.event.keyCode == 13)
    {
        var objbtn = document.getElementById(value);
        objbtn.click();
    }
}

                
function sendcancel(strmsg, strlocation)
{
	if(confirm(strmsg))
		window.location.href = strlocation;
}

                                             
function sendopen(strurl, strid, intwidth, intheight, strresizable, strscrollbars, boolreplace)
{
	var top = window.screen.availHeight / 2 - intheight / 2;
	var left = window.screen.availWidth / 2 - intwidth / 2;
	var objwin = window.open(strurl,strid,"top=" + top + ",left=" + left + ",width=" + intwidth + ",height=" + intheight + ",location=no,menubar=no,resizable=" + strresizable + ",scrollbars=" + strscrollbars + ",status=no,titlebar=no,toolbar=no",boolreplace);
	objwin.focus();
}

                                          
function sendpopupopen(strurl, strid, intleft, inttop, intwidth, intheight, strresizable, strscrollbars, boolreplace)
{
	var objwin = window.open(strurl,strid,"top=" + inttop + ",left=" + intleft + ",width=" + intwidth + ",height=" + intheight + ",location=no,menubar=no,resizable=" + strresizable + ",scrollbars=" + strscrollbars + ",status=no,titlebar=no,toolbar=no",boolreplace);
}
