//var _login_path = "http://alpha4.brickworkscomm.com/web_include/action_handler.php";
function handlelogIn(response){
	var r = response.evalJSON();
	if(r){ if(r.url){ /*window.location.href=r.url;*/ window.location.href=window.location.href; } }
}

function login(){
	params = {user:$('eneruse_user_name').value,pwd:$('eneruse_password').value,redirect:true}
	var _post = "action=get&category=profile&component_id=login&" + Object.toQueryString(params);
	var a = new Ajax.Request( _login_path + '?' + ajax_date(), {method:'post', postBody:_post, onSuccess:function(t) { handlelogIn(t.responseText) }/*, onComplete:checkSucess*/, onFailure:function(t) {alert ( 'Error ' + t.status + ' -- ' + t.statusText );} }	);
	//var html = "<table border='0' cellspacing='0' cellpadding='0' style='float:right;'><tr valign='middle'><td class='login_box_left'>&nbsp;</td><td class='login_box_middle' style='text-align:right;'><table border='0' cellspacing='0' cellpadding='0' class='header_login_form'><tr valign='middle'><td><span style='vertical-align: bottom; font-size: 12px; font-weight: normal;'>" + params.user + "&nbsp;</span></td><td style='width:5px;'>&nbsp;</td><td><a href='/user_signout.php' ><img src='/web_images/log_out.png' ></a></td></tr></table></td><td class='login_box_right'>&nbsp;</td></tr></table><br style='clear: both;'/>";
	var html = "<table border='0' cellspacing='0' cellpadding='0' style='float:right;'><tr valign='middle'><td class='' style='height:31px;width:7px;'></td><td class='' style='text-align:right;'><table border='0' cellspacing='0' cellpadding='0' class='header_login_form' style='width:380px'><tr valign='middle'><td><span style='vertical-align: bottom; font-size: 12px; font-weight: normal;'>"+ $('email').value +"&nbsp;</span></td><td style='width:5px;'></td><td><a href='/user_signout.php' ><img src='/web_images/log_out.png' ></a></td></tr></table></td><td class='' style='height:31px;width:7px;'></td></tr></table>";
	$('login_box').update(html);
}