function makeFontURL(id) { 
	var furl = '/fontgen/arcade.php';
			if($('#bubble'+ id).attr("checked")){ 
				// speech bubble enabled! add options. 
				if($('#bubflip'+id).attr("checked")) { 
					// it's flipped, so 
					furl = furl + '/b-u';
				} else { 
					furl = furl + '/b-d';
				}
				furl = furl + '/bp-' + $('#bubpos'+id).slider('value');
			}
			furl = furl + '/y-'+$('#pickfont'+id).val();
			furl = furl + '/z-'+$('#varfont'+id).val();
			if($('#sizefont'+id).val() > 1) { 
				furl = furl + '/dbl-' + $('#sizefont'+id).val();
			}
			furl = furl + '/x-'+ $('#labeltext'+id).val();
			toggleReport();
		return furl;
}
function fixDragAndClip(divtofix) { 
								var basepos =  $('#scene').offset();
								var ew = $(divtofix).width();
								var eh = $(divtofix).height();
								var cx1 = Math.floor(basepos.left - ((ew / 4)*3));
								var cy1 = Math.floor(basepos.top - ((eh/4)*3));
								var cx2 = Math.floor(basepos.left + $('#scene').width() + parseInt($('#scene').css('border-left-width')) - (ew / 4));
								var cy2 = Math.floor(basepos.top + $('#scene').height() + parseInt($('#scene').css('border-top-width')) - (eh / 4));
								$(divtofix).draggable('option', 'containment', [cx1, cy1, cx2, cy2] );
								$(divtofix).clipBy({clipdiv: '#scene'});
}

