var cvLiteBox = new Class({
	
	//implements
	Implements: [Options,Events],

	//options
	options: {
		class: '.size-medium',
		background: '#333',
		opacity: 0.5,
		transition: ''
	},
	
	//initialization
	initialize: function(options) {
		//set options
		this.setOptions(options);
		
		//variables
		self = this;
		this.images = $$(this.options.class); //images array
		
		
		//add events
		this.images.addEvent('click',function(i){
			i.stop();
			
			self.show(i);
		});
	},
	
	show: function(i){
		//var src = i.getParent('a');
		
		alert('Show large image: ');
	}
});

window.addEvent('domready',function() {
	/* Create an overlay */
	var olay = new Overlay(document.body, { 
		duration: 400,
		onOpen: function(){
				//new Element('div',{'id':'loader'}).inject(this.overlay);
				var image = new Element('img',{'src':'http://crispijnverkade.nl/blog/wp-content/themes/crispijnverkade/images/loading.gif',
										'styles': {
        										'opacity': 1.0
												}
										}).inject(this.overlay);
			}
	});
	
	olay.open();
	
	/* Get the image path */
	var base = 'http://crispijnverkade.nl/blog/wp-content/themes/crispijnverkade/images/'
	images = [base + 'h_portfolio.jpg',
			  base + 'h_blog.jpg',
			  base + 'h_projects.jpg',
			  base + 'h_about.jpg',
			  base + 'h_contact.jpg'];
	
	$$('img').each(function(i){
		images.push(i.getAttribute('src'));
	});
	
	/* Preload the images */
	var loading = new Asset.images(images, {
		onProgress: function(counter,index) {
			
		},
		onComplete: function(){
			olay.close();
		}
	});
	
	/* Add nice scrolling */
	new SmoothScroll({duration:500});
	
	/** Add Zoom images */
	new cvLiteBox({});
	
	/* Add syntax highlighter */
	$$('pre').set('name','code');
	dp.SyntaxHighlighter.ClipboardSwf = 'http://crispijnverkade.nl/blog/wp-content/themes/crispijnverkade/syntaxhighlighter/clipboard.swf';
	dp.SyntaxHighlighter.HighlightAll('code');

	$$('#content a').each(function(a){
		if(a.target && a.target.test(/^_blank/i)){
			a.addClass('external');
		}
	});
	
	/* Menu images*/
	$$('#menu li img').each(function(h){
		var src = h.getProperty('src');
		h.addEvents({
			'mouseenter': function(m){
				h.setProperty('src', h.getProperty('title'));
			},
			'mouseleave': function(m){
				h.setProperty('src', src);
			}
		});
	});
	
	/* Add menu interface */
	var menu = new cvMenu();
});