	var rowNo = 1;

	function generateKey(){
	  var key = 0;
	  key = Math.random() * 1000000000;
	  key = Math.round(key);
	  return key;
	};

	

	//This function makes sure the form has been filled out correctly
	function isFormValid(){
	  var atsign = false;

	  //Is the email field filled in
	  //if(document.getElementById("email").value.length < 1){
	    //window.alert("Fyll i din e-postadress");
	    //document.getElementById("email").focus();
	    //return false;
	  //}
	  
	  //Are the two email fields showing the same address?
	  if(document.getElementById("email").value != document.getElementById("email2").value){
		window.alert("Båda fälten för e-postadress måste vara ifyllda med exakt samma e-postadress");
		document.getElementById("email").focus();
		return false;
	  }	  
	  
	  //Did the customer fill in a store
	  if(document.getElementById("store").value == 0){
		  window.alert("Vänligen fyll i vilken butik som är din hemmabutik");
		  document.getElementById("store").focus();
		  return false;
	  }

	  //No ";" signs anywhere since that will interfere with the Java parser later
	  if(document.getElementById("fname").value.indexOf(";") != -1){
	    window.alert("Semikolon inte tillåtet i namnfältet");
	    document.getElementById("fname").focus();
	    return false;
	  }
	  
	  //No ";" signs anywhere since that will interfere with the Java parser later
	  if(document.getElementById("ename").value.indexOf(";") != -1){
	    window.alert("Semikolon inte tillåtet i namnfältet");
	    document.getElementById("ename").focus();
	    return false;
	  }

	  //No ";" signs anywhere since that will interfere with the Java parser later
	  if(document.getElementById("street").value.indexOf(";") != -1){
	    window.alert("Semikolon inte tillåtet i gatuadressen");
	    document.getElementById("street").focus();
	    return false;
	  }
	  
          //No ";" signs anywhere since that will interfere with the Java parser later
	  if(document.getElementById("city").value.indexOf(";") != -1){
	    window.alert("Semikolon inte tillåtet i ort-fältet");
	    document.getElementById("city").focus();
	    return false;
	  }

          //No ";" signs anywhere since that will interfere with the Java parser later
	  if(document.getElementById("zip").value.indexOf(";") != -1){
	    window.alert("Semikolon inte tillåtet i postnummerfältet");
	    document.getElementById("zip").focus();
	    return false;
	  }

	  //No ";" signs anywhere since that will interfere with the Java parser later
	  if(document.getElementById("email").value.indexOf(";") != -1){
	    window.alert("Semikolon inte tillåtet i e-post adressen");
	    document.getElementById("email").focus();
	    return false;
	  }


          //Make sure the zip-no field has 5 letters in it
	  if(document.getElementById("zip").value.length > 0){
            if(document.getElementById("zip").value.length != 5 || isNaN(document.getElementById("zip").value) == true){
  	      window.alert("Vänligen fyll i ett postnummer enligt '12345'");
	      document.getElementById("zip").focus();
	      return false;
	    }
	  }      
          
	
	  //e-mail checks, have to have an @-sign, a . and be atleast 6 letters in length.
	  if(document.getElementById("email").value.length > 0){ 
	    var addy = document.getElementById("email").value;
	    if(addy.indexOf(".") == -1 || addy.indexOf("@") == -1 || addy.length < 6){
	      window.alert("Fyll i en e-postadress");
	      document.getElementById("email").focus();
	      return false;
	    }
	  }

	  //Check first and last sign for @ == error
	  if(document.getElementById("email").value.length > 0){
	    if(addy.charAt(0) == "@" || addy.charAt((addy.length - 1)) == "@"){
	      window.alert("Kontrollera din e-postadress");
	      document.getElementById("email").focus();
	      return false;
	    }
	  }

	  //All addresses have 2, 3 or 4 letters after the ".", ala .com, or .se. Otherwise error.
	  if(document.getElementById("email").value.length > 0){
	    if(addy.charAt(addy.length - 3) != "." && addy.charAt(addy.length - 4) != "." && addy.charAt(addy.length - 5) != "."){
	      window.alert("Kontrollera din e-postadress, den verkar inte sluta på .com eller .se och så vidare");
	      document.getElementById("email").focus();
	      return false;
	    }
	  }



	  //Seems everything is ok then, so lets generate the key
	  document.getElementById("key").value = generateKey();

	  return true;
	};





	//This function runs after the submit button is pressed.
	function process(){

	  //First make sure all fields are filled in correctly
	  var bol = isFormValid();

	  if(bol == true){
	    return true;
	  }
	  //If the form wasn't validated, don't submit the form allowing the user to edit the fields as requested
	  else if(bol == false){
	    return false;
	  }	  
	};

	//This function prepares the form onLoad
	function prepareForm(){
		document.getElementById("fname").focus();	
	};

