/*
combined js file
*/
/*
	TODO
	diese in den Quelltexten ersetzen durch bindOn (s.u.)
*/

Function.prototype.bindAsEventListener = function(object) {
  var __method = this;
  return function(event) {
    __method.call(object, event);
  }
}

Function.prototype.bindOnParameter = function(object) {
  var __method = this;
  var __args = arguments;
  return function(event) {
    __method.call(object, event, __args);
  }
}

Array.prototype.contains = function (element) {
  for (var i = 0; i < this.length; i++) {
    if (this[i] == element) {
      return true;
    }
  }
  return false;
};

function $(id) {
  return document.getElementById(id);
}


/*
neuer Kram
*/

Function.prototype.bindOn = function(object) {
  var __method = this;
  return function(event) {
    __method.call(object, event);
  }
}

function log(msg) {
  if ((typeof opera) != 'undefined') {
    opera.postError(msg);
  } else if ((typeof console) != 'undefined') {
  	if (console.log) {
    	console.log(msg);
    }
  }
}

Date.prototype.isBefore = function(otherDate) {
  var myMillis = this.getTime();
  var otherMilis = otherDate.getTime();
  return myMillis < otherMilis;
}


function addEvent(obj, eventName, handler) {
  if (obj.addEventListener) {
    obj.addEventListener(eventName, handler, false);
    return true;
  }
  if (obj.attachEvent) {
    return obj.attachEvent('on' + eventName, handler);
  }
  return false;
}
/*
 * id ist die ID des Checkboxelements, dass durch ein Bild ersetzt wird
 * hidden ist die ID eines input type="hidden" in den der Status geschrieben wird true/false
 */
function Checkbox(id) {
  var e = document.getElementById(id);
  var textfield = null;
  var value = null;
  var disabled = null;
  var name = null;

  var img;
  var img_checked;
  var img_active;
  var img_unchecked;
  var img_disabled;
  var state;

  this.downHandler = function(e) {
    img.src = img_active.src;
  }

  this.upHandler = function(e) {
    switch (state) {
      case 'checked' :
        img.src = img_unchecked.src;
        state = 'unchecked';
        textfield.value = '';
        break;
      case 'unchecked' :
        img.src = img_checked.src;
        state = 'checked';
        textfield.value = value;
        break;
    }
  }

  this.outHandler = function(e) {
    switch (state) {
      case 'checked':
        img.src = img_checked.src;
        break;
      case 'unchecked':
        img.src = img_unchecked.src;
        break;
    }
  }

  this.preloadImages = function() {
    img_checked = new Image();
    img_checked.src = 'imagepfad/chkbox_chk.gif';
    img_active = new Image();
    img_active.src = 'imagepfad/chkbox_active.gif';
    img_unchecked = new Image();
    img_unchecked.src = 'imagepfad/chkbox_unchk.gif';
    img_unchecked_disabled = new Image();
    img_unchecked_disabled.src = 'imagepfad/chkbox_unchk_dis.gif';
    img_checked_disabled = new Image();
    img_checked_disabled.src = 'imagepfad/chkbox_chk_dis.gif';
    img = new Image();
  }

  this.installEventHandler = function() {
    if (img.addEventListener) {
      img.addEventListener('mousedown', this.downHandler.bindAsEventListener(this), false);
      img.addEventListener('mouseup', this.upHandler.bindAsEventListener(this), false);
      img.addEventListener('mouseout', this.outHandler.bindAsEventListener(this), false);
    } else {
      img.attachEvent('onmousedown', this.downHandler.bindAsEventListener(this));
      img.attachEvent('onmouseup', this.upHandler.bindAsEventListener(this));
      img.attachEvent('onmouseout', this.outHandler.bindAsEventListener(this));
    }
  }

  this.insertNodes = function() {
    textfield = document.createElement('input');
    textfield.setAttribute('type', 'hidden');
    textfield.setAttribute('name', name);
    e.parentNode.insertBefore(textfield, e);
    e.parentNode.replaceChild(img, e);
  }

  this.init = function() {
    value = e.getAttribute('value');
    name = e.getAttribute('name');
    // aw 2008-10-03 wegen IE anders, IE liefert immer etwas für disabled zurück
    // disabled = e.getAttribute('disabled') != null;
    disabled = e.disabled;
    // alert('disabled: ' + disabled);
    // aw 2008-10-03 wegen IE anders, IE liefert immer etwas für checked zurück
    // state = e.getAttribute('checked') != null ? 'checked' : 'unchecked';
    state = e.checked ? 'checked' : 'unchecked';
    // alert('state: ' + state);
    this.preloadImages();
    this.insertNodes();
    if (disabled) {
      switch (state) {
        case 'checked':
          img.src = img_checked_disabled.src;
          textfield.value = value;
          break;
        case 'unchecked':
          img.src = img_unchecked_disabled.src;
          textfield.value = '';
          break;
      }
    } else {
      img.style.cursor = 'pointer';
      this.installEventHandler();
      switch (state) {
        case 'checked':
          img.src = img_checked.src;
          textfield.value = value;
          break;
        case 'unchecked':
          img.src = img_unchecked.src;
          textfield.value = '';
          break;
      }
    }
  }

  if (e) {
    this.init();
  }
}
/**
 * @fileoverview eingabefeld.js Ein Eingabefeld wird auf Events Ã¼berwacht.
 * 
 * @author Sascha HÃ¼depohl sascha@ravenworks.de
 * @version 0.1
 */

var Eingabefelder = {
  forms : null,

  init : function() {
    Eingabefelder.forms = new Array();
  },

  addFeld : function(form,feld) {
  	Eingabefelder.getFelder(form).push(feld);
  },
  
  getFelder : function(form) {
  	for (var i = 0; i < Eingabefelder.forms.length; i++) {
  		if( Eingabefelder.forms[i]["form"] == form) {
  			return Eingabefelder.forms[i]["felder"]
  		}
  	}
  	var len = Eingabefelder.forms.length;
  	Eingabefelder.forms[len] = new Object();
  	Eingabefelder.forms[len]["form"] = form;
  	Eingabefelder.forms[len]["felder"] = new Array();
  	return Eingabefelder.forms[len]["felder"];
  },	
  
  setDefaultIfNotSet : function(form) {
  	var felder = Eingabefelder.getFelder(form);
  	if(felder ) {
	  	for (var i = 0; i < felder.length; i++) {
	  		felder[i].setDefaultIfNotSet();
	  	}
  	}
  },
  
  clearIfNotSet : function(form) {
  	var felder = Eingabefelder.getFelder(form);
  	if(felder ) {
	  	for (var i = 0; i < felder.length; i++) {
	  		felder[i].clearIfNotSet();
	  	}
  	}
  }
  
}

Eingabefelder.init();


/**
 * Eingabefeld Ã¼berwacht ein HTML-Input Element auf Events.
 *
 * @param {string} id Die id des Eingabefeldes im HTML-Dokument.
 * @param {string} defaultText Text der angezeigt wird, wenn das Feld leer ist.
 * @param {funcptr} csh Zeiger (Name) einer Funktion die als custom_submit_handler aufgerufen werden soll.
 * @constructor
 * @return Ein neues Eingabefeld Objekt
 */
function Eingabefeld(id, defaultText, csh) {
  var input = document.getElementById(id);
  var form = input.form;
  var abort = true;
  var skipsubmithandler = false;
  
  Eingabefelder.addFeld(form,this);
  
  if (!csh) {
    this.custom_submit_handler = function(e) {
      return true;
    }
  } else {
    this.custom_submit_handler = csh;
  }

  this.setAbort = function(b) {
  	abort = b;
  }

  this.setSkipSubmitHandler = function(b) {
  	skipsubmithandler = b;
  }
  
  this.focus_handler = function(e) {
    if (input.value == defaultText) {
      input.value = "";
   	  input.style.color = '';
    }
    else {
      input.select();
    }
  }

  this.blur_handler = function(e) {
  	this.setDefaultIfNotSet();
  }

  this.submit_handler = function(e) {
  	if(skipsubmithandler) {
  		return;
  	}
  	
  	// alert("in Eingabe submithandler");
    if ( (input.value.trim() == "" || input.value == defaultText) && abort) {
    /*
    	alert(input.labels);
      	if (input.labels && input.labels.length == 1) {
	    	alert("input required for " + input.labels[0].text);
      	}
      */
      e.preventDefault ? e.preventDefault() : e.returnValue = false;
      return;
    } 
    
    this.clearIfNotSet();

    if (!this.custom_submit_handler(e)) {
      e.preventDefault ? e.preventDefault() : e.returnValue = false;
      return;
    }
  }

  this.hasInput = function() {
  	return !(input.value.trim() == "" || input.value == defaultText);
  }
  
  this.clearIfNotSet = function() {
    if (input.value == defaultText || input.value.trim() == "" ) {
    	// alert("clear");
    	input.value = '';
    }
  }

  this.setDefaultIfNotSet = function() {
    if (input.value.length == 0 || input.value.trim() == "") {
      input.value = defaultText;    
      input.style.color = '#666666';    
    }
    if (input.value != defaultText) {
    	input.style.color = '';
    }
  }

  if (input.addEventListener) {
    input.addEventListener('focus', this.focus_handler.bindAsEventListener(this), false);
    input.addEventListener('blur', this.blur_handler.bindAsEventListener(this), false);
    form.addEventListener('submit', this.submit_handler.bindAsEventListener(this), false);
  } else {
    input.attachEvent('onfocus', this.focus_handler.bindAsEventListener(this));
    input.attachEvent('onblur', this.blur_handler.bindAsEventListener(this));
    form.attachEvent('onsubmit', this.submit_handler.bindAsEventListener(this));
  }
  
  this.setDefaultIfNotSet();
/*
  if (input.value == "") {
    input.value = defaultText;
  }
*/   

}

/**
 * Handler der vor dem Submit des Formulars aufgerufen wird.
 * Der RÃ¼ckgabewert bestimmt den Versand des Formulars.
 *
 * Diese Funktion kann Ã¼berschrieben werden:
 * Eingabefeld.prototype.custom_submit_handler = function(e) { alert("hier"); return true; }
 * 
 *
 * @return Boolean
 */
/*
Eingabefeld.prototype.custom_submit_handler = function() {
  return true;
}
*/


String.prototype.trim = function() {
  return this.replace(/^[ ]+/, '').replace(/[ ]+$/, '')
}
    function Eingabefeld_W_Button(id, csh) {
      var div = document.getElementById(id);
      var input = div.getElementsByTagName('input')[0];
      var inputId = input.getAttribute('id');
      //var input = document.getElementById(inputId);
      var inputEingabefeld = new Eingabefeld(inputId, csh);
      var button = div.getElementsByTagName('button')[0];
      var timeout;
      button.style.display = 'none';

      this.focus_handler = function(e) {
        window.clearTimeout(timeout);
        button.style.display = 'block';
      }

      this.blur_handler = function(e) {
        timeout = window.setTimeout("document.getElementById('button_suchen').style.display = 'none'", 1000);
      }

      if (input.addEventListener) {
        input.addEventListener('focus', this.focus_handler.bindAsEventListener(this), false);
        input.addEventListener('blur', this.blur_handler.bindAsEventListener(this), false);
      } else {
        input.attachEvent('onfocus', this.focus_handler.bindAsEventListener(this), false);
        input.attachEvent('onblur', this.blur_handler.bindAsEventListener(this), false);
      }
    }
/**
 * Sascha Hühdepohl und Andreas Wittek
 * 
 * benötigt
 * - validate.js
 * - lib.js (d.h. eigentlich nur Date.prototype.isBefore, bindOn
 */

var Messages = {
  MSG_DAYOVERFLOW : "Given month has only %s days! Please correct your dates!",
  MSG_UNPARSEABLE : "Sorry, but i can't interpret your input!",

  MSG_WARN_EMPTY  : "The input %s must not be empty",

  EMSG_DAY1       : "Please use one or two digits for day",                                                                                                                                                     
  EMSG_DAY2       : "Date must be from 1 to 31!",
  EMSG_YEAR1      : "Please use 4 digits for year!",
  EMSG_MONTH1     : "Please use one or two digits for month!",
  EMSG_MONTH2     : "Month must be from 1 to 12",
  EMSG_COMBI_JMD  : "Given month has only %s days!",
  EMSG_PLEASE_CR  : "Please correct your dates!",
  ETFORMAT        : "Please give time as HH:MM!",
  EDFORMAT        : "Please give date as %s or DDMMYY",
  EMSG_HOURS      : "Please use hours between 0 and 23.",
  EMSG_MINUTES    : "Please use minutes between 0 and 59.",
  EMSG_SECONDS    : "Please use seconds between 0 and 59.",
  EMSG_MINBOOK    : "Your times do not match or are below the minimal reservation time of %s minutes.",
  EMSG_BOOKBEGIN  : "Your reservation period starts too far in the past.",
  EMSG_WAGEN      : "Please select a car class!",
  EMSG_STATION    : "Please select a location!",
  EMSG_24_zu_00   : "We change the hour of departure / arrival to 0:00 a.m. next day.",

  MONTHNAMES      : new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'),
  DAYNAMES        : new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat'),

  setMessage : function(id, message) {
    if (this[id]) {
      this[id] = message;
    } else {
      var error = "invalid message id '" + id + "'";
      throw error;
    }
  }
};

