function checkOrganizer() {
  if (!document.org.agree.checked) {
    alert('You have to agree on our general selling terms and conditions.');
    return false;
  } else {
    return true;
  }
}

function payOld(){
  bRet = true;
if (!document.pform.pchoice[0].checked && !document.pform.pchoice[1].checked){
alert("Kies eerst de gewenste betaalmethode");
return;
}
if (document.pform.pchoice[0].checked && document.pform.BPE_Issuer.value=="X"){
alert("U kunt uitsluitend met iDeal betalen\nals u bankiert bij één van de genoemde banken.\nSelecteer creditcard of neem contact met ons op...");
document.pform.pchoice[1].checked=true;
return;
}
if (document.pform.pchoice[1].checked){
window.open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, width=800, height=600, top=150, left=300');
document.pform.action="https://payment.buckaroo.nl/sslplus/request_for_authorization.asp"
}
if (document.pform.pchoice[0].checked){
  if (confirm('Let erop dat u na het afronden van de betaling via internetbankieren klikt op "volgende" om terug te keren naar Beatfreax,\r anders ontvangt u niet direct maar pas later uw e-tickets.')) {
    window.open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, top=100, left=150');
    document.pform.action="https://payment.buckaroo.nl/gateway/ideal_payment.asp"
  } else {
    bRet = false;
  }
}

if (bRet) {
  document.pform.target="_pay"
  document.pform.submit();
}
}

function pay()
{
  if (document.paypalform.pchoice.checked) {
    document.paypalform.submit();
    return false;
  } else {
    bRet = true;
    if (!document.pform.pchoice[0].checked && !document.pform.pchoice[1].checked){
      alert("Kies eerst de gewenste betaalmethode");
      return;
    }
    if (document.pform.pchoice[0].checked && document.pform.BPE_Issuer.value=="X"){
      alert("U kunt uitsluitend met iDeal betalen\nals u bankiert bij één van de genoemde banken.\nSelecteer creditcard of neem contact met ons op...");
      document.pform.pchoice[1].checked=true;
      return;
    }
    if (document.pform.pchoice[1].checked){
      window.open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, width=800, height=600, top=150, left=300');
      document.pform.action="https://payment.buckaroo.nl/sslplus/request_for_authorization.asp"
    }
    if (document.pform.pchoice[0].checked){
      if (confirm('Let erop dat u na het afronden van de betaling via internetbankieren klikt op "volgende" om terug te keren naar Beatfreax,\r anders ontvangt u niet direct maar pas later uw e-tickets.')) {
        window.open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, top=100, left=150');
        document.pform.action="https://payment.buckaroo.nl/gateway/ideal_payment.asp"
      } else {
        bRet = false;
      }
    }
  
    if (bRet) {
      document.pform.target="_pay"
      document.pform.submit();
    }
  }
}

/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}

function checkTicketContact()
{
  if (document.contact.name.value == '') {
    alert('Please fill in your name.');
    document.contact.name.focus();
    return false;
  } else if (document.contact.email.value == '') {
    alert('Please fill in an EXISTING and valid e-mail address, this is used to contact you.');
    document.contact.email.focus();
    return false;
  } else if (document.contact.subject.selectedIndex == 0) {
    alert('Please choose a subject.');
    return false;
  } else if (document.contact.question.value == '') {
    alert('Please fill in your question.');
    document.contact.question.focus();
    return false;
  } else {
    return true;
  }
}

function checkOrder(p_nLan)
{
  if (p_nLan == "nl") {
    mess_amount = 'Kies het aantal kaarten dat je wilt bestellen.';
  } else {
    mess_amount = 'Please choose the amount of tickets to order.';
  }
  
  if (p_nLan == "nl") {
    mess_disclaimer = 'Om door te gaan met bestellen moet je akkoord gaan met onze algemene voorwaarden.';
  } else {
    mess_disclaimer = 'You\'ll have to agree on the disclaimer in order to continue.';
  }
  
  if (document.order.amount_tickets.selectedIndex == 0) {
    alert(mess_amount);
    return false;
  } else {
    return true;
  }
}

