// Thickbox for merchant applications
jQuery(document).ready(function() {
	var screenWidth = screen.availWidth;
	var screenHeight = screen.availHeight;
	var okScreenHeight = 960;
	if(screenHeight >= okScreenHeight) {
		jQuery("a.MerchantForm").fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'overlayOpacity'		: 0.65,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'frameWidth'			: 650,
			'frameHeight'			: 600
		});
	}
	else {
		jQuery('a.MerchantForm').click(function() {
			var l = screenWidth/2-325;
			var t = screenHeight/2-250;
			window.open(this.href, 'merchantform', 'scrollbars=yes, width=650, height=500, left='+l+', top='+t);
			return false;
		});
	}

	// Thickbox for home page screenshots
	if(screenHeight >= okScreenHeight) {
		jQuery("a.HomeShot").fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'overlayOpacity'		: 0.65,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
		});
	}
	else {
		jQuery('a.HomeShot').click(function() {
			if(navigator.userAgent.indexOf('MSIE') >= 0) {
				var w = 780;
				var h = 570;
			}
			else {
				var w = 745;
				var h = 555;
			}
			var l = screenWidth/2-(w/2);
			var t = screenHeight/2-(h/2);
			window.open(this.href, 'homeshot', 'scrollbars=yes, width='+w+', height='+h+', left='+l+', top='+t);
			return false;
		});
	}

	// Thickbox for store designs
	if(screenHeight >= okScreenHeight) {
		jQuery("a.StoreTemplate").fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'overlayOpacity'		: 0.65,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
		});
	}
	else {
		jQuery('a.StoreTemplate').click(function() {
			if(navigator.userAgent.indexOf('MSIE') >= 0) {
				var w = 845;
				var h = 630;
			}
			else {
				var w = 835;
				var h = 615;
			}
			var l = screenWidth/2-(w/2);
			var t = screenHeight/2-(h/2);
			window.open(this.href, 'storetemplate', 'scrollbars=yes, width='+w+', height='+h+', left='+l+', top='+t);
			return false;
		});
	}

	// The tour video
		jQuery("a.VideoTour").fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'overlayOpacity'		: 0.65,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'frameWidth'			: 660,
			'frameHeight'			: 500
		});

		// The feature tour videos
			jQuery("a.VideoTourFeature").fancybox({
				'zoomOpacity'			: true,
				'overlayShow'			: true,
				'overlayOpacity'		: 0.65,
				'zoomSpeedIn'			: 500,
				'zoomSpeedOut'			: 500,
				'frameWidth'			: 660,
				'frameHeight'			: 530
			});

	// Support videos
	jQuery('a.SupportVideo').click(function() {
		if(navigator.userAgent.indexOf('MSIE') >= 0) {
			var w = 840;
			var h = 665;
		}
		else {
			var w = 820;
			var h = 660;
		}

		var l = screenWidth/2-(w/2);
		var t = screenHeight/2-(h/2);
		window.open(this.href, 'tourvideo', 'scrollbars=yes, width='+w+', height='+h+', left='+l+', top='+t);
		return false;
	});

	// KB articles
	jQuery('a.SupportKb').click(function() {
		var w = 650;
		var h = 550;
		var l = screenWidth/2-(w/2);
		var t = screenHeight/2-(h/2);
		window.open(this.href, 'supportkb', 'scrollbars=yes, width='+w+', height='+h+', left='+l+', top='+t);
		return false;
	});

	jQuery('#SupportBar .PopularSearches em a').click(function() {
		jQuery('#Query').val(jQuery(this).html());
		jQuery('#SearchForm').submit();
		return false;
	});

	jQuery('#SupportBar #Query').
		focus(function() {
			if(jQuery(this).data('custom') == undefined) {
				jQuery(this).data('oldValue', jQuery(this).val());
				jQuery(this).val('');
			}
		})
		.blur(function() {
			if(jQuery(this).val()) {
				jQuery(this).data('custom', 1);
			}
			else if(jQuery(this).data('oldValue')) {
				jQuery(this).val(jQuery(this).data('oldValue'));
			}
		})
	;

	// IE needs some Javascript to handle the menu mouse overs
	if(document.all) {
		jQuery('#Menu li').hover(function() {
			jQuery(this).addClass('Over');
		}, function() {
			jQuery(this).removeClass('Over');
		});
	}
});

function PlayVideo(url, width, height) {
	window.open(url, 'supportVideo', 'width='+width+', height='+height);
}


function PlayVideo(url, width, height) {
	window.open(url, 'supportVideo', 'width='+width+', height='+height);
}