var MessagesGerman = {
  MSG_DAYOVERFLOW : "Der Monat hat nur %s Tage! Bitte pruefen Sie Ihre Eingabe.",
  MSG_UNPARSEABLE : "Ich kann Ihre Eingabe nicht auswerten.",

  MSG_WARN_EMPTY  : "Das Eingabefeld %s darf nicht leer sein",

  EMSG_DAY1      : "Bitte geben Sie den Tag als ein- oder zweistellige Zahl an!",
  EMSG_DAY2      : "Der Tag muss zwischen 1 und 31 liegen!",
  EMSG_YEAR1     : "Bitte geben Sie das Jahr 4-stellig an!",
  EMSG_MONTH1    : "Bitte geben Sie den Monat als ein- oder zweistellige Zahl an!",
  EMSG_MONTH2    : "Der Monat liegt nicht zwischen 1 und 12!",
  EMSG_COMBI_JMD : "Der von Ihnen angegebene Monat hat nur %s Tage!",
  EMSG_PLEASE_CR : "Bitte korrigieren Sie die Reisedaten!",
  ETFORMAT       : "Bitte die Zeit in der Form: SS:MM",
  EDFORMAT       : "Bitte das Datum in der Form: %s oder TTMMJJ eingeben!",
  EMSG_HOURS     : "Bitte geben Sie die Stunde zwischen 0 und 23 Uhr an.",
  EMSG_MINUTES   : "Bitte geben Sie die Minuten zwischen 0 und 59 an.",
  EMSG_SECONDS   : "Bitte geben Sie die Sekunden zwischen 0 und 59 an.",
  EMSG_MINBOOK   : "Ihre Buchungszeiten passen nicht zusammen oder unterschreiten die Mindestbuchungsdauer von %s Minuten.",
  EMSG_BOOKBEGIN : "Ihr Buchungsbeginn liegt unnoetig weit in der Vergangenheit.",
  EMSG_WAGEN     : "Bitte waehlen Sie eine Wagenklasse!",
  EMSG_STATION   : "Bitte waehlen Sie eine Station!",
  EMSG_24_zu_00  : "Wir aendern den Buchungsanfang/das Buchungsende auf 0:00 am folgenden Tag.",

  MONTHNAMES     : new Array('Januar', 'Februar', 'Maerz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember', 'Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'),
  DAYNAMES       : new Array('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam')
};

MessagesGerman.prototype = Messages;



function DateInput(id, initialDate, surpresshandler) {
  this.JUMP_DAY = 1;
  this.JUMP_MONTH = 2;
  this.JUMP_YEAR = 3;
  this.JUMP_MONTH_YEAR = 4;

  this.messages = Messages;

  if (initialDate) {
    var day = parseInt(initialDate.substr(0, 2), 10);
    var month = parseInt(initialDate.substr(3, 2), 10);
    var year = parseInt(initialDate.substr(6, 4), 10);
	
	this.setDateOnly(year,month,day);
/*    
    this.date.setDate(day);
    this.date.setMonth(month - 1);
    this.date.setFullYear(year);
*/    
  }
  else  {
  	this.date = new Date();
	this.setDateOnly(this.date.getFullYear(),this.date.getMonth()+1,this.date.getDate());  	
  }


  if( (typeof id) == 'string') {
	  this.input = document.getElementById(id);
  }
  else {
  	this.input = id;
  }
  
  this.refDate = new Date(this.date.getTime());
  this.formatString = 'dd.MM.yyyy';
  this.maxDaysPast = -1;
  this.forceNextFirst = false;
  this.silentCorrect = false;
  this.jumpFuture = this.JUMP_MONTH_YEAR;
  this.userEntered = 0;
  
  if(!surpresshandler) {
	  if (this.input.addEventListener) {
	    this.input.addEventListener('blur', this.blurHandler.bindOn(this), false);
	    this.input.addEventListener('keypress', this.keypressHandler.bindOn(this), false);
	    this.input.addEventListener('keyup', this.keyupHandler.bindOn(this), false);
	    this.input.form.addEventListener('submit', this.blurHandler.bindOn(this), false);
	  } else {
	    this.input.attachEvent('onblur', this.blurHandler.bindOn(this));
	    this.input.attachEvent('onkeypress', this.keypressHandler.bindOn(this));
	    this.input.attachEvent('onkeyup', this.keyupHandler.bindOn(this), false);
	    this.input.form.attachEvent('onsubmit', this.blurHandler.bindOn(this));
	  }
	  
  }
  // initialisieren, d.h. auslesen des inputs
  if (this.input.value != "") {
    this.blurHandler();
  }
  this.changeCallbackObj = null;
  this.changeCallback = null;
  this.allowEmpty = false;
  this.completeEmpty = true;
  this.warnIfEmpty = true;
}

DateInput.prototype.setClone = function(targetID, formatString) {
  this.cloneTarget = document.getElementById(targetID);
  if (!this.cloneTarget) {
    throw new Error("No Element with id '" + targetID + "'");
  }
  if (this.cloneTarget.hasChildNodes) {
    if (this.cloneTarget.firstChild) {
      if (this.cloneTarget.firstChild.nodeType != 3) {
        this.cloneTarget.insertBefore(document.createTextNode(""), this.cloneTarget.firstChild);
      }
    } else {
      this.cloneTarget.appendChild(document.createTextNode(""));
    }
  } else {
    this.cloneTarget.appendChild(document.createTextNode(""));
  }
  this.cloneTarget = this.cloneTarget.firstChild;
  this.cloneFormatString = formatString;
};

DateInput.prototype.setWarnIfEmpty = function(warn) {
  if (warn != null) {
    this.warnIfEmpty = warn;
  } else {
    this.warnIfEmpty = true;
  }
  return this;
};

DateInput.prototype.setMessages = function(messageObj) {
  this.messages = messageObj;
  return this;
};

DateInput.prototype.setAllowEmpty = function(allowEmpty) {
  if (allowEmpty != null) {
    this.allowEmpty = allowEmpty;
  } else {
    this.allowEmpty = true;
  }
  return this;
};

DateInput.prototype.setCompleteEmpty = function(completeEmpty) {
  if (completeEmpty != null) {
    this.completeEmpty = completeEmpty;
  } else {
    this.completeEmpty = true;
  }
  return this;
};

DateInput.prototype.setChangeCallback = function(cb, obj) {
  this.changeCallbackObj = obj;
  this.changeCallback = cb;
  return this;
};

DateInput.prototype.setSilentCorrection = function(s) {
  if (s != null) {
    this.silentCorrect = s;
  } else {
    this.silentCorrect = true;
  }
  return this;
};


DateInput.prototype.setFormat = function(formatString) {
  this.formatString = formatString;
  if (this.input.value != "") {
    this.input.value = this.format();
  }
  return this;
};

DateInput.prototype.keypressHandler = function(event) {
  var code = event.keyCode;
  switch (code) {
    case 13:
      this.blurHandler(event);
      break;
  }
};

DateInput.prototype.keyupHandler = function(event) {
	  var code = event.keyCode;
	  validate_on_input_date(this.input);
};

DateInput.prototype.getDate = function() {
  return this.input.value == "" ? null : new Date(this.date);
};

DateInput.prototype.getDateAsString = function() {
  return this.input.value == "" ? null : this.format();
};

DateInput.prototype.blurHandler = function(event) {
  if (event && event.type && event.type == 'submit') {
    if (this.input.value == '' && this.warnIfEmpty && !this.allowEmpty) {
      event.preventDefault ? event.preventDefault() : event.returnValue = false;
      if (this.input.labels && this.input.labels.length == 1) {
        window.alert(this.messages.MSG_WARN_EMPTY.replace(/%s/, " '" + this.input.labels[0].text + "'"));
      } else {
        window.alert(this.messages.MSG_WARN_EMPTY.replace(/%s/, ""));
      }
      // this.input.focus();
      // this.input.select();
      return;
    }
  }
  if (this.input.value == "" && this.allowEmpty) {
    return;
  }
  if (this.input.value == "" && !this.completeEmpty) {
    return;
  }
  try {
    this.parse();
    this.input.value = this.format();
  } catch (e) {
    var exceptionPattern = /^\[ERR(\d+)\] - (.*)$/;
    var match = exceptionPattern.exec(e);
    if (match) {
      var code = parseInt(match[1], 10);
      var message = match[2];
      switch (code) {
        case 100:
        case 101:
        case 102:
        case 103:
        case 105:
          window.alert(message);
          // event.preventDefault ? event.preventDefault() : event.returnValue = false;
          // this.input.focus();
          // this.input.select();
          break;
        default:
          throw e;
      }
    } else {
      throw e;
    }
  }
  if (this.changeCallback) {
    this.changeCallback.call(this.changeCallbackObj);
  }
  if (this.cloneTarget) {
    this.cloneTarget.nodeValue = this.format(this.cloneFormatString);
  }
};

DateInput.prototype.daysOfMonth = function(year, month) {
  var leapYear = false;
  var days;
  if (year % 4 == 0) { leapYear = true; }
  if (year % 100 == 0 && year % 400 != 0) { leapYear = false; }
  if (month == 2) {
    days = leapYear ? 29 : 28;
  } else {
    if (month < 7) {
      days = (month % 2 == 1) ? 31 : 30;
    } else {
      if (month == 7) {
        days = 31;
      } else {
        days = (month % 2 == 1) ? 30 : 31;
      }
    }
  }
  return days;
};

DateInput.prototype.setMaxDaysInPast = function(days) {
  this.maxDaysPast = days;
  return this;
};


DateInput.prototype.setJumpDay = function() {
  this.jumpFuture = this.JUMP_DAY;
  return this;
};

DateInput.prototype.setJumpMonth = function() {
  this.jumpFuture = this.JUMP_MONTH;
  return this;
};

DateInput.prototype.setJumpYear = function() {
  this.jumpFuture = this.JUMP_YEAR;
  return this;
};

DateInput.prototype.setJumpMonthYear = function() {
  this.jumpFuture = this.JUMP_MONTH_YEAR;
  return this;
};

DateInput.prototype.setForceNextFirst = function(n) {
  if (n != null) {
    this.forceNextFirst = n;
  } else {
    this.forceNextFirst = true;
  }
  return this;
};

DateInput.prototype.parse = function() {
  var value = this.input.value;
  var i = 0;
  var token;
  var num;
  var phase = 'PARSE_DAY';
  var day = this.refDate.getDate();;
  var month = this.refDate.getMonth() + 1;
  var year = this.refDate.getFullYear();
  this.userEntered = 0;

  var error = null;
  
  if (value.match(/^\d+$/)) {
    switch (value.length) {
      case 1:
      case 2:
        day = parseInt(value, 10);
        month = this.refDate.getMonth() + 1;
        year = this.refDate.getFullYear();
        this.userEntered = 1;
        break;
      case 4:
        day = parseInt(value.substr(0, 2), 10);
        month = parseInt(value.substr(2, 2), 10);
        year = this.refDate.getFullYear();
        this.userEntered = 3;
        break;
      case 6:
        day = parseInt(value.substr(0, 2), 10);
        month = parseInt(value.substr(2, 2), 10);
        year = parseInt(value.substr(4, 2), 10);
        this.userEntered = 7;
      case 8:
        day = parseInt(value.substr(0, 2), 10);
        month = parseInt(value.substr(2, 2), 10);
        year = parseInt(value.substr(4, 4), 10);
        this.userEntered = 7;
        break;
      default:
        error = "[ERR103] - " + this.messages.EDFORMAT.replace(/%s/, this.formatString);
        throw error;
    }
  } else {
    while (value.length > 0) {
      i = value.search(/[^\d]/);
      if (i == -1) {
        token = value;
        value = '';
      } else {
        token = value.substr(0, i);
        value = value.substr(i + 1);
      }
      num = parseInt(token, 10);
      if (isNaN(num) || (num < 1)) {
        error = "[ERR103] - " + this.messages.EDFORMAT.replace(/%s/, this.formatString);
        throw error;
      }
      switch (phase) {
        case 'PARSE_DAY':
          day = num;
          phase = 'PARSE_MONTH';
          this.userEntered |= 1;
          break;
        case 'PARSE_MONTH':
          month = num;
          phase = 'PARSE_YEAR';
          this.userEntered |= 2;
          break;
        case 'PARSE_YEAR':
          year = num;
          phase = 'NO_MORE';
          this.userEntered |= 4;
          break;
        default:
          error = "invalid phase '" + phase + "'";
          throw error;
      }
    }
  }
  if (year < 100) {
    year += 2000;
  }
  if(year < 2000) {
    error = "[ERR105] - " + this.messages.EDFORMAT;
    throw error;
  
  }
  if(year > 2050) {
    error = "[ERR105] - " + this.messages.EDFORMAT;
    throw error;
  }
  if (day > 31) {  
    error = "[ERR100] - " + this.messages.EMSG_DAY2;
    throw error;
  }
  if (month > 12) {
    error = "[ERR101] - " + this.messages.EMSG_MONTH2;
    throw error;
  }
  if (day > this.daysOfMonth(year, month)) {
    if (this.silentCorrect) {
      day = this.daysOfMonth(year, month);
    } else {
      error = "[ERR102] - " + this.messages.MSG_DAYOVERFLOW.replace(/%s/, this.daysOfMonth(year, month));
      throw error;
    }
  }
  this.setDateOnly(year,month,day);
  /*
  this.date.setFullYear(year);
  this.date.setMonth(month - 1);
  this.date.setDate(day);
  */
  this.checkConstraints();
};

/*
	aw 2009-02-25
	Datum genau auf den Tag setzen, keine Stunden etc
*/
DateInput.prototype.copyDateOnlyTo = function(date,fromdate) {
	if(!fromdate) {
		fromdate = this.date;
	}
	date.setFullYear(fromdate.getFullYear());
	date.setMonth(fromdate.getMonth());
	date.setDate(fromdate.getDate());
};

DateInput.prototype.setDateOnly = function(year,month,day) {
	this.date= new Date(0);
	this.date.setFullYear(year);
	this.date.setMonth(month-1);
	this.date.setDate(day);
	this.date.setHours(0);
	this.date.setMinutes(0);
    this.date.setSeconds(0);    
	this.date.setMilliseconds(0);
};


DateInput.prototype.checkConstraints = function() {
  var now = this.refDate.getTime();
  var daysInPastMillis = this.maxDaysPast * 24 * 60 * 60 * 1000;
  if (this.maxDaysPast == -1) {
    var maxPastDate = new Date(0);
  } else {
    var maxPastDate = new Date(this.refDate.getTime() - daysInPastMillis);
  }

  if (this.forceNextFirst) {
    var day = this.date.getDate();
    var month = this.date.getMonth() + 1;
    var year = this.date.getFullYear();
    if (day != 1) {
      day = 1;
      month++;
      if (month > 12) {
        month = 1;
        year++;
      }
	  this.setDateOnly(year,month,day);
/*      
      this.date.setDate(1);
      this.date.setMonth(month - 1);
      this.date.setFullYear(year);
*/      
    }
    while (this.date.isBefore(this.refDate)) {
      this.date.setMonth(this.date.getMonth() + 1);
    }
  } else {
    if (this.date.isBefore(maxPastDate)) {
      switch (this.jumpFuture) {
        case this.JUMP_DAY:
          this.date = maxPastDate;
          break;
        case this.JUMP_MONTH:
          var month = this.date.getMonth() + 1;
          var year = this.refDate.getFullYear();
          month++;
          if (month > 12) {
            month = 1;
            year++;
          }
          this.date.setMonth(month - 1);
          this.date.setFullYear(year);
          break;
        case this.JUMP_YEAR:
          this.date.setFullYear(this.refDate.getFullYear() + 1);
          break;
        case this.JUMP_MONTH_YEAR:
          var day = this.date.getDate();
          var month = this.date.getMonth() + 1;
          var year = this.date.getFullYear();

          switch (this.userEntered) {
            case 3:
              year++;
              break;
            case 1:
              month++;
              if (month > 12) {
                year++;
                month = 1;
              }
              break;
          }

		  this.setDateOnly(year,month,day);
/*		
          this.date.setDate(day);
          this.date.setMonth(month - 1);
          this.date.setFullYear(year);
*/
          break;
        default:
          var error = "unknown jump constant " + this.jumpFuture;
          throw error;
      }
    }
  }
};

