$(document).ready(function() {
	explorerHover();
	
	$('.explorer-dot').mouseover(function() {
		$('img',this).attr('src','/_images/common/explorer-dot-a.gif');
	}).mouseout(function() {
		$('img',this).attr('src','/_images/common/explorer-dot.gif');
	}).click(function() {
		//$('#product-explorer-info').css('visibility','visible');
		if(!$(this).data('tText')) $(this).data('tText',$(this).attr('title'));
		if($(this).data('qtip')) $(this).qtip('destroy');
		
		$(this).qtip({
			content:  {
				url: '/products/explorer-content.cfm',
				data: {id: $(this).attr('id')},
				method: 'get',
				title: {
					text: $(this).data('tText'),
					button: 'x',//<img src="/_images/common/Tooltip-CloseButton.png" alt="" />
					style: {
						fontSize: 13
					}
				}
			},
			position: {
				corner: {
					tooltip: 'rightMiddle',
					target: 'leftMiddle'
				}
			},
			show: {
				when: false,
				ready: true,
			 	solo: true
			},
			hide: false,
			style: {
				width: 250,
				border: {
					width: 2,
					radius: 0
				},
				fontSize: 12,
				padding: 10,
				textAlign: 'left',
				tip: {
					corner: 'leftMiddle',
					color: '#070707'
				},
				name: 'dark'
			}
		})
	});
	
	var origTitle = 'info';
	
	$('.product-tab').hover(function() {
		origTitle = $(this).attr('title');
		
		$(this).attr('title','');
	}, function() {
		$(this).attr('title',origTitle);
	}).click(function() {
		var active = $('#tab-active').attr('title');
		var tabLength = $('#product-tabs').children('div.product-tab').length;
		$('#tab-active').css('z-index',3);
		$('#tab-active').removeAttr('id');
		
		for(i=0; i < tabLength; i++) {
			$('#product-tabs .product-tab:eq('+ i +')').css('z-index',tabLength-i);
		}
		
		$(this).attr('id','tab-active');
		$(this).css('z-index',11);
				
		$('div#product-'+ active).hide();
		$('div#product-'+ origTitle).show();
	});
	
	$('a[rel^="prettyPhoto"]').prettyPhoto({
		show_title: false,
		overlay_gallery: false,
		theme: 'dark_square',
		deeplinking: false,
		social_tools: '',
		allow_resize: true
	});
	addthis.init();
});

function explorerHover() {
	$('#product-explorer').unbind('mouseenter mouseleave').hover(function() {
		$('.explorer-dot',$(this)).show();
	}, function() {
		$('.explorer-dot',$(this)).hide();
	});
}

