
	
	function RegCheck(element) {
		switch(element.id) {
			
			case "epost":
				if (/^[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}$/.test($("input#epost").val())){
					$("#lblEpost").html("<img src='/gfx/icons/y.png' alt='' />");
				} else {
					$("#lblEpost").html("<img src='/gfx/icons/n.png' alt='' />");
				}
			break;
			
			case "epost2":
				var epost = $("input#epost2").val();
				var epost2 = $("input#epost").val();
				if (epost.toLowerCase() == epost2.toLowerCase()){
					$("#lblEpost2").html("<img src='/gfx/icons/y.png' alt='' />");
				} else {
					$("#lblEpost2").html("<img src='/gfx/icons/n.png' alt='' />");
				}
			break;
			
			case "password":
				if (/^[\w\W]{6,}$/.test($("input#password").val())){
					$("#lblPassword").html("<img src='/gfx/icons/y.png' alt='' />");
				} else {
					$("#lblPassword").html("<img src='/gfx/icons/n.png' alt='' />");
				}
			break;
			
			case "password2":
				if ($("input#password2").val() == $("input#password").val()){
					$("#lblPassword2").html("<img src='/gfx/icons/y.png' alt='' />");
				} else {
					$("#lblPassword2").html("<img src='/gfx/icons/n.png' alt='' />");
				}
			break;
			
			case "namn":
				if(element.value.length>=2){ 
					$("#lblNamn").html("<img src='/gfx/icons/y.png' alt='' />");
				} else {
					$("#lblNamn").html("<img src='/gfx/icons/n.png' alt='' />");
				}
			break;
			
			case "efternamn":
				if(element.value.length>=2){ 
					$("#lblEfternamn").html("<img src='/gfx/icons/y.png' alt='' />");
				} else {
					$("#lblEfternamn").html("<img src='/gfx/icons/n.png' alt='' />");
				}
			break;
				
		}
	}
	
function Join(form){
 jQuery.ajax({
  type: "POST",
  url: "/ajax.php?action=join",
  dataType: "html",
  data: $("form#joinForm").serialize(),
  success: function(response){
   eval(response)
  },
  error: function(){
   alert("Ett oväntat fel uppstod!");
  }
 });
}

function Login(form){
 $("#loginStatus").show();
 $("#loginStatus").html("<img src='/gfx/icons/loader.gif' alt='' align='left' />&nbsp;Loggar in..");
 jQuery.ajax({
  type: "POST",
  url: "/ajax.php?action=login",
  dataType: "html",
  data: $("form#loginForm").serialize(),
  success: function(response){
   eval(response)
  },
  error: function(){
   $("#loginStatus").html("Ett fel uppstod..");
  }
 });
}
 
function changePw(form){
 jQuery.ajax({
  type: "POST",
  url: "/ajax.php?action=changepw",
  dataType: "html",
  data: $("form#cpwForm").serialize(),
  success: function(response){
   eval(response)
  },
  error: function(){
   alert("Ett fel uppstod..");
  }
 });
}

	function setInnerHtml(objID, txt){
		$("#" + objID + "").html("" +  txt + "");
	}

	function signout(){
		if(confirm('Är du säker på att du vill logga ut?')){
			location.href = '/signout';
		}
	}
	
	function deleteReport(){
		if(confirm('Är du säker på att du vill ta bort rapporten?')){
			return true;
		} else {
			return false;
		}
	}
	 
	function Contact(form){
		jQuery.ajax({
			type: "POST",
			url: "/ajax.php?action=contact",
			dataType: "html",
			data: $("form").serialize(),
			success: function(response){
				eval(response);
			},
			error: function(){
				alert("Ett oväntat fel uppstod!");
			}
		});
	 }
	 
	function forgotPassword(form){
		jQuery.ajax({
			type: "POST",
			url: "/ajax.php?action=forgotPassword",
			dataType: "html",
			data: $("form").serialize(),
			success: function(response){
				eval(response);
			},
			error: function(){
				alert("Ett oväntat fel uppstod!");
			}
		});
	 }
	 
	function toggleDrawer(){
		$(".toggleDrawer").toggle();
		$("#drawerContent").slideToggle("fast");
		$("#topDrawerBar_content ul li small").toggle();
	 }

