
function validEmail(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false;
		 }
 		 return true					
	}


function validateBookForm(thisObj){
  return true;
}	
	
function validateBookFormBak(thisObj){
  if(thisObj.bDate.value==''){
  	alert('You have to select an arrivaldate!\nWrite your date in the field or select date in the calendar!');
  	thisObj.bDate.focus();
  	return false;
  }

  thisDate=new Date();
  y2 = thisDate.getFullYear();
  m2 = thisDate.getMonth();
  d2 = thisDate.getDate();
	if(d2<10){d2 = '0' + d2;}
	if(m2<9){m2 = '0' + (m2+1);}
  thisDate = (y2 + '-' + m2 + '-' + d2);

	
  if(thisObj.bDate.value<thisDate){
  	alert('You cannot select a date prior to today!');
  	thisObj.bDate.focus();
  	return false;
  }
  
  return true;
}

function validateContact(thisObj){
  if(thisObj.subject.value==0){
  	alert('You have to select subject!');
  	thisObj.subject.focus();
  	return false;
  }
  if(thisObj.msg.value==''){
  	alert('You have to write a message!');
  	thisObj.msg.focus();
  	return false;
  }
  return true;
}





function validateChangeBooking(thisObj){
  if(thisObj.bookingNr.value==''){
  	alert('You have to write your booking number!\nContat us via e-mail or phone if you do not have your booking number available!');
  	thisObj.bookingNr.focus();
	return false;
  }
  return true;
}


function validateBooking(thisObj){
  if(thisObj.name.value==''){
  	alert('Du måste ange ditt namn!');
  	thisObj.name.focus();
  	return false;
  }
  if((thisObj.email.value=='')&&(thisObj.phone.value=='')){
  	alert('Du måste ange antingen e-post eller telefon!');
  	thisObj.email.focus();
  	return false;
  }
  if(thisObj.persons.value==''){
  	alert('Du måste ange antal personer!');
  	thisObj.persons.focus();
  	return false;
  }
  if(thisObj.arrivaldate.value==''){
  	alert('Du måste ange datum!');
  	thisObj.arrivaldate.focus();
  	return false;
  }
  if(thisObj.arrivaltime.value==''){
  	alert('Du måste ange tid!');
  	thisObj.arrivaltime.focus();
  	return false;
  }
  return true;
}