(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);

var answers = new Array(
	"Yes.",
	"Yep.",
	"No.",
	"Not that big of a deal.",
	"Not to worry. ",
	"Probably not.",
	"I don\'t think so.",
	"This problem is behind us.",
	"No, but any Mac software has much better features.",
	"I'm sending Katie C. after you. You\'ll regret you asked that.",
	"It\'s alive and well.",
	"It sounds like you're just looking for someone to get mad at other than yourself.",
	"My house has no furniture.",
	"This is an automated reply. I\'m out of the office right now.",
	"Ceci ce n\'est pas une pipe.",
	"No, Flash won\'t be on the iPad. Just try to change your taste in comics.",
	"Flash is going the way of the dodo.",
	"I don\'t know. You should ask David Pogue about it.",
	"Redmond, start your photocopiers.",
	"Why the U.S. Army came to Cupertino, you say? Haven't you watched The Man Who Stare at Goats?",
	"Boy, have we patented it!",
	"Last time I've seen a good product from Motorola we were still using their chips on our computers.",
	"Sergey, I am your father.",
	"Ask Woz about it.",
	"You are a bag of hurt.",
	"No, you can\'t have Blu-Ray on your Mac Cube.",
	"I'm suing you right now.",
	"Did you know? There are nine million bicycles in Beijing.",
	"Sorry, I have to go. I\'m late for my soy latte with Eric.",
	"No, Jony hasn\'t come up with a good design for that yet.",
	"I hate the 5th Ave glass cube. I always thought that it looks like a postmodernist gerbil cage.",
	"You probably need some serious counseling.",
	"Sorry for the bug -- the common bug.",
	"Yes, I do hate Eric Schmidt.",
	"I\'m on a boat.",
	"Katie will blow your mind with our new telepathic device.",
	"Actually, all of the new HD camcorders from the past few years use USB 2.",
	"The U.S. Patent System is broken.",
	"The one person I hate more than Eric Schmidt is John Sculley.",
	"Remember that if I had never founded NExT, the WWW would not exist.",
	"Eric Schmidt is a bag of hurt.",
	"People don\'t read anymore.",
	"I'm on a horse.",
	"Yes, Tap Tap Revenge on the iPad is awesome.",
	"Good artists copy, great artists steal."
);

var signs = new Array(
	"Steve.",
	"Sent from my iPad.",
	"Sent from my iPhone.",
	"Sent from my wife's iPod touch.",
	"Sent from Phil's Blackberry.",
	"Sent from Jackling House.",
	"Sent from my Newton.",
	"Sent from Eric's Nexus One",
	"Sent from Eric's mistress' iPhone prototype.",
	"Sent from Google's HQ in Beijing.",
	"Sent from my Pippin.",
	"Sent from Mars.",
	"Take care.",
	"Sent from my parents' garage",
	"Sent from my Lisa", 
	"Sent from my iSlate (checking out an old prototype).",
	"Namaste.",
	"Sent from Bob Dylan's porch."
);
	

$(document).ready(function(){
	
	jQuery('#answerBox').val('');
	jQuery('#questionBox').val('');
	jQuery('#prevAnswer').val('');
	
	jQuery("span.fb_share_no_count").each(function(){
    jQuery(this).removeClass("fb_share_no_count");
    jQuery("span.fb_share_count_inner", this).html("0");
  });
	
	// Form Handler
	jQuery('#askForm').submit(function() {
		
		if (jQuery('#questionBox').val() == '') {
			alert('Please ask a question to Steve');
		} else {
			// Shuffling arrays
			$.shuffle(answers);
			currentAnswer = answers[0];
			
			$.shuffle(signs);
			currentSign   = signs[0];
			
			jQuery('#answerBox').val(currentAnswer + '\n' + currentSign);
			jQuery('#prevAnswer').val('Your question:' + jQuery('#questionBox').val());
		}
		return false;
	});
});
