﻿$j(document).ready(function ()
{

	if (joCorpBrandFooter && typeof (joCorpBrandFooter) == 'function')
	{
		var joBrandFooter = new joCorpBrandFooter({})
		joBrandFooter.write('JOFooter');
	}

	$j('.Popup').live('click', function (event)
	{
		event.preventDefault();
		window.open(this.href);
	});

	$j('#Breadcrumbs a:not(:last)').after($j('<span>').text('>'))

	$j('#ChangeRegion').click(function (event)
	{
		event.preventDefault();
		$j('<div>', { id: 'ChangeRegionContainer' })
			.load(
				'/change-region.aspx',
				function ()
				{
					$j('#ChangeRegionContainer').dialog({
						title: 'Select Region',
						modal: true,
						close: function () { $j('#ChangeRegionContainer').remove() }
					})
				}
			)
				.appendTo($j('#Header'));
	});

	$j('#FooterLinks li:not(:first)').before($j('<li>').text('|'))

	if ($j.cookie('InitialVisit') == null)
	{
		$j.cookie('InitialVisit', { path: '/' });
		$j('#CultureIntro').removeClass('Hidden');
	}

	$j(document.body).click(function () { $j('#RightClickMsg').remove() });

	$j('div#Images img').bind('contextmenu', function (event)
	{
		event.preventDefault();
		$j('#RightClickMsg').remove();
		$j('<div>', { id: 'RightClickMsg' })
			.css({ position: 'absolute', borderLeft: '1px solid grey', borderTop: '1px solid grey', borderBottom: '2px solid black', borderRight: '2px solid black', padding: '4px', backgroundColor: '#f8f8f8' })
			.offset({ top: $j(event.currentTarget).offset().top + ($j(event.currentTarget).height() / 2) - 10, left: $j(event.currentTarget).offset().left + ($j(event.currentTarget).width() / 2) - 150 })
			.text('Copyright SCUBAPRO 2011.  All rights reserved.')
			.appendTo(document.body)
	});

	$j('.GoogleLink').click(trackLinkEvent);

});


function trackLinkEvent(event)
{
	_gaq.push(['MediaClicks', event.currentTarget.href, null, null]);
}


function blockRightClick(event)
{
	$j('#RightClickMsg').remove()

	if (event.which == 3)
	{
		event.preventDefault();
		$j('<div>', { id: 'RightClickMsg' })
			.css({ position: 'absolute', borderLeft: '1px solid grey', borderTop: '1px solid grey', borderBottom: '2px solid black', borderRight: '2px solid black', padding: '4px', backgroundColor: '#f8f8f8' })
			.offset({ top: $j(event.currentTarget).offset().top + ($j(event.currentTarget).height() / 2) - 10, left: $j(event.currentTarget).offset().left + ($j(event.currentTarget).width() / 2) - 150 })
			.text('Copyright SCUBAPRO 2011.  All rights reserved.')
			.appendTo(document.body)
	}
}


function getQueryString(key) {

	var qs = location.search.substring(1).split('&');
	for (i = 0; i < qs.length; i++) {
		keyAndValue = qs[i].split('=');
		if (keyAndValue[0] == key)
			return keyAndValue[1];
	}

}


function onYouTubePlayerReady(playerId){
	ytplayer = document.getElementById(playerId);
	ytplayer.playVideo();
}
