document.onkeydown = function(e) {
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  var ctrlKey = (window.event) ? event.ctrlKey : e.ctrlKey; 
  if (keycode==76 && ctrlKey==true) {
    Effect.Appear('adminlogin');
  }

}
Event.observe(window, 'load', init);

var rules = {
	'#div-directentry-nav' : function(el) {
	 	new Ajax.Updater(el, '/content/ajax/getdirectnavi.php',{onComplete:function(){Effect.Appear(el,{duration:2});}});
	},
	'#suche' : function(el) {
		el.onsubmit = function() {
			Element.hide($('suche'));
			Element.show($('waitbar'));
			
		
		}
	},
	'.mainnavi' : function(el) {
		//el.style.cursor='pointer';
		el.onclick = function() {
	 	//new Ajax.Updater($('div-subnav'), '/content/ajax/getleftnavi.php',{parameters:'sub='+el.getAttribute('rel'),onComplete:function(){Effect.SlideDown($('div-subnav'),{});}});
		
		};
	},
	'#div-subnav a' : function(el) {
		el.onmouseover = function() {
			if (!$('subtitle')) return;
			var id = 'dnavi_' + el.getAttribute("rel");
			Element.removeClassName(id,'entry-low');	
			Element.addClassName(id,'entry-high');	
			var text = el.innerHTML;
			$('subtitle').innerHTML= text;
		
		},
		el.onmouseout = function() {
			var id = 'dnavi_' + el.getAttribute("rel");
			Element.removeClassName(id,'entry-high');	
			Element.addClassName(id,'entry-low');	
			$('subtitle').innerHTML='';
		}
	
	},
	
	
	'.personalnavi' : function(el) {
		el.style.width  = 435 + 'px';
		el.style.height = 121 + 'px';
		el.style.position = 'relative';
		el.style.backgroundImage= 'url(/content/img/personalfahne.gif)';
	},
	'#gmap' : function(el) {
		el.style.width = '450px';	
		el.style.height = '500px';
		//el.src='/content/pages/kontakt/gmap.php';
	
	},
	'.textnavi' : function(el) {
	  var nimg = '/content/img/' + el.id + '.jpg';	
	  el.style.backgroundImage = 'url('+nimg+')';
	},
       '.h3' : function(el) {
	   el.style.textTransform = 'uppercase';	
	},
	'.h4' : function(el) {
	   el.style.textTransform = 'uppercase';	
	},
	'.scrollto' : function(el) {
		el.style.cursor='pointer';
		el.onclick = function() {
			var position = el.getAttribute('rel');
			if (position == null) position='pagetop';
			new Effect.ScrollTo(position);
		}
	},
	'.hauskiste' : function(el) {
		el.style.cursor = 'pointer';
		var active = false;
		el.onmouseover = function () {
    		$$('.hauskiste p').each(function(e){Element.hide(e)});
		   	Element.show(el.childNodes[1]);
		},
		el.onmouseout = function () {
		  Element.hide(el.childNodes[1]);
		},
		el.onclick = function() {
			
			if (el.hasClassName('drlink')) self.location = el.id;
		}

	},
	
	'.morenews' : function(el) {
		el.style.cursor='pointer';
		el.style.marginLeft='.5em';
		el.title='mehr Infos um Thema';
		el.onclick = function() {
		  Element.hide(el);
		  Effect.BlindDown(el.getAttribute('rel'));
		}
	
	},
		// neues Glossarteil einfŸgen:
	'#newitemstart': function(el) {
		el.onclick = function() {
		var item  = $F('newitem');
		if (item.length<3) return null;
		new Ajax.Updater('dummy', '/content/ajax/insertnewitem.ajax.php', {
			parameters:'item=' + encodeURIComponent(item), 
			evalScripts:true, 
			asynchronous:true,
			onComplete : function() {
			 	self.location.reload();
			 }
			}		
		);
	  }
	},
	// interen Glossarverlinkung:	
	'#glossliste li' : function(el) {
		el.style.cursor='pointer';
		el.onclick = function() {
			moveTo('glosscontent',el.getAttribute('rel'));			
		}
	}
};

function init(event) {
    $$('.hauskiste p').each(function(e){Element.hide(e)});
	Behaviour.register(rules);
	Behaviour.apply(rules);
}

function moveTo(container, element) {
 
  Position.prepare();
  container_y = Position.cumulativeOffset($(container))[1]
  element_y = Position.cumulativeOffset($(element))[1]
  new Effect.Scroll(container, {x:0, y:(element_y-container_y)});
  return false;
}

Effect.Scroll = Class.create();
Object.extend(Object.extend(Effect.Scroll.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);   
    var options = Object.extend({
      x:    0,
      y:    0,
      mode: 'absolute'
    } , arguments[1] || {}  );
    this.start(options);
  },
  setup: function() {
    if (this.options.continuous && !this.element._ext ) {
      this.element.cleanWhitespace();
      this.element._ext=true;
      this.element.appendChild(this.element.firstChild);
    }
     
    this.originalLeft=this.element.scrollLeft;
    this.originalTop=this.element.scrollTop;  
   
    if(this.options.mode == 'absolute') {
      this.options.x -= this.originalLeft;
      this.options.y -= this.originalTop; 
    } else {
   
    }
  }, 
  update: function(position) {
    this.element.scrollLeft = this.options.x * position + this.originalLeft;
    this.element.scrollTop  = this.options.y * position + this.originalTop; 
  }
});



