function checkEnter(e){
	// get key pressed (charCode from Mozilla/Firefox and Opera / keyCode in IE)
    var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
	if(key == 13){ 
		//document.forms[0].submit() //submit the form
		$("#btn_submit").click();
		return false
	}
	else{
		return true
	}
}


$(document).ready(function(){
	  $("#btn_submit").bind("click", function(){
	  		$("#loading").show();
			$("#error").hide();
			if($("#user").val()=="" || $("#pw").val()==""){
				$("#loading").hide();
				$("#error").show();
				return false;
			}
	  		$.getJSON("/phplib/users.php?user="+$("#user").val()+"&pw="+$("#pw").val(), function(json){
				//console.log("here");
			  	if(json.result != "true"){
					$("#loading").hide();
					$("#error").show();
				}else{
					window.location = "/media/";
				}
			});
	  	  
	  });
	  $("input.rad").keypress(function(event){
	  		checkEnter(event)
	  });
		$("#contact").click(function(){
			$(this).attr("href", "mailto:info@sherpalabs.com");
		})
});


