var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

/*** ±âº» ÇÔ¼ö ***/
function $(o){ return document.getElementById(o); }
function evalJSON(str){ return eval('(' + str + ')'); }
function getInnerText(o){ return o.textContent ? o.textContent : o.innerText; }

/*** ÀÌº¥Æ® Ãß°¡ ***/
function bindEvent(element, event, callback){
	if (element.addEventListener) element.addEventListener(event, callback, false); 
	else if (element.attachEvent) element.attachEvent("on" + event, callback);
}

/*** ÇÃ·¡½Ã º¸Á¤ ***/
function embed(src,width,height,vars){
	document.write('\
	<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+width+'" HEIGHT="'+height+'">\
	<PARAM NAME=movie VALUE="'+src+'">\
	<PARAM NAME=quality VALUE=high>\
	<PARAM NAME=wmode VALUE=transparent>\
	<PARAM NAME=bgcolor VALUE=#FFFFFF>\
	<PARAM NAME=allowScriptAccess VALUE="always">\
	<param name=flashvars value="' + vars + '">\
	<EMBED src="'+src+'" quality=high bgcolor=#FFFFFF wmode=transparent allowScriptAccess=always WIDTH="'+width+'" HEIGHT="'+height+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" flashvars="' + vars + '"></EMBED>\
	</OBJECT>\
	');
}

/*** ÄÞ¸¶ Ãâ·Â ***/
function comma(x){
	var temp = "", co = 3;
	var x = String(uncomma(x));
	var num_len = x.length;
	while (num_len>0){
		num_len = num_len - co;
		if (num_len<0){
			co = num_len + co;
			num_len = 0;
		}
		temp = ","+x.substr(num_len,co)+temp;
	}
	return temp.substr(1);
}

/*** ÄÞ¸¶ ¹ÌÃâ·Â ***/
function uncomma(x){
	var reg = /(,)*/g;
	x = parseInt(String(x).replace(reg,""),10);
	return (isNaN(x)) ? 0 : x;
}

/*** ¿ìÆí¹øÈ£ ÆË¾÷ ***/
function popupZipcode(rfunc){
	if (!rfunc) rfunc = "zipcode_return";
	window.open('/module/zipcode.php?rfunc='+rfunc,'','width=400,height=350,scrollbars=0');
}
function zipcode_return(){
	var fm = document.fm;
	var zipcode = arguments[0].split("-");
	fm['zipcode[]'][0].value = zipcode[0];
	fm['zipcode[]'][1].value = zipcode[1];
	fm.address.value = arguments[1];
	if (fm.address_sub){
		fm.address_sub.value = "";
		fm.address_sub.focus();
	} else {
		fm.address.focus();
		fm.address.value += " ";
	}
}

/*** ¿ÀºêÁ§Æ® À§Ä¡ ***/
function get_objectTop(obj){
	if (obj.offsetParent==document.body || obj==document.body) return obj.offsetTop;
	else return obj.offsetTop + get_objectTop(obj.offsetParent);
}
function get_objectLeft(obj){
	if (obj.offsetParent==document.body) return obj.offsetLeft;
	else return obj.offsetLeft + get_objectLeft(obj.offsetParent);
}

/*** ÄíÅ° ***/
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 setCookie (name, value) { 
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}