﻿var F1_Id,F1_Index=0,F1_Length=5;
var F2_Id,F2_Index=0,F2_Length=3;
var F3_Id,F3_Index=0,F3_Length=3;
var oScrollObj;
var oDivMarquee;//图片滚动
var oDivMarquee1;
var oDivMarquee2;
window.onload= function(){    SetTimeout(OnLoad,100); };

function OnLoad()
{
    F1_Id = window.setInterval("RunFocus('F1_')",2500);
    F2_Id = window.setInterval("RunFocus('F2_')",2500);
    F3_Id = window.setInterval("RunFocus('F3_')",2500);
    oScrollObj=new ScrollText(Get("Sobj1"),Get("Sobj2"),10,22,11);
    oScrollObj.Timeout=SetTimeout(Scrolling,oScrollObj.Time,oScrollObj);
    //图片滚动
    var speed=30;
    oDivMarquee = document.getElementById("demo");
    oDivMarquee1 = document.getElementById("demo1");
    oDivMarquee2 = document.getElementById("demo2");
    oDivMarquee2.innerHTML = oDivMarquee1.innerHTML;        
    var myMar=setInterval(Marquee,speed)
    oDivMarquee.onmouseover = function() 
    {
        clearInterval(myMar);
    }
    oDivMarquee.onmouseout = function()
    {
        myMar=setInterval(Marquee,speed);
    }
}
//图片滚动
function Marquee()
{                                                              
    if(oDivMarquee2.offsetWidth - oDivMarquee.scrollLeft<=0)
    {   
        oDivMarquee.scrollLeft -= oDivMarquee1.offsetWidth;
    }
    else
    {
        oDivMarquee.scrollLeft++;                
    }            
}
function ScrollText(obj1,obj2,length,height,speed)
{
    this.Obj1=obj1;
    this.Obj2=obj2;
    this.Obj2.innerHTML=this.Obj1.innerHTML;                
    this.Time=1500;
    this.Speed=speed;
    this.Timeout;
    this.Length=length;
    this.Height=height;
    this.SelectedIndex=0;
    this.IsObj1=true;
    this.SpeedIndex=0;
    this.IsPause=false;
}

function Scrolling(oScrollTextObj)
{
    if(oScrollTextObj.SpeedIndex<oScrollTextObj.Speed)
    {
        var iSpeed=oScrollTextObj.Height/oScrollTextObj.Speed;
        oScrollTextObj.SpeedIndex++;
        oScrollTextObj.Obj1.style.top=(ToFloat(oScrollTextObj.Obj1.style.top)-iSpeed).toString()+"px";
        oScrollTextObj.Obj2.style.top=(ToFloat(oScrollTextObj.Obj2.style.top)-iSpeed).toString()+"px";
        oScrollTextObj.Timeout=SetTimeout(Scrolling,500/oScrollTextObj.Speed,oScrollTextObj);
    }
    else
    {
        oScrollTextObj.SpeedIndex=0;
        oScrollTextObj.SelectedIndex=(oScrollTextObj.SelectedIndex+1)%oScrollTextObj.Length;
        if(oScrollTextObj.SelectedIndex==0)
        {
            
            if(oScrollTextObj.IsObj1)
            {
                
                oScrollTextObj.Obj1.style.top=(ToFloat(oScrollTextObj.Obj1.style.top) + ToFloat(oScrollTextObj.Obj1.offsetHeight) * 2).toString() + "px";                                    
            }
            else
            {
                oScrollTextObj.Obj2.style.top=oScrollTextObj.Obj1.style.top;
            }
            oScrollTextObj.IsObj1=!oScrollTextObj.IsObj1;
        }                            
        if(!oScrollTextObj.IsPause)                    
            oScrollTextObj.Timeout=SetTimeout(Scrolling,oScrollTextObj.Time,oScrollTextObj);                            
            
    }
}

function oScrollObj_OnMouseOut()
{
    oScrollObj.IsPause=false;
    window.clearTimeout(oScrollObj.Timeout);                       
    oScrollObj.Timeout=SetTimeout(Scrolling,2000,oScrollObj);
}

function oScrollObj_OnMouseOver()
{
    oScrollObj.IsPause=true;
}
