    function leesFile(naam)  {
        parent.frames[1].document.smorf.leesfile(naam+".smorf.bin");
        parent.frames[2].document.location = "textframe.php?filenaam=" + naam;
    }		
    	   	
	function ajax_getRandomFilenaam() {
		new Ajax.Request('php/getRandomFilenaam.php',
		  {
		    method:'post', 
		    onSuccess: function(transport){
		      var response = transport.responseText || "no response text";
		      leesFile(response);
		      //alert("Success! \n\n" + response);
		    },
		    onFailure: function(){ alert('Something went wrong...') }
		  });
	}
	
	var showWireframe=true;
	var display = "solid";
	var olddisplay = "solid";
	var showSticks = false;
	var showTexture = false;
	var showMillers = false;
	var showAxes = false;
	var transparency = 0.6;
	var rotate = true;
			
	function toggleWireframe() {
		showWireframe = !showWireframe; 
		document.smorf.showWireframe(showWireframe);
	}
	function toggleTexture() {
		showTexture = !showTexture;
		if (showTexture) {
			document.smorf.displaySticks()
		} else {
			document.smorf.displaySolid();
			if (!showWireframe) document.smorf.showWireframe(false);
		}
	}		
	function toggleSticks() {
		showSticks = !showSticks;
		if (showSticks) {
			document.smorf.displaySticks()
		} else {
			document.smorf.displaySolid();
			if (!showWireframe) document.smorf.showWireframe(false);
		}
	}
	function toggleMillers() {
		showMillers = !showMillers; 
		document.smorf.showMillers(showMillers);
	}
	function toggleAxes() {
		showAxes = !showAxes; 
		document.smorf.showAxes(showAxes);
	}
	function zoomIn() {
		document.smorf.zoom(1.2);
	}
	function zoomOut() {
		document.smorf.zoom(1/1.2);
	}
	function incTransparency() {
		transparency = transparency + 0.2;
		if (transparency > 1) transparency = 0;
		document.smorf.setTransparency(transparency);
	}
	function toggleRotation() {
		rotate = !rotate; 
		if (!rotate) document.smorf.stopRotation();
		document.smorf.setRotation(rotate);
	}
	function zoomInMillers() {
		if (showMillers) document.smorf.zoomMillers(1.2)
	}
	function zoomOutMillers() {
		if (showMillers) document.smorf.zoomMillers(1/1.2);
	}
	function toggleTexture() {
		showTexture = !showTexture;
		if (showTexture) {
			document.smorf.displayTextured()
		} else {
			document.smorf.displaySolid();
			if (!showWireframe) document.smorf.showWireframe(false);
		}
	}
