<!--
function layerScroll() {

	this.name = "";						//·¹ÀÌ¾î ÀÌ¸§
	this.itemcount = 0;					//·¹ÀÌ¾î º¯¼ö
	this.item_icount = 0;				//·¹ÀÌ¾î ÀüÃ¼°¹¼ö
	this.item_istart = 1;				//ÃÖÃÊ ·¹ÀÌ¾î
	this.currentspeed = 0;				//·¹ÀÌ¾î ½Ã°£º¯¼ö
	this.scrollspeed = 50;				//·¹ÀÌ¾î µ¿ÀÛ½Ã°£
	this.pausedelay = 1000;				//·¹ÀÌÀú ÁßÁö½Ã°£
	this.pausemouseover = false;
	this.stop = 0;
	this.count=0;
	this.tabname_on = "";				//·¹ÀÌ¾î Tab ÀÌ¸§
	this.tabname_off = "";				//·¹ÀÌ¾î Tab ÀÌ¸§
	this.type = 0;						//·¹ÀÌ¾î Å¸ÀÔ (0 ³»¿ë¸¸ÀÌµ¿, 1 ÇÑ¹ø¸¸½ÇÇà, 2 ÅÇ±îÁöÀÌµ¿ 3 ÇÑ¹ø¸¸½ÇÇà+ÅÇÀÌµ¿)
	
	this.scrollTimeout = null;
	
	this.start = function () {
		this.count = this.item_istart;
		
		this.currentspeed = this.scrollspeed;
		obj = document.getElementById(this.name+this.count).style;
		obj.display='block';
		if ( this.type == '2' || this.type == '3' ) {
			document.getElementById(this.name+'Tab'+this.count).src = this.tabname_on + this.count + '.gif';
		}
		
		//ÇÑ¹ø ½ÇÇà
		if ( this.type == '1' || this.type == '3' ) {
			if ( !this.stop ) {
				this.layerChange('');
			}			
		}
		//¹Ýº¹½ÇÇà
		else {
			scrollTimeout = setTimeout(this.name+'.scroll()',this.currentspeed);
		}
	};

	this.scroll = function () {
		this.currentspeed = this.scrollspeed;
		if ( !this.stop ) {
			this.layerChange('');
		}
		scrollTimeout = setTimeout(this.name+".scroll()",this.currentspeed);
	};

	this.layerChange = function (itemcount)
	{
		if (itemcount.length > 0) {
			this.count = itemcount;
		}
		
		for (k = 1; k <= this.item_icount; k++) {
			obj_i = document.getElementById(this.name+k).style;
			obj_i.display = 'none';
		}
		
		obj_i = document.getElementById(this.name+this.count).style;
		obj_i.display = 'block';
		
		//ÅÇ¿µ¿ª Ç¥½Ã
		if ( this.type == '2' || this.type == '3' ) {
			this.tabChange(this.count);
		}			
		
		if (this.count < this.item_icount) {
			this.count++;
		}
		else {
			this.count = 1;
		}
	}
	
	this.tabChange = function (itemcount)
	{
		for (k = 1; k <= this.item_icount; k++) {
			document.getElementById(this.name+'Tab'+k).src = this.tabname_off + k + '.gif';
		}
		
		document.getElementById(this.name+'Tab'+itemcount).src = this.tabname_on + itemcount + '.gif';
	}

	this.onmouseover = function ()
	{
		if ( this.pausemouseover ) {
			this.stop = 1;
		}
	};

	this.onmouseout = function ()
	{
		if ( this.pausemouseover ) {
			this.stop = 0;
		}
	};

	this.prev = function (itemcount)
	{
		var i;
	
		if (itemcount <= 1) {
			itemcount = this.item_icount;
		}
		else {
			itemcount-- ;
		}
		
		for (i = 1; i <= this.item_icount; i++) {
			obj_i = document.getElementById(this.name+i).style;
			obj_i.display = 'none';
		}
		obj_i = document.getElementById(this.name+itemcount).style;
		obj_i.display = 'block';
		
	}
	this.next = function(itemcount) 
	{
		var i;
		if (itemcount >= this.item_icount) {
			itemcount = 1;
		}
		else {
			itemcount++ ;
		}
		
		for (i = 1; i <= this.item_icount; i++) {
			obj_i = document.getElementById(this.name+i).style;
			obj_i.display = 'none';
		}
		obj_i = document.getElementById(this.name+itemcount).style;
		obj_i.display = 'block';
	}
}

