//////////////////
// LaTeX Addons //
//////////////////

			var numltx = 38;
			var ltxpack = new Array(numltx);
			var ltxusepack = new Array(numltx);
			ltxpack[0] = "amsfonts"; ltxusepack[0] = "\\usepackage{amsfonts}";
			ltxpack[1] = "amsmath"; ltxusepack[1] = "\\usepackage{amsmath}";
			ltxpack[2] = "amssymb"; ltxusepack[2] = "\\usepackage{amssymb}";
			ltxpack[3] = "cmbright"; ltxusepack[3] = "\\usepackage{cmbright}";
			ltxpack[4] = "graphicx"; ltxusepack[4] = "\\usepackage{graphicx}";
			ltxpack[5] = "multirow"; ltxusepack[5] = "\\usepackage{multirow}";
			ltxpack[6] = "palatino"; ltxusepack[6] = "\\usepackage{palatino}";
			ltxpack[7] = "rotating"; ltxusepack[7] = "\\usepackage{rotating}";
			ltxpack[8] = "times"; ltxusepack[8] = "\\usepackage{times}";
			ltxpack[9] = "arev"; ltxusepack[9] = "\\usepackage{arev}";
			ltxpack[10] = "colortbl"; ltxusepack[10] = "\\usepackage{colortbl}";
			ltxpack[11] = "helvet"; ltxusepack[11] = "\\usepackage{helvet}";
			ltxpack[12] = "textcomp"; ltxusepack[12] = "\\usepackage{textcomp}";
			ltxpack[13] = "url"; ltxusepack[13] = "\\usepackage{url}";
			ltxpack[14] = "ifthen"; ltxusepack[14] = "\\usepackage{ifthen}";
			ltxpack[15] = "calc"; ltxusepack[15] = "\\usepackage{calc}";
			ltxpack[16] = "array"; ltxusepack[16] = "\\usepackage{array}";
			ltxpack[17] = "txfonts"; ltxusepack[17] = "\\usepackage{txfonts}";
			ltxpack[18] = "qtree"; ltxusepack[18] = "\\usepackage{qtree}";
			ltxpack[19] = "tipa"; ltxusepack[19] = "\\usepackage{tipa}";
			ltxpack[20] = "varioref"; ltxusepack[20] = "\\usepackage{varioref}";
			ltxpack[21] = "cancel"; ltxusepack[21] = "\\usepackage{cancel}";
			ltxpack[22] = "lhelp"; ltxusepack[22] = "\\usepackage{lhelp}";
			ltxpack[23] = "tabularx"; ltxusepack[23] = "\\usepackage{tabularx}";
			ltxpack[24] = "booktabs"; ltxusepack[24] = "\\usepackage{booktabs}";
			ltxpack[25] = "fancyhdr"; ltxusepack[25] = "\\usepackage{fancyhdr}";
			ltxpack[26] = "inputenc"; ltxusepack[26] = "\\usepackage{inputenc}";
			ltxpack[27] = "amsthm"; ltxusepack[27] = "\\usepackage{amsthm}";
			ltxpack[28] = "fontenc [T1]"; ltxusepack[28] = "\\usepackage[T1]{fontenc}";
			ltxpack[29] = "tikz"; ltxusepack[29] = "\\usepackage{tikz}";
			ltxpack[30] = "siunitx"; ltxusepack[30] = "\\usepackage{siunitx}";
			ltxpack[31] = "verbatim"; ltxusepack[31] = "\\usepackage{verbatim}";
			ltxpack[32] = "color"; ltxusepack[32] = "\\usepackage{color}";
			ltxpack[33] = "units"; ltxusepack[33] = "\\usepackage{units}";
			ltxpack[34] = "pstricks"; ltxusepack[34] = "\\usepackage{pstricks}";
			ltxpack[35] = "pst-eucl"; ltxusepack[35] = "\\usepackage{pst-eucl}";
			ltxpack[36] = "mathtools"; ltxusepack[36] = "\\usepackage{mathtools}";
			ltxpack[37] = "vaucanson-g"; ltxusepack[37] = "\\usepackage{vaucanson-g}";

