var rTag;
if(!rTag){
	rTag = {};
}

rTag = {
	validateJoinForm: function(){
		the_form = document.forms['join'];	
		the_msg = "Missing Fields.";
		submitFlag = 1;
		if($("#handle").val() == ""){
			the_msg += "\nHandle";
			submitFlag = 0;
		}
		if($("#password").val() == ""){
			the_msg += "\nPassword";
			submitFlag = 0;
		}
		if($("#email").val() == ""){
			the_msg += "\nE-Mail";
			submitFlag = 0;
		}
		if(submitFlag == 1){the_form.submit();}
		else{alert(the_msg);}
	},
};

function validateLogin() {
	the_form = document.forms['loginForm'];	
	the_form.submit();
}

function getLocation() {			        
	navigator.geolocation.getCurrentPosition(
		function(pos) {
			$("#latitude").val(pos.coords.latitude);
			$("#longitude").val(pos.coords.longitude);
		}
    );
}

function locationToggle(locCheckBox){
	if(locCheckBox.checked === true){
		getLocation();
	}
	else {
		$("#latitude").val(0);
		$("#longitude").val(0);
	}
}

$(document).ready(function() {
	setTimeout(function() { window.scrollTo(0, 1) }, 100);
	
	$('#loginBtn').click(function (e) {
		validateLogin();
	});
	
	$('.navLogo').click(function(e) {  
		e.preventDefault();
		window.location = "/?v=home";
	});	
	
	$('#joinButton').click(function(e) {  
		e.preventDefault();
		rTag.validateJoinForm();
	});	
	
	
	
});
