// cookie
function getCookie(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) {
		// if there are any cookies
		var offset = document.cookie.indexOf(search);
		if (offset != -1) {
			// if cookie exists
			offset += search.length;
			// set index of beginning of value
			var end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
}

// set cookie
function setCookie(name, value, domain, path, expire) {
	currentDate = new Date();
	pathValue = path == null ? "/" : path;
	domainValue = domain == null ? null : domain;
	
	if (expire != null && expire.length > 0) currentDate.setDate( currentDate.getDate() + expire );
	
	document.cookie = 
		name + "=" + escape(value) + 
		((domainValue == null) ? "" : ("; domain="+domainValue) ) +
		((expire == null) ? "" : ("; expires=" + currentDate.toGMTString())) + 
		"; path="+pathValue+";"
}

// get string's byte length
function getByteLength(strVal) {
	return (strVal.length+(escape(strVal)+"%u").match(/%u/g).length-1);
}

// whether strValue has alpha
function hasAlpha(strValue) {
	var charStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	strValueUpper = strValue.toUpperCase();
	for (i = 0 ; i < strValueUpper.length ; i++){
		if(charStr.indexOf(strValueUpper.charAt(i)) >= 0 ) {
			return true;
		}
	}//for		
	return false;
}

// whether strValue has number
function hasNumber(strValue) {
	var charStr = "0123456789";
	for (i = 0 ; i < strValue.length ; i++){
		if(charStr.indexOf(strValue.charAt(i)) >= 0 ) {
			return true;
		}
	}//for		
	return false;
}

// whether strValue only contains alpha + number
function checkAlphaNum(strValue){
	var charStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	strValueUpper = strValue.toUpperCase();
	for (i = 0 ; i < strValueUpper.length ; i++){
		if(charStr.indexOf(strValueUpper.charAt(i)) == -1){
			return false;
		}
	}//for		
	return true;
}

function checkAlpha(strValue){
	var charStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	strValueUpper = strValue.toUpperCase();
	for(i=0; i < strValueUpper.length; i++){
		if(charStr.indexOf(strValueUpper.charAt(i)) == -1){
			return false;
		}
	}//for		
	return true;
}

// whether strVal only contains number
function checkNum(strVal){
	var numStr = "0123456789";
	for(i=0; i < strVal.length; i++){
		if(numStr.indexOf(strVal.charAt(i)) == -1){
			return false;
		}
	}
	return true;
}



//popup window
function openWindow(page, width, height) {
    var bannerWin = window.open(page,"popupWin","resizable=no,scrollbars=yes,width= " + width + ",height=" + height) ;
    browser_name = navigator.appName ;
    if (browser_name == "Netscape" ) {
    	bannerWin.focus() ;
    }
}

//³¯Â¥Ã¼Å© (20050101, 2005-01-01)
function chkDate(obj) {
  var input = obj.replace(/-/g,"");
  var inputYear = input.substr(0,4);
  var inputMonth = input.substr(4,2) - 1;
  var inputDate = input.substr(6,2);
  var resultDate = new Date(inputYear, inputMonth, inputDate);
  if ( resultDate.getFullYear() != inputYear ||
       resultDate.getMonth() != inputMonth ||
       resultDate.getDate() != inputDate) {
       alert('³¯Â¥Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù');
       return false;
  }
  return true;
}	

//¿À´Ã³¯Â¥¾ò±â
function getToday(){
   today = new Date();
   var Year = today.getFullYear();
   var Month = today.getMonth() +1;
   if(Month < 10) Month = "0" + Month;
   var Day = today.getDate();
   if(Day < 10) Day = "0" + Day;	   	   	   
   return Year + "" + Month + "" + Day;
}

// write object, embed, applet tag
function writeObjTag(objName)
{
	document.write(document.getElementById(objName).value);
}

function openPopup(url, width, height) {
	var winLeft = screen.width / 2 - (width / 2);
	var winTop = screen.height / 2 - (height / 2) - 20;
	if (winTop < 0) winTop = 10;
	
	uphotoWindow = window.open(
		url, 
		'', 
		'left='+winLeft+',top='+winTop+',width='+width+',height='+height+',resizable=no,menubar=no,scrollbars=no,status=no,toolbar=no,location=no,directories=no');
}