//////////////////////////
// Initialize variables //
//////////////////////////

			var nosvg = true;   // False if SVG support
			var screenWidth;    // Maximum width used
			var screenHeight;   // Maximum height used
			var wrapper;        // wrapper DIV
			var logo;           // logo DIV
			var content;        // content DIV
			var source;         // source DIV
			var sourcecode;     // source code DIV
			var preview;        // preview DIV
			var svg;            // SVG radio button
			var png;            // PNG radio button
			var addons;         // addons DIV
			var ltxoff;         // available LaTeX addons textbox
			var ltxon;          // included LaTeX addons textbox
			var previewiframe;  // preview iframe
			var buttons;        // buttons DIV
			var srcbuttons;     // source buttons DIV
			var previewbuttons; // preview buttons DIV
			var attachment;     // download textbox
			var emailme;        // email me DIV
			var figure;         // hidden form for processing data
			var pastebin;       // hidden form for sending code to pastebin
			var svgwin;         // popup window

///////////////////////
// Email Me Function //
///////////////////////

			function emailMe() {	document.location.href='\x6d\x61\x69\x6c\x74\x6f\x3a\x74\x68\x65\x6e\x64\x65\x72\x73\x6f\x6e\x40\x75\x6d\x6f\x62\x69\x6c\x65\x2e\x65\x64\x75' }

////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Check for Browser SVG Support (thanks to BTreeHugger's Blog -- http://thomas.tanreisoftware.com/?p=79) //
////////////////////////////////////////////////////////////////////////////////////////////////////////////

			function detectSVG() {
				var results = { support:null, plugin:null, builtin:null };
				var obj = null;
				if ( navigator && navigator.mimeTypes && navigator.mimeTypes.length ) {
					for ( var mime in { "image/svg+xml":null, "image/svg":null, "image/svg-xml":null } ) {
						if ( navigator.mimeTypes[ mime ] && ( obj = navigator.mimeTypes[ mime ].enabledPlugin ) && obj )
							results = { plugin:( obj = obj.name.toLowerCase()) && obj.indexOf( "adobe" ) >= 0 ? "Adobe" : ( obj.indexOf( "renesis" ) >= 0 ? "Renesis" : "Unknown" ) };
					}
				} else if ( ( obj = document.createElement( "object" )) && obj && typeof obj.setAttribute( "type", "image/svg+xml" )) {
					if ( typeof obj.USE_SVGZ == "string" )
						results = { plugin:"Adobe", IID:"Adobe.SVGCtl", pluginVersion:obj.window && obj.window._window_impl ? ( obj.window.evalScript ? 6 : 3 ) : 2 };
					else if ( typeof obj.ReadyState == "number" && obj.ReadyState == 0 )
						results = { plugin:"Renesis", IID:"RenesisX.RenesisCtrl.1", pluginVersion:">=1.0" };
					else if ( obj.window && obj.window.getSVGViewerVersion().indexOf( "enesis" ) > 0 )
						results = { plugin:"Renesis", IID:"RenesisX.RenesisCtrl.1", pluginVersion:"<1.0" };
				}
				results.IID = ( results.plugin == "Adobe" ? "Adobe.SVGCtl" : ( results.plugin == "Renesis" ? "renesisX.RenesisCtrl.1" : null ));

				// Does the browser support SVG natively? Gecko claims no support if a plugin is active, but still gives back an NSI interface. Safari 3 does not claim support but does - use devicePixelRatio
				var claimed = !!window.devicePixelRatio || ( typeof SVGAngle == "object" || ( document && document.implementation && document.implementation.hasFeature( "org.w3c.dom.svg", "1.0" )));
				var nsi = window.Components && window.Components.interfaces && !!Components.interfaces.nsIDOMGetSVGDocument;
				results.builtin = claimed ? ( !!window.opera ? "Opera" : ( nsi ? "Gecko" : "Safari" )) : ( !!window.opera && window.opera.version ? "Opera" : ( nsi ? "Gecko" : null ));
				results.builtinVersion = results.builtin && !!window.opera ? parseFloat( window.opera.version()) : ( nsi ? ( typeof Iterator == "function" ? ( Array.reduce ? 3.0 : 2.0 ) : 1.5 ) : null );

				// Which is active, the plugin or native support? Opera 9 makes it hard to tell..
				if ( !!window.opera && results.builtinVersion >= 9 && ( obj = document.createElement( "object" )) && obj && typeof obj.setAttribute( "type", "image/svg+xml" ) != "undefined" && document.appendChild( obj )) {
					results.support = obj.offsetWidth ? "Plugin" : "Builtin";
					document.removeChild( obj );
				} else
					results.support = results.plugin && !claimed ? "Plugin" : ( results.builtin && claimed ? "Builtin" : null );
				return results;
			}
			if ( (navigator.appName != "Microsoft Internet Explorer") && (detectSVG().support != null) ) { nosvg = false; }