function checkID(p_nLan)
{  
  if (!document.ident.sex[0].checked && !document.ident.sex[1].checked) {
    if (p_nLan == "nl") {
      alert('Selecteer man of vrouw.');
    } else {
      alert('Select male or female.');
    }
    return false;
  } else if (document.ident.lastname.value == "") {
    if (p_nLan == "nl") {
      alert('Vul je achternaam in. Deze wordt gebruikt om je informatie te verifiëren, zorg er dus voor dat hij overeenkomt met degene op je identificatie.');
    } else {
      alert('Please fill in your last name. This is used to verify your information, so make sure it\'s the same as on your ID.');
    }
    document.ident.lastname.focus();
    return false;
  } else if (document.ident.firstname.value == "") {
    if (p_nLan == "nl") {
      alert('Vul je voornaam in. Deze wordt gebruikt om je informatie te verifiëren, zorg er dus voor dat hij overeenkomt met degene op je identificatie.');
    } else {
      alert('Please fill in your first name. This is used to verify your information, so make sure it\'s the same as on your ID.');
    }
    document.ident.firstname.focus();
    return false;
  } else if (document.ident.city.value == "") {
    if (p_nLan == "nl") {
      alert('Vul je woonplaats in.');
    } else {
      alert('Please fill in your city.');
    }
    document.ident.city.focus();
    return false;
  } else if (document.ident.birthdate_month.selectedIndex == 0) {
    if (p_nLan == "nl") {
      alert('Vul je geboortedatum goed in.');
    } else {
      alert('Please fill in your correct birthdate.');
    }
    return false;
  } else if (document.ident.birthdate_day.selectedIndex == 0) {
    if (p_nLan == "nl") {
      alert('Vul je geboortedatum goed in.');
    } else {
      alert('Please fill in your correct birthdate.');
    }
    return false;
  } else if (document.ident.birthdate_year.selectedIndex == 0) {
    if (p_nLan == "nl") {
      alert('Vul je geboortedatum goed in.');
    } else {
      alert('Please fill in your correct birthdate.');
    }
    return false;
  } else if (document.ident.email.value == "") {
    if (p_nLan == "nl") {
      alert('Vul een GELDIG e-mail adres in, deze wordt gebruikt om je e-ticket naar toe te sturen.');
    } else {
      alert('Please fill in an EXISTING and valid e-mail address, this is used to send your e-ticket to.');
    }
    document.ident.email.focus();
    return false;
  /*
  } else if (!validateEmail(document.ident.email.value)) {
    alert('Please fill in an EXISTING and valid e-mail address, this is used to send your e-ticket to.');
    document.ident.email.focus();
    return false;*/
  } else if (!document.ident.agree.checked) {
    if (p_nLan == "nl") {
      alert('Je dient akkoord te gaan met onze algemene voorwaarden.');
    } else {
      alert('You have to agree on our terms and conditions.');
    }
    return false;
  } else if (!document.ident.payment.checked) {
    if (p_nLan == "nl") {
      alert('Kies een betaalmethode.');
    } else {
      alert('Choose a payment method.');
    }
    return false;
  } else {
    return true;
  }
}

<!--

function select_all(name, value) {
  formblock= document.getElementById('box');
  forminputs = formblock.getElementsByTagName('input');
  for (i = 0; i < forminputs.length; i++) {
    // regex here to check name attribute
    var regex = new RegExp(name, "i");
    if (regex.test(forminputs[i].getAttribute('name'))) {
      if (value == '1') {
        forminputs[i].checked = true;
      } else {
        forminputs[i].checked = false;
      }
    }
  }
}

function saveAlert()
{  
  selIt();
  selItLabels();
  selItLocations();
}

// PickList script- By Sean Geraty (http://www.freewebs.com/sean_geraty/)
// Visit JavaScript Kit (http://www.javascriptkit.com) for this JavaScript and 100s more
// Please keep this notice intact

