//用于取得元素可操作的ID
function GetObj(objID)
{
	if(document.getElementById)
	{
		return eval('document.getElementById("' + objID + '")');
	}
	else
	{
		if(document.layers)
		{
			return eval("document.layers['" + objID + "']");
		}
		else
		{
			return eval('document.all.' + objID);
		}
	}
}


// 设定一组 div 块的隐藏或显示 支持按 索引 或按 ID 设置显示状态
function divdisp() 
{
	var i			= 0;
	var m_curr_idx		= 0;
	var m_disp		= "";
	var m_id		= "";
	var m_div_string	= new Array();
	var m_div_array		= new Array();
	
	this.init = function( n ) 
	{
		m_div_string = n.split( "|" );
		for( i = 0; i < m_div_string.length; i++ ) 
		{
			m_div_array[m_div_array.length] = GetObj( m_div_string[i] );
		}
	}
	
	this.display = function( idx ) 
	{
		m_curr_idx	= idx;
		m_id		= m_div_string[idx];
		this.displayid( m_id );
	}
	
	this.displayid = function( divid ) 
	{
		for( i = 0; i < m_div_array.length; i++ ) 
		{
			if( m_div_array[i].id == divid ) 
			{
				m_disp	= "";
			} 
			else 
			{
				m_disp	= "none";
			}
			m_div_array[i].style.display	= m_disp;
		}
	}
	
	this.get_curr_idx = function() 
	{
		return	m_curr_idx;
	}
	
	this.len = function() 
	{
		return	m_div_array.length;
	}
}

function mpic_go(o,n) 
{
	if( o ) {
		o.display( default_range( o.get_curr_idx() + n, 0, o.len() - 1, 1 ) );
	}
}

// 返回某个范围内的值，就近取边界值，需要预先对 m_var 进行类型转换
function default_range( m_var, m_min, m_max, auto ) 
{
	if( m_var < m_min ) 
	{
		return	auto ? m_max : m_min;
	} 
	else if( m_var > m_max ) 
	{
		return	auto ? m_min : m_max;
	} 
	else 
	{
		return	m_var;
	}
}

//设定一组Div的显隐，同时更改另一元素的样式
function DataDisplay()
{
	var HeadName = "";
	var BodyName = "";
	
	var Sstyled = "";
	var Ustyled = "";
	
	var intDivs = 3;
	
	this.SetHeadName = function(str){HeadName = str;} 
	this.SetBodyName = function(str){BodyName = str;}
	this.SetDivs = function(str){intDivs = str;}
	this.SetSstyle = function(str){Sstyled = str;}
	this.SetUstyle = function(str){Ustyled = str;}
	
	this.Data_go = function(strID)
	{
		var arrBodyName = BodyName.split('|');
		
		for(var i=1;i <= intDivs;i++)
		{
			if(strID == i)
			{
				GetObj(HeadName + i).className = Sstyled;
				for(var d=0;d < arrBodyName.length;d++)
				{
					GetObj(arrBodyName[d] + i).style.display = "";
				}
			}
			else
			{
				GetObj(HeadName + i).className = Ustyled;
				for(var d=0;d < arrBodyName.length;d++)
				{
					GetObj(arrBodyName[d] + i).style.display = "none";
				}
			}		
		}
	}
}

//根据时间控制一组Div的显隐，
function AutoDisplay()
{
	var Interval = 8000;
	var Dynamic = 23;
	var ifChange = true;
	var div_count = 0;
	var ifStop = false;
	
	var div_of_string = new Array();
	var div_of_object = new Array();
	
	this.init = function(strIds)
	{
		div_of_string = strIds.split('|');
		var count = div_of_string.length;
		for(var i=0;i<count;i++)
		{
			div_of_object[i] = GetObj(div_of_string[i]);
		}
	}
	
	this.setTimes = function(intT)
	{
		Interval = intT;
	}
	this.setDynamic = function(intD)
	{
		Dynamic = intD;
	}
	this.setChange = function(boolC)
	{
		ifChange = boolC;	
	}
	this.setStop = function(boolS)
	{
		alert(boolS);
		ifStop = boolS;
	}
	this.Play = function()
	{
		if(!ifStop)
		{
			var count = div_of_object.length;
			if(div_count == count) div_count = 0;
			for(var i=0;i<count;i++)
			{
				var s = div_of_object[i];
				
				if(i == div_count)
				{
					s.style.display='';
				}
				else
				{
					s.style.display='none';
				}
			}
			div_count++;
		}
	}
	this.Start = function(a)
	{
		setInterval(a + '.Play()',Interval);
	}
}