////////////////////////////////////////////////////////////
// Homemade function to approximate font size (in pixels) //
////////////////////////////////////////////////////////////

			function pttopx(pt) {
				return Math.round(5/84*pt*pt+pt/28+145/21);
			}

///////////////////////////////////////////////////////////////////
// Resize the previewer initially and whenever window is resized //
///////////////////////////////////////////////////////////////////

			function resizePreviewer() {
				// Screen size
				if (self.innerHeight) {
					screenWidth = self.innerWidth;
					screenHeight = self.innerHeight;
				} else if (document.documentElement && document.documentElement.clientHeight) {
					screenWidth = document.documentElement.clientWidth;
					screenHeight = document.documentElement.clientHeight;
				} else if (document.body) {
					screenWidth = document.body.clientWidth;
				screenWidth = document.body.clientHeight;
				}
				screenWidth = Math.min(screen.width,screenWidth);
				screenHeight = Math.min(screen.height,screenHeight);

				// Fixed Width font sizes
				prefontpt = Math.round(screenHeight/160+4.05) + 1;
				prefontpx = pttopx(Math.round(screenHeight/160+4.05)) + 2;
				var ltxpre = document.getElementById("LTXPRE");
				var ltxpost = document.getElementById("LTXPOST");
				ltxpre.style.fontSize = prefontpt + "pt";
				ltxpost.style.fontSize = prefontpt + "pt";
				ltxoff.style.fontSize = prefontpt + "pt";
				ltxon.style.fontSize = prefontpt + "pt";

				// Previewer wrapper is ~ 95% of browser window
				wrapperWidth = Math.floor(0.95*screenWidth);
				wrapperHeight = Math.floor(0.95*screenHeight);

				// Size of the top DIV holding the logo
				logoWidth = wrapperWidth;
				logoHeight = Math.floor(0.13*wrapperHeight);

				// Size of the bottom DIV holding the buttons
				buttonsWidth = wrapperWidth;
				buttonsHeight = Math.floor(0.1*wrapperHeight);

				// Size of the DIV between the logo and buttons
				contentWidth = wrapperWidth;
				contentHeight = wrapperHeight - logoHeight - buttonsHeight;

				// Size of the DIV holding the MetaPost source code
				sourceWidth = Math.floor(0.5*contentWidth - 2*source.style.marginLeft.replace(/px,*\)*/g,"") - 2*source.style.marginRight.replace(/px,*\)*/g,""));
				sourceHeight = contentHeight - source.style.marginTop.replace(/px,*\)*/g,"") - source.style.marginBottom.replace(/px,*\)*/g,"") - 2*prefontpx;

				// Size of the DIV holding the preview iframe
				previewWidth = sourceWidth;
				previewHeight = sourceHeight;
				
				// Size of the DIV inside the buttons DIV for the source buttons
				srcbuttonsWidth = Math.floor(0.5*buttonsWidth);
				srcbuttonsHeight = buttonsHeight;

				// Size of the DIV inside the buttons DIV for the preview buttons
				previewbuttonsWidth = Math.floor(0.5*buttonsWidth);
				previewbuttonsHeight = buttonsHeight;

				// Style the wrapper DIV
				wrapper.style.width = wrapperWidth + "px";
				wrapper.style.height = wrapperHeight + "px";
				wrapper.style.display = "block";
				
				// Style to logo DIV
				logo.style.width = logoWidth + "px";
				logo.style.height = logoHeight + "px";
				logo.style.display = "block";

				// Style the content DIV
				content.style.width = contentWidth + "px";
				content.style.height = contentHeight + "px";
				content.style.display = "block";

				// Style the source DIV
				source.style.width = sourceWidth + "px";
				source.style.height = sourceHeight + "px";
				source.style.display = "block";

				// Style the sourcecode textarea
				sourcecode.style.width = sourceWidth + "px";
				sourcecode.style.height = (sourceHeight - (ltxpre.innerHTML.split(/\n/).length + ltxpost.innerHTML.split(/\n/).length + 2)*prefontpx) + "px";
				sourcecode.style.fontSize = prefontpt + "pt";
				sourcecode.style.border = "1px solid black";

				// Style the preview DIV
				preview.style.width = previewWidth + "px";
				preview.style.height = previewHeight + "px";

				// Style the addons DIV
				addons.style.width = previewWidth + "px";
				addons.style.height = previewHeight + "px";

				// Style the LaTeX addons textboxes
				ltxoff.style.width = Math.floor(previewWidth/3) + "px";
				ltxoff.style.height = (3/4*previewWidth) + "px";
				ltxon.style.width = ltxoff.style.width;
				ltxon.style.height = ltxoff.style.height;

				// Style the preview iframe
				previewiframe.style.width = (previewWidth-prefontpx) + "px";
				previewiframe.style.height = (previewHeight-2*prefontpx) + "px";
