$(document).ready(function () {
    $.fn.wait = function (time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function () {
            var self = this;
            setTimeout(function () {
                $(self).dequeue();
            }, time);
        });
    };
});

function showpanelinfo(str) {
	$(".panel_info").ready(function(){
		$(".panel_info span").text(str);
		$(".panel_info").fadeIn(100);		   
	})
}
function hidepanelinfo(str) {
	$(".panel_info").ready(function(){
		$(".panel_info").fadeOut(100);		   
	})
}

function companyContact(e) {
	theEmail = document.getElementById("company_email").value
	thePhone = document.getElementById("company_phone").value
	if (document.getElementById("company").value.length < 3) {alert('Du måste ange den skola/företag du representerar.'); document.getElementById("company").focus(); return false}

				  email = theEmail;
		  		  checkMailStatus = true;
				  AtPos = email.indexOf("@");
				  StopPos = email.lastIndexOf(".");
				  Message = ""
				  
				  if (email == "") {
				  checkMailStatus = false;
				  }
				  
				  if (AtPos == -1 || StopPos == -1) {
				  checkMailStatus = false;
				  }
				  
				  if (StopPos < AtPos) {
				  checkMailStatus = false;
				  }
				  
				  if (StopPos - AtPos == 1) {
				  checkMailStatus = false;
				  }
				  
	if (checkMailStatus == false) {alert('Ogiltig E-postadress.'); document.getElementById("company_email").focus(); return false}
	if (thePhone.length < 4) {alert('Du måste ange ett telefonnummer.');document.getElementById("company_phone").focus(); return false}
	if (document.getElementById("company_message").value.length < 10) {alert('För kort meddelande.');document.getElementById("company_message").focus(); return false}
	
	document.getElementById("form_company").submit();
//var xmlhttp;
//if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}
//else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
//xmlhttp.onreadystatechange=function()
//{if(xmlhttp.readyState==4){
////------------------------------------
//msg=xmlhttp.responseText;
// alert('Tack för ditt mail! Vi kommer att återkomma till er inom kort!')
//$("#btn_member_schcom").addClass("btn_member_schcom")
//$("#btn_member_schcom").removeClass("btn_member_schcom_active")
// $(".reg_member_company_div").slideUp(1000)
////------------------------------------
//}
//}
//xmlhttp.open("GET","/send_email.ashx?i=company&m="+document.getElementById("message").value+"&e="+document.getElementById("company_email").value+"&n="+document.getElementById("company").value+"&p="+document.getElementById("phone").value,true);
//xmlhttp.send(null);
	
}

function swap_material() {
	id = document.getElementById("material_Swap").value;
	$(".material_listings").css({'display':'none'})
	$("#material_"+id).css({'display':'block'})
}

	function activateUser(uid)
	{
		$(".btn_activateuser").fadeOut(300, function() {
			$(".activate_ajax").fadeIn(300, function() {
				$("#password_ajax").fadeIn(200, function() {
						
var xmlhttp;
if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4){
//------------------------------------
msg=xmlhttp.responseText;
if (msg == "1") {
	$(".activate_ajax").fadeOut(300, function() {
		$(".activate_complete")
		.fadeIn(300)
		.animate({opacity: 1}, 3000, function() {window.location = "/medlemmar/bli-medlem/aktivera-konto"})
	})
} else {
	$(".activate_ajax").fadeOut(300, function() {
		$(".activate_nocomplete")
		.fadeIn(300)
		.animate({opacity: 1}, 5000)
		.fadeOut(300, function() { $(".btn_activateuser").fadeIn(300) })
	})
}
//------------------------------------
}
}
xmlhttp.open("GET","/activate.ashx?do=activate&m="+document.getElementById("activate_mobile").value+"&c="+document.getElementById("activate_code").value+"&u="+uid,true);
xmlhttp.send(null);						
		
				})
			})
		})
	}



	function reActivateUser(uid)
	{
		$(".btn_activateuser").fadeOut(300, function() {
			$(".activate_ajax").fadeIn(300, function() {
				$("#password_ajax").fadeIn(200, function() {
						
var xmlhttp;
if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4){
//------------------------------------
msg=xmlhttp.responseText;
if (msg == "1") {
	$(".activate_ajax").fadeOut(300, function() {
		$(".activate_complete")
		.fadeIn(300)
		.animate({opacity: 1}, 3000, function() {window.location = "/medlemmar/bli-medlem/aktivera-konto?do=renew"})
	})
} else {
	$(".activate_ajax").fadeOut(300, function() {
		$(".activate_nocomplete")
		.fadeIn(300)
		.animate({opacity: 1}, 5000)
		.fadeOut(300, function() { $(".btn_activateuser").fadeIn(300) })
	})
}
//------------------------------------
}
}
xmlhttp.open("GET","/activate.ashx?do=reactivate&m="+document.getElementById("activate_mobile").value+"&c="+document.getElementById("activate_code").value+"&u="+uid,true);
xmlhttp.send(null);						
		
				})
			})
		})
	}
	
	
	
