document.observe('dom:loaded', function() {
	$$('.navlink[rel]').invoke('observe', 'click', function(event) {
		event.element().blur();
		event.stop();
		if ($(this.rel)) {
		if (Prototype.Browser.IE6) $(this.rel).scrollTo();
		else new Effect.ScrollTo(this.rel, { duration: 0.6 });
		}
	});
	
	// feature tips
	$('intro').select('.tipped[title]').each(function(element) {
	  var title = element.getAttribute('title');
	  var wrap = new Element('div').update(title);
	  wrap.insert({ top: new Element('p').update(element.down('span').innerHTML.replace(':', '')) });
								   
	  new Tip(element, wrap, { className: 'featureTip', border: 0, radius: 0, target: 'featuresImage', hook: { target: 'topRight', tip: 'topRight' }, effect: 'appear', delay: 0.2, hideAfter: 0.8, hideOn: false, duration: 0.3, viewport: false });
	  element.title = '';
    });
	
	Projects.createIdeas('lightview');

	// supported browsers
	new Tip('supportedBrowsersTooltip', $$('.supportedBrowsers')[0].cloneNode(true), {
		hook: { target: 'topRight', tip: 'bottomLeft' },
		stem: 'bottomLeft',
		width: 'auto'
	});

	$('confirmFirst').observe('click', function(event) {
	  event.stop();
	  event.element().blur();
	  $('confirm').show();
	});
	  
	$('no').observe('click', Element.hide.curry('confirm'));
	
	// changelog
	new Ajax.Request('../lightview/changelog/?format=json', {
		method: 'get',
		onComplete: function(transport) {
			var firstEntry = transport.responseJSON.first(),
			txt = firstEntry.title + '<br\/>\n' + firstEntry.description;
			txt = txt.gsub('\r\n', '<br/>');
			txt = txt.gsub(/\s\s/, '&nbsp;&nbsp;');
			$('download').down('div.code').update(txt);
		}
	});
});