var timerobj;
var intervalduration = 10;
var totalduration = 450;
var starttime;
var direction;
var endheight;
var pagetoload = null;
var currentpage;

function slidepage(sdirection){
endheight = document.getElementById('ajax-page-content').scrollHeight;
starttime = (new Date()).getTime();
direction = sdirection;

if (sdirection=='up'&&document.getElementById('sliding-content').clientHeight<30){
endslide();
} else {
timerobj = setInterval("movepage()",intervalduration); 
}}

function movepage(){
//alert('moving '+direction+' started at '+starttime+' endheight is '+endheight)
var elapsed = (new Date()).getTime() - starttime;
  if (elapsed > totalduration){
    endslide();
		return;
	}
	else{

    var d =Math.round(elapsed / totalduration * endheight);
    if(direction == "up"){
        d = endheight - d;
				if (d<1){
					 d=0;
				}
		}
    document.getElementById('sliding-content').style.height = d + "px";
}}
 

function endslide(){

  clearInterval(timerobj);
	//cleanup
 	if(direction=='up'){
	document.getElementById('sliding-content').style.height = "1px";
	}else{
  document.getElementById('sliding-content').style.height = document.getElementById('sliding-content').scrollHeight;
  }
	if(pagetoload!=null){
	  ajaxload(pagetoload);
		currentpage=pagetoload;
		pagetoload=null;
	}
}

function reloadonresize(){
  if (currentpage != null) {
  	if (document.getElementById('sliding-content').clientHeight < document.getElementById('sliding-content').scrollHeight)
	  	delayedload(currentpage)
  }
}