$(document).ready(function(){
				

								 
    $("#login_link").click(function() {
	    document.getElementById("username").value = "Användarnamn";
	    document.getElementById("password").style.display = "none"
	    document.getElementById("password_fake").style.display = "block"
	    document.getElementById("login_error").style.display = "none";
		$(".login_box").animate({ top: "0"}, 300)
		.animate({ top:"-3" },300)
	});
	
	$(".login_box_close").click(function() {
	    $(".login_box").animate({ top: "-78"}, 300);
	});
	
	$(".restore_password_box_close").click(function() {
	    $(".restore_password_box").animate({ top: "-78"}, 300);
	});
	
	$(".login_button").click(function() {
		check_login()    
	});

	$(".restore_password_button").click(function() {
		restore_password()    
	});
	
	$(".restore_password_link").click(function() {
		document.getElementById("restore_password").value = "Ange din E-postadress";
	    $(".login_box").animate({ top: "-78"}, 300);
	    $(".restore_password_box").animate({ top: "0"}, 300)
		.animate({ top:"-3" },300)
	});
	
});


function checkEmail(email)
	{
		  		  checkMailStatus = true
				  AtPos = email.indexOf("@")
				  StopPos = email.lastIndexOf(".")
				  Message = ""
				  
				  if (email == "") {
				  checkMailStatus = false;
				  }
				  
				  if (AtPos == -1 || StopPos == -1) {
				  checkMailStatus = false;
				  }
				  
				  if (StopPos < AtPos) {
				  checkMailStatus = false;
				  }
				  
				  if (StopPos - AtPos == 1) {
				  checkMailStatus = false;
				  }
	}
	
function login_press(e)
{
     var key

     if(window.event)
          key = window.event.keyCode;     //IE
    else
          key = e.which;     //firefox

     if(key == 13)
	     check_login()
     else
          return true;
}

function restore_password() {
	$(".restore_password_button").fadeOut(200, function() {
		$("#password_ajax").fadeIn(200, function() {
	
var xmlhttp;
if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4){
//------------------------------------
msg=xmlhttp.responseText;
if (msg == 'true') {
		$("#password_ajax").fadeOut(200, function() {
			$(".restore_password_button").fadeIn(200, function() {
				$(".restore_password_complete")
				.fadeIn(400)
				.animate({opacity: 1.0}, 3000)
				.fadeOut(400)
			});
		});
} else {
		$("#password_ajax").fadeOut(200, function() {
			$(".restore_password_button").fadeIn(200, function() {
				$(".restore_password_error")
				.fadeIn(400)
				.animate({opacity: 1.0}, 3000)
				.fadeOut(400)
			});
		});
}
//------------------------------------
}
}
xmlhttp.open("GET","/functions.asp?restorepw="+document.getElementById("restore_password").value,true);
xmlhttp.send(null);				

		})
	})
}

function infoBar(m) {
    $(document).ready(function () {
        $(".infoBar").css("margin-top", $(document).scrollTop() + "px");
        $(".infoBar").text(m);
        $(".infoBar").slideDown(500).wait(2000).slideUp(500);
    });
}

