if (!($.browser.msie && ($.browser.version) < 8)) {
	$('.proj-menu a').click(function(){
		switchMenus($(this).closest('.menu-item'),$(this).closest('span')[0]);
		});
	$('.next a').click(function(){
		next('#'+$(this).closest('.menu-item')[0].id);
		});
	$('.galleryclicky').click(function(){
		next('#'+$(this).closest('.menu-item')[0].id);
		});
	$('.prev a').click(function(){
		prev('#'+$(this).closest('.menu-item')[0].id);
		});

	function switchMenus(section, ancestor) {
		var galleryHTML="";
		for ( i=0 ; i<galleryData[section[0].id][ancestor.id][0].length ; i++ ) {
			// add code for image
			if (galleryData[section[0].id][ancestor.id][0][i]=='img'){
				if (i<10) {i="0"+i};
				galleryHTML=galleryHTML+'<img src="/img/projects/'+studiosOrAlaska+'/'+section[0].id+'/'+ancestor.id+'-'+i+'.jpg"'
				if (i==00) {
					galleryHTML=galleryHTML+' class="active"';
					}
				galleryHTML=galleryHTML+' alt="">'
				}
			// add code for nokia-film
			if (galleryData[section[0].id][ancestor.id][0][i]=='nokia-film'){
				if (i<10) {i="0"+i};
				galleryHTML=galleryHTML+'<iframe src="http://player.vimeo.com/video/19971314?autoplay=1&amp;loop=1" width="960" height="180" frameborder="0"';
				if (i==00) {
					galleryHTML=galleryHTML+' class="active"';
					}
				galleryHTML=galleryHTML+'></iframe>'
				}
			}
		section.find('.image-gallery').html(galleryHTML);

		section.find('.current-image-no').attr('src','/img/image-counter/1.gif');
		section.find('.max-image-no').attr('src','/img/image-counter/'+galleryData[section[0].id][ancestor.id][0].length+'.gif');
		if (sIFR.isActive) {
			section.find('.proj-menu object').each(function(i){
				sIFR.getReplacementByFlashElement($(this)[0]).changeCSS(
					'a:hover {color: black; text-decoration: underline;} a {color: black; text-decoration: none; text-align:center;}'
					);
				});
			sIFR.getReplacementByFlashElement($("#"+ancestor.id+" object")[0]).changeCSS(
					'a:hover {color: black; text-decoration: underline;} a {color: black; text-decoration: underline; text-align:center;}'
				);
			sIFR.getReplacementByFlashElement(section.find('.proj-text object')[0]).replaceText(galleryData[section[0].id][ancestor.id][1]);
			} else {
			section.find('.proj-text').html(galleryData[section[0].id][ancestor.id][1]);
			}

		};

	function next(sectionID) {
		var $active = $(sectionID+' .image-gallery .active');
		if ( $active.length == 0 ) $active = $(sectionID+' .image-gallery *:last');
		var $next =  $active.next().length ? $active.next() : $(sectionID+' .image-gallery *:first');
		$active.addClass('last-active');
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 200, function() {
				$active.removeClass('active last-active');
				});
		$(sectionID+' .current-image-no')[0].src="/img/image-counter/"+(jQuery.inArray($next[0],$(sectionID+' .image-gallery *'))+1)+".gif";
		};

	function prev(sectionID) {
		var $active = $(sectionID+' .image-gallery *.active');
		if ( $active.length == 0 ) $active = $(sectionID+' .image-gallery *:last');
		var $prev =  $active.prev().length ? $active.prev() : $(sectionID+' .image-gallery *:last');
		$active.addClass('last-active');
		$prev.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 200, function() {
				$active.removeClass('active last-active');
				});
		$(sectionID+' .current-image-no')[0].src="/img/image-counter/"+(jQuery.inArray($prev[0],$(sectionID+' .image-gallery *'))+1)+".gif";
		};
	}
