// Create the run button - optionally add a preview graphic the same size as the applet
function appletRunButton(name, width, height, jogl, preview){
	var div_id = "#"+name;
	$(div_id).width(width);
	$(div_id).height(height);
	var run_html = '';
	var top = ((height/2) - 25);
	if(preview === undefined); else{
		run_html += '<img src="'+preview+'" />';
		top -= height;
	}
	run_html += '<div id="runimg">';
	run_html += '<img src="http://www.robotacid.com/assets/run.png" /></div>';
	$(div_id).html(run_html);
	var img = "#runimg";
	$(div_id).css({cursor: "pointer", border:"solid 1px #333"});
	$(img).css({position:"relative", top:top, left:((width/2) - 25), zindex:2});
	$(div_id).click(function(){
		appletHtml(name, width, height);
	});
}
// Create applet html in the div reserved for the applet
function appletHtml(name, width, height){
	var div_id = "#"+name;
	var string = '<applet code="'+name+'" archive="'+name+'.jar" width="'+width+'" height="'+height+'" mayscript="true">';
	string += '<param name="image" value="loading.gif" />';
	string += '<param name="boxmessage" value="Loading Processing software..." />';
	string += '<param name="boxbgcolor" value="#FFFFFF" />';
	string += ' To view this content, you need to install Java from <a href="http://java.com">java.com</a>';
	string += '</applet>';
	$(div_id).html(string);
}