function check_login() {
    document.getElementById("form_login").submit();

    $(".login_button").fadeOut(200, function () {
        $("#login_ajax").fadeIn(200, function () {

            var xmlhttp;
            if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); }
            else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4) {
                    //------------------------------------
                    var msg = xmlhttp.responseText;
                    //$(".login_error").text(msg)
                    //alert(msg.substring(0, 4));
                    //if (msg.substring(0, 4) == 'true') {
                    //alert(msg)
                    if (msg == 'true') {
                        document.forms[0].submit()
                    } else {
                        $(document).ready(function () {
                            $("#login_ajax").fadeOut(200, function () {
                                $(".login_button").fadeIn(200, function () {
                                    $(".login_error")
								.fadeIn(400)
								.animate({ opacity: 1.0 }, 3000)
								.fadeOut(400)
                                });
                            });
                        });
                    }
                    //------------------------------------
                }
            }
            xmlhttp.open("GET", "/functions.asp?u=" + document.getElementById("username").value + "&p=" + document.getElementById("password").value, true);
            xmlhttp.send(null);

        })
    })
}

var username_error, email_error, password_error, checking_firstname = false, checking_lastname = false, checking_gender = false, checking_birthday = false, checking_username_ = false, checking_password_ = false, checking_verify_password = false, checking_email = false, checking_verify_email = false, checking_terms = false




//////////////////////////////
function set_reg_input(type) {
	input_str = document.getElementById(type).value
}


//////////////////////////////
function check_input(type) {
	input = document.getElementById(type)
	if (input_str != input.value) {
		if (window['checking_'+type] == false) { window['checking_'+type] = true; ajax_fade(type)}
	}
}

function ajax_approve(type) {
	$(ajax_approved).fadeIn("fast", function() { window["checking_" + type] = false })
	document.getElementById("text_"+type).style.color = '#5C5C5C';
	document.getElementById("text_"+type).style.fontWeight = 'normal';
    reg_get_errors(type);
}

function ajax_disapprove(type) {
	$(ajax_disapproved).fadeIn("fast", function() { window["checking_" + type] = false })
	document.getElementById("text_"+type).style.color = 'red';
	document.getElementById("text_"+type).style.fontWeight = 'bold';
	reg_get_errors(type);
}

function ajax_fade(type) {
	if (type == 'username_') { $("#username_error_info").fadeOut("fast") };
	if (type == 'email') { $("#email_error_info").fadeOut("fast") };
	
	ajax_load = "#ajax_load_"+type
	ajax_approved = document.getElementById("approved_"+type)
	ajax_disapproved = document.getElementById("disapproved_"+type)
	  $(ajax_approved).fadeOut("fast",function() {
		  $(ajax_disapproved).fadeOut("fast",function() {
			  $(ajax_load).fadeIn("fast",function() {
												  
				if (type == 'firstname') {
					if (input.value.length > 1) {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_approve(type)
						})
					} else {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_disapprove(type)
						})
					}
				}
				
				if (type == 'lastname') {
					if (input.value.length > 1) {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_approve(type)
						})
					} else {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_disapprove(type)
						})
					}
				}
				
				if (type == 'gender') {
					if (input.value !== 'none') {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_approve(type)
						})
					} else {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_disapprove(type)
						})
					}
				}
				
				if (type == 'username_') {
					if (input.value.length > 2) {
						  var re = new RegExp("[a-z]");
						  var m = re.exec(document.getElementById("username_").value);
						  if (!isDigits(document.getElementById("username_").value)) {
							  $(ajax_load).fadeOut("fast", function() {username_error=2;ajax_disapprove(type)})
							  } else {
								  
								  
								  
var xmlhttp;
if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4){
//------------------------------------
msg=xmlhttp.responseText;
if (msg=='True'){$(ajax_load).fadeOut("fast", function() {username_error=3;ajax_disapprove(type)})}else{$(ajax_load).fadeOut("fast", function() {ajax_approve(type)})}
//------------------------------------
}
}
xmlhttp.open("GET","/ajax.ashx?username="+document.getElementById("username_").value,true);
xmlhttp.send(null);
							
							  }
					} else {
						username_error=1;
						$(ajax_load).fadeOut("fast", function() {ajax_disapprove(type)});
					}
					
				}
				
				if (type == 'password_') {
					if (input.value.length > 4) {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_approve(type)
						})
					} else {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_disapprove(type)
						})
					}
				}
				
				if (type == 'verify_password') {
					if (input.value == document.getElementById("password_").value) {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_approve(type)
						})
					} else {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_disapprove(type)
						})
					}
				}

				if (type == 'email') {
					checkEmail(document.getElementById("email").value);
					
					if (checkMailStatus == true) {
						
						
var xmlhttp;
if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4){
//------------------------------------
msg=xmlhttp.responseText;
if (msg=='True'){$(ajax_load).fadeOut("fast", function() {email_error=2;ajax_disapprove(type)})}else{$(ajax_load).fadeOut("fast", function() {ajax_approve(type)})}
//------------------------------------
}
}
xmlhttp.open("GET","/ajax.ashx?email="+document.getElementById("email").value,true);
xmlhttp.send(null);

								
								
								
								
					} else {
						email_error=1;
						$(ajax_load).fadeOut("fast", function() {ajax_disapprove(type)});
					}
				}
				
				if (type == 'verify_email') {
					if (input.value == document.getElementById("email").value) {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_approve(type)
						})
					} else {
  						$(ajax_load).fadeOut("fast", function() {
							ajax_disapprove(type)
						})
					}
				}

				
			  })
		  })
	  })
	  
 
 
 
}