DateInput.prototype.format = function(formatString) {
  if (!formatString) {
    if (!this.formatString) {
      throw 'no formatstring';
    } else {
      formatString = this.formatString;
    }
  }

  var values = new Object();
  values.d = new String(this.date.getDate());
  values.dd = values.d;
  if (values.dd.length == 1) { values.dd = '0' + values.dd; }

  values.M = new String(this.date.getMonth() + 1);
  values.MM = values.M;
  values.MMM = this.messages.MONTHNAMES[this.date.getMonth()];
  if (values.MM.length == 1) { values.MM = '0' + values.MM; }

  values.y = new String(this.date.getFullYear());
  values.yy = new String(values.y).substr(2, 2);
  values.yyyy = values.y;

  values.EEEE = this.messages.DAYNAMES[this.date.getDay()];
  values.EE = this.messages.DAYNAMES[this.date.getDay() + 7];

  var result = '';  

  var i = 0;
  var token = '';
  var div = '';
  while (formatString.length > 0) {
    i = formatString.search(/[ .:\-/]/);
    if (i == -1) {
      token = formatString;
      formatString = '';
      div = '';
    } else {
      token = formatString.substring(0, i);
      div = formatString.charAt(i);
      formatString = formatString.substr(i + 1);
    }
    if (values[token]) {
      result += values[token] + div;
    } else {
      var error = "invalid formatstring - unknown token: '" + token + "'";
      throw error;
    }
  }
  
  return result;
};


// Liegt das Datum in der Vergangenheit
DateInput.prototype.isPast = function() {
  if (this.date.getFullYear() < this.refDate.getFullYear()) {
    return true;
  }
  if (this.date.getFullYear() > this.refDate.getFullYear()) {
    return false;
  }
  if (this.date.getMonth() < this.refDate.getMonth()) {
    return true;
  }
  if (this.date.getMonth() > this.refDate.getMonth()) {
    return false;
  }
  if (this.date.getDate() < this.refDate.getDate()) {
    return true;
  }
  return false;
};

// Liegt das Datum in der Zukunft
DateInput.prototype.isFuture = function() {
  if (this.date.getFullYear() > this.refDate.getFullYear()) {
    return true;
  }
  if (this.date.getFullYear() < this.refDate.getFullYear()) {
    return false;
  }
  if (this.date.getMonth() > this.refDate.getMonth()) {
    return true;
  }
  if (this.date.getMonth() < this.refDate.getMonth()) {
    return false;
  }
  if (this.date.getDate() > this.refDate.getDate()) {
    return true;
  }
  return false;
};

DateInput.prototype.isEqualTo = function(refDate) {
  return (this.date.getFullYear() == refDate.getFullYear() &&
  this.date.getMonth() == refDate.getMonth() &&
  this.date.getDate() == refDate.getDate());
}

// Das heutige Datum (ueber refDate gesetzt)

DateInput.prototype.isToday = function() { 
	return this.isEqualTo(this.refDate); 
};

DateInput.prototype.increaseOneDay = function() {
  this.date.setDate(this.date.getDate() + 1);
  this.input.value = this.format();
  return this;
};

/******************************************************************************************/

function TimeInput(id, initialTime, surpresshandler) {
  if( (typeof id) == 'string') {
	  this.input = document.getElementById(id);
  }
  else {
  	this.input = id;
  }
  this.date = new Date();
  if (initialTime) {
    var hour = parseInt(initialTime.substr(0, 2), 10);
    var minute = parseInt(initialTime.substr(3, 2), 10);
    this.setHoursMinutes(hour,minute);
  }
  this.refDate = new Date(this.date);

  this.messages = Messages;
  
  this.formatString = 'HH:mm';
  this.stepInterval = 0;
  this.stepBack = false;
  this.userEntered = 0;
  this.dateField = null;
  if(!surpresshandler) {
	  if (this.input.addEventListener) {
	    this.input.addEventListener('blur', this.blurHandler.bindOn(this), false);
	    this.input.addEventListener('keyup', this.keyupHandler.bindOn(this), false);
	    this.input.form.addEventListener('submit', this.blurHandler.bindOn(this), false);
	  } else {
	    this.input.attachEvent('onblur', this.blurHandler.bindOn(this));
	    this.input.attachEvent('onkeyup', this.keyupHandler.bindOn(this), false);
	    this.input.form.attachEvent('onsubmit', this.blurHandler.bindOn(this));
	  }
  }
  // initialisieren, d.h. auslesen des inputs
  if (this.input.value != "") {
    this.blurHandler();
  }
  
  this.changeCallbackObj = null;
  this.changeCallback = null;
  this.allowEmpty = false;
  this.completeEmpty = true;
  this.warnIfEmpty = true;
}

TimeInput.prototype.setHoursMinutes = function(hour,minute) {
    this.date.setHours(hour);
    this.date.setMinutes(minute);
    this.date.setSeconds(0);    
}

TimeInput.prototype.setWarnIfEmpty = function(warn) {
  if (warn != null) {
    this.warnIfEmpty = warn;
  } else {
    this.warnIfEmpty = true;
  }
  return this;
};


TimeInput.prototype.setCompleteEmpty = function(completeEmpty) {
  if (completeEmpty != null) {
    this.completeEmpty = completeEmpty;
  } else {
    this.completeEmpty = true;
  }
  return this;
};

TimeInput.prototype.setAllowEmpty = function(allowEmpty) {
  if (allowEmpty != null) {
    this.allowEmpty = allowEmpty;
  } else {
    this.allowEmpty = true;
  }
  return this;
};

TimeInput.prototype.setMessages = function(messageObj) {
  this.messages = messageObj;
  return this;
};

TimeInput.prototype.setChangeCallback = function(cb, obj) {
  this.changeCallback = cb;
  this.changeCallbackObj = obj;
  return this;
};

TimeInput.prototype.setDateField = function(obj) {
  this.dateField = obj;
  if(this.dateField) {
  	// aw gleich angleichen, 2009-09-16 aber getrennt nach Ref und date
  	this.dateField.copyDateOnlyTo(this.refDate,this.dateField.refDate);
  	this.dateField.copyDateOnlyTo(this.date);
  }
  return this;
};


TimeInput.prototype.setMinuteInterval = function(interval, back) {
  this.stepInterval = interval;
  if (back != null) {
    this.stepBack = back;
  }
  return this;
};

TimeInput.prototype.setFormat = function(formatString) {
  this.formatString = formatString;
  if (this.input.value != "") {
    this.input.value = this.format();
  }
  return this;
};

TimeInput.prototype.round = function() {
	if (this.stepInterval != 0) {
		var hours = this.date.getHours();
		var minutes = this.date.getMinutes();

		var mod = minutes % this.stepInterval;
		if (mod != 0) {
			if (this.stepBack) {
				minutes -= mod;
			} else {
				minutes += this.stepInterval - mod;
			}
			
			// eigentlich == 60, da es immer nur maximal auf 60 aufschlagen kann
			if (minutes > 59) {
				hours++;
				if (hours > 23) {
					if(this.dateField) {
						// aw 2009-09-16 auch hier hochzählen
						this.dateField.increaseOneDay();
						window.alert(this.messages.EMSG_24_zu_00);
						this.dateField.copyDateOnlyTo(this.date);
					}
					hours = 0;
				}
				minutes = 0;
			}
		}

		this.setHoursMinutes(hours,minutes);
	}
};

TimeInput.prototype.checkConstraints = function() {
  // wenn die Uhrzeit in der Vergangenheit liegt, wird sie auf den juengsten
  // moeglichen Zeitpunkt in der Vergangenheit gesetzt

  // wenn ein DatumsFeld definiert ist
  if (this.dateField) {
	  // aw 2009-09-16 auf jeden fall sicher stellen, dass das
	  // datum dieser Zeit richtig gesetzt ist
	this.dateField.copyDateOnlyTo(this.date); 
    if (this.dateField.isPast()) {
      // eh egal
      this.round();
    }
    if (this.dateField.isFuture()) {
      // auch egal
      this.round();
    }
    if (this.dateField.isToday()) {
      // schon vorbei?
      if (this.date.isBefore(this.refDate)) {
        this.date = new Date(this.refDate);
        this.userEntered = 3;
      }
      this.round();
    }
  } else {
    this.round();
  }
};

TimeInput.prototype.parse = function() {
	  // aw 2009-09-16 auf jeden fall sicher stellen, dass das
	  // datum dieser Zeit richtig gesetzt ist
	  if (this.dateField) {
		  this.dateField.copyDateOnlyTo(this.date);
	  }
  var value = this.input.value;
  var i = 0;
  var token;
  var num;
  var phase = 'PARSE_HOURE';
  var hour = this.refDate.getHours();
  var minute = this.refDate.getMinutes();
  this.userEntered = 0;
  if (value.match(/^\d+$/)) {
    switch (value.length) {
      case 1:
      case 2:
        hour = parseInt(value, 10);
        minute = 0;
        this.userEntered = 1;
        break;
      case 3:
        hour = parseInt(value.substr(0,1), 10);
        minute = parseInt(value.substr(1, 2), 10);
        this.userEntered = 3;
        break;
      case 4:
        hour = parseInt(value.substr(0, 2), 10);
        minute = parseInt(value.substr(2, 2), 10);
        this.userEntered = 3;
        break;
      default:
        throw "[ERR103] - " + this.messages.MSG_UNPARSEABLE;
    }
  } else {
    while (value.length > 0) {
      i = value.search(/[^\d]/);
      if (i == -1) {
        token = value;
        value = '';
      } else {
        token = value.substr(0, i);
        value = value.substr(i + 1);
      }
      num = parseInt(token, 10);
      if (isNaN(num) || (num < 0)) {
        var error = "invalid Input";
        throw error;
      }
      switch (phase) {
        case 'PARSE_HOURE':
          hour = num;
          phase = 'PARSE_MINUTE';
          this.userEntered |= 1;
          break;
        case 'PARSE_MINUTE':
          minute = num;
          phase = 'NO_MORE';
          this.userEntered |= 2;
          break;
        default:
          var error = "invalid phase '" + phase + "'";
          throw error;
      }
    }
  }
  if (hour == 24) { // Tag hochzaehlen und Zeit auf 0
    if (this.dateField) {
      this.dateField.increaseOneDay();
      hour = 0;
      minute = 0;
      window.alert(this.messages.EMSG_24_zu_00);
	  // aw 2009-09-16 auf jeden fall sicher stellen, dass das
	  // datum dieser Zeit richtig gesetzt ist
      this.dateField.copyDateOnlyTo(this.date);
      
    } else {
      var error = "[ERR200] - " + this.messages.EMSG_HOURS;
      throw error;
    }
  }
  if (hour > 24) {
    var error = "[ERR200] - " + this.messages.EMSG_HOURS;
    throw error;
  }
  if (minute > 59) {
    var error = "[ERR201] - " + this.messages.EMSG_MINUTES;
    throw error;
  }
  if (this.stepInterval != 0 && this.userEntered == 1) {
    minute = 0;
  }
  this.setHoursMinutes(hour,minute);
  this.checkConstraints();
};

TimeInput.prototype.format = function(formatString) {
  if (!formatString) {
    if (!this.formatString) {
      throw 'no formatstring';
    } else {
      formatString = this.formatString;
    }
  }

  var values = new Object();
  values.H = new String(this.date.getHours());
  values.HH = values.H;
  if (values.HH.length == 1) { values.HH = '0' + values.HH; }

  values.m = new String(this.date.getMinutes());
  values.mm = values.m;
  if (values.mm.length == 1) { values.mm = '0' + values.mm; }

  values.h = new String(this.date.getHours() % 12);
  values.hh = values.h;
  if (values.hh.length == 1) { values.hh = '0' + values.hh; }

  values.k = new String(this.date.getHours() == 0 ? '24' : this.date.getHours());
  values.kk = values.k;
  if (values.kk.length == 1) { values.kk = '0' + values.kk; }

  values.K = new String((this.date.getHours() % 12) == 0 ? '0' : (this.date.getHours() % 12));
  values.KK = values.K;
  if (values.KK.length == 1) { values.KK = '0' + values.KK; }

  values.s = new String(this.date.getSeconds());
  values.ss = values.s;
  if (values.ss.length == 1) { values.ss = '0' + values.ss; }


  var result = '';

  var i = 0;
  var token = '';
  var div = '';
  while (formatString.length > 0) {
    i = formatString.search(/[.:\-/ ]/);
    if (i == -1) {
      token = formatString;
      formatString = '';
      div = '';
    } else {
      token = formatString.substring(0, i);
      div = formatString.charAt(i);
      formatString = formatString.substring(i + 1);
    }
    if (values[token]) {
      result += values[token] + div;
    } else  {
      var error = "invalid formatstring - unknown token: '" + token + "'";
      throw error;
    }
  }
  return result;
};

TimeInput.prototype.keyupHandler = function(event) {
	  var code = event.keyCode;
	  try {
		  validate_on_input_time(this.input);
	  }
	  catch(e) {}
};


