function chkForm1(theForm)
{
  
  if (theForm.txtMail.value == "")
  {
    alert("Du måste ange e-postadress");
    theForm.txtMail.focus();
    return (false);
  }
  
  if ((theForm.txtMail.value.indexOf(".") > 2) && (theForm.txtMail.value.indexOf("@") > 0))
	{
		
	}
	else {
		alert("E-postadressen verkar felaktig, e-post måste innehålla @");
		theForm.txtMail.focus();
		return false;
	}
  
  
  if (theForm.txtName.value == "")
  {
    alert("Du måste ange namn");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.txtAddress.value == "")
  {
    alert("Du måste ange en adress");
    theForm.txtAddress.focus();
    return (false);
  }

  if (theForm.txtPostal.value == "")
  {
    alert("Du måste ange postnummer");
    theForm.txtPostal.focus();
    return (false);
  }

  if (theForm.txtCity.value == "")
  {
    alert("Du måste ange ort");
    theForm.txtCity.focus();
    return (false);
  }
  
  if (theForm.txtPhone.value + theForm.txtMobile.value == "")
  {
		alert("Minst ett telefonnr måste anges");
		return (false);
  }
  
  if (theForm.txtComment.value.length > 255)
  {
		alert("Fältet övrigt får innehålla maximalt 255 tecken.");
		return false;
  }
  
  return (true);
}

function chkForm1_de(theForm)
{
  
  if (theForm.txtMail.value != "")
  {
	if ((theForm.txtMail.value.indexOf(".") > 2) && (theForm.txtMail.value.indexOf("@") > 0))
	{
		
	}
	else {
		alert("Falsche E-Mail Adresse");
		theForm.txtMail.focus();
		return false;
	}
  }
  
  if (theForm.txtName.value == "")
  {
    alert("Bitte Ihre Name angeben");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.txtAddress.value == "")
  {
    alert("Bitte Ihre Adresse angeben");
    theForm.txtAddress.focus();
    return (false);
  }

  if (theForm.txtPostal.value == "")
  {
    alert("Bitte ein Postleizahl angeben");
    theForm.txtPostal.focus();
    return (false);
  }

  if (theForm.txtCity.value == "")
  {
    alert("Bitte den Stadt einfüllen");
    theForm.txtCity.focus();
    return (false);
  }
  
  if (theForm.txtPhone.value + theForm.txtMobile.value == "")
  {
		alert("Mindesten ein Telefonnummer eingegeben");
		return (false);
  }
  
  if (theForm.txtComment.value.length > 255)
  {
		alert("Der Kommentar kann nur 255 Zeichen lang sein");
		return false;
  }
  
  return (true);
}


function chkForm1_en(theForm)
{
  
  if (theForm.txtMail.value != "")
  {
	if ((theForm.txtMail.value.indexOf(".") > 2) && (theForm.txtMail.value.indexOf("@") > 0))
	{
		
	}
	else {
		alert("The E-Mail address is not correct");
		theForm.txtMail.focus();
		return false;
	}
  }
  
  if (theForm.txtName.value == "")
  {
    alert("Please enter your name");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.txtAddress.value == "")
  {
    alert("Please enter your address");
    theForm.txtAddress.focus();
    return (false);
  }

  if (theForm.txtPostal.value == "")
  {
    alert("Please enter a zip code or P.O. Box");
    theForm.txtPostal.focus();
    return (false);
  }

  if (theForm.txtCity.value == "")
  {
    alert("Please enter a city");
    theForm.txtCity.focus();
    return (false);
  }
  
  if (theForm.txtPhone.value + theForm.txtMobile.value == "")
  {
		alert("Please enter at least one phone number");
		return (false);
  }
  
  if (theForm.txtComment.value.length > 255)
  {
		alert("The comment can only be 255 characters long");
		return false;
  }
  
  return (true);
}



function chkForm2(theForm)
{
  
  if (theForm.txtMail.value != "")
  {
	if ((theForm.txtMail.value.indexOf(".") > 2) && (theForm.txtMail.value.indexOf("@") > 0))
	{
		
	}
	else {
		alert("E-postadressen verkar felaktig");
		theForm.txtMail.focus();
		return false;
	}
  }
  
  if (theForm.txtName.value == "")
  {
    alert("Ange ett namn i namnfältet");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.txtPhone1.value + theForm.txtPhone2.value == "")
  {
		alert("Minst ett telefonnr måste anges");
		return (false);
  }
  
  var dim1, dim2;
	
	if (theForm.txtDateFrom.value == "")
	{
		alert('Från-datum saknas');
		theForm.txtDateFrom.focus();
		return false;
	}
	
	if (theForm.txtDateTo.value == "")
	{
		alert('Till-datum saknas');
		theForm.txtDateTo.focus();
		return false;
	}
		
	if (theForm.txtDateFrom.value != "")
	{
		dim1 = isDate(theForm.txtDateFrom.value);
	}
	
	if (theForm.txtDateTo.value == "")
	{
		dim2 = isDate(theForm.txtDateTo.value);
	} 
	
	if (dim1 && dim2)
	{
		return true;
	} else return false;
  
  
}

