var Cooliris = new Class({

	initialize: function() {

		// Firefox
		if(!window.piclens && typeof PicLensContext != 'undefined') {
			window.piclens = new PicLensContext();
		}

		// Internet Explorer
		if(!window.piclens) {
			try { 
				window.piclens = new ActiveXObject("PicLens.Context");
			}
			catch (e) {
			}
		}

		// Safari
		/*
		 * Funktioniert nicht
		if(!window.piclens && navigator.mimeTypes['application/x-cooliris']) {
			window.piclens = document.createElement('object', {
				'type': 'application/x-cooliris',
				'style': 'display: none; width: 0; height: 0;'
			});
			document.documentElement.appendChild(window.piclens);
		}
		*/
	},

	start: function(url) {
		if(!window.piclens) {
			return true;
		}
		if(!url) {
			url = this.findFeed();
		}
		window.piclens.launch(url, '', '');
		return false;
	},

	findFeed: function() {
		var feeds = $$('link[rel=alternate]');
		if(feeds.length > 0) {
			return feeds[0].get('href');
		}		
		return false;
	}
});