//				previewiframe.style.border = "1px solid black";
				previewiframe.style.backgroundColor = "white";

				// Style the buttons DIV
				buttons.style.width = buttonsWidth + "px";
				buttons.style.height = buttonsHeight + "px";
				buttons.style.display = "block";

				// Style the source buttons DIV
				srcbuttons.style.width = srcbuttonsWidth + "px";
				srcbuttons.style.height = srcbuttonsHeight + "px";
				srcbuttons.style.display = "block";

				// Style the preview buttons DIV
				previewbuttons.style.width = srcbuttonsWidth + "px";
				previewbuttons.style.height = srcbuttonsHeight + "px";

				// Style the SPAN to email me
				emailme.style.fontSize = prefontpt + "pt";
				emailme.style.width = previewbuttonsWidth + "px";
				emailme.style.height = prefontpx + "px";
			}

/////////////////////////////////////////////////////////////////
// Remove \documentclass, \begin{document}, and \end{document} //
/////////////////////////////////////////////////////////////////
			function removecustom() {
				var thesource = sourcecode.value;
				thesource = thesource.split("\n");
				var newsource="";
				var line;
				var good;
				for (n=0;n<thesource.length;n++) {
					good=true;
					line = thesource[n].match(/\\documentclass.*/);
					if(!(line == null)) { good=false; }
					line = thesource[n].match(/\\documentstyle.*/);
					if(!(line == null)) { good=false; }
					line = thesource[n].match(/\\begin{document}/);
					if(!(line == null)) { good=false; }
					line = thesource[n].match(/\\thispagestyle.*/);
					if(!(line == null)) { good=false; }
					line = thesource[n].match(/\\end{document}/);
					if(!(line == null)) { good=false; }
					if(good) {
						newsource = newsource + thesource[n];
						if(n<thesource.length-1)
							newsource = newsource + "\n";
					}
				}
				sourcecode.value = newsource;
			}

/////////////////////////////////////////////////////////////
// Translated \usepackage{...} to include allowed packages //
/////////////////////////////////////////////////////////////
			function parsepackages() {
				var thesource = sourcecode.value;
				thesource = thesource.split("\n");
				var newsource="";
				var line;
				var packages;
				var bad;
				for (n=0;n<thesource.length;n++) {
					line = thesource[n].match(/^\\usepackage(?:\[.*\])?{(.*)}$/);
					if(! (line == null)) {
						line = line[0];
						packages = line.match(/^\\usepackage(?:\[.*\])?{(.*)}$/)[1].split(",");
						for(m=0;m<packages.length;m++) {
							bad=true;
							for (j=0;j<ltxon.options.length;j++) {
								if(packages[m] == ltxon.options[j].text) {
									bad=false;
									j=ltxon.options.length;
								}
							}
							if(bad) {
								for (j=0;j<ltxoff.options.length;j++) {
									if(packages[m] == ltxoff.options[j].text) {
										ltxon.options[ltxon.options.length] = new Option(ltxoff.options[j].text,ltxoff.options[j].value);
										ltxoff.options[j] = null;
										bad=false;
										j=ltxoff.options.length;
									}
								}
							}
							if(bad) 
								alert("Package \""+packages[m]+"\" is not allowed.\nIf you need it added, email me (Troy Henderson)!!!");
						}
					} else {
						newsource = newsource + thesource[n];
						if(n<thesource.length-1)
							newsource = newsource + "\n";
					}
				}
				sourcecode.value = newsource;
			}

