function showMovie(src, width, height) {
    var achtergrond = 'film_achtergrond';
    var frame = 'film_frame';
    
    var achtergrond_start = 85;
    var achtergrond_stop = 0;
    
    var frame_start = 100;
    var frame_stop = 0;
    
    if(document.getElementById(achtergrond).style.display == 'none') {
        achtergrond_start = 0;
        achtergrond_stop = 85;
        
        frame_start = 0;
        frame_stop = 100;
    }
    
    var display = document.getElementById(achtergrond).style.display;
    
    if(display == 'none') {
        styleDisplay(achtergrond);
        styleDisplay(frame);
        appendIframe(frame, src, width, height);
    } else {
        setTimeout("styleDisplay('" + achtergrond + "')", 200);
        setTimeout("styleDisplay('" + frame + "')", 200);
        removeIframe(frame);
    }
    
    fadeToOpacity(achtergrond, achtergrond_start, achtergrond_stop, 200);
    fadeToOpacity(frame, frame_start, frame_stop, 200);
}

function appendIframe(frame, src, width, height) {
    var iframe = document.createElement("IFRAME");
    iframe.setAttribute("src", src);
    iframe.setAttribute("width", width);
    iframe.setAttribute("height", height);
    iframe.setAttribute("class", "film_iframe");
    iframe.setAttribute("marginheight", 0);
    iframe.setAttribute("marginwidth", 0);
    iframe.setAttribute("scrolling", "no");
    iframe.setAttribute("frameborder", 1);
    
    document.getElementById(frame).appendChild(iframe);
}

function removeIframe(frame) {
    frame = document.getElementById(frame);
    
    for(var i = 0; i < frame.childNodes.length; i++) {
        if(frame.lastChild.nodeName == "IFRAME") {
            frame.removeChild(frame.lastChild);
        }
    }
}

function styleDisplay(id) {
    var display = document.getElementById(id).style.display;
    display = (display == 'none') ? 'block' : 'none';
    document.getElementById(id).style.display = display;
}

function fadeToOpacity(id, start, end, time) {
	var speed = Math.round(time / 100);
	var timer = 0;
	
	if(start > end) {
		for(i = start; i >= end; i--) {
			setTimeout("toOpacity('" + id + "', " + i + ")", (timer * speed));
			timer++;
		}
	} else if(start < end) {
		for(i = start; i <= end; i++) {
			setTimeout("toOpacity('" + id + "', " + i + ")", (timer * speed));
			timer++;
		}
	}
}

function toOpacity(id, opacity) {
	var object = document.getElementById(id).style;
	object.opacity = opacity / 100;
	object.MozOpacity = opacity / 100;
	object.KhtmlOpacity = opacity / 100;
	object.filter = "alpha(opacity=" + opacity + ")";
}