// Control flags for list selection and sort sequence
// Sequence is on option value (first 2 chars - can be stripped off in form processing)
// It is assumed that the select list is in sort sequence initially
var singleSelect = true;  // Allows an item to be selected once only
var sortSelect = false;  // Only effective if above flag set to true
var sortPick = false;  // Will order the picklist in sort sequence

// Initialise - invoked on load
function initIt() {
  var selectList = document.getElementById("SelectList");
  var selectOptions = selectList.options;
  var selectIndex = selectList.selectedIndex;
  var pickList = document.getElementById("PickList");
  var pickOptions = pickList.options;
  //pickOptions[0] = null;  // Remove initial entry from picklist (was only used to set default width)
  if (!(selectIndex > -1)) {
    selectOptions[0].selected = true;  // Set first selected on load
    selectOptions[0].defaultSelected = true;  // In case of reset/reload
  }
  //selectList.focus();  // Set focus on the selectlist
}

// Adds a selected item into the picklist
function addIt(p_sSelect, p_sPick) {
  var selectList = document.getElementById(p_sSelect);
  var selectIndex = selectList.selectedIndex;
  var selectOptions = selectList.options;
  var pickList = document.getElementById(p_sPick);
  var pickOptions = pickList.options;
  var pickOLength = pickOptions.length;
  // An item must be selected
  while (selectIndex > -1) {
    pickOptions[pickOLength] = new Option(selectList[selectIndex].text);
    pickOptions[pickOLength].value = selectList[selectIndex].value;
    // If single selection, remove the item from the select list
    if (singleSelect) {
      selectOptions[selectIndex] = null;
    }
    if (sortPick) {
      var tempText;
      var tempValue;
      // Sort the pick list
      while (pickOLength > 0 && pickOptions[pickOLength].value < pickOptions[pickOLength-1].value) {
        tempText = pickOptions[pickOLength-1].text;
        tempValue = pickOptions[pickOLength-1].value;
        pickOptions[pickOLength-1].text = pickOptions[pickOLength].text;
        pickOptions[pickOLength-1].value = pickOptions[pickOLength].value;
        pickOptions[pickOLength].text = tempText;
        pickOptions[pickOLength].value = tempValue;
        pickOLength = pickOLength - 1;
      }
    }
    selectIndex = selectList.selectedIndex;
    pickOLength = pickOptions.length;
  }
  selectOptions[0].selected = true;
}

// Deletes an item from the picklist
function delIt(p_sSelect, p_sPick) {
  var selectList = document.getElementById(p_sSelect);
  var selectOptions = selectList.options;
  var selectOLength = selectOptions.length;
  var pickList = document.getElementById(p_sPick);
  var pickIndex = pickList.selectedIndex;
  var pickOptions = pickList.options;
  while (pickIndex > -1) {
    // If single selection, replace the item in the select list
    if (singleSelect) {
      selectOptions[selectOLength] = new Option(pickList[pickIndex].text);
      selectOptions[selectOLength].value = pickList[pickIndex].value;
    }
    pickOptions[pickIndex] = null;
    if (singleSelect && sortSelect) {
      var tempText;
      var tempValue;
      // Re-sort the select list
      while (selectOLength > 0 && selectOptions[selectOLength].value < selectOptions[selectOLength-1].value) {
        tempText = selectOptions[selectOLength-1].text;
        tempValue = selectOptions[selectOLength-1].value;
        selectOptions[selectOLength-1].text = selectOptions[selectOLength].text;
        selectOptions[selectOLength-1].value = selectOptions[selectOLength].value;
        selectOptions[selectOLength].text = tempText;
        selectOptions[selectOLength].value = tempValue;
        selectOLength = selectOLength - 1;
      }
    }
    pickIndex = pickList.selectedIndex;
    selectOLength = selectOptions.length;
  }
}