TimeInput.prototype.blurHandler = function(event) {
  if (event && event.type && event.type == 'submit') {
    if (this.input.value == '' && this.warnIfEmpty && !this.allowEmpty) {
      event.preventDefault ? event.preventDefault() : event.returnValue = false;
      if (this.input.labels && this.input.labels.length == 1) {
        window.alert(this.messages.MSG_WARN_EMPTY.replace(/%s/, " '" + this.input.labels[0].text + "'"));
      } else {
        window.alert(this.messages.MSG_WARN_EMPTY.replace(/%s/, ""));
      }
      this.input.select();
      return;
    }
  }
  if (this.input.value == "" && this.allowEmpty) {
    return;
  }
  if (this.input.value == "" && !this.completeEmpty) {
    return;
  }
  try {
    this.parse();
    this.input.value = this.format();
  } catch (e) {
    var exceptionPattern = /^\[ERR(\d+)\] - (.*)$/;
    var match = exceptionPattern.exec(e);
    if (match) {
      var code = parseInt(match[1], 10);
      var message = match[2];
      switch (code) {
        case 200:
        case 201:
          window.alert(message);
          this.input.focus();
          this.input.select();
          break;
        default:
          throw e;
      }
    } else {
      throw e;
    }
  }
  if (this.changeCallback) {
    this.changeCallback.call(this.changeCallbackObj);
  }
};


/**************************************************************************************/

TimeInterval = function() {
  this.minIntervalSize = 0; 
  this.messages = Messages;
};

TimeInterval.prototype.setMessages = function(messageObj) {
  this.messages = messageObj;
  if (this.startDate) { this.startDate.setMessages(this.messages); }
  if (this.startTime) { this.startTime.setMessages(this.messages); }
  if (this.endDate) { this.endDate.setMessages(this.messages); }
  if (this.endTime) { this.endTime.setMessages(this.messages); }
  return this;
};

TimeInterval.prototype.setMinIntervalSize = function(minutes) {
  this.minIntervalSize = minutes;
};


TimeInterval.prototype.setStartDate = function(obj) {
  this.startDate = obj;
  this.setupHandler();
  return this;
};

TimeInterval.prototype.setStartTime = function(obj) {
  this.startTime = obj;
  this.setupHandler();
  return this;
};

TimeInterval.prototype.setEndDate = function(obj) {
  this.endDate = obj;
  this.setupHandler();
  return this;
};

TimeInterval.prototype.setEndTime = function(obj) {
  this.endTime = obj;
  this.setupHandler();
  return this;
};

TimeInterval.prototype.setFields = function(startDate, startTime, endDate, endTime) {
  this.startDate = startDate;
  this.startTime = startTime;
  this.endDate = endDate;
  this.endTime = endTime;
  this.setupHandler();
  this.endDate.setMaxDaysInPast(0);
  return this;
};

TimeInterval.prototype.checkConstraints = function() {
  // Bedingung: endDate >= startDate
  
  // sicher stellen, auch wenn es schon ueber startDateChangedHandler
  // erledigt wurde
  
  this.adjustEndDateTime();
  /*
  this.endDate.refDate = new Date(this.startDate.date);
  
  if (this.endDate.date.isBefore(this.startDate.date)) {
    this.endDate.date = new Date(this.startDate.date);
    this.endDate.input.value = this.endDate.format();
  }
  */
  
  // Wenn endDate == startDate
  // muss Mindestzeitspanne eingehalten werden
  // erst wenn der Benutzer auch in beide Zeitfelder etwas eingegeben hat
  if (this.startDate.isEqualTo(this.endDate.date)    ) {
	
	if (this.startTime.input.value != "" && this.endTime.input.value != "") {

      var start = this.startTime.date.getMinutes() + this.startTime.date.getHours() * 60;
      var end = this.endTime.date.getMinutes() + this.endTime.date.getHours() * 60;

      if ((start + this.minIntervalSize) > end) {
        this.endTime.date = new Date(this.startTime.date);
        this.endTime.refDate = new Date(this.endTime.date);
        this.endTime.date.setMinutes(this.endTime.date.getMinutes() + this.minIntervalSize);
        this.endTime.input.value = this.endTime.format();
      }
      // wenn startTime + minIntervalSize > 24 Stunden
      if (start + this.minIntervalSize >= 24 * 60) {
        this.endDate.date.setDate(this.endDate.date.getDate() + 1);
        this.endDate.input.value = this.endDate.format();
      }
    }
  }
};

TimeInterval.prototype.startDateChangedHandler = function() {
	this.startDate.copyDateOnlyTo(this.startTime.date);
	this.adjustEndDateTime();
}

TimeInterval.prototype.adjustEndDateTime = function() {
	// die refs immer aktualisieren
	this.endDate.refDate = new Date(this.startDate.date);
	this.endTime.refDate = new Date(this.startTime.date.getTime());

	// sicherheitshalber auch das date von endTime.date richtig setzen 

	if(this.endDate.input.value !== '')  {
		this.endDate.copyDateOnlyTo(this.endTime.date);
	}
	
	// das nur, wenn die Datumsangaben nicht passen
	if(this.endDate.input.value === ''
		|| this.endDate.date.isBefore(this.startDate.date)) {

		this.endDate.date = new Date(this.endDate.refDate);
		this.endDate.input.value = this.endDate.format();
		
		this.endDate.copyDateOnlyTo(this.endTime.date);
	} 
};

TimeInterval.prototype.setupHandler = function() {
  if (this.startDate && this.startTime && this.endDate && this.endTime) {
    this.startTime.setDateField(this.startDate);
    this.endTime.setDateField(this.endDate);

    addEvent(this.startDate.input, 'blur', this.startDateChangedHandler.bindOn(this));
    this.startDate.setChangeCallback(this.checkConstraints, this);
    this.startTime.setChangeCallback(this.checkConstraints, this);
    this.endDate.setChangeCallback(this.checkConstraints, this);
    this.endTime.setChangeCallback(this.checkConstraints, this);
    
    // und schon mal sicher stellen, dass alles konsistent ist
    this.adjustEndDateTime();
  }
  return this;
};


function bildVergroessern(url,breite, hoehe) {
	breite += 40;
	hoehe += 40;
	if(breite > 640) breite=640;
	if(hoehe > 480) hoehe=480;
	
	// IE hat ein Problem??
//		var win = window.open(url,"<%replace name=Allgemein.Vergroesserung format=escape%>Vergroesserung<%/replace%>","menubar=no,resizable=yes,scrollbars=yes,width="+breite+",height=" + hoehe);
	var win = window.open(url,"gross","menubar=no,resizable=yes,scrollbars=yes,width="+breite+",height=" + hoehe);
	win.focus();
}


function stdws_openDruck() {
	var url;
	if(location.search == "") {
		url = window.location.href + '?stdws_chtml=true&druckdarstellungVAR=true';
	}
	else  {
		url = window.location.href + '&stdws_chtml=true&druckdarstellungVAR=true';
	}
	var win = window.open(url,"Print","menubar=yes,resizable=yes,scrollbars=yes,width=600,height=700");
	win.focus();
}


function stdws_changeLocation(param,value,target) {
	var url;
	var query = param;
	if(value) {
		query = param + '=' + value;
	}
	
	if(window.location.search == "") {
		url = window.location.href + '?' + query;
	}
	else if(value) {
		// alten wert rauswerfen, wenn vorhanden
		var search = window.location.search;
		// TODO hier die einfachversion, d.h. funktioniert
		// nicht unter allen Umständen
		search = search.substring(1);
		// alert(search);
		sp = search.split('&');
		search = query;
		for(var i=0; i < sp.length; ++i) {
			if(sp[i].indexOf(param + '=') < 0) {
				search += '&' + sp[i];
			}
		}
		url = window.location.pathname + '?' + search;
	}	
	else  {
		url = window.location.href + '&' + query;
	}
	if(target) {
		target.location.href = url;
	}
	else {
		window.location.href = url;
	}
}

function stdws_makeLesezeichen(url,title) {

 	if(!title) {
		title = document.title; 
 	}
	if(!url) {
		url = window.location.href;
	}

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
	}
	else if(window.opera && window.print) { // Opera 
	    var elem = document.createElement('a');
    	elem.setAttribute('href',url);
    	elem.setAttribute('title',title);
    	elem.setAttribute('rel','sidebar');
    	elem.click();			
	} 
}

function stdws_canDoLesezeichen() {
	if( window.external 
			|| window.sidebar 
			// || (window.opera && window.print) 
			) {
		return true;
	}
	return false;
}

function fixFooterPadding() {
	//free some space
	var fheight = document.getElementById('footer').offsetHeight;
	document.getElementById('content').parentNode.style.paddingBottom = (fheight + 10) + 'px'; 
	
	//let footer float
	document.getElementById('footer').style.bottom = '0px';
	document.getElementById('footer').style.position = 'absolute';
}
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================


/* 
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition. 
   Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.
*/ 

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

/* 
PopupWindow.js
Author: Matt Kruse
Last modified: 05/15/03

DESCRIPTION: This object allows you to easily and quickly popup a window
in a certain place. The window can either be a DIV or a separate browser
window.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 
window with <STYLE> tags may cause errors.

USAGE:
// Create an object for a WINDOW popup
var win = new PopupWindow(); 

// Create an object for a DIV window using the DIV named 'mydiv'
var win = new PopupWindow('mydiv'); 

// Set the window to automatically hide itself when the user clicks 
// anywhere else on the page except the popup
win.autoHide(); 

// Show the window relative to the anchor name passed in
win.showPopup(anchorname);

// Hide the popup
win.hidePopup();

// Set the size of the popup window (only applies to WINDOW popups
win.setSize(width,height);

// Populate the contents of the popup window that will be shown. If you 
// change the contents while it is displayed, you will need to refresh()
win.populate(string);

// set the URL of the window, rather than populating its contents
// manually
win.setUrl("http://www.site.com/");

// Refresh the contents of the popup
win.refresh();

// Specify how many pixels to the right of the anchor the popup will appear
win.offsetX = 50;

// Specify how many pixels below the anchor the popup will appear
win.offsetY = 100;

NOTES:
1) Requires the functions in AnchorPosition.js

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.

4) When a PopupWindow object is created, a handler for 'onmouseup' is
   attached to any event handler you may have already defined. Do NOT define
   an event handler for 'onmouseup' after you define a PopupWindow object or
   the autoHide() will not work correctly.
*/ 

// Set the position of the popup window based on the anchor
function PopupWindow_getXYPosition(anchorname) {
	var coordinates;
	if (this.type == "WINDOW") {
		coordinates = getAnchorWindowPosition(anchorname);
		}
	else {
		coordinates = getAnchorPosition(anchorname);
		}
	this.x = coordinates.x;
	this.y = coordinates.y;
	}
// Set width/height of DIV/popup window
function PopupWindow_setSize(width,height) {
	this.width = width;
	this.height = height;
	}
// Fill the window with contents
function PopupWindow_populate(contents) {
	this.contents = contents;
	this.populated = false;
	}
// Set the URL to go to
function PopupWindow_setUrl(url) {
	this.url = url;
	}
// Set the window popup properties
function PopupWindow_setWindowProperties(props) {
	this.windowProperties = props;
	}
// Refresh the displayed contents of the popup
function PopupWindow_refresh() {
	if (this.divName != null) {
		// refresh the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).innerHTML = this.contents;
			}
		else if (this.use_css) { 
			document.all[this.divName].innerHTML = this.contents;
			}
		else if (this.use_layers) { 
			var d = document.layers[this.divName]; 
			d.document.open();
			d.document.writeln(this.contents);
			d.document.close();
			}
		}
	else {
		if (this.popupWindow != null && !this.popupWindow.closed) {
			if (this.url!="") {
				this.popupWindow.location.href=this.url;
				}
			else {
				this.popupWindow.document.open();
				this.popupWindow.document.writeln(this.contents);
				this.popupWindow.document.close();
			}
			this.popupWindow.focus();
			}
		}
	}
// Position and show the popup, relative to an anchor object
function PopupWindow_showPopup(anchorname) {
	this.getXYPosition(anchorname);
	this.x += this.offsetX;
	this.y += this.offsetY;
	
	
	if (!this.populated && (this.contents != "")) {
		this.populated = true;
		this.refresh();
		}
	if (this.divName != null) {
		// Show the DIV object
		if (this.use_gebi) {
		// alert('offset: ' + this.x + '/' + this.y);
			// aw 2008-08-29 macht Ärger bei IE und Opera, d.h.
			// wir machen es jetzt ohne verschieben nur über
			// die Position des divs
			// document.getElementById(this.divName).style.left = this.x;
			// document.getElementById(this.divName).style.top = this.y;
			document.getElementById(this.divName).style.visibility = "visible";
			}
		else if (this.use_css) {
			document.all[this.divName].style.left = this.x;
			document.all[this.divName].style.top = this.y;
			document.all[this.divName].style.visibility = "visible";
			}
		else if (this.use_layers) {
			document.layers[this.divName].left = this.x;
			document.layers[this.divName].top = this.y;
			document.layers[this.divName].visibility = "visible";
			}
		}
	else {
		if (this.popupWindow == null || this.popupWindow.closed) {
			// If the popup window will go off-screen, move it so it doesn't
			if (this.x<0) { this.x=0; }
			if (this.y<0) { this.y=0; }
			if (screen && screen.availHeight) {
				if ((this.y + this.height) > screen.availHeight) {
					this.y = screen.availHeight - this.height;
					}
				}
			if (screen && screen.availWidth) {
				if ((this.x + this.width) > screen.availWidth) {
					this.x = screen.availWidth - this.width;
					}
				}
			this.popupWindow = window.open("about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
			}
		this.refresh();
		}
	}
// Hide the popup
function PopupWindow_hidePopup() {
	if (this.divName != null) {
		if (this.use_gebi) {
			document.getElementById(this.divName).style.visibility = "hidden";
			}
		else if (this.use_css) {
			document.all[this.divName].style.visibility = "hidden";
			}
		else if (this.use_layers) {
			document.layers[this.divName].visibility = "hidden";
			}
		}
	else {
		if (this.popupWindow && !this.popupWindow.closed) {
			this.popupWindow.close();
			this.popupWindow = null;
			}
		}
	}
// Pass an event and return whether or not it was the popup DIV that was clicked
function PopupWindow_isClicked(e) {
	if (this.divName != null) {
		if (this.use_layers) {
			var clickX = e.pageX;
			var clickY = e.pageY;
			var t = document.layers[this.divName];
			if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
				return true;
				}
			else { return false; }
			}
		else if (document.all ) { // Need to hard-code this to trap IE for error-handling
			var t = window.event.srcElement;
			while (t.parentElement != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentElement;
				}
			return false;
			}
		else if (this.use_gebi) {
			// aw var t = e.originalTarget;
			var t = e.target;
			while (t.parentNode != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentNode;
				}
			return false;
			}
		return false;
		}
	return false;
	}