function toggleReport() { 
	if($('#scene img').length > 0) { 
		$('#doreport').show();
	} else { 
		$('#doreport').hide();
	}
}
function buildVars(numberVars, appendTo, extra, file) { 
	$(appendTo).empty();
	$(appendTo).load("names.php?f="+file+"&c="+numberVars+"&e="+extra);
}
$(document).ready(function() { 
	$('#pl, #sp, #bs,#bg').val("none");
	$('#bubble1,#bubflip1,#bubble2,#bubflip2').attr("checked",false);
	$('#pickfont1,#varfont1,#pickfont2,#varfont2').val(0);
	$('#bullets').data("info", {nextbullet : 0});
	$('#enemies').data("info", {nextenemy : 0});
	$('#shots').data("info", {nextshot : 0});
	$('#textcol1, #textcol2, #report').hide();
	$('#sizefont1, #sizefont2').val(2);
	toggleReport();
	$('#texttog1').click(function() { 
		$('#textcol1').toggle();
	});
	
	$('#texttog2').click(function(){ 
		$('#textcol2').toggle();
	});
	//$('#fliptext').hide()
	//$('#fliptext2').hide();
	// create initial font dropdown
	$('#bubpos1').slider({ 
		value: 25,
		min: 0, 
		max: 100,
		step: 5, 
		slide: function(event,ui) { 
			$('#pos1').html(ui.value + "%");	
		},
		change: function(event, ui) { 

			$('#tx1').attr('src',makeFontURL(1));
			$('#pos1').html(ui.value + "%");
		}
	});
		$('#bubpos2').slider({ 
		value: 25,
		min: 0, 
		max: 100,
		step: 5, 
		slide: function(event,ui) { 
			$('#pos2').html(ui.value + "%");	
		},
		change: function(event, ui) { 
			$('#tx2').attr('src',makeFontURL(2));
			$('#pos2').html(ui.value + "%");
		}
	});
	buildVars($('#pickfont1 option:selected').attr("variants"), '#varfont1', 'Version', $('#pickfont1 option:selected').val());
	buildVars($('#pickfont2 option:selected').attr("variants"), '#varfont2', 'Version', $('#pickfont2 option:selected').val());
		$('#textcol1, #textcol2, #report').hide();
	$('#bg').change(function() { 
		var img = $('#bg').val();
		if(img == "none") { 
			$('#scene').css({backgroundImage: 'none'});
		} else { 
			$('#scene').css({backgroundImage: 'url("'+ img + '")'});
			if($('#bg option:selected').attr("variants")) {
							$('#bgvardiv').remove();
							$('#bg').after( '<span id="bgvardiv"><br /><label>Option:</label> <select id="bgvar"></select></span>');
							buildVars($('#bg option:selected').attr("variants"), '#bgvar', 'Version', $('#bg option:selected').val());
							var src = $('#scene').css('background-image');
							// gives me url(http://shmups.info/hori/imgname)
							src = src.substring(src.indexOf('/bg/'));
							src = src.replace(')','');
							src= src.replace('"','');
							$('#scene').css('background-image', 'url("bgoffset.php?o=0'+src +'")');
							$('#bgvar').bind('change', function(){
								var src = $('#scene').css('background-image');
								src = src.substring(src.indexOf('/bg/'));
								src = src.replace(')','');
								src= src.replace('"','');
								$('#scene').css('background-image', 'url("bgoffset.php?o=' + $('#bgvar option:selected').val() + src +'")');
							});
							
						} else { 
							$('#bgvardiv').remove();
						}
		}
	});		
$('#bs').change(function(){
		var img = $('#bs').val();
		if(img == "none") { 
			$('#boss').remove();
			$('#bsvardiv').remove();
		} else { 
			$('#boss').remove();
			$('#scene').append('<img src="'+img+'" style="position: absolute;" id="boss" />');
				$(this).oneTime(300, "boss",function() { 
					if($('#bs option:selected').attr("variants")) {
						$('#bsvardiv').remove();
						$('#bs').after( '<div id="bsvardiv"> <label for="bsvar">Option:</label><select id="bsvar"></select></div>');
						buildVars($('#bs option:selected').attr("variants"), '#bsvar', 'Version',$('#bs option:selected').val());
						var src = $('#boss').attr('src');
						$('#boss').attr('src', 'offset.php?o=0/'+src);
						$('#bsvar').bind('change', function(){
							var src = $('#boss').attr('src');
							src = src.substring(src.indexOf('/')); // get the source. 
							$('#boss').attr('src', 'offset.php?o=' + $('#bsvar').val() + src);
						});
						$(this).oneTime(300, "fixagain", function() { fixDragAndClip('#boss')});
					} else { 
						$('#bsvardiv').remove();
					}
			$(this).oneTime(300, "boss",function() {fixDragAndClip('#boss')});
			fixDragAndClip('#boss');
				});
			$('#boss').draggable({
				containment: '#scene', 
				grid: [2,2],
				drag: function() { 
					$('#boss').clipBy({clipdiv: '#scene'});
				},
				stop: function() { 
					$('#boss').clipBy({clipdiv: '#scene'});
				},
				stack: { group: '#scene img', min: 25 }	
			});				
			}
			toggleReport();
	});
	$('#sp').change(function() { 
		var img = $('#sp').val();
		if(img == "none") { 
			$('#speech').remove(); 
		} else { 
			if($('#speech').length < 1) { 
				$('#scene').append('<img id="speech" style = "position: absolute" src="'+img+'"/>');
			} else { 
				$('#speech').attr('src', img);
			}
			$('#speech').draggable({ 
				containment: '#scene', 
				grid: [2,2],
				stack: { group: '#scene img', min: 25 }
			});
		}
		toggleReport();
	});
	$('#pl').change(function() { 
		var img = $('#pl').val();
		if(img == "none") { 
			$('#player').remove();
		} else { 
			$('#player').remove();
			$('#scene').append('<img id="player" style = "position: absolute" src="'+img+'"/>');
			$(this).oneTime(100, "plfix",function() { 
				if($('#pl option:selected').attr("variants")) {
					$('#plvardiv').remove();
					$('#pl').after( '<div id="plvardiv"><label>Option:</label> <select id="plvar"></select></div>');
					buildVars($('#pl option:selected').attr("variants"), '#plvar', 'Player',$('#pl option:selected').val());
					var src = $('#player').attr('src');
					$('#player').attr('src', 'offset.php?o=0/'+src);
					
					$('#plvar').bind('change', function(){
						var src = $('#player').attr('src');
						src = src.substring(src.indexOf('/'));
						$('#player').attr('src', 'offset.php?o=' + $('#plvar').val() + src);
					});
					$(this).oneTime(100, "fixagain", function() {
						$('#player').draggable('option', 'containment', '#scene');
					});
				} else { 
					$('#plvardiv').remove();
				}
			});
			$('#player').draggable({ 
				containment: '#scene', 
				grid: [2,2],
				stack: { group: '#scene img', min: 25 }
			});
		}
		toggleReport();
	});
		$('#addbullet').click(function() {
		if($('.bullet_class').length >= 15 ) { return false;}
		var nextbullet = $('#bullets').data("info").nextbullet + 1;
		$('#bullets').append('<div id="bulletdiv' + nextbullet + '"><label for="bulletopt'+nextbullet+'">Bullet:</label> <select id="bulletopt'+nextbullet+'">'+ $('#bullets').data("opts").boptions +'</select> <input type="button" id="delbullet'+nextbullet+'" value="X" /></div>');
		$('#scene').append('<img style = "position: absolute" class="bullet_class" src="'+ $('#bullets').data("db").defbullet +'" id="bl'+nextbullet+'" />');
		$('#bl' + nextbullet).draggable({
			containment: '#scene',
			grid: [2,2],
			drag: function() { 
				$('#bl'+nextbullet).clipBy({clipdiv: '#scene'});
			},
			stop: function() { 
				$('#bl'+nextbullet).clipBy({clipdiv: '#scene'});
			},
			stack: { group: '#scene img', min: 25 }
		});
		
		$(this).oneTime(100, "bl",function() { 
			if($('#bulletopt'+nextbullet+' option:selected').attr("variants")) { 
				$('#bulletvar'+nextbullet).remove();
				$('#bulletopt' + nextbullet).after( '<select style="width: 75px;" id="bulletvar'+nextbullet+'"></select>');
				buildVars($('#bulletopt'+nextbullet+' option:selected').attr("variants"), '#bulletvar'+nextbullet, '',$('#bulletopt'+nextbullet+' option:selected').val());
				var src = $('#bl'+nextbullet).attr('src');
				$('#bl'+nextbullet).attr('src', 'offset.php?o=0/'+src);
				$('#bulletvar'+nextbullet).bind('change', function(){
					var src = $('#bl'+nextbullet).attr('src');
					src = src.substring(src.indexOf('/')); // get the source. 
					$('#bl' + nextbullet).attr('src', 'offset.php?o=' + $('#bulletvar' + nextbullet).val() + src);
				});
				$(this).oneTime(100, "fixagain", function() {
					fixDragAndClip('#bl'+nextbullet)
				});
			} else { 
				$('#bulletvar'+nextbullet).remove();
			}
			$(this).oneTime(300, "fixagain", function() {fixDragAndClip('#bl'+nextbullet)});
		});

		$('#bulletopt' + nextbullet).bind("change", function(){
			// hey, wait a .5 sec!
			
			$('#bl' + nextbullet).attr("src", $('#bulletopt'+nextbullet+' option:selected').val());
			$(this).oneTime(100, "bl",function() { 
				if($('#bulletopt'+nextbullet+' option:selected').attr("variants")) { 
					$('#bulletvar'+nextbullet).remove();
					$('#bulletopt' + nextbullet).after( '<select style="width: 75px;" id="bulletvar'+nextbullet+'"></select>');
					buildVars($('#bulletopt'+nextbullet+' option:selected').attr("variants"), '#bulletvar'+nextbullet, '',$('#bulletopt'+nextbullet+' option:selected').val());
					var src = $('#bl'+nextbullet).attr('src');
					$('#bl'+nextbullet).attr('src', 'offset.php?o=0/'+src);
					$('#bulletvar'+nextbullet).bind('change', function(){
						var src = $('#bl'+nextbullet).attr('src');
						src = src.substring(src.indexOf('/')); // get the source. 
						$('#bl' + nextbullet).attr('src', 'offset.php?o=' + $('#bulletvar' + nextbullet).val() + src);
					});
				} else { 
					$('#bulletvar'+nextbullet).remove();
				}
				fixDragAndClip('#bl'+nextbullet)
			});
		});
		$('#delbullet' + nextbullet).bind("click", function(){
			$('#bl' + nextbullet).remove();
			$('#bulletdiv' + nextbullet).remove();
			toggleReport();
		});
		$('#bullets').data("info", {nextbullet: nextbullet});
		toggleReport();
	});
	$('#addenemy').click(function() {
		if($('.enemy_class').length >= 15 ) { return false;}

		var nextenemy = $('#enemies').data("info").nextenemy + 1;
		$('#enemies').append('<div id="enemydiv' + nextenemy + '"><label for="enemyopt'+nextenemy+'">Enemy:</label> <select id="enemyopt'+nextenemy+'">'+ $('#enemies').data("opts").eoptions +'</select> <input type="button" id="delenemy'+nextenemy+'" value="X" /></div>');
		$('#scene').append('<img style = "position: absolute" class="enemy_class" src="' + $('#enemies').data("db").defenemy +'" id="enemy'+nextenemy+'" />');
		$('#enemy' + nextenemy).draggable({
			containment: '#scene', 
			grid: [2,2],
			drag: function() { 

				$(this).clipBy({clipdiv: '#scene'});
			},
			stop: function() { 
				$(this).clipBy({clipdiv: '#scene'});
			},
			stack: { group: '#scene img', min: 25 }
		});
		$(this).oneTime(100, "enemydrag",function() { 
			// okay, .5 of a second later, let's check for variants.
				if($('#enemyopt' + nextenemy + ' option:selected').attr("variants")) {
					$('#enemyvar' + nextenemy).remove();
					$('#enemyopt' + nextenemy).after( '<select style="width: 75px;" id="enemyvar'+nextenemy+'"></select>');
					buildVars($('#enemyopt'+nextenemy+' option:selected').attr("variants"), '#enemyvar'+nextenemy, '',$('#enemyopt'+nextenemy+' option:selected').val());
					var src = $('#enemy'+nextenemy).attr('src');
					$('#enemy'+nextenemy).attr('src', 'offset.php?o=0/'+src);
					$('#enemyvar'+nextenemy).bind('change', function(){
						var src = $('#enemy'+nextenemy).attr('src');
						src = src.substring(src.indexOf('/')); // get the source. 
						$('#enemy' + nextenemy).attr('src', 'offset.php?o=' + $('#enemyvar' + nextenemy).val() + src);
					});
					$(this).oneTime(100, "fixagain", function() { 
						fixDragAndClip('#enemy'+nextenemy)
					});
				} else { 
					$('#enemyvar' + nextenemy).remove();
				}
				$(this).oneTime(100,'omgfix', function() { fixDragAndClip('#enemy'+nextenemy) });
				
		});
				
					
		$('#enemyopt' + nextenemy).bind("change", function(){
			$('#enemy' + nextenemy).attr("src", $('#enemyopt'+nextenemy+' option:selected').val());
				if($('#enemyopt' + nextenemy + ' option:selected').attr("variants")) {
					$('#enemyvar' + nextenemy).remove();
					$('#enemyopt' + nextenemy).after( '<select style="width: 75px;" id="enemyvar'+nextenemy+'"></select>');
					buildVars($('#enemyopt'+nextenemy+' option:selected').attr("variants"), '#enemyvar'+nextenemy, '',$('#enemyopt'+nextenemy+' option:selected').val());	
					var src = $('#enemy'+nextenemy).attr('src');
					$('#enemy'+nextenemy).attr('src', 'offset.php?o=0/'+src);
					$('#enemyvar'+nextenemy).bind('change', function(){
						var src = $('#enemy'+nextenemy).attr('src');
						src = src.substring(src.indexOf('/')); // get the source. 
						$('#enemy' + nextenemy).attr('src', 'offset.php?o=' + $('#enemyvar' + nextenemy).val() + src);
					});
				} else { 
					$('#enemyvar'+nextenemy).remove();
				}
			$(this).oneTime(100, "enemydrag",function() { fixDragAndClip('#enemy'+nextenemy)});
		});
		$('#delenemy' + nextenemy).bind("click", function(){
			$('#enemy' + nextenemy).remove();
			$('#enemydiv' + nextenemy).remove();
			toggleReport();
		});
		$('#enemies').data("info", {nextenemy: nextenemy});
		toggleReport();
	});
	$('#textopt1').click(function() { 
		if($('#tx1').length < 1) { 
			$('#scene').append('<img id="tx1" style="position: absolute;" />');
			$('#tx1').attr('src',makeFontURL(1));
			$('#tx1').draggable({
				containment: '#scene',
				grid: [2,2],
				stack: { group: "#scene img", min: 25}
			});
			$('#textopt1').val("Remove Text");
			//$('#fliptext1').show();
		} else { 
			$('#tx1').remove();
			$('#textopt1').val("Add Text");
			//$('#fliptext').hide();
		}
		toggleReport();
	});
		$('#textopt2').click(function() { 
		if($('#tx2').length < 1) { 
			$('#scene').append('<img id="tx2" style="position: absolute;" />');
		 var furl = '/fontgen/arcade.php/';
			
			$('#tx2').attr('src',makeFontURL(2));
			$('#tx2').draggable({
				containment: '#scene',
				grid: [2,2],
				stack: { group: "#scene img", min: 25}
			});
			$('#textopt2').val("Remove Text");
			$('#fliptext2').show();
		} else { 
			$('#tx2').remove();
			$('#textopt2').val("Add Text");
			$('#fliptext2').hide();
		}
		toggleReport();
	});
	$('#random1').click(function() {
		// ask for a random name!
		var first = ['Grad','Star', 'Laser', 'Thunder', 'Sky', 'Air', 'Last', 'Mystic', 'Space', 'Omega','Bio','Alien'];
		var second = ['ius','-Type',' Force', ' Fire', ' Riders', ' Blast'];
		var third = ['',' Special', ' DX', ' II', ' 3', ' Delta'];
		var pre =['', 'Super ', 'Ultra ', 'Mega '];
		
		out = pre[Math.floor (Math.random() * pre.length)];
		out = out + first[Math.floor (Math.random() * first.length)];
		out = out + second[Math.floor (Math.random() * second.length)];
		out = out +third[Math.floor (Math.random() * third.length)];
		$('#labeltext1').val(out);
		if($('#tx1').length > 0) { 

			$('#tx1').attr('src',makeFontURL(1));
		}
	});
	$('#random1').trigger('click');
	$('#random2').click(function() {
		// ask for a random name!
		var first = ['Grad','Star', 'Laser', 'Thunder', 'Sky', 'Air', 'Last', 'Mystic', 'Space', 'Omega','Bio','Alien'];
		var second = ['ius','-Type',' Force', ' Fire', ' Riders', ' Blast'];
		var third = ['',' Special', ' DX', ' II', ' 3', ' Delta'];
		var pre =['', 'Super ', 'Ultra ', 'Mega '];
		
		out = pre[Math.floor (Math.random() * pre.length)];
		out = out + first[Math.floor (Math.random() * first.length)];
		out = out + second[Math.floor (Math.random() * second.length)];
		out = out +third[Math.floor (Math.random() * third.length)];
		$('#labeltext2').val(out);
		if($('#tx2').length > 0) { 
		
			$('#tx2').attr('src',makeFontURL(2));
		}
	});
	$('#random2').trigger('click');
	$('#pickfont1').change(function() {
		if($('#tx1').length > 0) { 
			$('#tx1').attr('src',makeFontURL(1));
		}
		buildVars($('#pickfont1 option:selected').attr("variants"), '#varfont1', 'Version', $('#pickfont1 option:selected').val());
		$('#varfont1').val(0);
		$('#varfont1').trigger('change');
	});
	$('#pickfont2').change(function() {
		if($('#tx2').length > 0) { 
			$('#tx2').attr('src',makeFontURL(2));
		}
	buildVars($('#pickfont2 option:selected').attr("variants"), '#varfont2', 'Version', $('#pickfont2 option:selected').val());
		$('#varfont2').val(0);
		$('#varfont2').trigger('change');
	});
	$('#varfont1,#labeltext1,#sizefont1').change(function() {
			$('#tx1').attr('src',makeFontURL(1));
	});
	$('#varfont2,#labeltext2,#sizefont2').change(function() {
			$('#tx2').attr('src',makeFontURL(2));
	});
	$('#addshot').click(function() {
		if($('.shot_class').length >= 5 ) { return false;}
		var nextshot = $('#shots').data("info").nextshot + 1;
		$('#shots').append('<div id="shotdiv' + nextshot + '"><label for="shotopt' +nextshot+ '">Option:</label> <select id="shotopt' +nextshot+ '">'+ $('#shots').data("opts").psoptions+ '</select> <input type="button" id="delshot' +nextshot+ '" value="X" /></div>');
		$('#scene').append('<img style = "position: absolute" class="shot_class" src="'+ $('#shots').data("db").defshot +'" id="shot'+nextshot+'" />');
		
		$('#shot' + nextshot).draggable({
			containment: '#scene',
			grid: [2,2],
			drag: function() {
				$('#shot'+nextshot).clipBy({clipdiv: '#scene'});
			},
			stop: function() { 
				$('#shot'+nextshot).clipBy({clipdiv: '#scene'});
			},
			stack: { group: '#scene img', min: 25 }
		});
		$('#shotopt' + nextshot).bind("change", function(){
			$('#shot' + nextshot).attr("src", $('#shotopt'+nextshot+' option:selected').val());
			if($('#shotopt' + nextshot + ' option:selected').attr("variants")) {
				$('#shotvar' + nextshot).remove();
					$('#shotopt' + nextshot).after( '<select style="width: 50px;" id="shotvar'+nextshot+'"></select>');
					buildVars($('#shotopt'+nextshot+' option:selected').attr("variants"), '#shotvar'+nextshot, '',$('#shotopt'+nextshot+' option:selected').val());
					var src = $('#shot'+nextshot).attr('src');
					$('#shot'+nextshot).attr('src', 'offset.php?o=0/'+src);
					$('#shotvar'+nextshot).bind('change', function(){
						var src = $('#shot'+nextshot).attr('src');
						src = src.substring(src.indexOf('/')); // get the source. 
						$('#shot' + nextshot).attr('src', 'offset.php?o=' + $('#shotvar' + nextshot).val() + src);
					});
				} else { 
					$('#shotvar' + nextshot).remove();
				}
			$(this).oneTime(300, "shotdrag",function() { fixDragAndClip('#shot'+nextshot)});
		});
		$('#delshot' + nextshot).bind("click", function(){
			$('#shot' + nextshot).remove();
			$('#shotdiv' + nextshot).remove();
			toggleReport();
		});
		$(this).oneTime(300, "shotdrag",function() { 
			if($('#shotopt' + nextshot + ' option:selected').attr("variants")) {
					$('#shotvar' + nextshot).remove();
					$('#shotopt' + nextshot).after( '<select style="width: 50px;" id="shotvar'+nextshot+'"></select>');
					buildVars($('#shotopt'+nextshot+' option:selected').attr("variants"), '#shotvar'+nextshot, '',$('#shotopt'+nextshot+' option:selected').val());
					var src = $('#shot'+nextshot).attr('src');
					$('#shot'+nextshot).attr('src', 'offset.php?o=0/'+src);
					$('#shotvar'+nextshot).bind('change', function(){
						var src = $('#shot'+nextshot).attr('src');
						src = src.substring(src.indexOf('/')); // get the source. 
						$('#shot' + nextshot).attr('src', 'offset.php?o=' + $('#shotvar' + nextshot).val() + src);
					});
					$(this).oneTime(300, "fixagain", function() {fixDragAndClip('#shot'+nextshot)});
				} else { 
					$('#shotvar' + nextshot).remove();
				}
		fixDragAndClip('#shot'+nextshot);

		});
		$('#shots').data("info", {nextshot: nextshot});
		toggleReport();
	});
	$("#doreport").hover(function() { 
			$(this).attr("src","/fontgen/arcade.php/y-aura/dbl-4/z-15/x-Generate It!");
		},function() { 
			$(this).attr("src","/fontgen/arcade.php/y-aura/dbl-4/z-4/x-Generate It!");
		});
	$('#doreport').click(function(){
		var plpos = $('#player').position();
		var basepos = $('#scene').position();
		var bg = $('#scene').css('background-image');
		bg = bg.replace('url("','');
		bg = bg.replace('")','');
		bg = bg.replace('url(','');
		bg = bg.replace(')','');
		var output = 'bg=' + bg;
		$('#scene img').each(function(i) { 
			var bpos = $(this).position();
			output = output + '&i[' + this.id  + ']='+ $(this).attr("src") + '&x['+this.id+']=' + Math.floor(bpos.left - basepos.left - 1) + '&y['+this.id+']=' + Math.floor(bpos.top - basepos.top - 1) + '&z['+$(this).css('z-index')+']=' + this.id;
			
		});
		output = $.base64Encode(output);
		$('#exportdata').val(output);
		$('#export').submit();
	});
	$('#bubble1,#bubflip1').click(function(){ 
			$('#tx1').attr('src',makeFontURL(1));
	});
	
	$('#bubble2,#bubflip2').click(function(){ 
			$('#tx2').attr('src',makeFontURL(2));
	});
	$('#txcenter1').click(function() { 
		$('#tx1').css("left",(($('#scene').width() - $('#tx1').width()) /2) + $('#scene').position().left + parseInt($('#scene').css('border-left-width')));
	});
	$('#txcenter2').click(function() { 
		$('#tx2').css("left",(($('#scene').width() - $('#tx2').width()) /2) + $('#scene').position().left +parseInt($('#scene').css('border-left-width')));
	});
});