 function getPageHeight(){
        var y;
        var test1 = document.body.scrollHeight;
        var test2 = document.body.offsetHeight
        if (test1 > test2) // all but Explorer Mac
        {
            y = document.body.scrollHeight;
        }
        else // Explorer Mac;
             //would also work in Explorer 6 Strict, Mozilla and Safari
        {
            y = document.body.offsetHeight;
        }
        return parseInt(y);
    }

    function _getWindowHeight(){
        if (self.innerWidth)
        {
            frameWidth = self.innerWidth;
            frameHeight = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientWidth)
        {
            frameWidth = document.documentElement.clientWidth;
            frameHeight = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
            frameWidth = document.body.clientWidth;
            frameHeight = document.body.clientHeight;
        }
        return parseInt(frameHeight);
    }


    function getScrollHeight(){
        var y;
        // all except Explorer
        if (self.pageYOffset)
        {
            y = self.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop)   
        {
            y = document.documentElement.scrollTop;
        }
        else if (document.body) // all other Explorers
        {
            y = document.body.scrollTop;
        }
        return parseInt(y)+_getWindowHeight();
    }
    
	var times = 0 ;
	function sisypheCheck() {
		
		if (getPageHeight() - getScrollHeight() < preload_distance) {
			new Ajax.Request(
				dc_app_url+'/share/sisyphe/sisyphe_ajax.php',{
					method: 'post',
					parameters: $H({
						cat: sisyphe_cat,
						pos: sisyphe_pos
					}).toQueryString() ,
					onSuccess: function(r) { 
						new Insertion.Bottom('sisyphe',r.responseText) ;
						sisyphe_pos += dc_nb_post_per_page ;
						$('sisyphe_wait').parentNode.removeChild($('sisyphe_wait')) ;
						window.setTimeout(sisypheCheck,check_interval) ;
					},
					onFailure: function(r) {
						if (r.status != 404) {
							window.setTimeout(sisypheCheck,check_interval*3) ;
						}
						$('sisyphe_wait').parentNode.removeChild($('sisyphe_wait')) ;
					}
				}
			) ;
			new Insertion.Bottom('sisyphe','<img id="sisyphe_wait" src="'+dc_app_url+'/share/sisyphe/wait.gif" style="margin: 0 auto; display: block; height: 20px;">') ;
		} else {
			window.setTimeout(sisypheCheck,check_interval) ;
		}
	}

	function sisypheLoad() {
		$('sisyphe_load').parentNode.removeChild($('sisyphe_load')) ;
		sisypheCheck() ;
	}