function reg_get_errors(type) {

	 if (username_error == 1) {
		document.getElementById("username_error_info").innerHTML = "Måste innehålla minst 3 bokstäver"
		$("#username_error_info").fadeIn("fast")
     }
	 if (username_error == 3) {
		document.getElementById("username_error_info").innerHTML = "Detta användarnamn är redan taget"
		$("#username_error_info").fadeIn("fast")
     }
	 if (username_error == 2) {
		document.getElementById("username_error_info").innerHTML = "Får endast innehålla a-z 0-9 och _"
		$("#username_error_info").fadeIn("fast")
     }
	 if (email_error == 1) {
		document.getElementById("email_error_info").innerHTML = "Ogiltig E-postadress"
		$("#email_error_info").fadeIn("fast")
     }
	 if (email_error == 2) {
		document.getElementById("email_error_info").innerHTML = "Denna E-postadress finns redan registrerad"
		$("#email_error_info").fadeIn("fast")
     }
	 if (password_error == 1) {
		document.getElementById("password_error_info").innerHTML = "Måste minst innehålla 5 tecken"
		$("#password_error_info").fadeIn("fast")
     }
	 username_error = 0
	 email_error = 0
	 password_error = 0
}

function isDigits(str)
{
  return /^(\w*)+$/.test(str);
}



function reg_ajax_complete(type) {
	alert(document.getElementById("username_").value)
	
	if (document.getElementById("username_").value.length < 3) {
		appr_input = false;
		username_error = 1;
		alert(type)
	}
	if (type=='email' && checkMailStatus !== true) {
		appr_input = false;
		email_error = 1
	}
	if (type=='password_' && document.getElementById("password").value.length < 5) {
		password_error = 1
	}
	if (type=='verify_password') {
		if (document.getElementById("verify_password").value !== document.getElementById("password_").value) {
			appr_input=false;
		} else {
			appr_input=true;
		}
	}
	
	if (type=='verify_email') {
		if (document.getElementById("verify_email").value !== document.getElementById("email").value) {
			appr_input=false;
		} else {
			appr_input=true;
		}
	}
	
  var re = new RegExp("[a-z]");
  var m = re.exec(document.getElementById("username_").value);
  if (!isDigits(document.getElementById("username_").value)) alert('Fältet får enbart innehålla siffror.');

	
	if (appr_input==true) {
		  $(ajax_load).fadeOut("fast",function() {
			  $(ajax_approved).fadeIn("fast")
			  usernam_error = 0
		  })
	  } else {
		  $(ajax_load).fadeOut("fast",function() {
			  $(ajax_disapproved).fadeIn("fast", function() {reg_get_errors(type)})
		  })
	 }
	 
//	if (type=='password_' && document.getElementById("verify_password").value.length > 0) {
//	
//		  $("#approved_verify_password").fadeOut("fast",function() {
//			  $("#disapproved_verify_password").fadeOut("fast",function() {
//			  })
//		  })
//	}

}



