var oldtext = '';
var isOver = false;
var imgElem = false;

var rules = {
	'input#searchfield' : function(element){
		element.onfocus = function() {	
			if (this.value=='Suchwort eingeben')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Suchwort eingeben';				
		}		
	},
	'input#tx_tipafriend_name' : function(element){		

		element.onfocus = function() {		
			if (this.value=='Ihr Name: *')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Ihr Name: *';				
		}		
	},
	'input#tx_tipafriend_email' : function(element){
		element.onfocus = function() {	
			if (this.value=='Ihre E-Mail: *')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Ihre E-Mail: *';				
		}		
	},
	'input#tx_tipafriend_recipient' : function(element){
		element.onfocus = function() {	
			if (this.value=='E-Mail des Empfängers: *')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='E-Mail des Empfängers: *';				
		}		
	},
	'input#tx_tipafriend_pi1_captcha_response' : function(element){
		element.onfocus = function() {	
			if (this.value=='Bildwort *')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Bildwort *';				
		}		
	},	
	
	'textarea#tx_tipafriend_message' : function(element){
		element.onfocus = function() {	
			if (this.value=='Ihre Mitteilung an den Empfänger')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Ihre Mitteilung an den Empfänger';				
		}	
		element.onchange = function() {
			tmp=this.scrollHeight;
			if (tmp>225) 
				this.value = oldtext;	
		}
		element.onkeyup = function() {
			tmp=this.scrollHeight;
			if (tmp>225) 
				this.value = oldtext; 
			oldtext=this.value;

		}		
	},	
	'input#tx-sremailsubscribe-pi1-first_name' : function(element){
		element.onfocus = function() {	
			if (this.value=='Vorname')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Vorname';				
		}		
	},	
	'input#tx-sremailsubscribe-pi1-last_name' : function(element){
		element.onfocus = function() {	
			if (this.value=='Nachname')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Nachname';				
		}		
	},	
	'input#tx-sremailsubscribe-pi1-email' : function(element){
		element.onfocus = function() {	
			if (this.value=='E-Mail *')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='E-Mail *';				
		}		
	},	
	'input#tx-sremailsubscribe-pi1-module_sys_dmail_html' : function(element){
		element.onclick = function() {	
			if (this.checked)
				document.getElementById('tx-sremailsubscribe-pi1-module_sys_dmail_plain').checked=false;	
			else
				document.getElementById('tx-sremailsubscribe-pi1-module_sys_dmail_plain').checked=true;
		}		
	},	
	'input#tx-sremailsubscribe-pi1-module_sys_dmail_plain' : function(element){
		element.onclick = function() {	
			if (this.checked)
				document.getElementById('tx-sremailsubscribe-pi1-module_sys_dmail_html').checked=false;	
			else
				document.getElementById('tx-sremailsubscribe-pi1-module_sys_dmail_html').checked=true;
		}			
	},
	'.csc-textpic-image img': function(element){
		element.onmouseover = function() {	
			window.clearTimeout(isOver);
			objPar = this.parentNode;
			if (objPar.tagName!='DT')
				objPar = objPar.parentNode;
				
			if (objPar.nextSibling) {
				objPar.nextSibling.style.display = 'block';
				objPar.nextSibling.style.height = parseInt(this.offsetHeight)-10+'px';		
				imgElem = objPar;
			}
		}	
		element.onmouseout = function() {	
			//var obj = this;
			objPar = this.parentNode;
			if (objPar.tagName!='DT')
				objPar = objPar.parentNode;
			if (objPar.nextSibling) 
				isOver = window.setTimeout(function() {objPar.nextSibling.style.display = 'none';},100);
			
		}		
	},
	'.csc-textpic-caption': function(element){
		element.onmouseover = function() {	
			window.clearTimeout(isOver);
		}
		element.onmouseout = function() {	
			var obj = this;
			isOver = window.setTimeout(function() {imgElem.nextSibling.style.display = 'none';},100);		
		}			
	
	},
	'input#user' : function(element){
		element.onfocus = function() {	
			if (this.value=='Ihr Benutzername')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Ihr Benutzername';				
		}		
	},
	'input#pass' : function(element){
		element.onfocus = function() {	
			if (this.value=='Ihr Passwort')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Ihr Passwort';				
		}		
	},
	'input#ccctinp' : function(element){
		element.onfocus = function() {	
			if (this.value=='Titel der Veranstaltung, Veranstalter, Ort der Veranstaltung')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Titel der Veranstaltung, Veranstalter, Ort der Veranstaltung';				
		}		
	},
	'input#cclinp' : function(element){
		element.onfocus = function() {	
			if (this.value=='link zu Ihrer Website (www.netzwerkpartner.de)')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='link zu Ihrer Website (www.netzwerkpartner.de)';				
		}		
	},
	'input#ccsinp' : function(element){
		element.onfocus = function() {	
			if (this.value=='Datum (Format: JJJJ-MM-TT)' || !this.isChanged)
				this.value='';				
		}
		element.onchange = function() {	
			this.isChanged = true;				
		}		
		element.onblur = function() {	
			if (this.value=='')
				this.value='Datum (Format: JJJJ-MM-TT)';				
		}		
	},
	'input#ccsinp' : function(element){
		element.onfocus = function() {	
			if (this.value=='Datum (Format: JJJJ-MM-TT)' || !this.isChanged)
				this.value='';				
		}
		element.onchange = function() {	
			this.isChanged = true;				
		}		
		element.onblur = function() {	
			if (this.value=='')
				this.value='Datum (Format: JJJJ-MM-TT)';				
		}		
	},	
	'input#query' : function(element){
		element.onfocus = function() {	
			if (this.value=='Suchwort eingeben')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Suchwort eingeben';				
		}		
	},
	'input#cal_searchfield' : function(element){
		element.onfocus = function() {	
			if (this.value=='Suchwort eingeben')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Suchwort eingeben';				
		}		
	},	
	'a#printlink' : function(element){
		element.onclick = function() {
			document.getElementById('cal_printfield').value=document.getElementById('query').value;
			document.getElementById('printform').submit();
			return false;			
		}
	
	},
	'textarea#cal_event_description'  : function(element){
		if (element.value=='')
			element.value='Kurzbeschreibung';
		element.onfocus = function() {	
			if (this.value=='Kurzbeschreibung')
				this.value='';				
		}
		element.onblur = function() {	
			if (this.value=='')
				this.value='Kurzbeschreibung';				
		}			
		element.onkeyup = function() {
			if (this.value.length>200) {
				this.value=this.value.substr(0,200);
			}
			else if (this.value=='')
				this.value='Kurzbeschreibung';			
		}
	}
	
}	

Behaviour.register(rules);	