function simpledebug( theObject ) {
  alert( 'simpledebug: ' + theObject );
}

function debug( theObject ) {
  alert( 'debug: ' + theObject.type + " - " + theObject.name + " - " + theObject.length );
}

function displayErrorImage( questionId, ok, imgwidth, imgheight ) {
  // IE
  var anImage = document.images[questionId];
  if( ok ) {
    anImage.width = 0;
    anImage.height = 0;
  }
  else {
    anImage.width = imgwidth;
    anImage.height = imgheight;
  }
} 

function checkVotes( formName, ids, imagePrefix, imgwidth, imgheight, errorText) {
  var theForm = document.forms[formName];
  var question;
  var alternative;
  var result = true;

  // debug( theForm );  
  for( question=0; question<ids.length; question++ ) {
    // simpledebug(ids[question]);
    var selection = null;
    // Frågan, dvs en array av alternativen (inputs som har samma id)
    var theQuestion = theForm[ids[question]];
    // debug( theQuestion );
    for( i=0; i<theQuestion.length; i++ ) {
      if( theQuestion[i].checked ) {
        selection = theQuestion[i].value;
      }
    }
    if( selection == null ) {
      result = false;
      // alert( ids[question] + ' är inte ifylld ' + anImage.src );
    }
    // Hide or show the error-image
    //displayErrorImage( imagePrefix+ids[question], selection!=null, imgwidth, imgheight );
  }
  if( !result ) {
    alert( errorText );
  }
  return result;
}

