// Initialisierung von allen Elementen auf der Seite
function initPage()
{
	//Verhalten	
	$$('a.mail').each( function(element) {
		element.innerHTML = element.innerHTML.replace(/\(at\)/,'@'); 
		element.href = 'mailto:'+element.innerHTML.replace(/\(at\)/,'@');
	});
	
	$$('img[align=left]').each( function(element) {
		element.addClass('left');
	});	

	$$('img[align=right]').each( function(element) {
		element.addClass('right');
	});

	$$('input.clear').each( function(element) {
		element.onfocus = function () {if(this.value==this.defaultValue) this.value=''; this.removeClass('clear'); return false;},
		element.onblur = function () {if(this.value=='') this.value = this.defaultValue; this.addClass('clear'); return false;}
	});

	$$('table').each(function(element){
		var trs = element.getElementsBySelector('tr');
		for(i=0; i<trs.length; i++)
		{
			if(i % 2 == 0)
			{
				trs[i].addClass('even');
			}
			else
			{
				trs[i].addClass('odd');
			}
			
			markCellType = function (cellType, row) {
				var cells = row.getElementsBySelector(cellType);
				for(j=0; j<cells.length; j++)
				{
					cells[j].column = j+1;
					cells[j].addClass('column'+(j+1));

					if(j % 2 == 0)
					{
						cells[j].addClass('even');
					}
					else
					{
						cells[j].addClass('odd');
					}
				}
			}
			
			markCellType('td', trs[i]);
			markCellType('th', trs[i]);	
		}
	});
}
window.addEvent('domready', initPage);

