function intval( num ){
    num = parseInt(num);
    return isNaN(num) ? 0 : num;
}

function ShowMore(){

    this.b_stop = false;
    
    this.init = ShowMoreInit;
    this.update = ShowMoreUpdate;
    
    var o_self = this;

    add_event( 'onload', window, function(){o_self.init()}, false );
}


function ShowMoreInit(){
    var o_self = this;
    
    var o_page = document.getElementById('page');
    
    this.o_div = document.createElement('div');

    this.o_div.className = 'show_more';
    this.o_div.style.zIndex = 999;
    this.o_div.style.position = "absolute";
    this.o_div.style.color = "black";
    this.o_div.style.cursor  = "pointer";
    this.o_div.style.display  = "block";
    this.o_div.style.visibility = "visible";

    this.o_div.style.background = 'transparent url(images/whitebg.png) no-repeat scroll 8px 0';
    this.o_div.style.textAlign = 'center';

    this.o_div.style.width = 70;
    this.o_div.style.height = 40;
    
    this.o_div.innerHTML = '<span style="padding-top: 4px; color: #E80000;">'+teksty.wiecej+'<br><span id="down_arrows">	&darr; 	&darr; 	&darr;</span></span>';

    this.o_div.style.left = (intval(o_page.clientWidth) + intval(o_page.offsetLeft) - 30) ;
    
    this.o_div.onclick = function(){
        var diff = (intval(document.body.scrollHeight)- (intval(document.body.scrollTop) + intval(document.body.clientHeight)));

        if( 100 < diff   ){
            document.body.scrollTop += 100;
        }else if( diff > 0 ){
            document.body.scrollTop += diff;
        }
    };
    this.o_div.onmousedown  = function(){BodyBeginScroll();};
    this.o_div.onmouseup= function(){BodyEndScroll();}
    
    document.body.appendChild(this.o_div);

    this.o_blink_arrows = new Blink('down_arrows');
    
    add_event( 'scroll', window, function(){ o_self.update()}, false );

    o_self.update();
}


function ShowMoreUpdate(){
    if( document.body.scrollTop + document.body.clientHeight < document.body.scrollHeight ){
        this.o_div.style.top = intval(document.body.scrollTop) + intval(document.body.clientHeight) - 40;
    }else{
        this.o_div.style.display = 'none';
        this.o_div.style.visibility = 'hidden';
        
        remove_event( 'scroll', window );
    }
}

function ShowMoreAnime(){
}

/**************************************************************************************************/
var bBodyScroll = false;
function BodyScroll(){
    var diff = 0;
    
    if( bBodyScroll  &&
            (diff = intval(document.body.scrollHeight)- (intval(document.body.scrollTop) + intval(document.body.clientHeight)) ) > 0 ){
            
        
        document.body.scrollTop += (diff < 20 ? diff : 20);
        
        setTimeout( BodyScroll, 100);
    }else{
        bBodyScroll = false;
    }
}

function BodyBeginScroll(){
    bBodyScroll = true;
    BodyScroll();
}

function BodyEndScroll(){
    bBodyScroll = false;
}

/**************************************************************************************************/
new ShowMore();
console.log('jkdhfjkhdjkfh hjdskafh kjdshf kjh');