// Artist Selection - invoked on submit
function selIt(btn) {
  var pickList = document.getElementById("PickList");
  var pickOptions = pickList.options;
  var pickOLength = pickOptions.length;

  for (var i = 0; i < pickOLength; i++) {
    pickOptions[i].selected = true;
  }
  return true;
}
//-->

// Location Selection - invoked on submit
function selItLocations(btn) {
  var pickList = document.getElementById("PickListLocations");
  var pickOptions = pickList.options;
  var pickOLength = pickOptions.length;
  
  for (var i = 0; i < pickOLength; i++) {
    pickOptions[i].selected = true;
  }
  return true;
}
//-->

// Location Selection - invoked on submit
function selItLabels(btn) {
  var pickList = document.getElementById("PickListLabels");
  var pickOptions = pickList.options;
  var pickOLength = pickOptions.length;

  for (var i = 0; i < pickOLength; i++) {
    pickOptions[i].selected = true;
  }
  return true;
}
//-->

// Location Selection - invoked on submit
function selItCities(btn) {
  var pickList = document.getElementById("PickListCities");
  var pickOptions = pickList.options;
  var pickOLength = pickOptions.length;
  /*
  if (pickOLength < 1) {
    alert("No Selections in the Picklist\nPlease Select using the [->] button");
    return false;
  }*/
  for (var i = 0; i < pickOLength; i++) {
    pickOptions[i].selected = true;
  }
  return true;
}
//-->

function addPartySubmit()
{
  if(checkPartyForm()) {
    document.partyform.action.value = "add_party";
    selIt();
    
    return true;
  } else {
    return false;
  }
}

function addStoreSubmit()
{
  document.form.action.value = "add";
  
  return true;
}

function checkReview()
{
  if (document.review.release_id.selectedIndex == 0) {
    alert('Choose a release to review');
    document.review.release_id.focus();
    return false;
  } else if (document.review.intro.value == "") {
    alert('Write a small text for the homepage');
    document.review.intro.focus();
    return false;
  } else if (document.review.review.value == "") {
    alert('Write the review itself');
    document.review.review.focus();
    return false;
  } else if (document.review.verdict.selectedIndex == 0) {
    alert('Rate this release');
    document.review.verdict.focus();
    return false;
  } else {
    return true;
  }
}

function sendAgendaForm() {
  document.agenda_select.submit();
}

function clearText(thefield){
  if (thefield.defaultValue==thefield.value)
  thefield.value = ""
}

function checkOpinion ()
{
  if (document.opinion.verdict.selectedIndex == 0) {
    alert('Geef een cijfer');
    document.opinion.verdict.focus();
    return false;
  } else if (!document.opinion.Q1[0].checked && !document.opinion.Q1[1].checked) {
    alert('Beantwoord alle vragen.');
    return false;
  } else if (!document.opinion.Q2[0].checked && !document.opinion.Q2[1].checked) {
    alert('Beantwoord alle vragen.');
    return false;
  } else if (!document.opinion.Q3[0].checked && !document.opinion.Q3[1].checked) {
    alert('Beantwoord alle vragen.');
    return false;
  } else {
    return true;
  }
}

function checkAddLabel()
{
  if (document.label.name.value == "") {
    alert('What is the name of the label?');
    document.label.name.focus();
    return false;
  } else if(document.label.country_id.selectedIndex == 0) {
    alert('Choose a country (use "unknown" when unknown)');
    document.label.country_id.focus();
    return false;
  } else {
    return true;
  }
}

function checkAddRelease()
{
  if (document.release.label_id.selectedIndex == 0) {
    alert('Choose a label');
    document.release.label_id.focus();
    return false;
  } else if (document.release.format_id.selectedIndex == 0) {
    alert('Choose a format');
    document.release.format_id.focus();
    return false;
  } else if (document.release.artist_id.selectedIndex == 0) {
    alert('Choose an artist');
    document.release.artist_id.focus();
    return false;
  } else if (document.release.title.value == "") {
    alert('What is the title of the release?');
    document.release.title.focus();
    return false;
  } else if (document.release.style_id.selectedIndex == 0) {
    alert('Choose a style');
    document.release.style_id.focus();
    return false;
  } else {
    return true;
  }
}

