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

function $(o){ return document.getElementById(o); }
function evalJSON(str){ return eval('(' + str + ')'); }

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

function getInnerText(o){
  return o.textContent ? o.textContent : o.innerText;
}

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>\
	');
}


/*** »óÇ° ½ºÅ©·Ñ ***/
var eScroll = function(id,param)
{
	/******************************************************************
	 * eScroll Script v1.0
	 * by mirrh (imirrh@gmail.com)
	 *****************************************************************/
	this.param = {
		itemsize	: 100,	// °³´ç ¾ÆÀÌÅÛ »çÀÌÁî(°¡·Î ¶Ç´Â ¼¼·Î pixel)
		direction	: 'h',	// ½ºÅ©·Ñ ¹æÇâ (h:°¡·Î, v:¼¼·Î)
		speed		: 2,	// ½ºÅ©·Ñ ¼Óµµ (ÇÑ¹ø¿¡ ÀÌµ¿µÇ´Â pixel)
		delay		: 100	// ¾ÆÀÌÅÛÀÌ Àá±ñ ¸ØÃß´Â ½Ã°£
	};
	for (var x in param) this.param[x] = param[x];

	var _self = this;
	var box = document.getElementById(id), ul = box.getElementsByTagName('ul')[0];
	var sleep = 0, ea = 0, cutline = 0, move_stop = 0, course = 1;

	/*** mouse event ***/
	box.onmouseover = function(){_self.stop_move(1)}
	box.onmouseout = function(){_self.stop_move(0)}

	if (this.param.direction=="h") box.scrollLeft = 0;
	else box.scrollTop = 0;

	this.scroll = function(){
		var pos = (this.param.direction=="h") ? box.scrollLeft : box.scrollTop;
		if (move_stop || (pos%this.param.itemsize==0 && ++sleep<this.param.delay)) return;
		sleep = 0; pos = pos + course * this.param.speed;
		if (pos>=cutline) pos = 0;
		else if (pos<=0) pos = cutline;
		if (this.param.direction=="h") box.scrollLeft = pos;
		else box.scrollTop = pos;
	}
	this.setLayout = function(ea){
		ul.style.cssText = "list-style: none; margin:0; padding:0;";
		ul.style.width = cutline * 2;
		if (this.param.vitem_ea && this.param.vitem_ea<=ea) ul.innerHTML += ul.innerHTML;
	}
	this.setDirection = function(idx){ sleep = this.param.delay; course = idx; }
	this.stop_move = function(idx){ move_stop = idx; }
	this.init = function(){
		ea = ul.getElementsByTagName('li').length;
		cutline = ea * this.param.itemsize;
		this.setLayout(ea);
		setInterval(function(){_self.scroll()},10);
	}
	this.init();
}