// Check an onMouseDown event to see if we should hide
function PopupWindow_hideIfNotClicked(e) {
// aw wir wollen es auch verstecken wenn wir drauf klicken 
	if (this.autoHideEnabled && (!this.isClicked(e) || this.autoHideIfClickedEnabled)) {
		this.hidePopup();
		}
	}
// Call this to make the DIV disable automatically when mouse is clicked outside it
function PopupWindow_autoHide() {
	this.autoHideEnabled = true;
	}
// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
function PopupWindow_hidePopupWindows(e) {
	for (var i=0; i<popupWindowObjects.length; i++) {
		if (popupWindowObjects[i] != null) {
			var p = popupWindowObjects[i];
				p.hideIfNotClicked(e);
			}
		}
	}
// Run this immediately to attach the event listener
function PopupWindow_attachListener() {
	if (document.layers) {
		document.captureEvents(Event.MOUSEUP);
		}
	window.popupWindowOldEventListener = document.onmouseup;
	if (window.popupWindowOldEventListener != null) {
		document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
		}
	else {
		document.onmouseup = PopupWindow_hidePopupWindows;
		}
	}
	
/**
aw
*/

function PopupWindow_autoHideIfClicked() {
	this.autoHideIfClickedEnabled = true;
	}
	
// CONSTRUCTOR for the PopupWindow object
// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
function PopupWindow() {
	if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
	if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
	if (!window.listenerAttached) {
		window.listenerAttached = true;
		PopupWindow_attachListener();
		}
	this.index = popupWindowIndex++;
	popupWindowObjects[this.index] = this;
	this.divName = null;
	this.popupWindow = null;
	this.width=0;
	this.height=0;
	this.populated = false;
	this.visible = false;
	this.autoHideEnabled = false;
	// aw
	this.autoHideIfClickedEnabled = false;
	
	this.contents = "";
	this.url="";
	this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,dependent=yes,titlebar=no,alwaysRaised";
	if (arguments.length>0) {
		this.type="DIV";
		this.divName = arguments[0];
		}
	else {
		this.type="WINDOW";
		}
	this.use_gebi = false;
	this.use_css = false;
	this.use_layers = false;
	if (document.getElementById) { this.use_gebi = true; }
	else if (document.all) { this.use_css = true; }
	else if (document.layers) { this.use_layers = true; }
	else { this.type = "WINDOW"; }
	this.offsetX = 0;
	this.offsetY = 0;
	// Method mappings
	this.getXYPosition = PopupWindow_getXYPosition;
	this.populate = PopupWindow_populate;
	this.setUrl = PopupWindow_setUrl;
	this.setWindowProperties = PopupWindow_setWindowProperties;
	this.refresh = PopupWindow_refresh;
	this.showPopup = PopupWindow_showPopup;
	this.hidePopup = PopupWindow_hidePopup;
	this.setSize = PopupWindow_setSize;
	this.isClicked = PopupWindow_isClicked;
	this.autoHide = PopupWindow_autoHide;
	this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
	
	// aw
	this.autoHideIfClicked = PopupWindow_autoHideIfClicked;
	}


// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// HISTORY
// ------------------------------------------------------------------
// Feb 7, 2005: Fixed a CSS styles to use px unit
// March 29, 2004: Added check in select() method for the form field
//      being disabled. If it is, just return and don't do anything.
// March 24, 2004: Fixed bug - when month name and abbreviations were
//      changed, date format still used original values.
// January 26, 2004: Added support for drop-down month and year
//      navigation (Thanks to Chris Reid for the idea)
// September 22, 2003: Fixed a minor problem in YEAR calendar with
//      CSS prefix.
// August 19, 2003: Renamed the function to get styles, and made it
//      work correctly without an object reference
// August 18, 2003: Changed showYearNavigation and 
//      showYearNavigationInput to optionally take an argument of
//      true or false
// July 31, 2003: Added text input option for year navigation.
//      Added a per-calendar CSS prefix option to optionally use 
//      different styles for different calendars.
// July 29, 2003: Fixed bug causing the Today link to be clickable 
//      even though today falls in a disabled date range.
//      Changed formatting to use pure CSS, allowing greater control
//      over look-and-feel options.
// June 11, 2003: Fixed bug causing the Today link to be unselectable
//      under certain cases when some days of week are disabled
// March 14, 2003: Added ability to disable individual dates or date
//      ranges, display as light gray and strike-through
// March 14, 2003: Removed dependency on graypixel.gif and instead 
///     use table border coloring
// March 12, 2003: Modified showCalendar() function to allow optional
//      start-date parameter
// March 11, 2003: Modified select() function to allow optional
//      start-date parameter
/* 
DESCRIPTION: This object implements a popup calendar to allow the user to
select a date, month, quarter, or year.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.
The calendar can be modified to work for any location in the world by 
changing which weekday is displayed as the first column, changing the month
names, and changing the column headers for each day.

USAGE:
// Create a new CalendarPopup object of type WINDOW
var cal = new CalendarPopup(); 

// Create a new CalendarPopup object of type DIV using the DIV named 'mydiv'
var cal = new CalendarPopup('mydiv'); 

// Easy method to link the popup calendar with an input box. 
cal.select(inputObject, anchorname, dateFormat);
// Same method, but passing a default date other than the field's current value
cal.select(inputObject, anchorname, dateFormat, '01/02/2000');
// This is an example call to the popup calendar from a link to populate an 
// input box. Note that to use this, date.js must also be included!!
<A HREF="#" onClick="cal.select(document.forms[0].date,'anchorname','MM/dd/yyyy'); return false;">Select</A>

// Set the type of date select to be used. By default it is 'date'.
cal.setDisplayType(type);

// When a date, month, quarter, or year is clicked, a function is called and
// passed the details. You must write this function, and tell the calendar
// popup what the function name is.
// Function to be called for 'date' select receives y, m, d
cal.setReturnFunction(functionname);
// Function to be called for 'month' select receives y, m
cal.setReturnMonthFunction(functionname);
// Function to be called for 'quarter' select receives y, q
cal.setReturnQuarterFunction(functionname);
// Function to be called for 'year' select receives y
cal.setReturnYearFunction(functionname);

// Show the calendar relative to a given anchor
cal.showCalendar(anchorname);

// Hide the calendar. The calendar is set to autoHide automatically
cal.hideCalendar();

// Set the month names to be used. Default are English month names
cal.setMonthNames("January","February","March",...);

// Set the month abbreviations to be used. Default are English month abbreviations
cal.setMonthAbbreviations("Jan","Feb","Mar",...);

// Show navigation for changing by the year, not just one month at a time
cal.showYearNavigation();

// Show month and year dropdowns, for quicker selection of month of dates
cal.showNavigationDropdowns();

// Set the text to be used above each day column. The days start with 
// sunday regardless of the value of WeekStartDay
cal.setDayHeaders("S","M","T",...);

// Set the day for the first column in the calendar grid. By default this
// is Sunday (0) but it may be changed to fit the conventions of other
// countries.
cal.setWeekStartDay(1); // week is Monday - Sunday

// Set the weekdays which should be disabled in the 'date' select popup. You can
// then allow someone to only select week end dates, or Tuedays, for example
cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week

// Selectively disable individual days or date ranges. Disabled days will not
// be clickable, and show as strike-through text on current browsers.
// Date format is any format recognized by parseDate() in date.js
// Pass a single date to disable:
cal.addDisabledDates("2003-01-01");
// Pass null as the first parameter to mean "anything up to and including" the
// passed date:
cal.addDisabledDates(null, "01/02/03");
// Pass null as the second parameter to mean "including the passed date and
// anything after it:
cal.addDisabledDates("Jan 01, 2003", null);
// Pass two dates to disable all dates inbetween and including the two
cal.addDisabledDates("January 01, 2003", "Dec 31, 2003");

// When the 'year' select is displayed, set the number of years back from the 
// current year to start listing years. Default is 2.
// This is also used for year drop-down, to decide how many years +/- to display
cal.setYearSelectStartOffset(2);

// Text for the word "Today" appearing on the calendar
cal.setTodayText("Today");

// The calendar uses CSS classes for formatting. If you want your calendar to
// have unique styles, you can set the prefix that will be added to all the
// classes in the output.
// For example, normal output may have this:
//     <SPAN CLASS="cpTodayTextDisabled">Today<SPAN>
// But if you set the prefix like this:
cal.setCssPrefix("Test");
// The output will then look like:
//     <SPAN CLASS="TestcpTodayTextDisabled">Today<SPAN>
// And you can define that style somewhere in your page.

// When using Year navigation, you can make the year be an input box, so
// the user can manually change it and jump to any year
cal.showYearNavigationInput();

// Set the calendar offset to be different than the default. By default it
// will appear just below and to the right of the anchorname. So if you have
// a text box where the date will go and and anchor immediately after the
// text box, the calendar will display immediately under the text box.
cal.offsetX = 20;
cal.offsetY = 20;

NOTES:
1) Requires the functions in AnchorPosition.js and PopupWindow.js

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.

4) When a CalendarPopup object is created, a handler for 'onmouseup' is
   attached to any event handler you may have already defined. Do NOT define
   an event handler for 'onmouseup' after you define a CalendarPopup object 
   or the autoHide() will not work correctly.
   
5) The calendar popup display uses style sheets to make it look nice.

*/ 

// CONSTRUCTOR for the CalendarPopup Object
function CalendarPopup() {
	var c;
	if (arguments.length>0) {
		c = new PopupWindow(arguments[0]);
		}
	else {
		c = new PopupWindow();
		c.setSize(150,175);
		}
	c.offsetX = -152;
	c.offsetY = 25;
	c.autoHide();
	// Calendar-specific properties
	c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	c.dayHeaders = new Array("S","M","T","W","T","F","S");
	c.returnFunction = "CP_tmpReturnFunction";
	c.returnMonthFunction = "CP_tmpReturnMonthFunction";
	c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";
	c.returnYearFunction = "CP_tmpReturnYearFunction";
	c.weekStartDay = 0;
	c.isShowYearNavigation = false;
	c.displayType = "date";
	c.disabledWeekDays = new Object();
	c.disabledDatesExpression = "";
	c.yearSelectStartOffset = 2;
	c.currentDate = null;
	c.todayText="Today";
	c.cssPrefix="";
	c.isShowNavigationDropdowns=false;
	c.isShowYearNavigationInput=false;
	window.CP_calendarObject = null;
	window.CP_targetInput = null;
	window.CP_dateFormat = "MM/dd/yyyy";
	// Method mappings
	c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;
	c.setReturnFunction = CP_setReturnFunction;
	c.setReturnMonthFunction = CP_setReturnMonthFunction;
	c.setReturnQuarterFunction = CP_setReturnQuarterFunction;
	c.setReturnYearFunction = CP_setReturnYearFunction;
	c.setMonthNames = CP_setMonthNames;
	c.setMonthAbbreviations = CP_setMonthAbbreviations;
	c.setDayHeaders = CP_setDayHeaders;
	c.setWeekStartDay = CP_setWeekStartDay;
	c.setDisplayType = CP_setDisplayType;
	c.setDisabledWeekDays = CP_setDisabledWeekDays;
	c.addDisabledDates = CP_addDisabledDates;
	c.setYearSelectStartOffset = CP_setYearSelectStartOffset;
	c.setTodayText = CP_setTodayText;
	c.showYearNavigation = CP_showYearNavigation;
	c.showCalendar = CP_showCalendar;
	c.hideCalendar = CP_hideCalendar;
	c.getStyles = getCalendarStyles;
	c.refreshCalendar = CP_refreshCalendar;
	c.getCalendar = CP_getCalendar;
	c.select = CP_select;
	c.setCssPrefix = CP_setCssPrefix;
	c.showNavigationDropdowns = CP_showNavigationDropdowns;
	c.showYearNavigationInput = CP_showYearNavigationInput;
	c.copyMonthNamesToWindow();
	// Return the object
	return c;
	}
function CP_copyMonthNamesToWindow() {
	// Copy these values over to the date.js 
	if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) {
		window.MONTH_NAMES = new Array();
		for (var i=0; i<this.monthNames.length; i++) {
			window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i];
		}
		for (var i=0; i<this.monthAbbreviations.length; i++) {
			window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i];
		}
	}
}
// Temporary default functions to be called when items clicked, so no error is thrown
function CP_tmpReturnFunction(y,m,d) { 
	if (window.CP_targetInput!=null) {
		var dt = new Date(y,m-1,d,0,0,0);
		if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); }
		window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);
		// aw
		window.CP_targetInput.focus();
		window.CP_targetInput.select();
		}
	else {
		alert('Use setReturnFunction() to define which function will get the clicked results!'); 
		}
	}
function CP_tmpReturnMonthFunction(y,m) { 
	alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); 
	}
function CP_tmpReturnQuarterFunction(y,q) { 
	alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); 
	}
function CP_tmpReturnYearFunction(y) { 
	alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); 
	}

// Set the name of the functions to call to get the clicked item
function CP_setReturnFunction(name) { this.returnFunction = name; }
function CP_setReturnMonthFunction(name) { this.returnMonthFunction = name; }
function CP_setReturnQuarterFunction(name) { this.returnQuarterFunction = name; }
function CP_setReturnYearFunction(name) { this.returnYearFunction = name; }

// Over-ride the built-in month names
function CP_setMonthNames() {
	for (var i=0; i<arguments.length; i++) { this.monthNames[i] = arguments[i]; }
	this.copyMonthNamesToWindow();
	}

// Over-ride the built-in month abbreviations
function CP_setMonthAbbreviations() {
	for (var i=0; i<arguments.length; i++) { this.monthAbbreviations[i] = arguments[i]; }
	this.copyMonthNamesToWindow();
	}

// Over-ride the built-in column headers for each day
function CP_setDayHeaders() {
	for (var i=0; i<arguments.length; i++) { this.dayHeaders[i] = arguments[i]; }
	}

// Set the day of the week (0-7) that the calendar display starts on
// This is for countries other than the US whose calendar displays start on Monday(1), for example
function CP_setWeekStartDay(day) { this.weekStartDay = day; }

// Show next/last year navigation links
function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true; }

// Which type of calendar to display
function CP_setDisplayType(type) {
	if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year") { alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false; }
	this.displayType=type;
	}

// How many years back to start by default for year display
function CP_setYearSelectStartOffset(num) { this.yearSelectStartOffset=num; }

