$(document).ready(function(){

	//if there are accessories
	if($('.accs').length) {

		$('.accs h3').css('cursor', 'pointer');

		//add hover states
		$('.accs h3').hover(function(){
			$(this).addClass('hover');
		}, function(){
			$(this).removeClass('hover');
		});

		//hide table by default
		$('.accs table').hide();
		$('.accs').addClass('closed');

		$('.accs h3').click(function(){
			if($('.accs').hasClass('closed')){
				//open table
				$('.accs').removeClass('closed');
				$('.accs table').show();
			}else{
				//close table
				$('.accs').addClass('closed');
				$('.accs table').hide();
			}
		});

	}

//	if($('.sample').length) {
//		$("a.sample").prettyPhoto({
//			animationSpeed: 'normal', /* fast/slow/normal */
//			opacity: 0.70, /* Value between 0 and 1 */
//			showTitle: true, /* true/false */
//			allowresize: false, /* true/false */
//			default_width: 500,
//			default_height: 700,
//			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
//			theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square / facebook */
//		});
//	}

	if($('.images-block li').length > 1) {

		totalimages = $('.images-block li').length;
		currentimg = 1;
		//$('#image-navigation span').html(currentimg+' of '+totalimages);
		$('.images-block li').hide();
		$('.images-block li').eq(currentimg-1).show();

		altText = $('.images-block li').eq(currentimg-1).find('img').attr('alt');
		if(altText != ''){
			$('#image-navigation span').html(altText);
		}

		$('#image-navigation').show();
		$('.images-block').css('margin-bottom', 0);

		$('#image-navigation .prev').live('click', function(){
			if(currentimg-1 > 0){
				currentimg--;
				$('.images-block li').hide();
				$('.images-block li').eq(currentimg-1).show();
				//$('#image-navigation span').html(currentimg+' of '+totalimages);
				altText = $('.images-block li').eq(currentimg-1).find('img').attr('alt');
				$('#image-navigation span').html(altText);
			}

			return false;
		});

		$('#image-navigation .next').live('click', function(){
			if(currentimg+1 <= totalimages){
				currentimg++;
				$('.images-block li').hide();
				$('.images-block li').eq(currentimg-1).show();
				//$('#image-navigation span').html(currentimg+' of '+totalimages);
				altText = $('.images-block li').eq(currentimg-1).find('img').attr('alt');
				$('#image-navigation span').html(altText);
			}

			return false;
		});

	}

	if($('dl.info dd.icon').length > 0){

		$('dl.info dd.icon').hover(function(){

			itext = $(this).text();
			$('dl.info dd.text').text(itext);

		}, function(){

			$('dl.info dd.text').text('');

		});

	}

//	if($('a.title .pimg').length > 1){
//
//		var tallest = 0,
//				thish = 0;
//
//		$('a.title .pimg').each(function(){
//			thish = $(this).height();
//			if(thish > tallest) tallest = thish;
//		});
//
//		$('a.title .pimg').height(tallest);
//	}

});
