﻿/*	[MHz.Effect.UCCMover.js]
 *  (c) 2006, 2007 MHZ. (http://www.mediamob.co.kr // http://www.openblog.com)
 *	reference >> prototype.js // 
 *	Last Update : 2007.01.26  Pang
 *
 *	How to use ?
 *	---------------------------------------------------------------------------
 *	+ <script src="./lib/prototype/prototype.js" type="text/javascript"></script>
 * + <script>new imgNavi("contVod");</script>
 * + 움직일 이미지에 class = 'move', 네비게이션 이미지에는 nevi_r, nevi_l을 선언해준다.
 *
 *	Options
 *		+ Syntax : {viewcount: '3'}
 *		+ viewcount : 한번에 보여줄 개수
 *
 */

//<![CDATA[
var UCCMover = Class.create();
UCCMover.prototype =
{ 				
	initialize: function(element, options) 
	{
		this.element = $(element);
		this.options = Object.extend({viewcount: '3'}, options);
		
		this.elementList = document.getElementById(element).getElementsByTagName('dl');
		this.rollingList = new Array();				
		this.divElement = new Array();
		
		this.neviTemp = this.element.getElementsByTagName('p');
		this.neviTag = this.neviTemp[0].getElementsByTagName('img');
		this.nevi_l = null;
		this.nevi_r = null;
		
		this.viewcount = this.options.viewcount;				
		this.init();
	}, 
	
	init: function()
	{
		for(i = 0;  i < this.elementList.length; i++)
		{
			this.rollingList[this.rollingList.length] = $(this.elementList[i]);
		}
		
		for(i = 0 ; i < this.neviTag.length; i++)
		{
		    if(this.neviTag[i].className =="nevi_l")
	        {	
		        this.nevi_l = this.neviTag[i];
		        this.nevi_l.onclick = this.prev_scroll;
		        this.nevi_l.component = this;
		        this.set_style(this.nevi_l);
	        }	
    		
	        if(this.neviTag[i].className =="more")
	        {
		        this.nevi_r = this.neviTag[i];
		        this.nevi_r.onclick = this.next_scroll;
		        this.nevi_r.component = this;	
		        this.set_style(this.nevi_r);
	        }
		}
        
		for(i = 0;  i < this.elementList.length; i++)
		{
			if(i >= this.viewcount)
			{
				this.elementList[i].style.display = 'none';
			}
		}		
	},	
			
	set_style: function(element)
	{
		try
		{
			element.style.cursor = 'pointer';
		}
		catch(e)
		{
			element.style.cursor = 'hand';
		}
	},
	
	next_scroll: function()
	{		
		this.component.next();	
	},
	
	next: function()
	{
		var temp1, temp2, temp3;
		var tempArr1 = new Array();		
		var tempArr2 = new Array();						
				
		for(i=0; i < this.rollingList.length; i++)
		{			
			if(i == 0)
				temp1 = this.rollingList[i].innerHTML;
			if(i == 1)
				temp2 = this.rollingList[i].innerHTML;
			if(i == 2)
				temp3 = this.rollingList[i].innerHTML;
				
			if(i == this.rollingList.length - 1)
				this.rollingList[i].innerHTML = temp3;
			else if(i == this.rollingList.length - 2)
				this.rollingList[i].innerHTML = temp2;
			else if(i == this.rollingList.length - 3)
				this.rollingList[i].innerHTML = temp1;
			else
				this.rollingList[i].innerHTML = this.rollingList[i+3].innerHTML;
		}		
	},
	
	prev_scroll: function()
	{		
		this.component.prev();	
	},
	
	prev: function()
	{
		var temp1, temp2, temp3;
		var tempArr1 = new Array();		
		var tempArr2 = new Array();		
						
		for(i=this.rollingList.length-1; i >= 0; i--)
		{					
			if(i == this.rollingList.length-1)
				temp1 = this.rollingList[i].innerHTML;
			if(i == this.rollingList.length-2)
				temp2 = this.rollingList[i].innerHTML;
			if(i == this.rollingList.length-3)
				temp3 = this.rollingList[i].innerHTML;
			
			if(i == 0)
				this.rollingList[i].innerHTML = temp3;
			else if(i == 1)
				this.rollingList[i].innerHTML = temp2;
			else if(i == 2)
				this.rollingList[i].innerHTML = temp1;
			else
			    this.rollingList[i].innerHTML = this.rollingList[i-3].innerHTML;
		}		
	}	
}

//]]>