/* Begin snippets */

Element.implement({
	confirm: function(msg) {
		this.addEvent('click',function(e) {
			if (!confirm(msg)) {e.stop();}
		});
	}
});

/* End snippets */

window.addEvent("domready",function(){
	/*
	 * Uiteindelijk net als het shopframework moet dit in losse classes zitten.
	 */
	$$('.confirm').each( function(el){el.confirm((el.get('rel')? el.get('rel') : 'Weet u zeker dat u door wilt gaan?') ); } );
	
	document.getElements('textarea.editor').each(function(el) {
		CKEDITOR.replace(el.id, {
			enterMode : 2
		});
	});
	
	$$('a.delete').each(function(el) {
		el.addEvent('click',function(e) {
			e.stop();
			if (!confirm('Weet je zeker dat je dit item wilt verwijderen?')) {
				e.stop();
			} else {
				location.href = el.href;
				e.stop();
			}
		});
	});

	$$('.iframe').each(function(el){
		new Element('iframe',{'src':el.get('href')}).inject(el, 'after').setStyles({'backgroundColor':'#fff','width':'100%','height':'250px'});
		el.destroy();
	});
/*	
	var panel = document.id('adminfooter');
	if (panel) {
		panel.setStyle('visibility','visible');
		var slideFx = new Fx.Tween(panel,{link:'wait'});
		var opacityFx = new Fx.Tween(panel,{link:'cancel',duration:1000});
		var panelStatus = ((Cookie.read('adminpanel_open') == 'true') ? true:false);
		var panelHeight = panel.getSize().y.toInt();
		(panelStatus ? document.id(document.body).setStyle('marginBottom',panelHeight) : document.id(document.body).setStyle('marginBottom',0));
		panel.store('open',panelStatus).setStyles({
			'bottom':((panelStatus) ? 0 :(-1 * panelHeight)+12),
			'opacity':((panelStatus) ? 1 :.01)
		}).addEvents({
			'mouseenter':function(){
				opacityFx.start('opacity',1);
			},
			'mouseleave':function(){
				if (this.retrieve('open') == false){
					opacityFx.start('opacity',.01);
				}
			},
			'click':function(e){
				if (!e.target.getParent('ul')) {
					if (this.retrieve('open') == false){
						Cookie.write('adminpanel_open', true,{domain: window.location.host,path:'/'});
						this.store('open',true);
						document.body.tween('marginBottom',[panelHeight]);
						slideFx.start('bottom',[0]);
					} else {
						Cookie.write('adminpanel_open', false,{domain: window.location.host,path:'/'});
						this.store('open',false);
						document.body.tween('marginBottom',[0]);
						slideFx.start('bottom',[(-1 * panelHeight)+12]);
					}
				}
			}
		});
	}
	*/
	/* end admin panel */
	//alert(window.location.host);
});