var got_birthdate, got_birthmonth, got_birthyear, birthday_complete = false, birthday_disapprove = false, type = ""

function set_birthday(id) {
	input = document.getElementById("birthday_"+id)
	if (id=='date') { got_birthdate = true }
	if (id=='month') { got_birthmonth = true }
	if (id=='year') { got_birthyear = true }
	
	if (got_birthdate == true && got_birthmonth == true && got_birthyear == true) {
		$("#approved_bday").fadeOut("fast",function() {
			$("#disapproved_bday").fadeOut("fast",function() {
				$("#ajax_load_bday").fadeIn("fast",function() {
					if (document.getElementById("birthday_date").value !== 'none' && document.getElementById("birthday_month").value !== 'none' && document.getElementById("birthday_year").value !== 'none') {										 
					  $("#ajax_load_bday").fadeOut("fast",function() {
						  $("#approved_bday").fadeIn("fast")
							document.getElementById("text_bday").style.color = '#5C5C5C';
							document.getElementById("text_bday").style.fontWeight = 'normal';
					  })
					} else {
					  $("#ajax_load_bday").fadeOut("fast",function() {
						  $("#disapproved_bday").fadeIn("fast")
							document.getElementById("text_bday").style.color = 'red';
							document.getElementById("text_bday").style.fontWeight = 'bold';
					  })
					}
				  })
			})
		})
	}
}

function set_birthday_complete() {
  $("#ajax_load_bday").fadeIn("fast",function() {
	if (document.getElementById("birthday_date").value !== 'none' && document.getElementById("birthday_month").value !== 'none' && document.getElementById("birthday_year").value !== 'none') {										 
	  $("#ajax_load_bday").fadeOut("fast",function() {
		  $("#approved_bday").fadeIn("fast")
			document.getElementById("text_bday").style.color = '#5C5C5C';
			document.getElementById("text_bday").style.fontWeight = 'normal';
	  })
	} else {
	  $("#ajax_load_bday").fadeOut("fast",function() {
		  $("#disapproved_bday").fadeIn("fast")
			document.getElementById("text_bday").style.color = 'red';
			document.getElementById("text_bday").style.fontWeight = 'bold';
	  })
	}
  })
}

function set_membership(id) {
	if (id=="private") {
		$("#btn_member_schcom").addClass("btn_member_schcom")
		$("#btn_member_schcom").removeClass("btn_member_schcom_active")
		$("#btn_member_private").removeClass("btn_member_private")
		$("#btn_member_private").addClass("btn_member_private_active")
		$('.reg_member_company_div').slideUp('5000', function() {
			$('#reg_member_private_div').slideDown('7000', function() { window.location = '#steg1' })
		})
		
	}
	if (id=="company") {
		$("#btn_member_private").addClass("btn_member_private")
		$("#btn_member_private").removeClass("btn_member_private_active")
		$("#btn_member_schcom").removeClass("btn_member_schcom")
		$("#btn_member_schcom").addClass("btn_member_schcom_active")
		$('#reg_member_private_div').slideUp('7000', function() {$('.reg_member_company_div').slideDown('5000', function() { window.location = '#kontakta' })})
	}
}


function set_password() {
    if (document.getElementById("password_fake").style.display == "block") {
		document.getElementById("password_fake").style.display = "none";
		document.getElementById("password").style.display = "block";
		document.getElementById("password").focus()
	}
}

function set_username() {
    if (document.getElementById("username").value == "Användarnamn") {
        document.getElementById("username").value = ""
    }
}

function set_restore_password() {
    if (document.getElementById("restore_password").value == "Ange din E-postadress") {
        document.getElementById("restore_password").value = ""
    }
}





