(function() {


	function handlesearch(e) {
		var t = $(this), type, user, ipt, url = '';
		type = t.cssSelect('#searchtype');
		user = t.cssSelect('input[name="member_name"]');
		ipt = t.cssSelect('input[type="search"]');
		
		if(type.length > 0) {
			if(type.first().value == 'search') {
				url = '/search/' + encodeURIComponent(ipt.first().value);
			} else if(type.first().value == 'bing') {
			    url = '/bing/' + encodeURIComponent(ipt.first().value);
			}
		}
		
		if(user.length > 0) {
			url = '/' + encodeURIComponent(user.first().value) + '/search/' + encodeURIComponent(ipt.first().value);
		}
		
		if(url.length > 0) {
			BBX.log('navigating to : ' + url);
			window.location.href = url;
			e.preventDefault();
		}
	
	
	}




	var f = $('form');
	
	for(var i=0;i<f.length;i++) {
		frm = $(f[i]);
		if(frm.cssSelect('input[type="search"]').length > 0) {
			frm.addEvent('submit',handlesearch);
		}
	}









})();
