$(function () {
	
	$("a.zoom").fancybox({
		'transitionIn'  :	'elastic',
		'transitionOut' :	'elastic',
		'titlePosition' :	'over',
		'speedIn'       :	600, 
		'speedOut'      :	200, 
		'overlayShow'   :	false,
		'transitionIn'  :	'bounce',
		'transitionOut' :	'bounce',
		'easingIn'      :	'easeOutBack',
		'easingOut'     :	'easeInBack',
		'speedOut'      :	600,
		'speedIn'       :	600
	})
	
	$('.show-more').click(function (e) {
		var i = $(this).attr('rel')
		$('#'+i).toggleClass('hidden')
		e.preventDefault();
	})
	
	var buttons = $('#header .hl').toArray()
	appearQueue(buttons)
		
	$('.em').each(function () {
		var d = $(this).attr('rel')
		d = d.split(';')
		$(this).attr('href', 'mailto:'+d[1]+'@'+d[0]).html(d[1]+'@'+d[0])
	})
	
	$('.tip h3').append('<span class="inner">&nbsp;</span>')
	
	$('.spot').hover(
		function () {
			var rel = $(this).attr('rel')
			$('#'+rel).show()
		},
		function () {
			var rel = $(this).attr('rel')
			$('#'+rel).hide()
		}
	)
	
	$('.tip .tip-text').each(function () {
		$(this).addClass('clearfix').wrapInner('<div class="inner-text">')
		$('.inner-text', this).addClass('clearfix')
		
		$('<div>').addClass('cr-tl').addClass('png').prependTo(this)
		$('<div>').addClass('cr-tr').addClass('png').prependTo(this)
		$('<div>').addClass('cr-bl').addClass('png').prependTo(this)
		$('<div>').addClass('cr-br').addClass('png').prependTo(this)
		$('<div>').addClass('cr-l-t').addClass('png').prependTo(this)
		$('<div>').addClass('cr-l-l').addClass('png').prependTo(this)
		$('<div>').addClass('cr-l-r').addClass('png').prependTo(this)
		$('<div>').addClass('cr-l-b').addClass('png').prependTo(this)
	})
})

function appearQueue(list) {
	if (list.length > 0) {
		var elem = list.pop()
		$(elem)
			.animate(
					{opacity: 1.0},
					{duration: 240, easing: 'easeInElastic',
						complete: function () {
							appearQueue(list)
						}
					}
				)
	} else {
		$('#header .hl').hover(
				function () { $(this).stop().animate({opacity: .6}, {duration: 500, easing: 'easeOutQuad'}) },
				function () { $(this).stop().animate({opacity: 1}, {duration: 200, easing: 'easeOutQuad'}) }
			)
	}
}
