(function() { 

// FBN
var FBN = {
	
	roomExplorer: null,

	closeDOMWindow: function(e) {
		FBN.roomExplorer.css('visibility', 'visible');
		$.closeDOMWindow();
	},


	// Photo Gallery
	photoGalleryTitle: '',
	photoGalleryUrl: 'http://s7d5.scene7.com/is-viewers-3.9/flash/genericzoom.swf?serverUrl=http://s7d5.scene7.com/is/image/&contentRoot=http://s7d5.scene7.com%2fskins&config=Scene7SharedAssets/ImageSet7-Views&contentRoot=/skins/&image=',
	photoGalleryParams: '',

	photoGallery: function(params) {
		if(typeof params.brand==='undefined') {
			params.brand = 'lane';
		}
		if(params.url) {
			FBN.photoGalleryUrl = params.url;
		}
		
		// JSK ******* THESE ARE ONLY TEST VALUES
		// they should be taken out when we have real/more collectionIDs
		// params.brand = 'broyhill';
		// params.collectionID = '4330';

		FBN.photoGalleryParams = params.brand + '%2F' + params.collectionID;
		
        $.openDOMWindow({
			borderSize:'0',
			windowBGColor: '#fff',
			//width: 947,
			//height: 469,
			width: 875,
			height: 475,
			overflow: 'hidden',
			windowSource: 'inline',
			windowSourceID: '#lightbox360',
			functionCallOnOpen: FBN.handlePhotoGalleryOpen,
			functionCallOnClose: FBN.closeDOMWindow
		}); 
	},

	handlePhotoGalleryOpen: function() {
		FBN.roomExplorer.css('visibility', 'hidden');
		var flashUrl = FBN.photoGalleryUrl + FBN.photoGalleryParams;
		// don't use AC_FL_RunContent() here becuase it uses document.write and writes over the whole page
		$("#DOMWindow").html('<a href="/" class="closeDOMWindow">Close</a><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="PhotoGallery" height="469" width="947" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="' + flashUrl + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><embed wmode="transparent" height="469" align="middle" width="947" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" allowscriptaccess="always" name="PhotoGallery" bgcolor="#CCCCCC" quality="high" id="PhotoGallery" src="' + flashUrl + '"/></object>');
		$('#DOMWindow .closeDOMWindow').click(function(e) {
			FBN.closeDOMWindow();
			e.preventDefault();
		});
	},


	// Panoramic View
	panoramicTitle: '',
	panoramicUrl: '',

	panoramicView: function(url,title) {
		FBN.panoramicTitle = title;
		FBN.panoramicUrl = url;
		// open lightbox with blank source
		$.openDOMWindow({ 
			borderSize:'0',
			windowBGColor: 'transparent',
			width: 947,
			height: 469,
			windowSource: 'inline',
			windowSourceID: '#lightbox360',
			functionCallOnOpen: FBN.handleRoomViewerOpen,
			functionCallOnClose: FBN.closePanoramic
		}); 
	},

	handleRoomViewerOpen: function() {
		FBN.roomExplorer.css('visibility', 'hidden');
		// don't use AC_FL_RunContent() here becuase it uses document.write and writes over the whole page
		$('#DOMWindow').html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="RoomViewer" height="469" width="947" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="cmn/swf/RoomViewer.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="FlashVars" value="title='+FBN.panoramicTitle+'&amp;dataProvider='+FBN.panoramicUrl+'&amp;brand=lane" /><embed wmode="transparent" height="469" align="middle" width="947" type="application/x-shockwave-flash" flashvars="title='+FBN.panoramicTitle+'&amp;dataProvider='+FBN.panoramicUrl+'&amp;brand=lane" pluginspage="http://www.adobe.com/go/getflashplayer" allowscriptaccess="sameDomain" name="RoomViewer" bgcolor="#CCCCCC" quality="high" id="RoomViewer" src="cmn/swf/RoomViewer.swf"/></object>');
	},
	
	closePanoramic: function() {
		FBN.closeDOMWindow();
	},
	
	_init: function() {
	 	FBN.roomExplorer = $('#RoomExplorer');

		$('.photoGallery').click(function(e) {
			e.preventDefault();
			var params = {
				brand: 'lane',
				collectionID: this.id
			};
			FBN.photoGallery(params);
		});
	}

}; // FBN

$(document).ready(function() {
	FBN._init();
	window.FBN = FBN;
}); // 

})();