//Javascript

$(document).ready(function() {
	// fancy lightbox
	$("a.zoom").fancybox({
		'frameWidth': 930,
		'frameHeight': 635,
		'hideOnContentClick': false,
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'overlayOpacity': 0.5,
		'hideOnOverlayClick': true,
		'showCloseButton': false,
		'callbackOnClose': boxClosed,
		'callbackOnStart': function() { $("#fancy_overlay").bind("click", "null"); }
	});

	$("a.iframe").fancybox({
		'frameWidth': 940,
		'frameHeight': 608,
		'hideOnContentClick': false,
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'overlayOpacity': 0.5,
		'hideOnOverlayClick': true,
		'showCloseButton': false,
		'centerOnScroll': false,
		'scrolling': 'no',
		'callbackOnClose': boxClosed
		// 'callbackOnStart': function() { $("#fancy_overlay").bind("click", "null"); }
	});

	// <!-- CALLED WHEN FANCYBOX CLOSES -->
	function boxClosed() {
		//history.back();
		SWFAddress.setValue('');
	}

	function expandLightbox() {
		// Called during page load for deep linking referrals e.g. banner ads
		if (getQuerystringVar("expand").toLowerCase() == 'mymarvin') {
			// openFancyBox("#mymarvinlink");
			// $("#mymarvinlink").trigger('click');
			// alert('Expand command is mymarvin');
			// document.write('Expand command is mymarvin');
			var sDeepLink = SWFAddress.getValue();
			switch (sDeepLink) {
			case '_artist_kr_video':
				$("#mymarvinlinkkrvideo").trigger('click');
				break;
			case '_artist_mg_video':
				$("#mymarvinlinkmgvideo").trigger('click');
				break;
			case '_artist_pa_video':
				$("#mymarvinlinkpavideo").trigger('click');
				break;
			case '_artist_ss_video':
				$("#mymarvinlinkssvideo").trigger('click');
				break;
			default:
				// Open myMarvin movie with normal generic introduction
				$("#mymarvinlink").trigger('click');
			}
		};
	}

	// Always try to expand the lightbox (Fancy Box), if appropriate
	expandLightbox();
});


