var sH = {
  // initialisation function, call with load
  init: function() {
    if (!document.getElementById) return;
    
    sH.qform = document.getElementById('qform');
    
    sH.age = document.getElementById('age');
    sH.ethnicity = document.getElementById('ethnicity');
    sH.location = document.getElementById('location');

    sH.subbut = document.getElementById('subbut');
    
    sH.addEvent(sH.subbut, 'click', sH.val, false);
  },
	
	// function to add event listener, also caches events so they can be removed when the
	// page unloads to avoid memory leaks in IE
  addEvent: function(elm, evType, fn, useCapture) {
		// for W3C DOM complience
    if (elm.addEventListener) {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } 
		// for IE...
		else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      //EventCache.add(elm, evType, fn);
      return r;
    } else {
			// for anyone else not IE or Moz... Safari etc
      elm['on' + evType] = fn;
    }
  },
	
	// cross-browser get target
	find_target: function(e) 	{
		var target; 	
		// for IE, target is held in window.event array
		if (window.event && window.event.srcElement) 
			target = window.event.srcElement;
		else if (e && e.target)
			target = e.target;
		if (!target)
			return null;
			
		return target;
	},
	
	val: function() {
    var error;



    if(sH.age.selectedIndex == 0) {
      error = "Please select your age group";
      alert(error);
      return;
    }
    if(sH.ethnicity.selectedIndex == 0) {
      error = "Please select your ethnic group";
      alert(error);
      return;
    }
    if(sH.location.selectedIndex == 0) {
      error = "Please select where you are based";
      alert(error);
      return;
    }


    sH.qform.submit();

  }
	
	
	
}

sH.addEvent(window, 'load', sH.init, false);
// flush events on unload to avoid memory probs in IE
//sH.addEvent(window, 'unload', EventCache.flush, false);