function mp_layerScroll(id) {
	this.id = id;			// ½Äº°¸íÄª
	this.start_idx = -1;		// Default Start Index
	this.delay = 0;					// Time
	this.width = 0;					// width
	this.height = 0;				// height
	this.pausemouseover = true;
	this.swf_m = '';				// Flash mode
	this.scroll_items = 1;
	this.view_items = 1;
	this.scroll_speed = 1;

	this.item_height = 0;
	this.scroll_item_cnt = 0;
	this.current_top_item = 0;
	this.time_id;

	this.m_arr = null;			// ÀÚ·á [0:Type, 1:Resource, 2:Link]
	this.is_pause = false;	// µ¿ÀÛ¿©ºÎ
	this.obj;
	this.is_init = false;
	this.set_data = function (p_arr) { this.m_arr = p_arr; }

	this.init = function () {
		this.obj = document.getElementById(this.id);
		if (!this.obj) { return; }

		var i, ii, n_arr_idx, n_idx;
		var a_data, s_data_type, s_data_res, s_data_link, s_tag, s_tag_all, s_style;

		if (this.m_arr.constructor != Array) { this.m_arr = new Array; }

		this.start_idx = ad_get_cookie(this.id);
		if (!ad_is_number(this.start_idx)) { this.start_idx = ad_get_random_idx(this.m_arr.length); }
		this.start_idx = parseInt(this.start_idx, 10);

		s_tag = '<div id="'+this.id+'_items" style="position:relative; overflow:hidden; width:'+this.width+'; height:'+this.height+';"></div>';
		this.obj.innerHTML = s_tag;
		this.item_height = (this.height/this.view_items);
		s_style = 'style="position:absolute; left:0px; top:0px; display:hidden; width:'+this.width+'; height:'+this.item_height+';"';
		
		this.obj = document.getElementById(this.id + '_items');
		this.obj.ad_obj = this;
		if (this.pausemouseover ==  true) {
			if (!this.obj.onmouseover) { this.obj.onmouseover = function() { this.ad_obj.onmouseover(); } }
			if (!this.obj.onmouseout)  { this.obj.onmouseout =  function() { this.ad_obj.onmouseout(); } }
		}

		n_arr_idx = 0;
		s_tag_all = '';
		for (i = 0; i < this.m_arr.length; i++) {
			n_idx = ((this.start_idx + i) % this.m_arr.length);
			a_data = this.m_arr[n_idx];
			if (a_data.constructor != Array) { continue; }
			if (a_data.length < 2) { continue; }
			s_data_type = a_data[0].toLowerCase();
			s_data_res = a_data[1];
			s_data_link = ((a_data.length == 3) ? a_data[2] : '');
			s_tag = '';
			if (s_data_type == 'img') {       s_tag += ad_get_img_tag(s_data_res); }
			else if (s_data_type == 'swf') {  s_tag += ad_get_swf_tag(s_data_res, this.width, this.height, this.swf_m); }
			else if (s_data_type == 'html') { s_tag += ad_get_html_tag(s_data_res); }
			else { continue; }
			if (s_data_link.length > 0) {     s_tag = ('<a href="'+s_data_link+'" target="_blank">' + s_tag + '</a>'); }
			s_tag = '<div id="'+this.id+'_item'+n_arr_idx+'" ' + s_style + '>' + s_tag + '</div>';
			s_tag_all += s_tag;
			n_arr_idx++;
		}
		this.obj.innerHTML = s_tag_all;

		this.m_arr = new Array;
		for (i = 0; i < n_arr_idx; i++) {
			ii = (i + this.start_idx) % n_arr_idx;
			this.m_arr[i] = document.getElementById(this.id+'_item'+ii);
			this.m_arr[i].style.top = (this.item_height * i);
			this.m_arr[i].style.display = 'block';
		}

		this.is_init = true;
	}
	this.onmouseover = function () { if (this.pausemouseover) { this.is_pause = true;  } }
	this.onmouseout = function ()  { if (this.pausemouseover) { this.is_pause = false; } }
	this.run = function () {
		if (!this.is_init) { this.init(); }
		if (!this.obj) { return; }
		if (this.m_arr.length <= 0) { return; }

		this.is_pause = true;
		this.scroll_item_cnt = 0;
		this.time_id = window.setTimeout(this.id+'.scroll()', this.scroll_speed);
		window.setTimeout(this.id+".is_pause = false", this.delay);

		this.start_idx++;
		this.start_idx %= this.m_arr.length;

		var expireDate = new Date;
		expireDate.setMonth(expireDate.getMonth() + 12);
		ad_set_cookie(this.id, this.start_idx, expireDate, '/');
	}
	this.scroll = function () {
		if (this.is_pause) { this.time_id = window.setTimeout(this.id+'.scroll()', this.scroll_speed); return; }
		var delay = this.scroll_speed;
		var obj_style;
		if (!this.is_pause) {
			for (var i = 0; i < this.m_arr.length; i++) {
				obj_style = this.m_arr[i].style;
				obj_style.top = parseInt(obj_style.top, 10) - 1;
				if (parseInt(obj_style.top, 10) <= this.item_height * (-1) ) {
					obj_style.top = this.item_height * (this.m_arr.length - 1);
				}
				if (parseInt(obj_style.top, 10) == 0) {
					this.current_top_item = i;
					this.scroll_item_cnt++;
					if (this.scroll_item_cnt >= this.scroll_items) {
						delay = this.delay;
						this.scroll_item_cnt = 0;
					}
				}
			}
		}
		this.time_id = window.setTimeout(this.id+'.scroll()', delay);
	}
	this.current_top_position = function() {
		var obj_style = this.m_arr[this.current_top_item].style;
		return parseInt(obj_style.top, 10);
	}
	this.up = function() {
		window.clearTimeout(this.time_id);
		var delta = (this.item_height - (this.current_top_position() * -1));
		delta = ((delta == 0) ? this.item_height : delta);

		for (var i = 0; i < this.m_arr.length; i++) {
			obj_style = this.m_arr[i].style;
			obj_style.top = parseInt(obj_style.top, 10) - (delta);
			if (parseInt(obj_style.top, 10) <= (this.item_height * (-1))) {
				obj_style.top = this.item_height * (this.m_arr.length - 1);
			}
			if (parseInt(obj_style.top, 10) == 0) {
				this.current_top_item = i;
			}
		}
		this.scroll_item_cnt = 0;
		this.time_id = window.setTimeout(this.id+'.scroll()', this.delay);
	}
	this.dn = function() {
		window.clearTimeout(this.time_id);
		var delta = (this.current_top_position() * -1);
		delta = ((delta == 0) ? this.item_height : delta);

		for (var i = 0; i < this.m_arr.length; i++) {
			obj_style = this.m_arr[i].style;
			obj_style.top = parseInt(obj_style.top, 10) + (delta);
			if (parseInt(obj_style.top, 10) <= this.item_height * (-1) ) {
				obj_style.top = this.item_height * (this.m_arr.length - 1);
			}
			if (parseInt(obj_style.top, 10) >= (this.item_height * this.m_arr.length)) {
				obj_style.top = 0;
			}
			if (parseInt(obj_style.top, 10) == 0) {
				this.current_top_item = i;
			}
		}
		this.scroll_item_cnt = 0;
		this.time_id = window.setTimeout(this.id+'.scroll()', this.delay);
	}
}

function setLayerCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getLayerCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
		} else {
			begin += 2;
		}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}
//--> 