function checkAddTrack()
{
  if (document.tracks.track_pos.value == '') {
    alert('On what position is this track? (e.g. 1, 2,  A1 or B2)');
    document.tracks.track_pos.focus();
    return false;
  }
  if (document.tracks.track_id.selectedIndex == 0) { 
    if (tracks['artists[]'].selectedIndex == -1 && document.tracks.artist_name.value == '') {
      alert('Choose an artist or fill in a new one.');
      document.tracks.artist_name.focus();
      return false;
    } else if (document.tracks.track_title.value == '') {
      alert('What is the title of this track?');
      document.tracks.track_title.focus();
      return false;
    } else {
      return true;
    }
  } else {
    return true;
  }
}

function checkEditRecensie()
{
  if (document.recensie.medium_id.selectedIndex == 0) {
    alert('Choose a medium.');
    document.recensie.medium_id.focus();
    return false;
  } else if (document.recensie.beatfreak_id.selectedIndex == 0 && document.recensie.artist_name.value == '') {
    alert('Choose an artist or fill in a new one.');
    document.recensie.beatfreak_id.focus();
    return false;
  } else if (document.recensie.label_id.selectedIndex == 0 && document.recensie.label_name.value == '') {
    alert('Choose a label or fill in a new one.');
    document.recensie.label_id.focus();
    return false;
  } else if (document.recensie.title.value == '') {
    alert('What is the title?');
    document.recensie.title.focus();
    return false;
  } else if (document.recensie.teaser.value == '') {
    alert('Give a short description.');
    document.recensie.teaser.focus();
    return false;
  } else if (document.recensie.review.value == '') {
    alert('Write down your review.');
    document.recensie.review.focus();
    return false;
  } else {  
    return true;
  }
}

function checkPost() {
  
  if((document.create_mess.f.value != 2 && document.create_mess.f.value != 3 && document.create_mess.f.value != 4) && document.create_mess.subject.value == '' && document.create_mess.action.value == "new_topic") {
    alert('Enter a subject.');
    document.create_mess.subject.focus();
    return false;
  } else if ((document.create_mess.f.value == 2 || document.create_mess.f.value == 3 || document.create_mess.f.value == 4) && document.create_mess.ext_id.value == 0) {
    alert('Choose a subject.');
    document.create_mess.ext_id.focus();
    return false;
  } else if (document.create_mess.text.value == '') {
    alert('Forgetting something?');
    document.create_mess.text.focus();
    return false;
  } else { 
    return true;
  }
}

