// JavaScript Document
// Joakim Øien Iversen
// Validation
function validate() {
//Er det noen av feltene som ikke er fylt inn?
if (document.bestille.tlfnr.value == "" || document.bestille.kontakt.value == "" || document.bestille.forbruk.value == "" || document.bestille.postnr.value == "" || document.bestille.poststed.value == "" || document.bestille.adresse.value == "" || document.bestille.firma.value == "" || document.bestille.epost.value == "") {
//Fyll inn forbruk
if (document.bestille.forbruk.value == "") {
alert("Vennligst fyll inn en forbruk.");
document.bestille.forbruk.focus();
}
//Fyll inn mail
if (document.bestille.epost.value == "") {
alert("Vennligst fyll inn en e-post adresse.");
document.bestille.epost.focus();
}
//Fyll inn telefonnummer
if (document.bestille.tlfnr.value == "") {
alert("Vennligst fyll inn telefonnummer.");
document.bestille.tlfnr.focus();
}
//Fyll inn postnummer
if (document.bestille.postnr.value == "") {
alert("Vennligst fyll inn postnummer.");
document.bestille.postnr.focus();
}
//Fyll inn poststed
if (document.bestille.poststed.value == "") {
alert("Vennligst fyll inn poststed.");
document.bestille.poststed.focus();
}
//Fyll inn adresse
if (document.bestille.adresse.value == "") {
alert("Vennligst fyll inn en adresse.");
document.bestille.adresse.focus();
}
//Fyll inn kontaktperson
if (document.bestille.kontakt.value == "") {
alert("Vennligst fyll inn en kontaktperson.");
document.bestille.kontakt.focus();
}
//Fyll inn firma
if (document.bestille.firma.value == "") {
alert("Vennligst fyll inn firma.");
document.bestille.firma.focus();
}

}

//Sender skjema hvis alt er fylt inn.
else { 
//sendMail();
document.bestille.submit();
}

}

/*

function sendMail() {
  // SET MESSAGE VALUES
  	var firma = "";
	var kontaktperson = "";
	var adresse = "";
	var poststed = "";
	var postnummer = "";
	var telefonnummer = "";
	var epost = "";
	var fax = "";
	var forbruk = "";
	var kommentar = "";
	if (document.bestille.firma){
	var firma = document.bestille.firma.value;
	}
	if (document.bestille.kontakt){
	var kontaktperson = document.bestille.kontakt.value;
	}
	if (document.bestille.adresse){
	var adresse = document.bestille.adresse.value;
	}
	if (document.bestille.poststed){
	var poststed = document.bestille.poststed.value;
	}
	if (document.bestille.postnr){
	var postnummer = document.bestille.postnr.value;
	}
	if (document.bestille.tlfnr){
	var telefonnummer = document.bestille.tlfnr.value;
	}
	if (document.bestille.epost){
	var epost = document.bestille.epost.value;
	}
	if (document.bestille.fax){
	var fax = document.bestille.fax.value;
	}
	if (document.bestille.forbruk){
	var forbruk = document.bestille.forbruk.value;
	}
	if (document.bestille.kommentar){
	var kommentar = document.bestille.kommentar.value;
	}
  
  var to = "post@elkraft-se.se";
  //var cc = "joiv@mac.com";
  //var bcc = "firmapost@elkraft.no";
  var subject = "Företag:" + firma +"";
  var msg =
    "\n Företag: " + firma +
    "\n\n Kontaktperson: " + kontaktperson +
    "\n\n Adress: " + adresse +
    "\n\n Ort: " + poststed +
    "\n\n Postnr: " + postnummer +
    "\n\n Telefon: " + telefonnummer +
    "\n\n Fax: " + fax +
	"\n\n E-post: " + epost +
    "\n\n Årsförbrukning: " + forbruk +
	"\n\n\nKommentar:\n" + kommentar;
alert("Vennligst send inn e-posten som genereres dersom du ønsker et tilbud på kraft.");
  // BUILD MAIL MESSAGE COMPONENTS
  var doc = "mailto:" + to +
    //"?cc=" + cc +
    //"&bcc=" + bcc +
    "?subject=" + subject +
    "&body=" + msg;

  // POP UP EMAIL MESSAGE WINDOW
  window.location = doc;
}*/