var imgs = new Array();
var srcImgHtml;
var _internal = 3000;
var _isStop;
var _playIndex;
//滚动条移动 @scrollwidth : 移动宽度
function scrollHiddenDiv(div, scrollwidth)
{
	div.scrollLeft += scrollwidth;
}

//相册图片
var ShowPhotoBar = {
	ImgsList : [],
	Imgs :[],
	S_Obj : null,
	S_ok : 0,
	S_ele : null,
	S_w : 0,
	n : 20,
	t : 50,
	k : 0,
	timers : null,
	get : function(){
		ShowPhotoBar.S_Obj = gid("scroll").getElementsByTagName("LI");

		ShowPhotoBar.S_ok = Math.ceil(ShowPhotoBar.S_Obj.length/3)-1;
		ShowPhotoBar.S_ele = gid("scrollbar");
		ShowPhotoBar.S_w = ShowPhotoBar.S_ele.clientWidth;
		ShowPhotoBar.timers = new Array(ShowPhotoBar.n);
	},
	//滚动方向ONCLICK事件
	doSlide : function(s){
		if (ShowPhotoBar.S_Obj==null)
		{
			ShowPhotoBar.get();
		}
		if (ShowPhotoBar.k>=ShowPhotoBar.S_ok &&s>0|| ShowPhotoBar.k<=0 &&s<0){alert("所有相片都展示完了 ")}
		else{
		ShowPhotoBar.k+=s;
		var x=ShowPhotoBar.S_ele.scrollLeft;
		var d=ShowPhotoBar.k*ShowPhotoBar.S_w-x;
		for(var i=0;i<ShowPhotoBar.n;i++)(
			function(){
				if(ShowPhotoBar.timers[i]) clearTimeout(ShowPhotoBar.timers[i]);
				var j=i;
				ShowPhotoBar.timers[i]=setTimeout(function(){ShowPhotoBar.S_ele.scrollLeft=x+Math.round(d*Math.sin(Math.PI*(j+1)/(2*ShowPhotoBar.n)));},(i+1)*ShowPhotoBar.t);
			}
		)();
	};},

	//滚动条图片HTML数据
	InnerImgsbar : function(div){
		
		var piclist = ShowPhotoBar.ImgsList;
		var count = piclist.length;
		var html = "";
		for (var i = 0; i < count; i += 1) {
		//imgs[i] = new Image();
		//imgs[i].src = piclist[i].pic;	
		html +="<li>";
		html +="<a href=\""+piclist[i].url+"\"><img src=\""+piclist[i].pic+"\" title=\""+piclist[i].title+"\" class=\"ImgBox\" height=\"90\"/></a>";
		html +="</li>";
		};
		if (div)
		{
			div.innerHTML = html;
			
		};
		
	},
	//sliverlight 图片数据
	SilverlightShow : function(){
		var piclist = ShowPhotoBar.ImgsList;
		var count = piclist.length;
		for (var i = 0; i < count; i += 1) {
			if (i>11)
			{
				break;
			}else{
				Hst.AlbumImages[i] = piclist[i].pic;
			};
		};
	}
}

// 相册幻灯播放控制类

/* 播放设置 */
var adRotator = ({});

adRotator.loads = function ()
{
	if (_playIndex < imgs.length && _isStop < 1)
	{
        //gid('rotatorPlayer').innerHTML = '<center><img id="showimg" src="' + imgs[_playIndex].src + '" onClick="adRotator.browse();" style="cursor: pointer;"></center>';
        gid('rotatorPlayer').innerHTML = '<center><img id="showimg" src="' + (imgs[_playIndex - 1] ? imgs[_playIndex - 1].src : imgs[_playIndex].src) + '" onClick="adRotator.browse();" style="cursor: pointer;"></center>';
  		transImg(0);
  		transImg(1);
  		gid('showimg').src = imgs[_playIndex].src;
        _playIndex = _playIndex + 1;
  		transImg(0);
  		if(_isStop < 1)
  			window.setTimeout("adRotator.loads(" + _playIndex + ")",_internal);
  		     
        if (_playIndex + 1 > imgs.length)
			_playIndex = 0; 		
    }    
}

/* 播放 */
adRotator.play = function ()
{
	if(imgs.length <= 0)
		return;
	
	_isStop = 0;
	_playIndex = 0;		
	//document.getElementById('stop').disabled='';
	//document.getElementById('play').disabled='true';
	srcImgHtml = gid('rotatorPlayer').innerHTML;
	adRotator.loads();
}

/* 停止播放 */
adRotator.stop = function ()
{   
	_isStop = 1;
	//document.getElementById('stop').disabled='true';
	//document.getElementById('play').disabled='';	
	gid('rotatorPlayer').innerHTML = srcImgHtml;
}

/* 浏览 */
adRotator.browse = function ()
{
	
	var oBrowse = gid('browse');
	var oSet = gid("set");
	var oSecond = gid("second");
	if("幻灯播放" == oBrowse.value)
	{
		oBrowse.value = "停止播放";
		oSet.style.display = "";
		oSecond.style.display = "";
		this.play();
	}
	else
	{
		oBrowse.value = "幻灯播放";
		oSet.style.display = "none";
		oSecond.style.display = "none";
		this.stop();
	}
}

adRotator.reSize = function(img)
{

	if(650 < img.width)
	{
		img.width = 650;
	}
}

/* 间隔时间 */
adRotator.set = function ()
{
	var _sfc = document.getElementById('second').value;
	if (isInteger(_sfc)){
		_internal = _sfc * 1000;
	}
	else{
		alert('提示：只能输入数字！');
		gid('second').value=5;
		gid('second').select();
	}
}

function onplayalubm()
{		
}

/* 渐隐渐现 */
function  transImg(enable)
{
	if(window.netscape){return;}
	gid("showimg").style.filter = "alpha(opacity=1,enabled=1) blendtrans(duration=2) revealTrans(duration=2,transition=20)";
	adRotator.reSize(gid("showimg"));
	gid("showimg").filters.revealTrans.Transition=Math.floor(Math.random()*23);
    gid("showimg").filters.revealTrans.apply();  
	gid("showimg").filters.blendtrans.Apply();
	gid("showimg").filters[0].enabled=enable;
	gid("showimg").filters.revealTrans.Play();
	gid("showimg").filters.blendtrans.Play();
}
function isInteger(str)
{  
	var regu = /^[-]{0,1}[0-9]{1,}$/;
	return regu.test(str);
}