	window.addEvent("domready",function() {

		/* BOUNCE MENU */
		
		var open = 216;
		var close = 22;
				
		var zappers = $$(".zap");
		var fx = new Fx.Elements(zappers, {wait: false, duration: 400, transition: Fx.Transitions.Quint.easeOut});
		zappers.each(function(aZap, i) {
			aZap.addEvent("mouseenter", function(event) {
				var o = {};
				o[i] = {height: [aZap.getStyle("height").toInt(), open]}
				zappers.each(function(other, j) {
					if(i != j) {
						var h = other.getStyle("height").toInt();
						if(h != close) o[j] = {height: [h, close]};
					}
				});
				fx.start(o);
			});
		});
		
		/* COLLAPSE EXTRA */
		
		if(eh = Cookie.get("extraheight")) $('extrarow').setStyle('height', eh+'px');
		
		if($('extrarow').getStyle('height').toString().toInt()==350) { 
			$('min').setStyle('display','');
			$('plus').setStyle('display','none');
		}
		else {
			$('plus').setStyle('display','');
			$('min').setStyle('display','none');
		}
		
		$('extra_collapse').addEvent('click',function(e){
			new Event(e).stop();
			
			var collapsebox = $('extrarow');
			var open = 350;
			var close = 50;
			
			var fx = new Fx.Styles('extrarow', {wait: false, duration: 400, transition: Fx.Transitions.Quint.easeOut});
			
			if(collapsebox.getStyle('height')=='50px') {
				fx.start({'height': open});
				/* SET COOKIE */
				Cookie.set('extraheight', open, {duration: 14 , path: "/"}); // save 14 days
				$('min').setStyle('display','');
				$('plus').setStyle('display','none');
			}
			else {
				fx.start({'height': close});
				/* SET COOKIE */
				Cookie.set('extraheight', close, {duration: 14 , path: "/"}); // save 14 days
				$('plus').setStyle('display','');
				$('min').setStyle('display','none');
			}
			
		});

	});
	
	/* DROPBOX CLASS (only choice, autocomplete later) */
	
	var DropBox = new Class({
    	initialize: function(data,field,auto){
        	this.data = data;
        	this.field = field;
        	this.auto = auto;
        	this.box = null;
        	
        	theBox = this.field+'box';
	
			/* MAKE BOX IF DON'T EXIST */
			if(!$(theBox)) {
			
				inputbox = $(this.field);
			
				/* getPosition */
				obj = inputbox;				
				var curleft = curtop = 0;
				if (obj.offsetParent) {
					curleft = obj.offsetLeft;
					curtop = obj.offsetTop;
					while (obj = obj.offsetParent) {
						curleft += obj.offsetLeft;
						curtop += obj.offsetTop;}}
			
				xpos = curleft;
				ypos = curtop;
			
				/* getSize */
				toth = 0;
				inw = inputbox.getStyle('width').toInt();
				butw = 0
				
				var next = inputbox.getNext();
				while (next.getTag()!="a") {
					next = next.getNext();
				}
				butw = next.getStyle('width').toInt();				
				
				totw = inw + butw;
				topm = inputbox.getStyle('height').toInt()+4; /* +4 correction ... don't know why */
				
				var dropdown = new Element('div').setProperty('id',theBox).addClass('dropbox').setStyles({
					width: totw + 'px',
					position: 'absolute',
					left: (xpos)+'px',
					top: (ypos+topm)+'px',
					'z-index': 10,
					'display': 'none'
				}).setOpacity(0.9);
				
				this.box = dropdown;
				$('contentrow').adopt(dropdown);
			}
    	},
    	
    	hideIt: function(){
			this.box.setStyle('display','none').empty(); 
		},
    	
		dropIt: function() {

			theBox = this.box;
			
			if(theBox.getStyle('display')=='block') {
				theBox.setStyle('display','none').empty();
			}
			else {
				theBox.setStyle('display','block');
				inputbox = $(this.field);
				sVal = inputbox.getValue();
			
				this.data.each(function(item,index){
					var aRow = new Element('a').addClass('dropitem').setStyle('height','16px').setText(item);
					toth = toth + 16;
					aRow.addEvents({
						'click':function(){
							inputbox.value = this.getText();
							theBox.setStyle('display','none').empty();
						},
						'mouseover':function(){
							aRow.setStyles({
							'background-color':'#555',
							'color':'#FFF',
							'cursor':'pointer'
							});
						},
						'mouseleave':function(){
							aRow.setStyles({
							'background-color':'#FFF',
							'color':'#222',
							'cursor':'default'
							});
						}
					});
					
					theBox.adopt(aRow);
				});
			
				if(toth<128) theBox.setStyle('height',toth+'px');
				else theBox.setStyle('height','128px');

				document.addEvent('click',function tralala(){
					theBox.setStyle('display','none').empty(); 
					document.removeEvent('click',tralala);
				});

			}
		}
    	
	});
