locationSelector = function (e)
{
	field=e.target;

	if(field.getValue()==108)
	{
		$("area").disabled=false;
	}
	else
	{
		$("area").value="";
	}
}

areaSelector = function (e)
{
	loc=document.getElements("select[name^=tx_mjseventpro_pi1[location]");
	alert(loc.options);

}

var Countable = new Class({

  initialize: function(inputId, max, className, errorClass) {

    this.input = $(inputId);
 	this.max = max;
 	this.className = className ? className : "count";
 	this.errorClass = errorClass ? errorClass : "error";
 	
    this.handle = new Element("div", {class: this.className});
    this.handle.setHTML('&nbsp;').injectAfter(this.input);
    this.input.addEvent('keydown', this.onKeyPress.bindWithEvent(this));
    this.input.addEvent('keyup', this.onKeyPress.bindWithEvent(this));
    this.update();
   
  },
  
  onKeyPress: function(event) {
    event = new Event(event);
    if(!event.shift && !event.control && !event.alt && !event.meta) this.update();
  },
  
  update: function() {

    if (this.input.value.length > this.max)
      this.input.value = this.input.value.substring(0, this.max);
 
      var count = this.max - this.input.value.length;
 
      if (count == 0) {
        var string = "<span class=\""+this.errorClass+"\">Keine Zeichen &uuml;brig</span>";
      } else if (count == 1) {
        var string = "1 character left";
      } else {
        var string = "noch "+ count + " Zeichen";
      }
      this.handle.setHTML(string);
  }
  
});

window.addEvent("load", function() {                                                                                                                                                    
        document.getElements("select[name^=tx_mjseventpro_pi1[location]").addEvent("change",locationSelector);       
        $("area").addEvent("change",areaSelector);
	//$("area").disabled=true;
});  

window.addEvent('domready',function(){
	new Countable("title",100);
	new Countable("desc",450);
    new Countable("longdesc",3000);
	new Countable("age",50);
	new Countable("fees",100);
	new Countable("speakers",100);
});
	

