Hasbro.SearchBox = new Class({
	initialize : function (id) {
		this.id = $(id);
		this.storedVal = this.id.getProperty('value');
		
		this.id.addEvent('click', this._setVal.pass(['click'],this));
		this.id.addEvent('blur', this._setVal.pass(['blur'], this));
	},
	_setVal : function(evt) {
		if (evt == 'click') {
			if (this.id.value == this.storedVal) { this._doClearVal(); }
		} else {
			if (this.id.value == '') { this._doRestoreVal(); }
		}
	},
	_doClearVal : function() {
		this.id.value = '';
	},
	_doRestoreVal : function() {
		this.id.value = this.storedVal;
	}
});

function Search(useSeoFormatter, locale, alertDefault, alertText) {
	if (document.getElementById("hsb_search_input").value == alertDefault || document.getElementById("hsb_search_input").value == '') {
		alert (alertText);
	} else {
		if(useSeoFormatter) {
			if(locale == "en_US") {
				window.location = "/search/_/Ntt-"+ encodeURIComponent(document.getElementById("hsb_search_input").value) + "?Ntk=All&Ntx=mode+matchallpartial";
			} else {
				window.location = "/" + locale + "/search/_/Ntt-" + encodeURIComponent(document.getElementById("hsb_search_input").value) + "?Ntk=All&Ntx=mode+matchallpartial";
			}
		} else {
			if(locale == "en_US") {
				window.location = "/search.cfm?Ntk=All&Ntt=" + encodeURIComponent(document.getElementById("hsb_search_input").value) + "&Ntx=mode+matchallpartial";
			} else {
				window.location = "/" + locale + "/search.cfm?Ntk=All&Ntt=" + encodeURIComponent(document.getElementById("hsb_search_input").value) + "&Ntx=mode+matchallpartial";
			}
		}
	}
}