function ieGetAgendaScrollHeight()
{
    totalOffsetPx=0; firstOffsetPx=0;
    offsetContinue=true;
    var elmLI=document.getElementById('mainScrollContent').getElementsByTagName('ul');
    for (var i=0;i<elmLI.length;i++)
    {
	if(elmLI[i] && elmLI[i].getAttribute('id'))
	{
    	    cid=elmLI[i].getAttribute('id');
    	    if(cid.substring(0,8)=="vergdiv_")
    	    {
	        if(offsetContinue)
		{
	    	    if(firstOffsetPx==0)
		    {
			firstOffsetPx=document.getElementById(cid).offsetTop;
		    }
		    totalOffsetPx+=document.getElementById(cid).offsetTop;		    
	        }
		if(curVergId==cid.substring(8))
	        {
//			debug('niet meer erbij');
	    	    offsetContinue=false;
		}
//	    debug('offsettop:'+document.getElementById(cid).offsetTop+' ,id: '+cid.substring(8));
	    }
	}
    }
    
    //debug('total extra scrolling pix: '+totalOffsetPx);
    if(totalOffsetPx>firstOffsetPx) // als er meerdere vergaderingen zijn gekoppeld, en bezig met 2e of daarna...
    {
        return (totalOffsetPx-firstOffsetPx);
    }
    else
    {
        return totalOffsetPx;
    }
}




function scrollContent(type,divId)
{
    var objDiv = document.getElementById('mainScrollContent'); // container
    doTScroll=true; // voer de scrollactie uit (wordt false bij niet bestaan div)
    
    if(type=='agenda')
    {		
	// open agendaitem:
	openAgenda(divId);
	
	
	// offset van div achterhalen
	if(document.getElementById('AgContainer_'+divId))
	{
	    divItemHeight = document.getElementById('AgContainer_'+divId).offsetTop;
	    if(!non_IE)
	    {
		//divItemHeight+=ieGetAgendaScrollHeight();
		doTScroll=false; // hack om IE te negen?
	    }
	}
	else
	    doTScroll=false;
	
    }
    else if(type=='indexering')
    {
	// agendapunt openen
	openAgenda(getAgendaIndexering())
    
	// offset van div achterhalen
	if(document.getElementById('InContainer_'+divId))
	{
	    if(non_IE)
    	    {
		divItemHeight = document.getElementById('InContainer_'+divId).offsetTop;
	    }
	    else
    	    {
		//document.getElementById('AgContainer_'+getAgendaIndexering()).style.display='inline-block'; // IE workaround
		//document.getElementById('InContainer_'+divId).style.display='inline-block'; // IE workaround
		//debug('agcont: '+document.getElementById('AgContainer_'+getAgendaIndexering()).offsetTop+', icont: '+document.getElementById('InContainer_'+divId).offsetTop);
		
		divItemHeight = (document.getElementById('AgContainer_'+getAgendaIndexering()).offsetTop+document.getElementById('InContainer_'+divId).offsetTop);
		// IE is onmogelijk om goed te scrollen in indexeringen van agenda. Daarom gekozen enkel agendapunten te volgen
		doTScroll=false; // hack om IE te negen?
		//console.log('height: '+divItemHeight);
		//divItemHeight-=48+document.getElementById('header').offsetHeight; // #header
	    }
	    
	}
	else
	{
	    doTScroll=false;
	    
	}
    }
    
    //debug('divItemHeight: '+divItemHeight);
    
    if(doTScroll)
    {
	if(document.getElementById("mainHeaderScrollContent"))
	{
	    height_of_scrollHeader = document.getElementById("mainHeaderScrollContent").clientHeight;
	    
	    // moet 58 zijn, anders aanpassen
	    alter=-58+height_of_scrollHeader; // alter wordt gebruikt in geval van hogere titel als verwacht
	    
	}else{ alter=0; }
	
	if(non_IE)
        {
    	    scrollToVar=divItemHeight-78-alter; //-divContentHeight;
	}
	else
        {
	    //fixme
	    scrollToVar=divItemHeight; //-alter; //-divContentHeight;
	}
	
	// perform scrolling
        objDiv.scrollTop = scrollToVar;
    }
}



// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)

// usage: put this after the scrollbox div:  var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');
function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 5;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{
        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
        //        this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);
            div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
                div_up_obj.setAttribute("onmouseover", scrollname + ".scrollUp();")
                div_up_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")

div_dn_obj.setAttribute("onmouseover", scrollname + ".scrollDown();")
                div_dn_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
            }
        }
    }
    

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
	    this.scrollCursor = this.div_obj.scrollTop;
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
        if (this.div_obj) {
	    this.scrollCursor = this.div_obj.scrollTop;
            this.scrollCursor += this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        }
    }

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}