function chkForm2_de(theForm)
{
  
  if (theForm.txtMail.value != "")
  {
	if ((theForm.txtMail.value.indexOf(".") > 2) && (theForm.txtMail.value.indexOf("@") > 0))
	{
		
	}
	else {
		alert("E-Mail Adresse ist nich korrekt");
		theForm.txtMail.focus();
		return false;
	}
  }
  
  if (theForm.txtName.value == "")
  {
    alert("Bitte Ihre Name angeben");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.txtPhone1.value + theForm.txtPhone2.value == "")
  {
		alert("Am mindesten ein Telefonnummer muss eingefüllt geworden");
		return (false);
  }
  
  var dim1, dim2;
	
	if (theForm.txtDateFrom.value == "")
	{
		alert('Von-Datum fehlt');
		theForm.txtDateFrom.focus();
		return false;
	}
	
	if (theForm.txtDateTo.value == "")
	{
		alert('Zu-Datum fehlt');
		theForm.txtDateTo.focus();
		return false;
	}
		
	if (theForm.txtDateFrom.value != "")
	{
		dim1 = isDate(theForm.txtDateFrom.value);
	}
	
	if (theForm.txtDateTo.value == "")
	{
		dim2 = isDate(theForm.txtDateTo.value);
	} 
	
	if (dim1 && dim2)
	{
		return true;
	} else return false;
  
  
}

function chkForm3(theForm)
{
 
  if (theForm.txtName.value == "")
  {
    alert("Du måste ange namn");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.txtVarvsnr.value == "")
  {
    alert("Du måste ange varvsnr");
    theForm.txtVarvsnr.focus();
    return (false);
  }


  radio_choice = false;
  
  // For each radio button at this row, check if its selected. 
  for (counter = 0; counter < theForm.vecka.length; counter++) {
    // If a radio button has been selected it will return true
    if (theForm.vecka[counter].checked)
  	  radio_choice = true; 
  }
  if (!radio_choice)
  { // no choice selected     
  	alert("Du måste välja vecka");
    return (false);
	}
  
	
  if (theForm.txtComment.value.length > 255)
  {
		alert("Fältet övrigt får innehålla maximalt 255 tecken.");
		return false;
  }
  
  return (true);
}



function textLimit(field, maxlen)
	{
		if (field.value.length > maxlen + 1)
		alert('Texten kortades pga för många tecken');
		if (field.value.length > maxlen)
		field.value = field.value.substring(0, maxlen);
	}
	
function textLimit_de(field, maxlen)
	{
		if (field.value.length > maxlen + 1)
		alert('Zu viele Zeichnen');
		if (field.value.length > maxlen)
		field.value = field.value.substring(0, maxlen);
	}
	
function textLimit_en(field, maxlen)
	{
		if (field.value.length > maxlen + 1)
		alert('The text was shortened because of too many chars');
		if (field.value.length > maxlen)
		field.value = field.value.substring(0, maxlen);
	}
	
function chkForm_kontakt(theForm)
{
	if (theForm.txtFrom.value == "")
	{
		alert("Du måste ange ditt namn");
		theForm.txtFrom.focus();
		return false;
	}
	
	if (theForm.txtMail.value + theForm.txtPhone.value == "")
	{
		alert("Du måste ange antingen ett telefonnr eller en e-postadress.");
		return false;
	}
	
	if (theForm.txtMessage.value == "")
	{
		alert("Du glömde vad ärendet gällde.");
		theForm.txtMessage.focus();
		return false;
	}
	
	return true;
}

function chkForm_kontakt_de(theForm)
{
	if (theForm.txtFrom.value == "")
	{
		alert("Sie müssen Ihre Name angeben.");
		theForm.txtFrom.focus();
		return false;
	}
	
	if (theForm.txtMail.value + theForm.txtPhone.value == "")
	{
		alert("Sie müssen eine Telefonnummer oder eine E-Mailadresse angeben.");
		return false;
	}
	
	if (theForm.txtMessage.value == "")
	{
		alert("Sie müssen einen Mitteilung angeben.");
		theForm.txtMessage.focus();
		return false;
	}
	
	return true;
}

function chkForm_kontakt_en(theForm)
{
	if (theForm.txtFrom.value == "")
	{
		alert("Please enter your name");
		theForm.txtFrom.focus();
		return false;
	}
	
	if (theForm.txtMail.value + theForm.txtPhone.value == "")
	{
		alert("Please enter either a phone number or an E-mail address");
		return false;
	}
	
	if (theForm.txtMessage.value == "")
	{
		alert("Please enter a message");
		theForm.txtMessage.focus();
		return false;
	}
	
	return true;
}

function isDate(dateStr) {

    // var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var datePat = /^(\d{4})(-)(\d{1,2})(-)(\d{1,2})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?
	

    if (matchArray == null) {
		
	    alert("Datum ska vara i formatet åååå-mm-dd");
        return false;
    }

    year = matchArray[1];// parse date into variables
    month = matchArray[3]; 
    day = matchArray[5];
    
  
    if (month < 1 || month > 12) { // check month range
        alert("Månaden måste vara mellan 1 och 12!");
        return false;
    }

    if (day < 1 || day > 31) {
        alert("Dagen måste vara mellan 1-31!");
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Månaden "+month+" har inte 31 dagar!")
        return false;
    }

    if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            alert("Februari " + year + " har inte " + day + " dagar!");
            return false;
        }
    }
    return true; // date is valid
}