var doodle = Class.create();

doodle.prototype = {

	textId: "doodle",
	initText: "",
	searchString: "",

	initialize: function() {
		this.queryBox = $(this.textId);
		this.initText = this.queryBox.value;
		this.setBehavior();
	},

	setBehavior: function(){
		this.queryBox.onblur = this.handleLabel.bind(this, "blur");
		this.queryBox.onfocus = this.handleLabel.bind(this, "focus");
	},

	handleLabel: function(fState){
		if(fState == "focus"){
			if(this.queryBox.value == this.initText){
				this.queryBox.value = "";
			}
		}else if(fState == "blur"){
			this.searchString = this.queryBox.value;
			if(this.queryBox.value == ""){
				this.queryBox.value = this.initText;
			}
		}
	},

	doSearch: function(){
		if(this.queryBox.value != this.initText){
			$("doodleForm").submit();
		}
	}
};
