text: var utils = {
  
  	fillArray: function(value, len) {
  		var arr = [];
  		for (var i = 0; i < len; i++) {
  			arr.push(value);
  		}
  		return arr;
  	},
  	
  	showSlide: function(slidename) {
  			$(".slide").hide();
  			$(".fullslide").hide();
  			$("#" + slidename).show();
  	},
  
  	get_exp_length: function() {
  		if (exp.structure && exp.slides) {
  				var length = 0;
  				for (var i=0; i<exp.structure.length; i++) {
  						var a_slide = exp.slides[exp.structure[i]];
  						if (a_slide.present) {
  								length += a_slide.present.length;
  						} else {
  								length ++;
  						}
  				}
  				return length - 1; //don't count the last slide
  		}
  	},
  
  	/* eq_el_height and match_row_height adapted from:
  	 * http://stackoverflow.com/questions/15397966/how-to-get-table-cells-to-have-equal-height
  	 */
  	eq_el_height: function(els, min_or_max) {
  			els.each(function() {
  					$(this).height('auto');
  			});
  
  			var m = $(els[0]).height();
  
  			els.each(function() {
  					var h = $(this).height();
  
  					if (min_or_max === "max") {
  							m = h > m ? h : m;
  					} else {
  							m = h < m ? h : m;
  					}
  			});
  
  			els.each(function() {
  					$(this).height(m);
  			});
  	},
  
  	match_row_height: function(label, sublabel) {
  		$(label).each(function() {
  			utils.eq_el_height($(this).find(sublabel/*'tr'*/), "max");
  		});
  	},
  
  	make_slider: function(label, response_callback, orientation) {
  		var orientation = (orientation == null) ? "horizontal" : orientation;
  		$(label).empty();
  		$(label).slider({
  			range : "min",
  			min : 0,
  			max : 1,
  			step: 0.01,
  			value : 0.5,
  			slide : response_callback,
  			change : response_callback,
  			orientation : orientation
  		});
  		$(label + ' .ui-slider-handle').hide();
  		$(label).mousedown(function(){
  			$(label + ' .ui-slider-handle').show();
  			$(label).css({"background":"#99D6EB"});
  			$(label + ' .ui-slider-handle').css({
  				"background":"#667D94",
  				"border-color": "#001F29"
  			});
  		});
  		$(label).css({"background":"#eee"});
  	}
  }
  /*
  		var keys = getUnique.apply(list_keys);
  		//var keys = _.unique(list_keys);
  		keys.push(['sid', 1]);
  		var mysql_begin="CREATE TABLE `" + name +"`(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), ";
  
  		$.each(keys, function(i, val) {
  				mysql_begin = mysql_begin + "`" + val[0] + "`" + sqlKind[val[1]];
  				//mysql_begin = mysql_begin + val + sqlKind[0];
  		});
  		mysql_begin = mysql_begin.substring(0, mysql_begin.length-2) + ")";
  		return mysql_begin;
  
  }
  
  
  function makeTable() {
  		var x=newTable();
  		$.ajax({
  				type: "POST",
  				url:  "../shared/php/create.php",
  				data: {command: JSON.stringify(x)},
  				success: function() { console.log("success"); },
  				error: function(xhr, textStatus, errorThrown) { alert(textStatus); }
  		});
  		//makeSID();
  }
  
  function makeTableAll(data) {
  		_.each(data, function(data, name){
  				var x=newTable(data, exp.name + "_" + name);
  				$.ajax({
  						type: "POST",
  						url:  "../shared/php/create.php",
  						data: {command: JSON.stringify(x)},
  						success: function() { console.log("success"); },
  						error: function(xhr, textStatus, errorThrown) { alert(textStatus); }
  				});
  		});
  		//makeSID();
  }
  
  function sendAllData(data){
  		_.each(data, function(data, name){
  				var datafin={};
  				datafin[exp.name + "_" + name] = JSON.stringify(data);
  				$.ajax({
  						type: "POST",
  						url:  "../shared/php/handle_data.php",
  						data: datafin,
  						success: function() { console.log("All good");
  																	exp.data_sent=1;
  																},
  						error: function(xhr, textStatus, errorThrown) { alert(textStatus); }
  				});
  		});
  }
  
  function makeSID() {
  		var alter = "ALTER TABLE SID ADD "  + exp.name + " INT";
  		$.ajax({
  				type: "POST",
  				url:  "../shared/php/create.php",
  				data: {command: JSON.stringify(alter)},
  				success: function() { console.log("success"); },
  				error: function(xhr, textStatus, errorThrown) { alert(textStatus); }
  		});
  		sendJustData("SID", _.map(_.range(1,1000), function(x){return({sid:x});}));
  }
  
  function calc_relative_sizes() {
  		//  var offset=screen.width/2-(parseInt($('.slide').css('width'), 10 )/2);
  		var offset= ($(window).width()-22)/5;
  		$('#progress').css( 'width', offset -30);
  		$('.slide').css('width', $(window).width()-21);
  		//exp is full screen
  		$('.exp').css('height' , $(window).height());
  		$('.exp').css('width',  $(window).width());
  
  		//offset slide
  		//  $('.slide').css({'left' : offset});
  		//  $('.slide').css('width', $(window).width()*(4/5));
  		//  $('.slide').css('width', ($('.exp').width()-22)*(4/5));
  
  		//don't offset slide
  		//$('.slide').css({'left' : 0});
  		//  $('.slide').css('width', $('.exp').width());
  		//  $('.slide').css('overflow', 'hidden');
  		exp.height = $(window).height(); // $('.exp').css('height');
  		exp.width = $(window).width();
  
  		//Center all the things we need to
  		//$('#sim_slide').centerhin();
  		//  $('button.bCent').css({'left' : exp.width/2-30});
  		$('.bcent').centerh();
  
  		//  $('#training_sort_cont').centerh();
  		//  $('#sim_cont').centerh();
  
  }
  
  function makeASCII() {
  		// var the_char = Math.floor(Math.random()*(123-33) + 33);
  		var the_char = Math.floor(Math.random()*(90 -65) + 65);
  		return(String.fromCharCode(the_char));
  }
  
  
  function extract(data, where) {
  		for (var key in data) {
  				where[key] = data[key];
  		}
  }
  
  function getURLParameter(name) {
  		return decodeURI(
  				(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
  		);
  }
  
  function insertParam(key, value) {
  		key = escape(key); value = escape(value);
  
  		var kvp = document.location.search.substr(1).split('&');
  		if (kvp == '') {
  				document.location.search = '?' + key + '=' + value;
  		}
  		else {
  
  				var i = kvp.length; var x; while (i--) {
  						x = kvp[i].split('=');
  
  						if (x[0] == key) {
  								x[1] = value;
  								kvp[i] = x.join('=');
  								break;
  						}
  				}
  
  				if (i < 0) { kvp[kvp.length] = [key, value].join('='); }
  				return(kvp);
  				//this wil); reload the page, it's likely better to store this until finished
  				//document.location.search = kvp.join('&');
  		}
  }
  
  function addParams(data, url){
  		if(url === undefined) url=window.location.href;
  		var dataString = [];
  
  		for(var key in data) {
  				if (data.hasOwnProperty(key)) {
  						dataString.push(key+"="+escape(data[key]));
  				}
  		}
  
  		url += "?" + dataString.join("&");
  		window.location.href = url;
  
  }
  
  function roundNumber(num, dec) {
  		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
  		return result;
  }
  
  
  function textWrap(x,y, r, content, maxWidth, size){
  
  		var t = r.text(x, y).attr('text-anchor', 'start');
  		//var maxWidth = 100;
  		var words = content.split(" ");
  
  		var tempText = "";
  		for (var i=0; i<words.length; i++) {
  				t.attr("text", tempText + " " + words[i]);
  				if (t.getBBox().width > maxWidth) {
  						tempText += "\n" + words[i];
  				} else {
  						tempText += " " + words[i];
  				}
  		}
  
  		t.attr({"text": tempText.substring(1), "font-size": size });
  }
  
  function position_debug() {
  		$(document).mousedown(function(e){
  				console.log(e.pageX +', '+ e.pageY);
  		});
  }
  
  // $(document).ready(
  // function(){exp=make_exp();}
  // );
  
  function oldworker() {
  		$.ajax({
  				type: "POST",
  				url:  "../shared/php/old_worker.php",
  				data: {ID: turk.workerId, table:exp.tables},
  				success: function(response) {
  						php.wid=response * 1;
  						console.log("php says: " + response);},
  				error: function(xhr, textStatus, errorThrown) { alert(textStatus); }
  		});};
  
  _.mixin({
  		swap : function(arr, ind1, ind2) {
  				var temp = arr[ind1];
  				arr[ind1] = arr[ind2];
  				arr[ind2] = temp;
  				return arr;
  		}
  });
  
  // _.mixin({
  //   shift : function(arr, ind1, ind2) {
  //       var temp = arr[ind1];
  //       arr[ind1] = arr[ind2];
  //       arr[ind2] = temp;
  //     return arr;
  //   }
  // });
  
  
  function addData(key,val) {
  		exp.data[exp.data.length-1][key]= val;
  }
  
  function getData(key) {
  		return exp.data[exp.data.length-1][key];
  }
  
  function makeid(len)
  {
  		var text = "";
  		var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  
  		for( var i=0; i < len; i++ )
  				text += possible.charAt(Math.floor(Math.random() * possible.length));
  
  		return text;
  }
  
  function preload2(arrayOfImages) {
  		$(arrayOfImages).each(function () {
  				$('<img />').attr('src',this).appendTo('body').css('display','none');
  		});
  }
  
  function preload() {
  								var images = new Array();
  								for (i = 0; i < preload.arguments.length; i++) {
  										images[i] = new Image();
  										images[i].src = preload.arguments[i];
  								}
  }
  
  // preload([
  //     'img/imageName.jpg',
  //     'img/anotherOne.jpg',
  //     'img/blahblahblah.jpg'
  // ]);
  
  exp_sizing=function(){
  		exp.width=800;
  		exp.height=600;
  		$('.slide').css('width', exp.width);
  		$('.slide').css('height', exp.height);
  		$('.exp').css('height', exp.height+2);
  		$('.slide_wrapper').css('width', exp.width);
  		$('.slide_wrapper').css('height', exp.height);
  }
  
  randomChar = (function (){
  		var charSet = _.shuffle(["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]);
  		return function(){return charSet.pop();};
  })();
  >>>>>>> master
  */
  