// Created for GreatEqualizer.com (http://www.greatequalizer.com/) and
// documented at DHTML Lab (http://www.webreference.com/dhtml/)

var bannerHeight2 = 300;

var oChaser2 = {
        topOffset        : 30,
        topMargin        : document.all ? document.body.clientHeight - bannerHeight2 : window.innerHeight - bannerHeight2,
        callRate        : 50,
        slideTime        : 800,
        maxDiff                : document.all ? document.body.clientHeight : window.innerHeight,
        isIE                : document.all ? true : false,
        isMoz                : document.getElementById ? true : false
}


if(document.all) {
        oChaser2.chaserDiv=document["all"]["beuszolayer"];
        oChaser2.chaserDiv.style.pixelTop=-200;
} else {
        if(document.getElementById) {
                oChaser2.chaserDiv=document.getElementById("beuszolayer");
                oChaser2.chaserDiv.style.top= -200;
        } else {
                        oChaser2.chaserDiv=document["layers"]["beuszolayer"];
                        oChaser2.chaserDiv.top= -200;
        }
}

function girl_close()
{
        oChaser2.chaserDiv.style.visibility='hidden';

}

function KezdSzamol2()
{
        x2=document.body.clientWidth;
        if (x2<970)
        {
                kezd2=(970/2);
        }else
        {
                kezd2=Number((x2-970)/2)+(970/2);
        }
        kezd2=kezd2-240 ;

        oChaser2.chaserDiv.style.left=kezd2;
        oChaser2.chaserDiv.style.visibility='visible';

}
KezdSzamol2();
// Arrange to have the main loop called as often as possible, 
// but not more often than every 35 milliseconds.
// Even though some OS's can acheive better than that, there's no real reason to
// overload them if its not going to improve the animation quality very much.
// I tested, and better than 35ms doesn't do very much visually.
window.setInterval("oChaser2.main( )", oChaser2.callRate);
//window.onresize = window_resize2;

function window_resize2() {
//        oChaser2.topMargin=document.all ? document.body.clientHeight - bannerHeight2 : window.innerHeight - bannerHeight2;
        KezdSzamol2();
        oChaser2.main();
}


// Main loop. Updates targetY, and decides whether to start
// the animation over again, continue an existing animation,
// or do nothing at all.
oChaser2.main = function( )
{
        this.currentY        = this.isIE ? this.chaserDiv.style.pixelTop : this.isMoz ? this.chaserDiv.style.top.substr(0, this.chaserDiv.style.top.length-2) : this.chaserDiv.top;
        this.scrollTop        = this.isIE || this.isMoz ? document.body.scrollTop : window.pageYOffset;
//        var newTargetY        = this.scrollTop + this.topMargin;
        var newTargetY        = this.scrollTop;

        if ( this.scrollTop < this.topOffset ) {
                newTargetY = newTargetY + ( this.topOffset )
        }

        if ( this.currentY != newTargetY ) {

                if ( newTargetY != this.targetY ) {

                        this.targetY = newTargetY
                        this.slideInit( )
        
                }

                this.slide( )
                
        }
}


// .slideInit( ). Initializes the slide animation. Sets properties
// of the oChaser2 object that will represent the various paramaters
// for the sine wave function.
oChaser2.slideInit = function( )
{
        var now        = new Date( )
        
        this.A = this.targetY - this.currentY
        this.B = Math.PI / ( 2 * this.slideTime )
        this.C = now.getTime( )

        if (Math.abs(this.A) > this.maxDiff) {
                this.D = this.A > 0 ? this.targetY - this.maxDiff : this.targetY + this.maxDiff
                this.A = this.A > 0 ? this.maxDiff : -this.maxDiff
        } else {
                this.D = this.currentY
        }

}



// .slide( ). Moves the oChaser2 one frame. Its rate decreases and
// is defined by a sine wave.
oChaser2.slide = function( )
{

        var now        = new Date( )
        var newY = this.A * Math.sin( this.B * ( now.getTime( ) - this.C ) ) 
        newY = newY+Number(this.D)
        newY = Math.round( newY)

        if (( this.A > 0 && newY > this.currentY ) ||
                ( this.A < 0 && newY < this.currentY )) {
                        
                if ( this.isIE ) {
                        this.chaserDiv.style.pixelTop = newY;
                } else if ( this.isMoz ) {
                        this.chaserDiv.style.top = newY;
                } else {
                        this.chaserDiv.top = newY
                }

        }

}

