// called from onload tag
function preloadImages() {
        for (i=0;i<buttonsList.length;i++) {
                buttonsList[i].def                = newImage("images/but_"+buttonsList[i].type+"_"+buttonsList[i].content+"_def.gif");
                buttonsList[i].hig                = newImage("images/but_"+buttonsList[i].type+"_"+buttonsList[i].content+"_hig.gif");
                buttonsList[i].act                = newImage("images/but_"+buttonsList[i].type+"_"+buttonsList[i].content+"_act.gif");

                buttonsList[i].preload        = true;
        }
}

// called from button.preload
function newImage(arg) {
        if (document.images) {
                rslt = new Image();
                rslt.src = arg;
                return rslt;
        }
}

function draw_button() {
        for (i=0;i<buttonsList.length;i++) {

                if ( buttonsList[i].preload ) {
                        if ( buttonsList[i].active ) {
                                window[buttonsList[i].frame].document.images[buttonsList[i].type + '_' + buttonsList[i].content].src = buttonsList[i].act.src;
                                //window.status=buttonsList[i].status;
                        } else {
                                if ( buttonsList[i].over ) {
                                        window[buttonsList[i].frame].document.images[buttonsList[i].type + '_' + buttonsList[i].content].src = buttonsList[i].hig.src;
                                 //       window.status=buttonsList[i].status;
                                } else {
                                        //window[buttonsList[i].frame].document.images[buttonsList[i].type + '_' + buttonsList[i].content].src = buttonsList[i].def.src;
                                }
                        }
                }
        }
}

// class definition
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function navButton(frame, type, content, status) {
        this.type                = type;
        this.content        = content;
        this.frame                = frame;
        this.status                = status;
        this.active                = false;
        this.over                = false;
        this.preload        = false;
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// end class definition

// mouse actions on achors are send here (parent.mouse)
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function mouse(action, type, content, pageid) {
        // action                -> can be over,out,click
        // type                        -> can be function,channel,register
        // content                -> usually a part of the name of gif
        // pageid                -> pageid this page has in the database
        switch (action) {
                case 'over' :
                        for (i=0;i<buttonsList.length;i++) {
                                if ( buttonsList[i].type == type && buttonsList[i].content == content ) {
                                        buttonsList[i].over        = true;
                                        window.status = buttonsList[i].status;
                                }
                                else buttonsList[i].over = false;

                        }
                        draw_button();
                        //buttonsList[i].draw_button();

                break;
                case 'out' :
                        for (i=0;i<buttonsList.length;i++) {
                                if ( buttonsList[i].type == type && buttonsList[i].content == content ) buttonsList[i].over = false;

                        }
                        draw_button();
                        //buttonsList[i].draw_button();

                        window.status='';
                break;
                case 'click' :
                        // switch header images
                        if (pageid==null) {
                                top.contentframe.location.href = 'content_' + type + '_' + content + '.php3';
                        }else {
                                if (parseInt(pageid)>=1) {
                                        //top.contentframe.location.href = 'display.php3?pageid=' + pageid;
                                        top.contentframe.location.href = 'display.php3?pageid=' + pageid + '&type=' + type + '&content=' + content;
                                }else {
                                        top.contentframe.location.href = 'content_' + type + '_' + content + '.php3';
                                }
                        }

                        for (i=0;i<buttonsList.length;i++) {
                                if ( buttonsList[i].type == type && buttonsList[i].content == content ) buttonsList[i].active = true;
                                else buttonsList[i].active = false;

                        }
                        draw_button();
                        //buttonsList[i].draw_button();
                break;
                default : nothing;
        }
}
// end mouse actions

//CHANGE YG & ST - Nieuwe functie tbv de back-knop
function reloadtop(type,content)
{
    if (type != '' && content != '') {
      // set animation-gif to change_to
      top.topframe.document.images["animation"].src = 'images/top/' + type + '_' + content + '_a.gif';

      // set title-gif to change_to
      top.topframe.document.images["title"].src         = 'images/top/' + type + '_' + content + '_t.gif';
    }  
}

// Ad writing function
var magic2=Math.floor(Math.random() * 4573285835)
function makeAD(sito, tags, dimw, dimh)
{
	var now = new Date()
	var magic=now.getTime()
	return '<sc'+'ript language="JavaScript1.2" src="'+sito+'/jserver' + tags + '/ACC_RANDOM='+magic+'/PAGEID='+magic2+'"></sc'+'ript>';
}
