function validateemail(filed) {
if(filed.indexOf("@")==-1 || filed.indexOf(".")==-1) return false;
return true;
}

function IsDate(a){return/^\d{4}-\d{2}-\d{2}$/.test(a)} 

function bookstep1()
{
  f = document.forms['step1'];
 
  
  if (!IsDate(f.date.value)) {
    window.alert("Enter valid date!");
    return false;
  }
  
  s=f.date.value;
  y=s.substring(0,4);
  if(s.charAt(5)=='0') p1=6; else p1=5;
  m=s.substring(p1,7);
  if(s.charAt(8)=='0') p2=9; else p2=8;
  d=s.substring(p2,10);
  dat=new Date(y,m-1,d,23,59,59,0);
  dzis=new Date();
  data1=dat.getTime();
  data2=dzis.getTime();
  if(data1<data2){
	window.alert("You can't choose this date!");
    return false;
  }
  
  if (f.session.options[f.session.selectedIndex].value == '') {
    window.alert("Choose session!");
    return false;
  }

  return true;
}

function bookstep3()
{

  f = document.forms['step3'];

  if (f.fname.value == '') {
    window.alert("Enter your name!");
    return false;
  }

  if (f.surname.value == '') {
    window.alert("Enter your surname!");
    return false;
  }

  if (f.partyfor.value == '') {
    window.alert("Please fill the field \'Who is the party for?\'");
    return false;
  }

  if ((f.specialoccasion[0].checked) && (f.specialoccasion_what.value == '')) {
    window.alert("Please fill the field \'What is the occasion?\'");
    return false;
  }

  if (!validateemail(f.email.value)) {
    window.alert("Enter valid email!");
    return false;
  }

  if (f.email.value != f.email_confirm.value){
    window.alert("Field \'Email address\' and \'Confirm email address\' are not the same!");
    return false;
  }

  return true;
}

function bookstep4()
{

  f = document.forms['step4'];
//  alert(f.where_hear[].options[1].selected)

  if (f.address.value == '') {
    window.alert("Enter your address!");
    return false;
  }

  if (f.postcode.value == '') {
    window.alert("Enter your post code!");
    return false;
  }

  if (f.landline.value == '') {
    window.alert("Enter your land line telephone!");
    return false;
  }

  if (f.custom_tracks.options[f.custom_tracks.selectedIndex].value == '') {
	    window.alert("Please choose if you want us to create custom backing tracks!");
	    return false;
  }

  if (f.custom_tracks.options[f.custom_tracks.selectedIndex].value == '1') {
	  if (f.custom_song1_title.value=='' || f.custom_song1_artist.value=='')
	  {
	    window.alert("Enter title and artist for the first song!");
	    return false;
	  }
  }

  if (f.custom_tracks.options[f.custom_tracks.selectedIndex].value == '2') {
	  if (f.custom_song2_title.value=='' || f.custom_song2_artist.value=='')
	  {
	    window.alert("Enter title and artist for the second song!");
	    return false;
	  }
  }

  return true;
}