// Set which weekdays should not be clickable
function CP_setDisabledWeekDays() {
	this.disabledWeekDays = new Object();
	for (var i=0; i<arguments.length; i++) { this.disabledWeekDays[arguments[i]] = true; }
	}
	
// Disable individual dates or ranges
// Builds an internal logical test which is run via eval() for efficiency
function CP_addDisabledDates(start, end) {
	if (arguments.length==1) { end=start; }
	if (start==null && end==null) { return; }
	if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; }
	if (start!=null) { start = parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}
	if (end!=null) { end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}
	if (start==null) { this.disabledDatesExpression+="(ds<="+end+")"; }
	else if (end  ==null) { this.disabledDatesExpression+="(ds>="+start+")"; }
	else { this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")"; }
	}
	
// Set the text to use for the "Today" link
function CP_setTodayText(text) {
	this.todayText = text;
	}

// Set the prefix to be added to all CSS classes when writing output
function CP_setCssPrefix(val) { 
	this.cssPrefix = val; 
	}

// Show the navigation as an dropdowns that can be manually changed
function CP_showNavigationDropdowns() { this.isShowNavigationDropdowns = (arguments.length>0)?arguments[0]:true; }

// Show the year navigation as an input box that can be manually changed
function CP_showYearNavigationInput() { this.isShowYearNavigationInput = (arguments.length>0)?arguments[0]:true; }

// Hide a calendar object
function CP_hideCalendar() {
	if (arguments.length > 0) { window.popupWindowObjects[arguments[0]].hidePopup(); }
	else { this.hidePopup(); }
	}

// Refresh the contents of the calendar display
function CP_refreshCalendar(index) {
	var calObject = window.popupWindowObjects[index];
	if (arguments.length>1) { 
		calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));
		}
	else {
		calObject.populate(calObject.getCalendar());
		}
	calObject.refresh();
	}

// Populate the calendar and display it
function CP_showCalendar(anchorname) {
	if (arguments.length>1) {
		if (arguments[1]==null||arguments[1]=="") {
			this.currentDate=new Date();
			}
		else {
			this.currentDate=new Date(parseDate(arguments[1]));
			}
		}
	this.populate(this.getCalendar());
	this.showPopup(anchorname);
	}

// Simple method to interface popup calendar with a text-entry box
function CP_select(inputobj, linkname, format) {
	var selectedDate=(arguments.length>3)?arguments[3]:null;
	if (!window.getDateFromFormat) {
		alert("calendar.select: To use this method you must also include 'date.js' for date formatting");
		return;
		}
	if (this.displayType!="date"&&this.displayType!="week-end") {
		alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");
		return;
		}
	if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 
		alert("calendar.select: Input object passed is not a valid form input object"); 
		window.CP_targetInput=null;
		return;
		}
	if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input!
	window.CP_targetInput = inputobj;
	window.CP_calendarObject = this;
	this.currentDate=null;
	var time=0;
	if (selectedDate!=null) {
		time = getDateFromFormat(selectedDate,format)
		}
	else if (inputobj.value!="") {
		time = getDateFromFormat(inputobj.value,format);
		}
	if (selectedDate!=null || inputobj.value!="") {
		if (time==0) { this.currentDate=null; }
		else { this.currentDate=new Date(time); }
		}
	window.CP_dateFormat = format;
	this.showCalendar(linkname);
	}
	
// Get style block needed to display the calendar correctly
function getCalendarStyles() {
	var result = "";
	var p = "";
	if (this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!="") { p=this.cssPrefix; }
	result += "<style type=\"text/css\">\n";
	result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:middle; text-decoration:none; color:#000000; font-weight:bold; }\n";
	result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n";
	result += "td."+p+"cpDayColumnHeader { padding: 0px; text-align:right; border:1px solid #C0C0C0;border-width:0px 0px 1px 0px; }\n";
	result += "td."+p+"cpCurrentMonthDate, ."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate  { padding: 0px; text-align:right; text-decoration:none; }\n";
	result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n";
	result += "."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n";
	result += "."+p+"cpOtherMonthDate { color:#808080; }\n";
	result += "td."+p+"cpCurrentDate { padding: 0px; color:white; background-color: #C0C0C0; border-width:1px; border:1px solid  #800000; }\n";
	result += "td."+p+"cpCurrentDateDisabled { padding: 0px; border-width:1px; border:1px solid  #FFAAAA; }\n";
	result += "td."+p+"cpTodayText, td."+p+"cpTodayTextDisabled { padding: 0px; border:1xp solid  #C0C0C0; border-width:1px 0px 0px 0px;}\n";
	result += "a."+p+"cpTodayText, span."+p+"cpTodayTextDisabled { height:20px; }\n";
	result += "a."+p+"cpTodayText { color:black; }\n";
	result += "."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n";
	result += "."+p+"cpBorder { border:1px solid  #808080; }\n";
	result += "</style>\n";
	return result;
	}

// Return a string containing all the calendar code to be displayed
function CP_getCalendar() {
	var now = new Date();
	// Reference to window
	if (this.type == "WINDOW") { var windowref = "window.opener."; }
	else { var windowref = ""; }
	var result = "";
	// If POPUP, write entire HTML document
	if (this.type == "WINDOW") {
		result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";
		result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';
		}
	else {
		result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';
		result += '<TR><TD ALIGN=CENTER>\n';
		result += '<CENTER>\n';
		}
	// Code for DATE display (default)
	// -------------------------------
	if (this.displayType=="date" || this.displayType=="week-end") {
		if (this.currentDate==null) { this.currentDate = now; }
		if (arguments.length > 0) { var month = arguments[0]; }
			else { var month = this.currentDate.getMonth()+1; }
		if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; }
			else { var year = this.currentDate.getFullYear(); }
		var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
		if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) {
			daysinmonth[2] = 29;
			}
		var current_month = new Date(year,month-1,1);
		var display_year = year;
		var display_month = month;
		var display_date = 1;
		var weekday= current_month.getDay();
		var offset = 0;
		
		offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;
		if (offset > 0) {
			display_month--;
			if (display_month < 1) { display_month = 12; display_year--; }
			display_date = daysinmonth[display_month]-offset+1;
			}
		var next_month = month+1;
		var next_month_year = year;
		if (next_month > 12) { next_month=1; next_month_year++; }
		var last_month = month-1;
		var last_month_year = year;
		if (last_month < 1) { last_month=12; last_month_year--; }
		var date_class;
		if (this.type!="WINDOW") {
			result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
			}
		result += '<TR>\n';
		var refresh = windowref+'CP_refreshCalendar';
		var refreshLink = 'javascript:' + refresh;
		if (this.isShowNavigationDropdowns) {
			result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';
			for( var monthCounter=1; monthCounter<=12; monthCounter++ ) {
				var selected = (monthCounter==month) ? 'SELECTED' : '';
				result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';
				}
			result += '</select></TD>';
			result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';

			result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';
			for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) {
				var selected = (yearCounter==year) ? 'SELECTED' : '';
				result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';
				}
			result += '</select></TD>';
			}
		else {
			if (this.isShowYearNavigation) {
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</A></TD>';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</A></TD>';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';

				result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</A></TD>';
				if (this.isShowYearNavigationInput) {
					result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';
					}
				else {
					result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';
					}
				result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</A></TD>';
				}
			else {
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;&lt;</A></TD>\n';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';
				result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;&gt;</A></TD>\n';
				}
			}
		result += '</TR></TABLE>\n';
		result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';
		result += '<TR>\n';
		for (var j=0; j<7; j++) {

			result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';
			}
		result += '</TR>\n';
		for (var row=1; row<=6; row++) {
			result += '<TR>\n';
			for (var col=1; col<=7; col++) {
				var disabled=false;
				if (this.disabledDatesExpression!="") {
					var ds=""+display_year+LZ(display_month)+LZ(display_date);
					eval("disabled=("+this.disabledDatesExpression+")");
					}
				var dateClass = "";
				if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) {
					dateClass = "cpCurrentDate";
					}
				else if (display_month == month) {
					dateClass = "cpCurrentMonthDate";
					}
				else {
					dateClass = "cpOtherMonthDate";
					}
				if (disabled || this.disabledWeekDays[col-1]) {
					result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';
					}
				else {
					var selected_date = display_date;
					var selected_month = display_month;
					var selected_year = display_year;
					if (this.displayType=="week-end") {
						var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);
						d.setDate(d.getDate() + (7-col));
						selected_year = d.getYear();
						if (selected_year < 1000) { selected_year += 1900; }
						selected_month = d.getMonth()+1;
						selected_date = d.getDate();
						}
					result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';
					}
				display_date++;
				if (display_date > daysinmonth[display_month]) {
					display_date=1;
					display_month++;
					}
				if (display_month > 12) {
					display_month=1;
					display_year++;
					}
				}
			result += '</TR>';
			}
		var current_weekday = now.getDay() - this.weekStartDay;
		if (current_weekday < 0) {
			current_weekday += 7;
			}
		result += '<TR>\n';
		result += '	<TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';
		if (this.disabledDatesExpression!="") {
			var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());
			eval("disabled=("+this.disabledDatesExpression+")");
			}
		if (disabled || this.disabledWeekDays[current_weekday+1]) {
			result += '		<SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';
			}
		else {
			result += '		<A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';
			}
		result += '		<BR>\n';
		result += '	</TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';
	}

	// Code common for MONTH, QUARTER, YEAR
	// ------------------------------------
	if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") {
		if (arguments.length > 0) { var year = arguments[0]; }
		else { 
			if (this.displayType=="year") {	var year = now.getFullYear()-this.yearSelectStartOffset; }
			else { var year = now.getFullYear(); }
			}
		if (this.displayType!="year" && this.isShowYearNavigation) {
			result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
			result += '<TR>\n';
			result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');">&lt;&lt;</A></TD>\n';
			result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';
			result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">&gt;&gt;</A></TD>\n';
			result += '</TR></TABLE>\n';
			}
		}
		
	// Code for MONTH display 
	// ----------------------
	if (this.displayType=="month") {
		// If POPUP, write entire HTML document
		result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
		for (var i=0; i<4; i++) {
			result += '<TR>';
			for (var j=0; j<3; j++) {
				var monthindex = ((i*3)+j);
				result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';
				}
			result += '</TR>';
			}
		result += '</TABLE></CENTER></TD></TR></TABLE>\n';
		}
	
	// Code for QUARTER display
	// ------------------------
	if (this.displayType=="quarter") {
		result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';
		for (var i=0; i<2; i++) {
			result += '<TR>';
			for (var j=0; j<2; j++) {
				var quarter = ((i*2)+j+1);
				result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';
				}
			result += '</TR>';
			}
		result += '</TABLE></CENTER></TD></TR></TABLE>\n';
		}

	// Code for YEAR display
	// ---------------------
	if (this.displayType=="year") {
		var yearColumnSize = 4;
		result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
		result += '<TR>\n';
		result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');">&lt;&lt;</A></TD>\n';
		result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">&gt;&gt;</A></TD>\n';
		result += '</TR></TABLE>\n';
		result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
		for (var i=0; i<yearColumnSize; i++) {
			for (var j=0; j<2; j++) {
				var currentyear = year+(j*yearColumnSize)+i;
				result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';
				}
			result += '</TR>';
			}
		result += '</TABLE></CENTER></TD></TR></TABLE>\n';
		}
	// Common
	if (this.type == "WINDOW") {
		result += "</BODY></HTML>\n";
		}
	return result;
	}
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
//                 perfectly with SimpleDateFormat formats, but 
//                 backwards-compatability was required.

// ------------------------------------------------------------------
// These functions use the same 'format' strings as the 
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
// 
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
//  "MMM d, y" matches: January 01, 2000
//                      Dec 1, 1900
//                      Nov 20, 00
//  "M/d/yy"   matches: 01/20/00
//                      9/2/00
//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------

var MONTH_NAMES_en=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES_en=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');

var DAY_NAMES=new Array('Sonntag','Montag','Dinstag','Mittwoch','Donerstag','Freitag','Samstag','So','Mo','Di','Mi','Do','Fr','Sa');
var MONTH_NAMES=new Array("Januar", "Februar", "M?rz", "April", "Mai", "Juni", "Juli", "August", "September", "Jan","Feb","M?r","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez");
function LZ(x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) { y=""+(y-0+1900); }
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";

	// aw schon mal richtig vorbelegen
	if(year < 1900) {
		year = year + 1900;
	}
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------

// with locale
function parseDateWL(val,loc) {
	if(loc) {
		if(loc.indexOf("en_US") > -1) {
			return parseDate(val,false);
		}
	}
	return parseDate(val,true);
}

function parseDate(val) {
	// aw ver?ndert
	//var preferEuro=(arguments.length==2)?arguments[1]:false;
	var df = (arguments.length==2)?arguments[1]:true;
	
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
//	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
//	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	dateFirst =new Array('d','d.','d.M','d.M.','d.M.y','ddMM','ddMMy','d/','d/M','d/M/','d/M/y','d-','d-M','d-M-','d-M-y','E, d.M.y','E d.M.y');
	//var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var checkList;
	if(df == true) {
		checkList=new Array('dateFirst');
	}
	else {
		checkList=new Array('monthFirst');
	}
	var d=null;
	if(val == null) return null;
	if(val == '') return null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
		}
	}
	return null;
}	


// aw 2005-09-22


/**
	Mit Ver?ndern des Datums, so dass es gr??er= als Heute ist
	wir ver?ndern aber nur etwas, wenn es mit einer ?nderung des Monats
	um 1 hinzubekommen ist
*/

function parseDateGrEq_Heute(val,validateonly) {
	var pdate = parseDate(val);
	if(val.length <= 3 || validateonly) {
		var d =  parseDateGrEq_Date(pdate,new Date());
		if(d == null) {
			return null;
		}
		if( validateonly && d.getTime() != pdate.getTime()) {
			return null;
		}
		return d;
	}
	else {
		return pdate;
	}
}

