var inspGal = {
	
	setGlobals: function() {
		$cboxLink = $('a.cbox');
		$zoomLink = $('a.cbox-zoom');
		$roomDetailsLink = $('a.cbox-room-details');
		$floorplanLink = $('a.cbox-floor-plan');
		$photosLink = $('a.cbox-photos');
		$videoLink = $('a.cbox-video');
		$360Link = $('a.cbox-360');
		myHref = '';
		hotspotsClickable = true;
	},
	
	setColorBox: function() {
		$zoomLink.colorbox({ width:'940px', height: '540px', iframe: true });
		$photosLink.colorbox({ width:'940px', height: '525px', iframe:true });
		$floorplanLink.colorbox({ width:'940px', height: '100%', iframe:true });
		$videoLink.colorbox({ width:'750px', height: '484px', iframe:true });
		$roomDetailsLink.colorbox({ width:'900px', height: '525px', iframe:true });
		$360Link.colorbox({ width:'880px', height: '474px', iframe:true });
	},
	
	setCarousels: function() {
		var selectedIndex;
		$('#other-photos-carousel').find('a').each(function() {
			if($(this).hasClass('selected')) {
				selectedIndex = $('#other-photos-carousel').find('a').index(this);
			};
		});
		console.log(selectedIndex)
		jQuery('#other-photos-carousel').jcarousel({ start: selectedIndex });
	},
	
	setHotspots: function() {
		var overlayHTML = '<div id="hotspot-overlay" style="display:none;" class="clearfix"><a href="#" class="hotspot-close replaced">Close</a><div id="hotspot-content"></div></div>';
		$('#room-view img.room-image').before(overlayHTML);
		$('div#room-view a.hotspot').click(function() {
			
			if(hotspotsClickable === true) {
				hotspotsClickable = false;
				myHref = $(this).attr('href');
				//console.log(myHref);

				$('#hotspot-content').load(myHref, function() {
					Cufon.replace('#hotspot-overlay h1', { textShadow: '2px 2px rgba(0,0,0,0.1), 1px 1px rgba(0,0,0,0.2)', fontFamily: 'Helvetica Neue' });
					$('#hotspot-overlay').fadeIn(200);
					flashIndex.setGlobals();
					flashIndex.initFlash(flashIndex.compareBodyId());
				});
			};
			
			$('.hotspot-close').click(function() {
				$('#hotspot-overlay').fadeOut(200);
				hotspotsClickable = true;
				$('#hotspot-content').html('');
				return false;
			});
			
			return false;
		});
	}
	
};

$('document').ready(function() {
	inspGal.setGlobals();
	inspGal.setColorBox();
	inspGal.setCarousels();
	inspGal.setHotspots();
	if($('body#inspiration-gallery-hotspot-page, body#inspiration-gallery-page').length > 0){
		var st = setTimeout("$('a#first-show-hide-link').click()", 2400);
	};
});
