var Rolston = {
	fsdefaults : defaults = {
			pollcontainer:'',
			choiceclass: 'choice',
			replaceDiv : ''
	},

	selectedItem: null,
	currentid : 0, 


	init : function (options){
		this.o = $.extend({}, this.fsdefaults, options);
		this.o.replaceDiv = jQuery(this.o.replaceDiv);
		this.addListeners();
	},
	
	addListeners : function(){
		var m = this;	
		var choices = jQuery("."+this.o.choiceclass);
		var sel = jQuery("#select-one");
		
		choices.live('click', function(){
			sel.fadeOut();
			var el = $(this);
			choices.removeClass("selected");
			el.addClass("selected");
			m.selectedItem = el;
		});		
		
		jQuery("#poll-submit").live('click', function(){
			if(m.selectedItem == null){
				sel.fadeIn();
			}else{
				m.submitForm();
			}

		});	
		
	},
	
	submitForm : function(){
		var m = this;
		var res = this.selectedItem.html();
		res = (res == "Yale") ? 1 : 2;

		 jQuery.post("/survey/gatherResponse/", { response: res, step : 1, ajax : 1 },
	   function(data){
	     m.hideForm();
	   });
	},
	
	hideForm : function(){
		var m = this;
	  this.o.replaceDiv.fadeOut('slow', function() {
			m.o.replaceDiv.html('<img src="/assets/img/label_thank_you.gif" id="thanks" alt="Thank You" />')
			m.o.replaceDiv.fadeIn();
	  });
	}


};
