$(document).ready(function(){
	// go button handler
	$('.btnGo').click(function(){
		$('.frmRandom').submit();
	});
	
	$('.spinner').hide();
	
	//login form handler
	var options = { 
        success:showResponse  // post-submit callback 
       , beforeSubmit:function(){$('.spinner').show();}
		}; 
		
		$('.btnLogin').click(function(){
		$('.frmLogin').ajaxSubmit(options);
		return false; // prevent default behaviour
	});  
	
	$('.frmLogin').submit(function(){
		$('.frmLogin').ajaxSubmit(options);
			return false;
	});
	
	//capture the return key
	/*$(".txtLoginForm").bind("keydown", function(e) {
			if (e.keyCode == 13) {
				$('.frmLogin').ajaxSubmit(options);
				return false;
			}
	}); 	*/	
});

// post-submit callback 
function showResponse(responseText, statusText)  { 
	res = jQuery.trim(responseText);
	if(res.substr(0,7) == "Success"){
		window.location.href = res.substr(8,res.length);
	} else {
		 $('.loginStatus').html(responseText);
	}
	$('.spinner').hide();
} 	