////////////////////////////////////////////////////////////////////////
function validate_member_private() {
	dont_register_member = false
	firstname = document.getElementById("firstname").value;
	lastname = document.getElementById("lastname").value;
	gender = document.getElementById("gender").value;
	birthdate = document.getElementById("birthday_date").value;
	birthmonth = document.getElementById("birthday_month").value;
	birthyear = document.getElementById("birthday_year").value;
	username = document.getElementById("username_").value;
	password = document.getElementById("password_").value;
	verify_password = document.getElementById("verify_password").value;
	email = document.getElementById("email").value;
	verify_email = document.getElementById("verify_email").value;
	
	if (firstname.length < 2) {
		ajax_approved = document.getElementById("approved_firstname")
		ajax_disapproved = document.getElementById("disapproved_firstname")
		dont_register_member = true
		ajax_disapprove('firstname');
	}
	if (lastname.length < 2) {
		ajax_approved = document.getElementById("approved_lastname")
		ajax_disapproved = document.getElementById("disapproved_lastnamee")
		dont_register_member = true
		ajax_disapprove('lastname');
	}
	if (gender == 'none') {
		ajax_approved = document.getElementById("approved_gender")
		ajax_disapproved = document.getElementById("disapproved_gender")
		dont_register_member = true
		ajax_disapprove('gender');
	}
	
	if (birthdate == 'none' || birthmonth == 'none' || birthyear == 'none') {
		ajax_approved = document.getElementById("approved_bday")
		ajax_disapproved = document.getElementById("disapproved_bday")
		dont_register_member = true
		ajax_disapprove('bday');
	}

	if (username.length < 3) {
		ajax_approved = document.getElementById("approved_username_")
		ajax_disapproved = document.getElementById("disapproved_username_")
		dont_register_member = true
		ajax_disapprove('username_');
	}
	
	if (password.length < 5) {
		ajax_approved = document.getElementById("approved_password_")
		ajax_disapproved = document.getElementById("disapproved_password_")
		dont_register_member = true
		ajax_disapprove('password_');
	}

	if (document.getElementById("password_").value !== document.getElementById("verify_password").value) {
		ajax_approved = document.getElementById("approved_verify_password")
		ajax_disapproved = document.getElementById("disapproved_verify_password")
		dont_register_member = true
		ajax_disapprove('verify_password');
	}

	if (document.getElementById("verify_password").value == "") {
		ajax_approved = document.getElementById("approved_verify_password")
		ajax_disapproved = document.getElementById("disapproved_verify_password")
		dont_register_member = true
		ajax_disapprove('verify_password');
	}
	
	if (email.length < 5) {
		ajax_approved = document.getElementById("approved_email")
		ajax_disapproved = document.getElementById("disapproved_email")
		dont_register_member = true
		ajax_disapprove('email');
	}

	if (document.getElementById("email").value !== document.getElementById("verify_email").value) {
		ajax_approved = document.getElementById("approved_verify_email")
		ajax_disapproved = document.getElementById("disapproved_verify_email")
		dont_register_member = true
		ajax_disapprove('verify_email');
	}

	if (document.getElementById("agree_terms").checked == false) {
		document.getElementById("text_terms").style.color = "red";
		document.getElementById("text_terms").style.fontWeight = "bold";
		$("#disapproved_terms").fadeIn('fast')
	} else {
		document.getElementById("text_terms").style.color = "#090";
		document.getElementById("text_terms").style.fontWeight = "normal";
		$("#disapproved_terms").fadeOut('fast')
	}
	

	if (password.length < 5 ) {
		dont_register_member = true
		$("#disapproved_password").fadeOut("fast", function() {
			 $("#approved_password").fadeOut("fast", function() {
				 $("#disapproved_password").fadeIn("fast")
			})
		})
	}
	
	if (dont_register_member == false) {
		if (document.getElementById("agree_terms").checked == true) {
			document.getElementById("text_terms").style.color = "#090";
			$("#disapproved_verify_terms").fadeOut('fast')
		}
		else {
			document.getElementById("text_terms").style.color = "red";
			$("#disapproved_terms").fadeIn('fast')
			alert('Du måste godkänna avtalsvillkoren')
			dont_register_member = true
		}
	} else {
		//alert('Var god fyll i dem nödvändiga fälten markerade med ett kryss')
	}
	if (dont_register_member == false) {document.form.submit()}

}


