var whichButton;
var focusElementId;
$(document).ready(function() {
	initForms();
});
function initForms() {
	$("#btShowDevelopments").hide();
	whichButton = new Array();
	whichButton['toplogin_tbEmail'] = 'toplogin_bLogin';
	whichButton['toplogin_tbPassword'] = 'toplogin_bLogin';
	whichButton['hsLocation'] = 'hsSearchButton';
	whichButton['hsDistance'] = 'hsSearchButton';
	whichButton['hsMaxPrice'] = 'hsSearchButton';
	whichButton['hsNumBedrooms'] = 'hsSearchButton';
	whichButton['selDev'] = 'btGoToDevelopment';
	$("#toplogin_tbEmail,#hsLocation,#hsDistance,#hsMaxPrice,#hsNumBedrooms,#selDev").focus(function() {
		focusElementId = $(this).attr("id");
	});
	$("#toplogin_tbEmail").one("focus",function () {
		$(this).val("");
	});
	var replaced = $("#toplogin_tbPassword").replaceWith("<input name='toplogin$tbPassword' type='text' id='toplogin_tbPassword' class='frm_pw' />");
	replaced.val("");
	$(".header #toplogin_tbPassword").val("Password");
	$("#toplogin_tbPassword").one("focus",function () {
		$(this).replaceWith(replaced);
		replaced.focus(function() {
			focusElementId = $(this).attr("id");
		});
		replaced.focus();
	});
	$("form").keypress(function(e) {
		if(e.which == 13) {
		    
			//buttonId = whichButton[focusElementId];
			// alert("click: " + buttonId);
			//$("#" + buttonId).click();
			return false;
		} else {
			return true;
		}
	});
}