function parseDateGrEq_Date(eingabe,now) {
	if(eingabe == null) {
		return null;
	}

	var year=now.getYear();
	var month=now.getMonth();
	var date=now.getDate();;

	now.setHours(0);
	now.setMinutes(0);
	now.setSeconds(0);
	now.setMilliseconds(0);

	//alert(now.getTime() + ' >+ ' + eingabe.getTime());
	if(now.getTime() > eingabe.getTime()) {
		var pyear=eingabe.getYear();
		var pmonth=eingabe.getMonth();
		var pdate=eingabe.getDate();;
		
		if(pyear == year && pmonth == month) {
			++pmonth;
			if(pmonth == 12) {
				pmonth = 0;
				++pyear;
			}
			if(pyear <= 1900) {
				pyear += 1900;
			}
			return new Date(pyear,pmonth,pdate,0,0,0);
		}
		// sonst einfach ung?ltig
		return null;
	}
	return eingabe;
}

/**
 * TODO funktioniert leider nicht so ganz im Sinne von wird nicht auf den ersten gesetzt
 * @author andreas 18.03.2010 11:13:46
 * @param val
 * @param validateonly
 * @return
 */
// mit Monatsanfang
function parseMonatGrEq_Heute(val,validateonly) {
	var pdate = parseDate(val);
	if(pdate == null) {
		return null;
	}
	// nur umsetzen, wenn kein komplettes datum
	if(val.length <= 3 || validateonly) {
		pdate.setDate(1);
		var d = parseDateGrEq_Date(pdate,new Date());
		if(d == null) {
			return null;
		}
		if( validateonly && d.getTime() != pdate.getTime()) {
			return null;
		}
		return d;
		
	}
	else {
		return pdate;
	}
}

function parseMonatBeginn(val,validateonly) {
	var pdate = parseDate(val);
	if(pdate == null) {
		return null;
	}
	// nur umsetzen, wenn kein komplettes datum
	if(val.length <= 3 || validateonly) {
		pdate.setDate(1);
		var d = parseDateGrEq_Date(pdate,new Date());
		if(d == null) {
			return null;
		}
		if( validateonly && d.getTime() != pdate.getTime()) {
			return null;
		}
		return d;
		
	}
	else {
		return pdate;
	}
}
/*
	Benötigt AnchorPosition, PopupWindow, CalenderPopup, date
*/

var KalenderResources = {
  	MONTHNAMES      : new Array('Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'),
  	DAYHEADERS      : new Array('So','Mo','Di','Mi','Do','Fr','Sa'),
	TODAY			: 'Heute',
	DATEFORMAT		: 'dd.MM.yyyy'
}

function Kalender(inputid,divid,kr,img) {
	this.inputid = inputid;
	this.anchorid = 'anchor' + inputid;
	this.imageid = 'img' + inputid ;
	this.cal = new CalendarPopup(divid);
	this.img = img;

	this.cal.setWeekStartDay(1);
	if(kr) {
		this.setStrings(kr);
	}
	else {
		this.setStrings(KalenderResources);
	}
	this.writeKalender();
	addEvent(window,'load',this.setupHandler.bindOn(this));
}

Kalender.prototype.setStrings = function(resources) {
	var month = resources.MONTHNAMES;
	var days = resources.DAYHEADERS;
	var today = resources.TODAY;
	
	this.cal.setMonthNames(month[0],month[1],month[2],month[3],month[4],month[5],month[6],month[7],month[8],month[9],month[10],month[11]);
	this.cal.setDayHeaders(days[0],days[1],days[2],days[3],days[4],days[5],days[6]);
	this.cal.setTodayText(today);
	this.dateformat = resources.DATEFORMAT;
	return this;
}

Kalender.prototype.writeKalender = function() {
		var line = '<span name="' + this.anchorid + '" id="' + this.anchorid + '"><\/span>'
			+ '<img class="kalender" id="' + this.imageid + '" alt="" src="' + this.img + '" border="0">';
		document.write(line);
	return this;
}

Kalender.prototype.clickHandler = function(event) {
	var el = document.getElementById(this.inputid);
	this.cal.select(el,this.anchorid,this.dateformat);
}

Kalender.prototype.setupHandler = function() {
	var elem = document.getElementById(this.imageid);
    addEvent(elem, 'click', this.clickHandler.bindOn(this));
	return this;
}



var diverses_hilfetitel = "";
var diverses_hilfetext = "";

function diverses_setHilfe(titel,text) {
	diverses_hilfetitel = titel;
	diverses_hilfetext = text;
}

function diverses_showHilfe(anchorname) {
	//// Create an object for a WINDOW popup
	// var helpwin = new PopupWindow(); 
	// Create an object 
	var helpwin = new PopupWindow(anchorname); 

	helpwin.autoHide(); 
	helpwin.autoHideIfClicked(); 
	helpwin.setSize(400,250);
	var html = null;
	if(false) {
    	html = "<html><head>\n"
            + "<title>"+ diverses_hilfetitel+"</title>\n"
            + "<meta http-equiv='Content-Type' content='text/html;CHARSET=iso-8859-1'>\n"
            + "<LINK REL=STYLESHEET HREF=\"/web/common/cambio.css\" TYPE=\"text/css\">\n"
            + "</head><body class=\"hilfewin\">\n"
            + "<div id=hilfewinid>\n"
            + diverses_hilfetext
            + "</div>\n"
            +"\n</body></html>";
	}
	else {
		html = diverses_hilfetext;
	}
	
	helpwin.populate(html);
	
	helpwin.showPopup(anchorname);
//	var cors = getAnchorWindowPosition(anchorname);
//	alert(" cors: " + cors.x + "/" + cors.y);
}

function diverses_showInfo(anchorname,titel,text) {
	diverses_setHilfe(titel,text);
	diverses_showHilfe(anchorname);
}
	/**
		Das erste Formelmement fokusieren
		Wenn es ein Textfeld ist wird es selektiert.
	*/
	function formular_fokusiereErstesElement(form) {
		//var str = "";
		var elements = document.forms[0].elements;
		for(i=0; i<elements.length; ++i) {
		/*
			str += elements[i].name + ": " 
				+ elements[i].type	+ ", " 
				+ elements[i].disabled	+ ", " 
				+ elements[i].readOnly
				+ "\n";
		*/
			if(elements[i].type == 'hidden') {
				continue;
			}	
			if(elements[i].disabled || elements[i].readOnly) {
				continue;
			}	
			elements[i].focus();
			if(elements[i].type == 'text' || elements[i].type=='textarea') {
				elements[i].select();
			}	
			break;
		}
		//alert(str);
	}

	/**
		den Werte eines Radio Elements herausfinden
	*/
	
	function formular_getRadioWert(element) {
		if(element[0].type) {
			if(element[0].type == 'radio') {
				for(i=0; i < element.length; ++i) {
					if(element[i].checked) {
						return element[i].value;
					}
				}
			}
		}
		return "";
	}
	
	/**
		Überprüfen, ob Werte geändert wurden
		TODO funktioniert zur Zeit nur für ein Formular
	*/
		
	var altewerte = new Object();
	
	function formular_UeberpruefeWerteGeaendert(element) {
		if(!element) { // falls das Argument nicht definiert ist
			return false;
		}
		var newval = "-999";		
		if(element.type) { // könnte auch sein, dass wir eine liste haben bei radio
			var oldval = altewerte[element.name];
			//alert(element.name + ' ' + oldval);
			if(	element.type == 'select') {
				 var idx = element.selectedIndex;
				 if(idx > -1) {
				 	newval = element.options[idx].value;
				 }
			}
			else if(	element.type == 'checkbox') {
				//alert(element.name + ": " + element.value);
				if(element.checked) {
				//alert(element.name + ": " + element.value);
					newval = element.value;
				}
			}
			else if(	element.type == 'radio') {
				// aw 2008-07-15
				// passiert anscheinend nur, wenn wir einen radio haben
				//alert(element.name + ": " + element.value);
				if(element.checked) {
					newval = element.value;
				}
			}
			else {
				newval = element.value;
			}
			
			if(newval != oldval) {
				//alert(element.name + ' wurde geändert: ' + oldval + '/' + newval);
				return true;
			}
		}
		else if(element[0].type) {
			if(element[0].type == 'radio') {
				var oldval = altewerte[element[0].name];
				//alert("check radio " + element[0].name + " : " + element.length);
				for(i=0; i < element.length; ++i) {
					if(element[i].checked) {
						newval = element[i].value;
						//alert(element[i].name + ' wurde geändert: ' + oldval + '/' + newval);
						break;
					}
				}
				if(newval != oldval) {
					return true;
				}
			}
		}
		return false;
	}
	
	/*
		Alte Werte, d.h. die Werte merken, die gesetzt waren
		beim Laden des Dokuments 
	*/
	
	function formular_merkeAlteWerte(formular) {
		var elements = formular.elements;
		var cnt = 0;
		for(i=0; i<elements.length; ++i) {
			var element = elements[i];
			var name = elements[i].name;
			var val = "-999";
			//if(element.type == 'hidden') {
			//	continue;
			//}
			if(	element.type == 'select') {
				 var idx = element.selectedIndex;
				 if(idx > -1) {
				 	val = element.options[idx].value;
				 }
				altewerte[name] = val;				
			}
			else if(	element.type == 'radio' || element.type == 'checkbox') {
					//alert(name + ": " + element.value);
				if(element.checked) {
					val = element.value;
					//alert(name + ": " + element.value);
				}			
				altewerte[name] = val;				
			}
			else if(element[0].type) {
				if(element[0].type == 'radio') {
					for(i=0; i < element.length; ++i) {
						if(element[i].checked) {
							altewerte[name] = element[i].value;
							break;
						}
					}
				}
			}
			else  {
				val = element.value;
				altewerte[name] = val;				
			}
		}
		/*
		var str =''
		for(var n in altewerte) {
			str += n + ': ' + altewerte[n] + '\n';
		}
		alert(str);
		*/
	}

	
	
	
function validate_on_input(elem, regexp) {
    var value = elem.value;
    var newvalue = value.match(regexp);
    if(newvalue == null) {
        elem.value = "";
        window.status = "Zeichen war nicht erlaubt!";
    }
	else if(newvalue[0] == value) {
        window.status = "OK";
        return true;
	 }
    else  { // if (newvalue != null) {
        elem.value = newvalue[0];
        window.status = "Zeichen war nicht erlaubt!";
    }    
    return false;
}

function validate_on_submit(elem, regexp) {
    var value = elem.value;
    var newvalue =  value.match(regexp);
	 if(newvalue == value) {
        return true;
	 }
    return false;
}

function validate_float(elem, clamp_min, clamp_max, decimal) {
    value = elem.value;
    regexp = /[+-]?\d+[,.]?\d*/;
    match = value.match(regexp);
    value = value.replace(/\./g, '');
    value = value.replace(/,/g, '.');
    floatvalue = parseFloat(value);
    decimalOK = true;

    if (value.lastIndexOf('.') > 0) {
        decimalOK = (value.substring(value.lastIndexOf('.') + 1, value.length).length <= decimal);
    }

    if (match && (floatvalue >= clamp_min) && (floatvalue <= clamp_max) && decimalOK) {
        window.status = value + " entspricht den Bedingungen. (" + floatvalue + ")";
        return floatvalue;
    } else {
        window.status = value + " entspricht den Bedingungen NICHT.";
        return false;
    }
}

//#############################################################################
// Wrapper - Common Cases

function validate_on_input_posint(elem) {
    return validate_on_input(elem, /\d+/);
}

function validate_on_input_int(elem) {
    return validate_on_input(elem, /[+-]?\d*/);
}

function validate_on_input_float(elem) {
   // return validate_on_input(elem, /[+-]?\d*[,.]?\d*/);
    return validate_on_input(elem, /^[+-]\d*(\.\d\d\d)*(\.\d{0,2})?(,\d*)?/);
}

function validate_on_input_posfloat(elem) {
    //log('elem: ' + elem.value);
    // stimmt so fast - nur 123., waere noch erlaubt
    return validate_on_input(elem, /^\d*(\.\d\d\d)*(\.\d{0,2})?(,\d*)?/);
//    return validate_on_input(elem, /\d+[,.]?\d*/);
}

function validate_on_input_date(elem) {
	// 1. variante
	// erst mal schauen ob mit ., oder / oder -
	var val = elem.value;
	var idx = val.indexOf('.'); 
	if( idx > -1) {
		// dd.MM.yyyy
		if(val.length > (idx +1 )) {
			if(val.indexOf('.',idx+1) > -1) {
			    return validate_on_input(elem, /^(\d{1,2}\.){2,2}\d{0,4}/);
			}
		}
	    return validate_on_input(elem, /^(\d{1,2}\.)\d{0,2}/);
	}
	else {
		idx = val.indexOf('/'); 
		if( idx > -1) {
			if(val.length > (idx +1 )) {
				//  dd/MM/yyyy
				if(val.indexOf('/',idx+1) > -1) {
					return validate_on_input(elem, /^(\d{1,2}\/){2,2}\d{0,4}/);
				}
			}
			return validate_on_input(elem, /^(\d{1,2}\/)\d{0,2}/);
		}
		else  {
			// ddMMyyyy
		    return validate_on_input(elem, /^\d{0,8}/);
		}
	}
}

function validate_on_input_time(elem) {
	// 1. variante
	// erst mal schauen ob mit ., oder / oder -
	var val = elem.value;
	var idx = val.indexOf('.'); 
	if( idx > -1) {
		// HH.mm
	    return validate_on_input(elem, /^(\d{1,2}\.)\d{0,2}/);
	}
	else {
		idx = val.indexOf(':'); 
		if( idx > -1) {
			// HH.mm
		    return validate_on_input(elem, /^(\d{1,2}\:)\d{0,2}/);
		}
		else  {
			// HHmm
		    return validate_on_input(elem, /^\d{0,4}/);
		}
	}
}


function validate_posfloat(elem) {
    return validate_float(elem, 0, Number.MAX_VALUE, 8);
}

function validate_email(elem) {
	var value = elem.value;
	if(value != '') {
		var suche = /.*@.*\...+/;
		return suche.test(value);
	}
	else {
		return true;
	}
}

function validate_on_submit_cambio_phone(elem) {
	// kann sein, dass wir altlasten aus cwo haben
	// die etwas anders formatiert sind
	
	var str = elem.value;
	str = str.replace(/ /g,'');
	str = str.replace(/\(/g,' (');
	str = str.replace(/\)/g,') ');
	elem.value = str;
    return validate_on_submit(elem, /^[+]\d\d\d?\s\(0\d+\)\s\d\d\d\d*/);
}

