var currPicId = 0, chgPicTimer, RUN_DELAY = 5000, RUN_SPEED = 10, CIRCLE_RO_WIDTH = 180, CIRCLE_RO_HEIGHT = 200;
var picroll =  document.getElementById('picRotate')
var arr_a = picroll.getElementsByTagName('ul')[0].getElementsByTagName('li');
var arr_b = picroll.getElementsByTagName('dl')[0].getElementsByTagName('dd');
var doing = false;
var tf = true;//ture 表示向左运动
function autoSwitch(m){
try{
arr_a[m].onmouseover()
}catch(e){
try{arr_a[m].onmousemove()}catch(e){}
}
currPicId = m;
var nxtId = (m+1) % arr_a.length;
chgPicTimer = window.setTimeout("autoSwitch("+nxtId+")",RUN_DELAY);
}
function clrPicTimer(m){
currPicId = m;
chgPicTimer = window.clearTimeout(chgPicTimer);
}
/** layer_lf_01 pics auto change end **/
function circleRo(c,n,dr){
doing = true;
arr_b[c].style.left = arr_b[n].style.left = arr_b[c].style.top = arr_b[n].style.top = 0
arr_b[c].style.zIndex = 20;
arr_b[n].style.zIndex = 15;
setTimeout('doCircleRo('+c+','+n+','+dr+')',RUN_SPEED);
}
function doCircleRo(c,n,dr){
if (tf){ //imgID向左边移动2/3，nextImgID向右边1/3 			dr =0 为左右切换 dr = 1 为上下切换
if (!dr && parseInt(arr_b[c].style.left)>-CIRCLE_RO_WIDTH){
arr_b[c].style.left = (parseInt(arr_b[c].style.left)-10) + 'px';
arr_b[n].style.left = (parseInt(arr_b[n].style.left)+5) + 'px';
setTimeout('doCircleRo('+c+','+n+','+dr+')',RUN_SPEED);
} else if(dr && parseInt(arr_b[c].style.top)>-CIRCLE_RO_HEIGHT){
arr_b[c].style.top = (parseInt(arr_b[c].style.top)-10) + 'px';
arr_b[n].style.top = (parseInt(arr_b[n].style.top)+5) + 'px';
setTimeout('doCircleRo('+c+','+n+','+dr+')',RUN_SPEED);
} else {
tf = !tf;
arr_b[c].style.zIndex = 15;
arr_b[n].style.zIndex = 20;
setTimeout('doCircleRo('+c+','+n+','+dr+')',RUN_SPEED);
}
} else {
if (!dr && parseInt(arr_b[c].style.left)<0){
arr_b[c].style.left = (parseInt(arr_b[c].style.left)+10) + 'px';
arr_b[n].style.left = (parseInt(arr_b[n].style.left)-5) + 'px';
setTimeout('doCircleRo('+c+','+n+','+dr+')',RUN_SPEED);
} else if(dr && parseInt(arr_b[c].style.top)<0) {
arr_b[c].style.top = (parseInt(arr_b[c].style.top)+10) + 'px';
arr_b[n].style.top = (parseInt(arr_b[n].style.top)-5) + 'px';
setTimeout('doCircleRo('+c+','+n+','+dr+')',RUN_SPEED);
} else {
arr_b[n].style.zIndex = 10;
arr_b[c].style.zIndex = 0
tf = !tf;
picroll.setAttribute('curr',n);
doing = false;
//autoSwitch(n);
}
}
}
function picRotate_ini(tp,m,currpicid,rundelay,runspeed,circlerowidth,circleroheight){
m = m || 0;
RUN_DELAY = rundelay || RUN_DELAY;
RUN_SPEED = runspeed || RUN_SPEED;
CIRCLE_RO_WIDTH = circlerowidth || CIRCLE_RO_WIDTH;
CIRCLE_RO_HEIGHT = circleroheight || CIRCLE_RO_HEIGHT;
picroll.className = 'picRotate' + "_" + parseInt(tp)
picroll.setAttribute('curr',m);
var i
i = 0;
while( i<arr_a.length ){
arr_a[i].setAttribute('num',i);
if(i == m){
arr_a[i].className += ' hov';
}else{
arr_a[i].className = ''
}
if( parseInt(tp) == 1 || tp == 2.1 || tp == 2.0 ){
if( tp == 2.0 || tp == 2.1 ){
arr_a[i].innerHTML = '<div></div><img src="'+arr_b[i].getElementsByTagName('img')[0].src+'" width="75" height="50"/>'
}
arr_a[i].onmousemove = function(){
clrPicTimer(currPicId);
if(doing) return;
var c = parseInt(picroll.getAttribute('curr'));
arr_a[c].className = arr_a[c].className.replace(/\s*hov\s*/g,' ');
var n = this.getAttribute('num');
currPicId = n;
arr_a[n].className += ' hov';
if(c!=n) circleRo(c,n, 10* (tp - parseInt(tp) ) )
}
arr_a[i].onmouseout = function(){
autoSwitch(currPicId);
}
}else {
if( tp == 2.2 )
arr_a[i].innerHTML = '<div></div><img src="'+arr_b[i].getElementsByTagName('img')[0].src+'" width="75" height="50"/>'
arr_a[i].onmouseover = function(){
clrPicTimer(currPicId);
var c = parseInt(picroll.getAttribute('curr'));
arr_a[c].className = arr_a[c].className.replace(/\s*hov\s*/g,' ');
arr_b[c].className = 'dn';
var n = this.getAttribute('num');
currPicId = n;
arr_a[n].className += ' hov';
arr_b[n].className = '';
picroll.setAttribute('curr',n);
}
arr_a[i].onmouseout = function(){
autoSwitch(currPicId);
}
}
i++;
}
i = 0;
while( i<arr_b.length ){
var da = arr_b[i].getElementsByTagName('a')[0]
da.onmouseover = function(){
clrPicTimer(currPicId);
}
da.onmouseout = function(){
autoSwitch(currPicId);
}
if(i != m)
arr_b[i].className = 'dn';
else{
arr_b[i].className = '';
}
i++;
}
autoSwitch(m);
}
