$(document).ready(function() {
		
	// image transition code
	$('div.photoset').each(function(index) {
		// create ids on prev, next links
		$(this).prev('div.nav').find('a.prev').attr('id', 'prev-' + index);
		$(this).prev('div.nav').find('a.next').attr('id', 'next-' + index);
		// init cycle plugin
		$(this).cycle({
			timeout: 0,
			speed: 500,
			prev: 'a#prev-' + index, // reference correct nav links
			next: 'a#next-' + index, // reference correct nav links
			before: function() {
				var width = $(this).width();
				var height = $(this).height();
				// move close link with image size
				if(width > 0) { // if needed by webkit
					$(this).parent().prev('div.nav').find('a.close').animate({ 'margin-left': (width - 113) }, 300);
				}
				// keep other sections in correct horizontal position
				$(this).parent().css({ height: height + 15 });
				
				// counter
				var set = $(this).parents('div.photoset').find('img');
				var total = set.length;
				var position = set.index($(this)) + 1;
				// update values
				$(this).parents('div.scroller').find('span.current').text(position);
				$(this).parents('div.scroller').find('span.total').text(total);
				
			}
		});
	});
	
	// open and close accordion menu items
	$('div#accordion h2').click(function() {
		if($.browser.msie && $.browser.version < 8) {
			$(this).next().toggle();
		} else {
			$(this).next().slideToggle('normal');
		}
		$(this).toggleClass('open'); // add hover style when scroller is opened
		return false;
	}).next().hide(); // initially hide all div.scroller elements
	
	// manually close accordion menu item with link
	$('a.close').click(function() {
		$(this).parents('div.scroller').prev('h2').click();
		return false;
	});
	
	var email = $.rotate("znvy@eboinaqrecynax.pbz");
	$("a.email").attr("href", "mailto:" + email).text(email);
	
	// resize window to fullscreen
	// window.moveTo(0, 0);
	// window.resizeTo(screen.width, screen.height);
	
});