//////////////////////////
// Show the preview DIV //
//////////////////////////

			function showpreview() {
				addons.style.width = "0";
				addons.style.height = "0";
				addons.style.border = "0";
				addons.style.margin = "0";
				addons.style.display = "none";
				emailme.style.width = "0";
				emailme.style.height = "0";
				emailme.style.display = "none";
				preview.style.width = previewWidth + "px";
				preview.style.height = previewHeight + "px";
				preview.style.display="block";
				previewiframe.style.display = "block";
				previewiframe.style.border = "1px solid black";
				previewiframe.src = "loading.html";
				previewbuttons.style.width = srcbuttonsWidth + "px";
				previewbuttons.style.height = srcbuttonsHeight + "px";
				previewbuttons.style.display = "block";

				figure.width.value = previewWidth;
				figure.height.value = previewHeight;
				figure.ltx.value = "";
				removecustom()
				parsepackages();
				for (n=0;n<ltxon.options.length;n++) { figure.ltx.value += ltxon.options[n].value + "\n"; }
				figure.ltxsource.value = sourcecode.value;
				if(svg.checked == true) { figure.result.value = "preview"; } else { figure.result.value = "png"; }
				figure.target = "previewiframe";
				attachment.options.selectedIndex = 0;
				if(svgwin) { svgwin.close() };
				resizePreviewer();
				figure.init.value = "0";
				setTimeout("figure.submit()",250);
//				figure.submit();
			}

//////////////////////////////////////////////////
// Add available LaTeX addon to included addons //
//////////////////////////////////////////////////

			function addltx() {
				if (ltxoff.selectedIndex != -1) {
					ltxon.options[ltxon.options.length] = new Option(ltxoff.options[ltxoff.selectedIndex].text,ltxoff.options[ltxoff.selectedIndex].value);
					ltxoff.options[ltxoff.selectedIndex] = null;
				}
			}
	
/////////////////////////////////
// Remove included LaTeX addon //
/////////////////////////////////

			function removeltx() {
				if (ltxon.selectedIndex != -1) {
					ltxoff.options[ltxoff.options.length] = new Option(ltxon.options[ltxon.selectedIndex].text,ltxon.options[ltxon.selectedIndex].value);
					ltxon.options[ltxon.selectedIndex] = null;
					sortoff("LTX");
				}
			}

//////////////////////////////////////////
// Sort available addons alphabetically //
//////////////////////////////////////////

			function sortoff(off) {
				var avail = document.getElementById(off + "OFF");
				var tmp = new Array();
				for (n=0;n<avail.options.length;n++) {	tmp[n] = new Option(avail.options[n].text,avail.options[n].value); }
				tmp.sort( function (a,b) { return a.text!=b.text ? a.text<b.text ? -1 : 1 : 0; } );
				for (n=0;n<tmp.length;n++) { avail.options[n] = new Option(tmp[n].text,tmp[n].value); }
			}

/////////////////////
// Show addons DIV //
/////////////////////

			function showaddons() {
				preview.style.width = "0";
				preview.style.height = "0";
				preview.style.border = "0";
				preview.style.margin = "0";
				preview.style.display = "none";
				previewiframe.style.display = "none";
				previewbuttons.style.width = "0";
				previewbuttons.style.height = "0";
				previewbuttons.style.display = "none";
				addons.style.width = previewWidth + "px";
				addons.style.height = previewHeight + "px";
//				addons.style.marginLeft = "2ex";
				addons.style.border = "0";				
				addons.style.display = "block";
				emailme.style.width = previewbuttonsWidth + "px";
				emailme.style.height = prefontpx + "px";
				emailme.style.display = "block";
			}

/////////////////////////////////////
// Reset settings to initial state //
/////////////////////////////////////

			function reset() {
//				sourcecode.value = "";
				for(n=ltxoff.options.length-1;n>=0;n--) { ltxoff.options[n] = null; }
				for(n=ltxon.options.length-1;n>=0;n--) { ltxon.options[n] = null; }
				for(n=0;n<numltx;n++) {	ltxoff.options[n] = new Option(ltxpack[n],ltxusepack[n]); }
				attachment.options.selectedIndex = 0;
				sortoff("LTX");
				if(svgwin) { svgwin.close() };
				figure.ltxsource.value = "";
				figure.target = "previewiframe";
				figure.result.value = null;
				preview.style.display = "none";
				previewiframe.style.border = "0";
				previewiframe.style.display = "none";
				previewbuttons.style.display = "none";
				addons.style.display = "none";
				emailme.style.display = "none";
				if (nosvg == false) {
					svg.checked = true;
					png.checked = false;
				} else {
					svg.checked = false;
					png.checked = true;
				}
				figure.init.value = "1";
				figure.submit();
//				sourcecode.value = "Place some LaTeX code here";
//				sourcecode.select();
				sourcecode.focus();
				message();
			}