function validate_on_input_cambio_phone(elem) {
	// grobe Struktur sollte zumindest vorhanden sein
	var regexp = new Array();
	var cnt = 0;
	regexp[cnt++] = /[+]/;
	regexp[cnt++] =	/[+]\d/;
	regexp[cnt++] =	/[+]\d\d\d?/;
	regexp[cnt++] =	/[+]\d\d\d?\s/;
	regexp[cnt++] =	/[+]\d\d\d?\s\(/;
	regexp[cnt++] =	/[+]\d\d\d?\s\(0/;
	regexp[cnt++] =	/[+]\d\d\d?\s\(0\d*/;
	regexp[cnt++] =	/[+]\d\d\d?\s\(0\d+\)/;
	regexp[cnt++] =	/[+]\d\d\d?\s\(0\d+\)\s/;
	regexp[cnt++] =	/[+]\d\d\d?\s\(0\d+\)\s\d*/;
	
    //return validate_on_submit(elem, /[+]\d*\s?\(?\d*\)?\s?\d*/);
    return validate_on_input_progressiv(elem, regexp);
}

function validate_on_input_progressiv(elem, regexp) {
	if(!regexp || regexp.length < 1) {
		return true;
	}
    var value = elem.value;
    var lastgood = "";
    
    for(var i=0; i< regexp.length; ++i) {
	    var newvalue = value.match(regexp[i]);
		 if(newvalue == value) {
	    	//log(i + ' OK newvalue: ' + newvalue);
	        lastgood = newvalue;
		 }
	    else if (newvalue != null) {
	    	//log(i + ' Not quite newvalue: ' + newvalue);
	        lastgood = newvalue;
	    } else {
	        //elem.value = lastgood;
	    	//log(i + ' Not at all newvalue: ' + newvalue);
	        window.status = "Zeichen war nicht erlaubt!";
	    }
	}
    elem.value = lastgood;
	
    return true;
}


function validate_on_input_cambio_phone3(id) {
	var land = document.getElementById(id + '_land');
	validate_on_input_posint(land);
	var vorwahl = document.getElementById(id + '_vorwahl');
	validate_on_input_posint(vorwahl);
	var nummer = document.getElementById(id + '_nummer');
	validate_on_input_posint(nummer);

	var phone = document.getElementById(id);
	if(vorwahl.value == "" || !(vorwahl.value.substring(0,1) == '0')) {
		vorwahl.value = "0" + vorwahl.value;
	}
	phone.value='+' + land.value + ' (' + vorwahl.value + ') ' + nummer.value;
}

function split_cambio_phone3(val) {
	var str = val.replace(/ /g,'');
	var regex = /^[+](\d\d\d?)\((0\d+)\)(\d\d\d\d*)$/ ;
	var split = regex.exec(str);
	//log(val + " is not a cambio telephone number");
	//alert(split[1] + " " + split[2] + " " + split[3] ); 
	
	return split;
}

function init_new_cambio_phone3(oldid,id,defland) {

	var land = document.getElementById(id + '_land');
	var vorwahl = document.getElementById(id + '_vorwahl');
	var nummer = document.getElementById(id + '_nummer');


	if(!land || !vorwahl || !nummer) {
		return;
	}

	if(	land.value != '' 
		|| vorwahl.value != ''
		|| nummer.value != ''
		) {
		return;
	}
	
	
	var phone = null;
	if(oldid) {
		phone = document.getElementById(oldid);
	}
	
	if(phone) {
		var split = split_cambio_phone3(phone.value);
		if(split != null) {
			land.value = split[1];
			vorwahl.value = split[2];
			return;
		}
	}
	if(defland) {
		land.value = defland;
	}
}



function Reiter(div, reiterleiste, callBack, zindex) {
  var a = div.getElementsByTagName('a')[0];
  var tarif;
  var klassNames;
  var klass;
  
  this.getTarif = function() {
	  return tarif;
  }
  
  this.showTarifTable = function() {
	  if ($('tarif_' + tarif)) {
	     $('tarif_' + tarif).style.display = '';
	  }  
  }

  this.clickHandler = function(event) {
    callBack.call(reiterleiste, tarif);
    this.aktiv(true);
    this.showTarifTable();
    if (event.preventDefault) {
      event.preventDefault();
    } else {
      event.returnValue = false;
    }
  }

  this.init = function() {
    a.addEventListener
      ? a.addEventListener('click', this.clickHandler.bindAsEventListener(this), false)
      : a.attachEvent('onclick', this.clickHandler.bindAsEventListener(this));

    tarif = a.id.substr(a.id.indexOf('_') + 1);
    klassNames = new Array();
    var c = div.className.split(' ');
    for (var i = 0; i < c.length; i++) {
      if (c[i] == 'rot') {
        klass = 'rot';
      } else if (c[i] == 'blau') {
        klass = 'blau';
      } else {
        klassNames.push(c[i]);
      }
    }
    div.style.zIndex = zindex;
  }

  this.aktiv = function(a) {
    if (a) {
      div.style.zIndex = 100;
      klass = 'blau';
      div.className = klassNames.join(' ') + ' ' + klass;
    } else {
      div.style.zIndex = zindex;
      klass = 'rot';
      div.className = klassNames.join(' ') + ' ' + klass;
    }
  }

  this.init();

}

var Tarifwechsel = {
reiterleiste : null,

reiter : null,

tabellen : null,

tarife2_tabelle : null,

tarife_wechselnd_div : null,

findeReiter : function() {
                var divs = this.reiterleiste.getElementsByTagName('div');
                var zindex = 0;
                for (var i = 0; i < divs.length; i++) {
                  if (divs[i].className.split(' ').contains('reiter')) {
                    zindex++;
                    this.reiter.push(new Reiter(divs[i], this, this.reiterClickCallback, zindex));
                  }
                }
              },

findeTabellen : function() {
                  var tabs = $('content').getElementsByTagName('table');
                  for (var i = 0; i < tabs.length; i++) {
                    if (tabs[i].className.split(' ').contains('tarife')) {
                      if (!tabs[i].className.split(' ').contains('tarife2')) {
                        this.tabellen.push(tabs[i]);
                      } else {
                        this.tarife2_tabelle = tabs[i];
                      }
                    }
                  }
                  
                  var divs = $('content').getElementsByTagName('div');
                  for (var i = 0; i < divs.length; i++) {
                    if (divs[i].className.split(' ').contains('tarife_wechselnd')) {
                        this.tarife_wechselnd_div = divs[i];
                        break;
                    }
                  }
                  
                },
                
hideTarifTables : function() {
                	for (var i = 0; i < this.tabellen.length; i++) {
                        this.tabellen[i].style.display = 'none';
                    }
                },

reiterClickCallback : function(tarif) {
                        for (var i = 0; i < this.reiter.length; i++) {
                          this.reiter[i].aktiv(false);
                        }
                        this.hideTarifTables();
                        this.highlightTarife2(tarif);
                      },
                      
                      /*
                       * Den Reiter eines Tarifs aktivieren, so als wäre er angeklickt worden.
                       */
activateReiter : function(tarif) {
                    	  var reiter = false;
                    	  for (var i = 0, l = this.reiter.length; i < l; i++) {
                    		  if (this.reiter[i].getTarif() == tarif) {
                    			  reiter = this.reiter[i];
                    			  break;
                    		  }
                    	  }
                    	  
                    	  if (reiter) {
                    		  this.reiterClickCallback(tarif);
                    		  reiter.showTarifTable();
                    		  reiter.aktiv(true);
                    	  }
                    	  
                      
                      },
                      
highlightTarife2 : function(tarif) {
                     var tds = this.tarife2_tabelle.getElementsByTagName('thead')[0].getElementsByTagName('td');
                     for (var i = 0; i < tds.length; i++) {
                       if (tds[i].className.split(' ').contains('tarif_' + tarif)) {
                         tds[i].className = tds[i].className + " active";
                       } else {
                         tds[i].className = tds[i].className.replace(/active/, "");
                       }
                     }


                     var trs = this.tarife2_tabelle.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
                     for (var j = 0; j < trs.length; j++) {
	                     tds = trs[j].getElementsByTagName('td');
	                     for (var i = 0; i < tds.length; i++) {
	                       if (tds[i].className.split(' ').contains('tarif_' + tarif)) {
	                         tds[i].className = tds[i].className + " active_" + (i+1);
	                       } else {
	                         tds[i].className = tds[i].className.replace(/active_./, "");
	                       }
	                     }
					}
					                     
                     var span = this.tarife_wechselnd_div.getElementsByTagName('div');
                     for (var i = 0; i < span.length; i++) {
                       if (span[i].className.split(' ').contains('tarif_' + tarif)) {
                         // span[i].style.display = 'block';
                         span[i].style.display = '';
                       } else {
                         span[i].style.display = 'none';
                       }
                     }
                     
                   },

highlightTarife2Alt : function(tarif) {
                     var tds = this.tarife2_tabelle.getElementsByTagName('thead')[0].getElementsByTagName('td');
                     for (var i = 0; i < tds.length; i++) {
                       if (tds[i].className.split(' ').contains('tarif_' + tarif)) {
                         tds[i].className = tds[i].className + " active";
                       } else {
                         tds[i].className = tds[i].className.replace(/active/, "");
                       }
                     }
                     var span = this.tarife_wechselnd_div.getElementsByTagName('span');
                     for (var i = 0; i < span.length; i++) {
                       if (span[i].className.split(' ').contains('tarif_' + tarif)) {
                         // span[i].style.display = 'block';
                         span[i].style.display = '';
                       } else {
                         span[i].style.display = 'none';
                       }
                     }
                     
                   },

init : function(event) {
         if ($('reiterleiste')) {
           this.reiterleiste = $('reiterleiste');
           this.reiter = new Array();
           this.findeReiter();
           this.tabellen = new Array();
           this.findeTabellen();
         }
       }
}

window.addEventListener
  ? window.addEventListener('load', Tarifwechsel.init.bindAsEventListener(Tarifwechsel), false)
  : window.attachEvent('onload', Tarifwechsel.init.bindAsEventListener(Tarifwechsel));
function Bubble(anker) {

  var button;
  var timer;
  var alt;

  this.STOPP = 0;
  this.FLYOUT = 2;
  this.FLYIN = 4;
  this.MAX_RIGHT = -24;
  this.STARTPOS = -8;
  this.SPEED = 3;

  var right = this.STARTPOS;
  var phase = this.STOPP;

  this.start = function(e) {
    phase = this.FLYOUT;
  }

  this.end = function(e) {
    phase = this.FLYIN;
  }

  this.setPhase = function(newphase) {
    phase = newphase;
  }

  this.nextFrame = function() {
    switch (phase) {
      case this.FLYOUT:
        right -= this.SPEED;
        if (right <= this.MAX_RIGHT) {
          phase = this.STOPP;
          right = this.MAX_RIGHT;
        }
        button.style.right = right + "px";
        break;
      case this.FLYIN:
        right += this.SPEED;
        if (right >= this.STARTPOS) {
          right = this.STARTPOS;
          phase = this.STOPP;
        }
        button.style.right = right + "px";
        break;
    }
    return phase;
  }

  this.installEventHandler = function() {
    if (anker.addEventListener) {
      anker.addEventListener('mouseover', this.start.bindAsEventListener(this), false);
      anker.addEventListener('mouseout', this.end.bindAsEventListener(this), false);
    } else {
      anker.attachEvent('onmouseover', this.start.bindAsEventListener(this));
      anker.attachEvent('onmouseout', this.end.bindAsEventListener(this));
    }
  }

  this.getAlt = function() {
    return alt;
  }

  this.installCSS = function() {
    button.style.right = this.STARTPOS + 'px';
  }

  this.init = function() {
    this.installEventHandler();
    var spans = anker.getElementsByTagName('span');
    for (var i = 0; i < spans.length; i++) {
      if (spans[i].className.split(" ").contains("bubble_button")) {
        button = spans[i];
        break;
      }
    }
    alt = button.getAttribute('alt'); 
    this.installCSS();
  }

  this.init();
}


var Bubbles = {
  bubbles : null,
  timer : null,
  timeout : 50,
  counter : 0,

  init : function() {
    Bubbles.bubbles = new Array();
    Bubbles.findBubbles();
    Bubbles.startAnimation();
  },

  nextFrame : function() {
    var ps = 0;
    for (var i = 0; i < Bubbles.bubbles.length; i++) {
      ps += Bubbles.bubbles[i].nextFrame();
    }
    Bubbles.startAnimation();
    Bubbles.counter++;
    /*
    window.status = Bubbles.counter;
    if (Bubbles.counter > 400) {
      window.clearTimeout(Bubbles.timer);
    }
    */
    if (Bubbles.counter == 10) { Bubbles.bubbles[0].setPhase(Bubbles.bubbles[0].FLYOUT); }
    if (Bubbles.counter == 15) { Bubbles.bubbles[0].setPhase(Bubbles.bubbles[0].FLYIN); }
    if (Bubbles.counter == 12) { Bubbles.bubbles[1].setPhase(Bubbles.bubbles[1].FLYOUT); }
    if (Bubbles.counter == 17) { Bubbles.bubbles[1].setPhase(Bubbles.bubbles[1].FLYIN); }
    if (Bubbles.counter == 14) { Bubbles.bubbles[2].setPhase(Bubbles.bubbles[2].FLYOUT); }
    if (Bubbles.counter == 19) { Bubbles.bubbles[2].setPhase(Bubbles.bubbles[2].FLYIN); }
    if (Bubbles.bubbles[3]) {
      if (Bubbles.counter == 18) { Bubbles.bubbles[3].setPhase(Bubbles.bubbles[3].FLYOUT); }
      if (Bubbles.counter == 23) { Bubbles.bubbles[3].setPhase(Bubbles.bubbles[3].FLYIN); }
    }
  },

  startAnimation : function() {
    Bubbles.timer = window.setTimeout("Bubbles.nextFrame()", Bubbles.timeout);
  },

  findBubbles : function() {
    var anker = document.getElementsByTagName('a');
    for (var i = 0; i < anker.length; i++) {
      if (anker[i].className.split(" ").contains('bubble')) {
        if (!anker[i].className.split(" ").contains('active')) {
          Bubbles.bubbles.push(new Bubble(anker[i], this));
        }
      }
    }
  }
}

function anim_init() {
  Bubbles.init(); 
}

/*
// jetzt im Layout
window.addEventListener ?
  window.addEventListener('load', anim_init, false) :
  window.attachEvent('onload', anim_init);
*/