function emoticon(text) {
	var txtarea = document.create_mess.text;
	text = '' + text + '';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function sendForm() {
  var message = '';
  var filter = '/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i';
  
  if(document.edit_profile.username.value == '') {
    alert('Change username');
    document.edit_profile.username.focus();
    return false;
  }else if(!(document.edit_profile.password.value == document.edit_profile.passwordcheck.value)) {
    alert('Enter correct password.');
    document.edit_profile.password.focus();
    return false;
  }else if(document.edit_profile.password.value == ''){
    alert('Enter password.');
    document.edit_profile.password.focus();
    return false;
  }else if(document.edit_profile.email.value == ''){
    alert('Enter e-mail address.');
    document.edit_profile.email.focus();
    return false;
  /*
  }else if(!(filter.test(document.edit_profile.email.value))) {
    alert('Vul een geldig e-mail adres in.');
    document.edit_profile.email.focus();
    return false;
  */
  }else if(document.edit_profile.naam.value == ''){
    alert('Enter your name.');
    document.edit_profile.naam.focus();
    return false;
  }else if(document.edit_profile.country_select.selectedIndex == 0 && document.edit_profile.country_text.value == '') {
    alert('Choose a country.');
    document.edit_profile.country_select.focus();
    return false;
  }else if(document.edit_profile.city_select.selectedIndex == 0 && document.edit_profile.city_text.value == '') {
    alert('Choose a city.');
    document.edit_profile.city_select.focus();
    return false;
  }else if(document.edit_profile.Dag.selectedIndex == 0) {
    alert('Enter your birthdate right.');
    document.edit_profile.Dag.focus();
    return false;
  }else if(document.edit_profile.Maand.selectedIndex == 0) {
    alert('Enter your birthdate right.');
    document.edit_profile.Maand.focus();
    return false;
  }else if(document.edit_profile.Jaar.selectedIndex == 0) {
    alert('Enter your birthdate right.');
    document.edit_profile.Jaar.focus();
    return false;
  }else if(true) {
    for(i = 0; i < document.edit_profile.geslacht.length; i++) {
      if(document.edit_profile.geslacht[i].checked) {
        show = false;
        break;
      }else{
        message = 'Enter your sex.';
        show = true;
      }
    }
    if(show) {
      alert(message);
      return false;
    }else{
      document.edit_profile.action.value = "update";
      document.edit_profile.submit();
      return true;
    }
  }
}

function changeForum() {
  document.forumselect.submit();
}

function checkPartyForm() {
  if(document.partyform.name.value == '') {
    alert('Enter the name of the party.');
    document.partyform.name.focus();
    return false;
  }else if(document.partyform.day.selectedIndex == 0) {
    alert('Enter the day.');
    document.partyform.day.focus();
    return false;
  }else if(document.partyform.month.selectedIndex == 0) {
    alert('Enter the month.');
    document.partyform.month.focus();
    return false;
  }else if(document.partyform.city_select.selectedIndex == 0 && document.partyform.city.value == '') {
    alert('Choose a city from the pulldown menu, or enter a new one in the textbox next to it.');
    document.partyform.city_select.focus();
    return false;
  }else if(document.partyform.country_select.selectedIndex == 0 && document.partyform.country.value == '') {
    alert('Choose a country from the pulldown menu, or enter a new one in the textbox next to it.');
    document.partyform.country_select.focus();
    return false;
  }else if(document.partyform.location_select.selectedIndex == 0 && document.partyform.location.value == '') {
    alert('Choose a location from the pulldown menu, or enter a new one in the textbox next to it.');
    document.partyform.location_select.focus();
    return false;
  }else if(document.partyform.info.value == '' && document.partyform.PickList.length == 0) {
    alert('Enter the line-up.');
    document.partyform.info.focus();
    return false;
  }else{
    return true;
  }
}

/* function to check if add_gallery.php is filled in right */
function checkGalleryForm() {
  if(document.galleryform.party_id.selectedIndex == 0 && 
     document.galleryform.beatfreak_id.selectedIndex == 0 && 
     document.galleryform.name.value == '' && 
     document.galleryform.day.selectedIndex == 0 && 
     document.galleryform.month.selectedIndex == 0 &&
     document.galleryform.equip_id.selectedIndex == 0) {
    
    alert('Kies een feest, beatfreak of iets anders waar je een gallery voor gaat aanmaken.');
    return false;
  }else if(document.galleryform.party_id.selectedIndex == 0 && 
     document.galleryform.beatfreak_id.selectedIndex == 0 && 
     document.galleryform.name.value != '' && 
     (document.galleryform.day.selectedIndex == 0 || 
     document.galleryform.month.selectedIndex == 0)){
    
    alert('Vul een goede datum in voor deze gallery.');
    return false;
  }else if(document.galleryform.party_id.selectedIndex == 0 && 
     document.galleryform.beatfreak_id.selectedIndex == 0 && 
     document.galleryform.name.value == '' && 
     document.galleryform.day.selectedIndex > 0 && 
     document.galleryform.month.selectedIndex > 0){
    
    alert('Vul een naam in voor deze gallery.');
    return false;
  }else{
    return true;
  }
}

/* function to check if add_report.php is filled in right */
function checkReportForm() {
  if(document.reportform.party_id.selectedIndex == 0) {
    alert('Choose a party.');
    return false;
  }else{
    return true;
  }
}

function checkBeatfreak() 
{ 
  if(document.add_beatfreak.name.value == '') {
    alert('Enter the name.');
    document.add_beatfreak.name.focus();
    return false;
  }else{
    selIt();
    document.add_beatfreak.action.value = "add_artist";
    document.add_beatfreak.submit();
    return true;
  }
}

function editBeatfreak() {
  if(document.edit_beatfreak.cat.selectedIndex == 0) {
    alert('Vul een categorie in.');
    document.edit_beatfreak.cat_id.focus();
    return false;
  }else if(document.edit_beatfreak.name.value == '') {
    alert('Vul een naam in.');
    document.edit_beatfreak.name.focus();
    return false;
  }else if(document.edit_beatfreak.country_select.selectedIndex == 0 && document.edit_beatfreak.country_text.value == '') {
    alert('Vul een land in.');
    document.edit_beatfreak.country_select.focus();
    return false;
  }else if(!document.edit_beatfreak.country_select.selectedIndex == 0 && !document.edit_beatfreak.country_text.value == '') {
    alert('Kies OF een land uit de pulldown, OF voer een nieuwe in.');
    document.edit_beatfreak.country_select.focus();
    return false;
  }else if(document.edit_beatfreak.city_select.selectedIndex == 0 && document.edit_beatfreak.city_text.value == '') {
    alert('Vul een stad in.');
    document.edit_beatfreak.city_select.focus();
    return false;
  }else if(!document.edit_beatfreak.city_select.selectedIndex == 0 && !document.edit_beatfreak.city_text.value == '') {
    alert('Kies OF een stad uit de pulldown, OF voer een nieuwe in.');
    document.edit_beatfreak.city_select.focus();
    return false;
  }else{
    //document.edit_beatfreak.action.value = "add";
    document.edit_beatfreak.submit();
    return true;
  }
}

/* function to open pop-up window without properties but WITH scrollbar */
function openWin(Page, w, h) {
  window.open(Page, 'actie', 'toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=' + w + ',height=' + h);
}

function checkForm(form) {
  //alert(form.getElementsByTagName("SELECT").item(0).options.text);
	for(var i = 0; i < form.getElementsByTagName("SELECT").length; i++) {
	  if(form.getElementsByTagName("SELECT").item(0).options.text == "[kies]") {
	    alert("alles invullen!");
	    return true;
	  }else{
	    return true;
	  }
  }
}

function checkReaction() {
  if(document.reaction.reaction.value == ''){
    alert('Enter a reaction.');
    document.reaction.reaction.focus();
  }else{
    document.reaction.submit();
  }
}

function checkMessage() {
  if(document.create.to_id.selectedIndex == 0) {
    alert('Choose the receiver.');
    document.create.to_id.focus();
    return false;
  }else if(document.create.subject.value == ''){
    alert('Enter a subject.');
    document.create.subject.focus();
    return false;
  }else if(document.create.text.value == ''){
    alert('No empty messages please.');
    document.create.text.focus();
    return false;
  }else{
    return true;
  }
}

function update(thisEl) {
 var text = thisEl.options[thisEl.selectedIndex].innerHTML;
 var items = document.getElementsByTagName("SELECT");
 for(var i=0; i<items.length; i++) {
  try {
  if(items[i]==thisEl) {continue;}
  if(items[i].selectedIndex!=-1 && items[i].options[items[i].selectedIndex].innerHTML==text)
    items[i].selectedIndex=-1;
  } catch(exc) {}
 }
}


function checkCriteria() {
  var items = document.forms[0].getElementsByTagName("SELECT");
  for(var i=0; i<items.length; i++) {
    if(items[i].options[items[i].selectedIndex].value == "[kies]") {
      bSubmit = false;;
    }else{
      bSubmit = true;
    }
  }
  
  if(bSubmit) {
    return true;
  }else{
    alert('Vul alle criteria in.');
    return false;
  }
}

function checkSubmitTopic() {
  if(document.create_topic.subject.value == '') {
    alert('Enter a subject.');
    document.create_topic.subject.focus();
    return false;
  }else if(document.create_topic.text.value == '') {
    alert('Enter the text.');
    document.create_topic.text.focus();
    return false;
  }else{
    return true;
  }
}

function checkCreateAfter() {
  if(document.create_topic.party_id.selectedIndex == 0) {
    alert('Choose a party on which you\'d like to react.');
    return false;
  }else if(document.create_topic.text.value == '') {
    alert('Enter the text.');
    document.create_topic.text.focus();
    return false;
  }else{
    return true;
  }
}

function checkCreateBeatfreak() {
  if(document.create_topic.beatfreak_id.selectedIndex == 0) {
    alert('Choose an artist on which you\'d like to react.');
    return false;
  }else if(document.create_topic.text.value == '') {
    alert('Enter the text.');
    document.create_topic.text.focus();
    return false;
  }else{
    return true;
  }
}

function checkMailing() {
  if(!document.mailing.to[0].checked && !document.mailing.to[1].checked) {
    alert('Naar wie moet de mailing gaan?');
    document.mailing.to.focus();
    return false;
  }else if(document.mailing.from.value == '') {
    alert('Vul een afzender e-mail adres in.');
    document.mailing.from.focus();
    return false;
  }else if(document.mailing.subject.value == '') {
    alert('Vergeet het onderwerp niet!');
    document.mailing.subject.focus();
    return false;
  }else if(document.mailing.text.value == '') {
    alert('Vergeet de text niet!');
    document.mailing.text.focus();
    return false;
  }else{
    return true;    
  }
}

function checkSet()
{
  if(document.add_set.artist_id.selectedIndex == 0) {
    alert('Select an artist from the database. If the artist does not appear in our system, add it with "add artist".');
    return false;
  } else if(document.add_set.url.value == '') {
    alert('Fill in the URL / path to the set.');
    return false;
  } else {
    return true;
  }
}

function sendForm() {
  var message = '';
  var filter = '/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i';
  
  if(!(document.register.Password.value == document.register.Passwordcheck.value)) {
    alert('Fill in you password correctly.');
    document.register.Password.focus();
    return false;
  }else if(document.register.Username.value == '') {
    alert('Fill in your username.');
    document.register.Username.focus();
    return false;
  }else if(document.register.Password.value == ''){
    alert('Fill in your password.');
    document.register.Password.focus();
    return false;
  }else if(document.register.Email.value == ''){
    alert('Fill in your e-mail.');
    document.register.Email.focus();
    return false;
  }else if(document.register.Naam.value == ''){
    alert('Fill in your name.');
    document.register.Naam.focus();
    return false;
  }else if(document.register.country_select.selectedIndex == 0 && document.register.country_text.value == '') {
    alert('Choose your country or fill in a new one if it doesn\'t appear in the pulldown.');
    return false;
  }else if(document.register.city_select.selectedIndex == 0 && document.register.city_text.value == '') {
    alert('Choose your city or fill in a new one if it doesn\'t appear in the pulldown.');
    return false;
  }else if(document.register.Dag.selectedIndex == 0) {
    alert('Fill in your birthdate.');
    return false;
  }else if(document.register.Maand.selectedIndex == 0) {
    alert('Fill in your birthdate.');
    return false;
  }else if(document.register.Jaar.selectedIndex == 0) {
    alert('Fill in your birthdate.');
    return false;
  }else if(true) {
    for(i = 0; i < document.register.Geslacht.length; i++) {
      if(document.register.Geslacht[i].checked) {
        show = false;
        break;
      }else{
        message = 'Fill in your sex.';
        show = true;
      }
    }
    if(show) {
      alert(message);
      return false;
    }else{
      document.register.action.value = "register";
      document.register.submit();
      return true;
    }
  }
}