////////////////////////////
// A Message to the Users //
////////////////////////////
			function message() {
				preview.style.width = previewWidth + "px";
				preview.style.height = previewHeight + "px";
				preview.style.display = "block";
				previewiframe.style.border = "0";
				previewiframe.style.display = "block";
				previewbuttons.style.display = "none";
				previewiframe.style.backgroundColor = "#dcedff";
				previewiframe.style.border = "0";
				previewiframe.src = "message.html";
			}

//////////////////////
// Send to PasteBin //
//////////////////////
			function topastebin() {
				var pastebincode;
				pastebincode = "\\documentclass{article}\n";
            for (n=0;n<ltxon.options.length;n++) { pastebincode += ltxon.options[n].value + "\n"; }
				pastebincode += "\\begin{document}\n";
				pastebincode += "\\thispagestyle{empty}\n";
            pastebincode += sourcecode.value + "\n";
            pastebincode += "\\end{document}\n";
            pastebin.code.value = pastebincode;
            pastebin.submit();
         }

////////////////////////////
// Popup the MetaPost log //
////////////////////////////
			function log() {
				figure.width.value = previewWidth;
				figure.height.value = previewHeight;
				figure.ltx.value = "";
				for (n=0;n<ltxon.options.length;n++) { figure.ltx.value += ltxon.options[n].value + "\n"; }
				figure.ltxsource.value = sourcecode.value;
				figure.result.value = "log";
				figure.target = "previewiframe";
				previewiframe.scrolling = "yes";
				if(svgwin) { svgwin.close() };
				svgwin = window.open("","svgwin","width="+previewWidth+",height="+Math.floor(previewHeight/2)+",resizeable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no");
				figure.target = "svgwin";
				figure.submit();
				svgwin.focus();
			}

/////////////////////////////////
// Popup the previewed graphic //
/////////////////////////////////

			function popup() {
				figure.width.value = previewWidth;
				figure.height.value = previewHeight;
				figure.ltx.value = "";
				for (n=0;n<ltxon.options.length;n++) { figure.ltx.value += ltxon.options[n].value + "\n"; }
				figure.ltxsource.value = sourcecode.value;
				if(svg.checked == true) {
					figure.result.value = "popup";
				} else {
					figure.result.value = "png";
//					figure.width.value = screen.availWidth;
//					figure.height.value = screen.availHeight;
					figure.width.value = Math.floor(4/3*previewWidth);
					figure.height.value = Math.floor(4/3*previewHeight);
				}
//				svgwin = window.open("","svgwin","width="+screen.availWdith+",height="+screen.availHeight+",resizeable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no");
				svgwin = window.open("","svgwin","width="+Math.floor(4/3*previewWidth)+",height="+Math.floor(4/3*previewHeight)+",resizeable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no");
				figure.target = "svgwin";
				resizePreviewer();
				figure.submit();
				svgwin.focus();
			}

/////////////////////////////////////////////////
// Download the selected vector graphic format //
/////////////////////////////////////////////////

			function download() {
				figure.width.value = previewWidth;
				figure.height.value = previewHeight;
				figure.ltx.value = "";
				for (n=0;n<ltxon.options.length;n++) { figure.ltx.value += ltxon.options[n].value + "\n"; }
				figure.ltxsource.value = sourcecode.value;
				figure.result.value = attachment.options[attachment.options.selectedIndex].value;
				figure.target = "previewiframe";
				if (attachment.options.selectedIndex > 0 ) { figure.submit(); }
				setTimeout(function () { attachment.options.selectedIndex = 0; },1000);
			}

//////////////////////////////////////////////
// Initialize all data, settings, and sizes //
//////////////////////////////////////////////

			function init() {
				wrapper = document.getElementById("WRAPPER");
				logo = document.getElementById("LOGO");
				content = document.getElementById("CONTENT");
				source = document.getElementById("SOURCE");
				sourcecode = document.getElementById("SOURCECODE");
				preview = document.getElementById("PREVIEW");
				svg = document.getElementById("SVG");
				png = document.getElementById("PNG");
				addons = document.getElementById("ADDONS");
				ltxoff = document.getElementById("LTXOFF");
				ltxon = document.getElementById("LTXON");
				previewiframe = document.getElementById("PREVIEWIFRAME");
				buttons = document.getElementById("BUTTONS");
				srcbuttons = document.getElementById("SRCBUTTONS");
				previewbuttons = document.getElementById("PREVIEWBUTTONS");
				attachment = document.getElementById("ATTACHMENT");
				emailme = document.getElementById("EMAILME");
				figure = document.getElementById("FIGURE");
				pastebin = document.getElementById("PASTEBIN");

				resizePreviewer();
				reset();
			}
