function show(lager)
{
if(document.layers)
	{ document.layers[lager].visibility = "show" 
	}
else if (document.all)
	{ document.all[lager].style.visibility = "visible" 
	}
}
function hide(lager)
{
if(document.layers)
	{ document.layers[lager].visibility = "hide" }
else if (document.all)
	{ document.all[lager].style.visibility = "hidden" }
}

function emailvalidation(entered) {
  // E-mail Validation by Henrik Petersen / NetKontoret, Explained at www.echoecho.com/se/jsforms.htm, Please do not remove this line and the two lines above.
  with (entered)
  {
    if (value==""){ return false; }
    apos=value.indexOf("@");
    dotpos=value.lastIndexOf(".");
    lastpos=value.length-1;
    if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) { return false; }
    else {return true;}
  }
}
function emailvalidation2(entered) {
  // E-mail Validation by Henrik Petersen / NetKontoret, Explained at www.echoecho.com/se/jsforms.htm, Please do not remove this line and the two lines above.
  with (entered)
  {
    if (value==""){ return true; }
    apos=value.indexOf("@");
    dotpos=value.lastIndexOf(".");
    lastpos=value.length-1;
    if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) { return false; }
    else {return true;}
  }
}

function emptyvalidation(entered) {
  with (entered)
  {
    if (value=="" || value=='' || value==null) { return false; }	// returns false if field is empty
    else { return true; }
  }
}


function digitvalidation(entered, min, max, datatype)
{
// Digit Validation by Henrik Petersen / NetKontoret, Explained at www.echoecho.com/jsforms.htm, Please do not remove this line and the two lines above.
with (entered)
{ 
 checkvalue=parseFloat(value);
 if (datatype)
 { smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i")
   { checkvalue=parseFloat(value); if (value.indexOf(".")!=-1) { checkvalue=checkvalue+1; }
   }
 }
 if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue) { return false; }
// if (value.length<min || value.length>max || value!=checkvalue) { return false; }
 else {return true;}
}
}


function containschar(field, char1) {
  with (field) {
    return value.indexOf(char1) == -1;
  }
}



function formvalidation1(small_form)
{
with (small_form)
text = "";
if (emptyvalidation(small_form.namn)==false) { small_form.namn.focus(); text = "Namn måste fyllas i.\n"; }
if (emailvalidation(small_form.epost)==false) { small_form.epost.focus(); text = text+"Din e-postadressen är inte korrekt.\n"; }
if (emailvalidation2(small_form.receiver1)==false) { small_form.receiver1.focus(); text = text+"E-postadress 1 är inte korrekt.\n"; }
if (emailvalidation2(small_form.receiver2)==false) { small_form.receiver2.focus(); text = text+"E-postadress 2 är inte korrekt.\n"; }
if (emailvalidation2(small_form.receiver3)==false) { small_form.receiver3.focus(); text = text+"E-postadress 3 är inte korrekt.\n"; }
if (emailvalidation2(small_form.receiver4)==false) { small_form.receiver4.focus(); text = text+"E-postadress 4 är inte korrekt.\n"; }
if (text=='') { return true; }
else { alert(text); return false; }
}

function formvalidation2(small_form)
{
with (small_form)
text = "";
if (emptyvalidation(small_form.subject)==false) { small_form.subject.focus(); text = "Ämnet måste fyllas i.\n"; }
if (emptyvalidation(small_form.content)==false) { small_form.content.focus(); text = text+"Innehåll måste fyllas i.\n"; }
if (text=='') { return true; }
else { alert(text); return false; }
}



function formvalidation3(small_form)
{
 with (small_form)
 text = "";
 if (emptyvalidation(small_form.namn)==false) { small_form.namn.focus(); text = "Namn måste fyllas i.\n"; }
 if (emailvalidation(small_form.epost)==false) { small_form.epost.focus(); text = text+"E-postadressen är inte korrekt.\n"; }
 if (emptyvalidation(small_form.telefon)==true) { 
   if (digitvalidation(small_form.telefon,9,10,"I")==false) { small_form.telefon.focus(); text = text+"Telefonnumret får endast innehålla siffror (9-10).\n"; }
 }
 if (emptyvalidation(small_form.bil)==false) { small_form.bil.focus(); text = text+"Bilmärke måste fyllas i.\n"; }
 if (emptyvalidation(small_form.modell)==false) { small_form.modell.focus(); text = text+"Bilmodell måste fyllas i.\n"; }
 if (emptyvalidation(small_form.ar)==true) { 
   if (digitvalidation(small_form.ar,2,2,"I")==false) { small_form.ar.focus(); text = text+"Årsmodell måste innehålla 2 siffror.\n"; }
 } else { small_form.ar.focus(); text = text+"Årsmodell måste fyllas i.\n"; }
 if (emptyvalidation(small_form.mil)==true) { 
   if (digitvalidation(small_form.mil,1,5,"I")==false) { small_form.mil.focus(); text = text+"Milantalet får endast innehålla siffror (max 5).\n"; }
 } else { small_form.ar.focus(); text = text+"Mil (mätarställning) måste fyllas i.\n"; }
 if (emptyvalidation(small_form.pris)==true) { 
   if (digitvalidation(small_form.pris,1,7,"I")==false) { small_form.pris.focus(); text = text+"Priset får endast innehålla siffror (max 7).\n"; }
 }

 if (emptyvalidation(small_form.info)==true) { 
   if (containschar(small_form.info, "\"")==false) { small_form.info.focus(); text = text+"Info får inte innehålla citattecknen.\n"; }
 }
 if (emptyvalidation(small_form.info)==true) { 
   if (containschar(small_form.info, "\'")==false) { small_form.info.focus(); text = text+"Info får inte innehålla citattecknen.\n"; }
 }
 if (emptyvalidation(small_form.info)==true) { 
   if (containschar(small_form.info, "\´")==false) { small_form.info.focus(); text = text+"Info får inte innehålla citattecknen.\n"; }
 }
 if (emptyvalidation(small_form.info)==true) { 
   if (containschar(small_form.info, "\`")==false) { small_form.info.focus(); text = text+"Info får inte innehålla citattecknen.\n"; }
 }

 if (text=='') { return true; }
 else { alert(text); return false; }
}

