function SendElements() {
		var i,j;
		for (i=0; i < document.forms[0].elements.length-1; i++)
			switch (String(document.forms[0].elements[i].name).substring(0,3))
			{
				case "chk":
					if (document.forms[0].elements[i].checked)
						document.forms[0].elements[i].value = "Ja";
					else {
						document.forms[0].elements[i].checked = false;
						document.forms[0].elements[i].value = "Nej";
					}
					break;
			}
}

// Intresseformulär specifikt objekt
function MailTo_Validator(theForm)
{

  if (theForm.txtPersonnummer.value == "")
  {
    alert("Fyll i fältet \"Personnummer\"!");
    theForm.txtPersonnummer.focus();
    return (false);
  }

  if (theForm.txtFornamn.value == "")
  {
    alert("Fyll i fältet \"Förnamn\"!");
    theForm.txtFornamn.focus();
    return (false);
  }


  if (theForm.txtEfternamn.value == "")
  {
    alert("Fyll i fältet \"Efternamn\"!");
    theForm.txtEfternamn.focus();
    return (false);
  }

  if (theForm.txtAdress.value == "")
  {
    alert("Fyll i fältet \"Adress\"!");
    theForm.txtAdress.focus();
    return (false);
  }

  if (theForm.txtPostnummer.value == "")
  {
    alert("Fyll i fältet \"Postnummer\"!");
    theForm.txtPostnummer.focus();
    return (false);
  }

  if (theForm.txtPostnummer.value.length > 6)
  {
    alert("Max 5 siffror i \"Postnummer\"!");
    theForm.txtPostnummer.focus();
    return (false);
  }

  if (theForm.txtOrt.value == "")
  {
    alert("Fyll i fältet \"Ort\"!");
    theForm.txtOrt.focus();
    return (false);
  }

  if (theForm.txtTelefon.value == "")
  {
    alert("Fyll i fältet \"Telefon\"!");
    theForm.txtTelefon.focus();
    return (false);
  }

  if (theForm.txtTelefon.value.length > 25)
  {
    alert("Max 25 siffror för \"Telefon\".");
    theForm.txtTelefon.focus();
    return (false);
  }

  if (theForm.chkAccepterar_UC.check = (theForm.chkAccepterar_UC.checked) ? false:true)
  {
    alert("Du måste läsa och acceptera PUL (SFS 1998:20) och godkänna att vi hämtar kreditupplysning!");
    theForm.chkAccepterar_UC.focus();
    return (false);
  }
  return (true);
}

// Formulär felmeddelande
function MailFel_Validator(theForm)
{

  if (theForm.txtFornamn.value == "")
  {
    alert("Fyll i fältet \"Förnamn\"!");
    theForm.txtFornamn.focus();
    return (false);
  }


  if (theForm.txtEfternamn.value == "")
  {
    alert("Fyll i fältet \"Efternamn\"!");
    theForm.txtEfternamn.focus();
    return (false);
  }

  if (theForm.txtAdress.value == "")
  {
    alert("Fyll i fältet \"Adress\"!");
    theForm.txtAdress.focus();
    return (false);
  }

  if (theForm.txtVaningsplan.value == "")
  {
    alert("Fyll i fältet \"Våningsplan\"!");
    theForm.txtVaningsplan.focus();
    return (false);
  }

  if (theForm.txtLghNr.value == "")
  {
    alert("Fyll i fältet \"Lägenhetsnummer\"!");
    theForm.txtLghNr.focus();
    return (false);
  }

  if (theForm.txtTelefon.value == "")
  {
    alert("Fyll i fältet \"Telefon\"!");
    theForm.txtTelefon.focus();
    return (false);
  }

  if (theForm.txtTelefon.value.length > 25)
  {
    alert("Max 25 siffror för \"Telefon\".");
    theForm.txtTelefon.focus();
    return (false);
  }

  if (theForm.chkHuvudnyckel.check = (theForm.chkHuvudnyckel.checked) ? false:true)
  {
    alert("Vi måste få tillgång till lägenheten med huvudnyckel då ingen är hemma!");
    theForm.chkHuvudnyckel.focus();
    return (false);
  }
  return (true);
}

