window.addEvent('domready', function() {
	if(!(Browser.Engine.name == 'trident' && Browser.Engine.version < 5)) {
	$$('img.shop').addEvents({
		'mouseenter': function() {
			var rel = this.getProperty('src');
			this.setProperty('src', this.getProperty('rel'));
			this.setProperty('rel', rel);
		},
		'mouseleave': function() {
			var rel = this.getProperty('src');
			this.setProperty('src', this.getProperty('rel'));
			this.setProperty('rel', rel);
		}
	});
	}
	
	var myTips = new Tips('.thisisatooltip', { offsets:  {'x': 20, 'y': 20 }, className: 'tooltip' });
	input_tooltip_inside();
	if($('step')) {
		var step = $('step').get('html');
	}
	var myAccordion = new Accordion($('accordion'), 'h1.toggler', 'div.element', { display: step });
	$$('.gallery').each(function(elm, index) {
		if(index > 0) {
			elm.setStyle('opacity', 0);
		}
	});
	fadeHeader.delay(1000);
});

function fadeHeader() {
	var found = false;
	var last = null;
	$$('.gallery').each(function(elm, index) {
		if(elm.getStyle('opacity') == 0) {
			var myFx = new Fx.Tween(elm, {
				onComplete: function() {
					fadeHeader.delay(5000);
				},
				duration: "long"
			});
			if(!found) myFx.start('opacity', 1);
			found = true;
			return;
		}
		last = elm;
	});
	if(!found) { //alle staan aan, dus weer resetten
		$$('.gallery').each(function(elm, index) {
			if(elm != last && index != 0) {
				elm.setStyle('opacity', 0);
			}
		});
		var myFx = new Fx.Tween(last, {
			onComplete: function() {
				fadeHeader.delay(5000);
			},
			duration: "long"
		});
		if(!found) myFx.start('opacity', 0);		
	}
}

function input_tooltip_inside() {
	$$('input[type=text][title]')
		.each(function(elm) {
			if (elm.get('value') == '' || elm.get('value') == elm.get('title')) {
				elm.set('value', elm.get('title')).addClass('gray');
			}
			elm.addEvents({
			    'focus': function() {
					if (this.get('value') == this.get('title')) {
						this.set('value', '').removeClass('gray');
					}
			    },
				'blur': function() {
					if (this.get('value') == '') {
						this.addClass('gray').set('value', this.get('title'));
					}
				}
			});
		});
}
