// JavaScript Document

	// Load Event function

	function addLoadEvent(func) {	
		var oldonload = window.onload;
		if (typeof window.onload != 'function'){
			window.onload = func;
		} else {
			window.onload = function(){
			oldonload();
			func();
			}
		}
	}
	
	// Suche

	function SearchField () {
		var str = "Suchbegriff eingeben ...";
		var q = document.getElementById('words');
		q.value = str;
		//q.onfocus = function() { q.value="";q.style.color="#000"; }
		q.onfocus = function() { q.value=""; }
	}	

	function NewsletterField () {
		var str = "E-Mail Adresse hier eintragen";
		var q = document.getElementById('email');
		q.value = str;
		//q.onfocus = function() { q.value="";q.style.color="#000"; }
		q.onfocus = function() { q.value=""; }
	}	

	// imagerotator

	function imagerotator () {
		if ($('ImgRotator')) {
			var r = ImgRotator.initialize('ImgRotator');
		}
	}	

	function mainload (PID) {
	}

	function mainunload (PID) {
		if (PID == 374) {
			GUnload();
		}
	}

	// onload="load()" onunload="GUnload()"


	sfHover = function() {
		var sfEls = document.getElementById("topicsul").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" hover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
			}
		}
	}
	if (window.attachEvent) addLoadEvent(sfHover);

// loadEvents

addLoadEvent(SearchField);
addLoadEvent(NewsletterField);
addLoadEvent(imagerotator);

/*	accessibleview
* @author: sindre wimberger // wimberger@echonet.at
* @version: 1.0 2010-03-15
* @depencies: prototype, scripty2
* @usage:
 var hdc = new accessibleview({
	button: 'handicap-button',
	container: 'a-wrap',
	showclass: 'help',
	hideclass: 'nohelp',
	url: window.location.pathname
 });	 
* @info: Barrierefreibedienung wird dnyamisch ein uns ausgeblendet und zusätzlich ein AJAX request abgesetzt.
*/
var accessibleview = {
	stat: true,
	show: false,
	options: {
		button: 'specialhandler',
		container: 'special'
	},
  initialize: function() {
		this.button = $(this.options.button);		  
		this.container = $(this.options.container);		  
		if(!this.button || !this.container) {return false;}
		if(!this.button.hasClassName('close')) {return false;} 
		this._observe();		
	},
	_observe: function() {
		var anchor = this.button.down('a');
		if(anchor) {
			this.anchor = anchor;
			this.url = anchor.readAttribute('href');
		}
		this.anchor.observe('click', function(ev) {this._toggle(ev);}.bind(this));			
	},
	_toggle: function(e) {
		if(this.stat) {
		Event.stop(event);
			this.stat = false;
			new Ajax.Request(this.url, {
				method: 'get'
			});
			this._hide();
		}
	},
	_hide: function() {		
		new Effect.Morph(this.container, {
			style: 'height:0px;',
			transition: Effect.Transitions.spring,
			duration: .5,
			afterFinish: function() {
				this.button.removeClassName('close').addClassName('open');
				this.anchor.update(this.button.readAttribute('data-off'));
				this.anchor.href= this.url.replace(/off/g, "on");
			}.bind(this)	
		});
	}
}

function commercialview () {
	 accessibleview.initialize();
}

addLoadEvent(commercialview);