// Formulär allmänt
function MailToOther_Validator(theForm)
{

  if (theForm.txtPersonnummer.value == "")
  {
    alert("Fyll i fältet \"Personnummer\"!");
    theForm.txtPersonnummer.focus();
    return (false);
  }

  if (theForm.txtNamn.value == "")
  {
    alert("Fyll i fältet \"Namn\"!");
    theForm.txtNamn.focus();
    return (false);
  }

  if (theForm.txtGatuadress.value == "")
  {
    alert("Fyll i fältet \"Adress\"!");
    theForm.txtAdress.focus();
    return (false);
  }

  if (theForm.txtPostadress.value == "")
  {
    alert("Fyll i fältet \"Postadress\"!");
    theForm.txtPostadress.focus();
    return (false);
  }

  if (theForm.txtHemtelefon.value == "")
  {
    alert("Fyll i fältet \"Telefon\"!");
    theForm.txtTelefon.focus();
    return (false);
  }

  if (theForm.txtTelefon.value.length > 25)
  {
    alert("Max 25 siffror för \"Telefon\".");
    theForm.txtTelefon.focus();
    return (false);
  }

  return (true);
}

// Intresseformulär allmänt
function MailIntresse_Validator(theForm)
{

  if (theForm.txtFornamn.value == "")
  {
    alert("Fyll i fältet \"Förnamn\"!");
    theForm.txtFornamn.focus();
    return (false);
  }

  if (theForm.txtEfternamn.value == "")
  {
    alert("Fyll i fältet \"Efternamn\"!");
    theForm.txtEfternamn.focus();
    return (false);
  }

  if (theForm.txtPersonnummer.value == "")
  {
    alert("Fyll i fältet \"Personnummer\"!");
    theForm.txtPersonnummer.focus();
    return (false);
  }

  if (theForm.txtAdress.value == "")
  {
    alert("Fyll i fältet \"Adress\"!");
    theForm.txtAdress.focus();
    return (false);
  }

  if (theForm.txtPostnummer.value == "")
  {
    alert("Fyll i fältet \"Postnummer\"!");
    theForm.txtPostnummer.focus();
    return (false);
  }

  if (theForm.txtOrt.value == "")
  {
    alert("Fyll i fältet \"Ort\"!");
    theForm.txtOrt.focus();
    return (false);
  }

  if (theForm.txtTelefon.value == "")
  {
    alert("Fyll i fältet \"Telefon\"!");
    theForm.txtTelefon.focus();
    return (false);
  }

  if (theForm.txtTelefon.value.length > 25)
  {
    alert("Max 25 siffror för \"Telefon\".");
    theForm.txtTelefon.focus();
    return (false);
  }

	if (theForm.txtEpost.value == "")
	{
		alert("Fyll i fältet \"Epost\"!");
		theForm.txtEpost.focus();
		return (false);
	}
	else
	{
		apos=theForm.txtEpost.value.indexOf("@");
		dotpos=theForm.txtEpost.value.lastIndexOf(".");
		lastpos=theForm.txtEpost.value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
		{
			alert("Fel angiven e-postadress!");
			theForm.txtEpost.focus();
			return (false);
		}
	}

  if (theForm.chkAccepterar_UC.check = (theForm.chkAccepterar_UC.checked) ? false:true)
  {
    alert("Du måste acceptera att vi tar en kreditupplysning!");
    theForm.chkAccepterar_UC.focus();
    return (false);
  }
  return (true);
}

function emailvalidation(entered, alertbox)
{
	with (entered)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
		{
			if (alertbox) {alert(alertbox);} return false;
		}
		else
		{
			return true;
		}
	}
}

function nytt(URL,width,height) {
  unik=new Date();
  unik=unik.getSeconds()+"_"+unik.getMinutes()+"_"+unik.getHours();
  yPos=(screen.availHeight/2)-(height/2);
  xPos=(screen.availWidth/2)-(width/2);

  if (navigator.appName=="Netscape") {
    window.open(URL,unik,"screenY="+yPos+",screenX="+xPos+",width="+width+",height="+height+",resizable=no,scrollbars=yes,toolbar=no,status=no");
    }
    else {
      window.open(URL,unik,"top="+yPos+",left="+xPos+",width="+width+",height="+height+",resizable=no,scrollbars=yes,toolbar=no,status=no");
      }
}

//Skriva ut funktion :

function myprint() {
  window.print();
  }
  var da = (document.all) ? 1 : 0;
  var pr = (window.print) ? 1 : 0;
  var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage(frame, arg) {
  if (frame == window) {
    printThis();
  } else {
    link = arg; // a global variable 
    printFrame(frame);
  }
  return false;
}

function printThis() {
  if (pr) { // NS4, IE5
    window.print();
  } else if (da && !mac) { // IE4 (Windows)
    vbPrintPage();
  } else { // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  }
}

function printFrame(frame) {
  if (pr && da) { // IE5
    frame.focus();
    window.print();
    link.focus();
  } else if (pr) { // NS4
    frame.print();
  } else if (da && !mac) { // IE4 (Windows)
    frame.focus();
    setTimeout("vbPrintPage(); link.focus();", 100);
  } else { // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  }
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}
//Slut skrivar funktion

