		function writeFlashCode() {
			var flashspinCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + spin[0]['size_x'] + '" height="' + spin[0]['size_y'] + '" id="flashspin">';
			flashspinCode += '<param name="allowScriptAccess" value="always" />';
			flashspinCode += '<param name="movie" value="'+language+'/flashvr.swf?initscene=scene' + curr_spin + '" />';
			flashspinCode += '<param name="swLiveConnect" value="true" />';
			flashspinCode += '<param name="bgcolor" value="#cccccc" />';
			flashspinCode += '<embed src="'+language+'/flashvr.swf?initscene=scene' + curr_spin + '" bgcolor="#ffffff" width="' + spin[0]['size_x'] + '" height="' + spin[0]['size_y'] + '" id="flashspin" allowScriptAccess="always" scale=noBorder type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" swLiveConnect="true"/>';
			flashspinCode += '</object>';

			return flashspinCode;
		}

		document.writeln('<div id="spinDiv">');		
		if (spin[0]['flash'] != "1") {
			document.writeln('<applet id="ptviewer" name="ptviewer" archive="ptviewer.jar" code="ptviewer.class" width="' + spin[0]['size_x'] + '" height="' + spin[0]['size_y'] + '" mayscript="true">');

			var s = 0;
			while (s < spin.length) {
				var file = spin[s]['file'];
				var pan = spin[s]['initangle'];
				var tilt = spin[s]['inittilt'];
				var fov = parseInt(spin[s]['fov']) + 0;
				var fovmin = fov / (parseInt(spin[s]['maxzoom']) / 100);

				document.writeln('<param name="pano' + s + '" value=" {file=' + file + '};');
				document.writeln('			{pan=' + pan + '}');
				document.writeln('			{tilt=' + tilt + '}');
				document.writeln('			{fov=' + fov + '}');
				document.writeln('			{fovmin=' + fovmin + '}');
				document.writeln('			{waittime=0}');
		
				
				
					if (parseInt(spin[s]['part']) != 360) {
					var panmin = -175;
					var panmax = parseInt(spin[s]['part']) / 2 - 80;

					document.writeln('			{panmin=' + panmin + '}');
					document.writeln('			{panmax=' + panmax + '}');
				}
				
	
				
				
				var hs = 0; hsNr = 0;
				while (hs < spin[s]['hotspot'].length) {
				
					var hs_text = spin[s]['hotspot'][hs]['hs_text'];
					var hs_textcolor = spin[s]['hotspot'][hs]['hs_textcolor'];
					var pos_x = spin[s]['hotspot'][hs]['pos_x'];
					var pos_y = spin[s]['hotspot'][hs]['pos_y'];
					var pos_a = spin[s]['hotspot'][hs]['pos_a'];
					var pos_b = spin[s]['hotspot'][hs]['pos_b'];
					var position;
					if (typeof pos_a == "undefined" || pos_a == "null" || pos_a == null) {
						position = "X" + pos_x + " Y" + pos_y;
					} else {
						position = "X" + Math.round(pos_x - pos_a/2) + " Y" + Math.round(pos_y - pos_b/2) + " A" + Math.round(Number(pos_x) + pos_a/2) + " B" + Math.round(Number(pos_y) + pos_b/2);
					}						
					var hs_img = spin[s]['hotspot'][hs]['hs_img'];
					var target = spin[s]['hotspot'][hs]['target'];
					document.writeln("		{hotspot" + hsNr++ + "= " + position + " n'" + hs_text + "' q i'" + hs_img + "' u'" + target + "'}");
					document.writeln("		{hotspot" + hsNr++ + "= " + position + " c" + hs_textcolor + " n'" + hs_text + "' p i'" + hs_text + "' e}");
					
					hs++;
				}							
					
				document.writeln('">');
				s++;
			}
			document.writeln('<param name="file" value="ptviewer:' + (curr_spin-1) + '">');
			document.write('</applet>');
		}
		
		document.writeln('</div>');
