﻿var Movekey=[];
var jj=[];
var ftopl=[];
var ttopl=[];
var fhl=[];
var thl=[];
var hi=[];
function MoveDiv(divID,high,mm,s)
{
    var d = divID;
    jj[d]=0;
    hi[d]=high;
    var div,fist,two;
    var ftop,ttop,fh,th;
    var tool;
    div=$("#"+divID);
    fist= $("#"+divID+" > div").eq(0);
    two=$("#"+divID+" > div").eq(1);
    div.css("position","absolute");
    div.css("overflow","hidden");
    fist.css("position","absolute");
    fist.css("top","0");
    two.css("position","absolute");
    //fist.clone().append(two);
    two.html(fist.html());
    //alert(fist.html());
    //alert(two.html());
    var hig=fist.height();
    two.css("top",hig);
    ftop = parseInt(fist.css("top"));
    ttop=parseInt(two.css("top"));
    fh=parseInt(fist.height());
    th=parseInt(two.height());
    //stop(divID,true,mm,s);
   // div.slideUp("1000");
    Movekey[d] = false;
    window["_Tep_tip_"+d]="false";
    ftopl[d]=ftop;
    fhl[d]=fh;
    ttopl[d]=ttop;
    thl[d]=th;
    tool = setInterval(function(){divJ(d,fist,two,mm,s,high)},mm);
//    for(var i=0;i<10;i++)
//    {
//        fist.css("top",i);
//    }
    //alert(8%4);
}

function divJ(d,fist,two,m,ss,high)
{
    var k=0,ftop,fh,ttop,th;
    ftop=ftopl[d];
    fh=fhl[d];
    ttop=ttopl[d];
    th=thl[d];
    
    //alert(Movekey[d]);
    //var stopkey=window["_Tep_tip_"+d];
    if(Movekey[d]==false)
    {
        if(jj[d]>0)
        {
            jj[d]=jj[d]+m;
        }else
        {
            jj[d]=m;
        }
        //alert(jj[d]+"---"+ss);
        if(jj[d]>ss)
        {
            //alert("true");
            jj[d]=0;
            Movekey[d]=true;
        }
    }else
    {
        ftopl[d]--;
        k=0-ftopl[d];
        fist.css("top",ftopl[d]);
        if(ftopl[d]<0)
        {
            ttopl[d]=fhl[d]+ftopl[d];
            //alert(ttopl[d]);
            if(k%high==0)
            {
                Movekey[d]=false;
            }
        }
        ttopl[d]--;
        k=0-ttopl[d];
        two.css("top",ttopl[d]);
        if(ttopl[d]<0)
        {
            ftopl[d]=thl[d]+ttopl[d];
            if(k%high==0)
            {
                Movekey[d]=false;
            }
        }
    }
}