﻿var strExternalUrl = '#';

if (document.all && /MSIE (5\.5|6)/.test(navigator.userAgent) &&
	document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule) {
	DD_belatedPNG.fix('img, h2, h3, h4, li, a, p, div');
}

function showOverlay(strOverlay) {
	$('#Content').append('<div class="UIBlock"></div>');
	$(strOverlay).show();
	$('.UIBlock').css({
		display: 'block',
		opacity: 0.5
	});

	if ($.browser.msie && $.browser.version < 7) {
		var intContentHeight = parseInt(($('#Content').height() + 35), 10);
		$('.UIBlock').css({ 'height': intContentHeight });
	}
}

function externalLink(strUrl) {
	strExternalUrl = strUrl;
	showOverlay('.overlay_prompt');
}

function trackFlashExternalLink() {
	try {
		pageTracker._trackEvent('Twilight New Moon', 'Flash External Site Navigation', strExternalUrl);
	}
	catch (e) { }
}

function flashSectionChange(siteSection) {
	try {
		pageTracker._trackEvent('Twilight New Moon', 'Flash Site Navigation', siteSection);
	}
	catch (e) { }
}

function flashLink(strId) {
	if (strId == 'bottles') {
		externalLink('http://www.newmoonbottles.com');
		trackFlashExternalLink();
	}
	else if (strId == 'summit') {
		externalLink('http://www.summit-ent.com/');
		trackFlashExternalLink();
	}
	else if (strId == 'crowncard') {
		window.open('http://bkcrowncard.com/');
		trackFlashExternalLink();
	}
	else if (strId == 'bugershots') {
		window.location.href = '/en/us/menu-nutrition/category1/menu-item2005/index.html';
	}
	else if (strId == 'menu') {
		window.location.href = '/en/us/menu-nutrition/index.html';
	}
	else if (strId == 'restaurant') {
		window.location.href = '/en/us/restaurant-locator/index.html';
	}
	else if (strId == 'legal') {
		window.location.href = '/en/us/company-info/legal/index.html';
	}
	else if (strId == 'privacy') {
		window.location.href = '/en/us/company-info/legal/privacy-policy.html';
	}
	else if (strId == 'doublecheeseburger') {
		window.location.href = '/en/us/menu-nutrition/category11/menu-item10/index.html';
	}
	else if (strId == 'whopperjr') {
		window.location.href = '/en/us/menu-nutrition/category11/menu-item5/index.html';
	}
	else if (strId == 'mastercard-rules') {
		showOverlay('.mastercard_overlay');
	}
}

$(document).ready(function() {
	$('.NewMoon #main #main_nav li a.active').hover(function() {
		$(this).css('cursor', 'default');
		return false;
	});

	$('.NewMoon #main #main_nav li a.active').click(function() {
		return false;
	});

	$('#official_rules_footer').click(function() {
		showOverlay('.mastercard_overlay');
		return false;
	});

	$('#official_rules').click(function() {
		showOverlay('.mastercard_overlay');
		return false;
	});

	$('.mastercard_overlay a').live('click', function() {
		$('.UIBlock').remove();
		$('.mastercard_overlay').hide();

		return false;
	});

	$('a[rel=prompt]').click(function() {
		var $this = $(this);
		externalLink($this.attr('href'));
		return false;
	});
	
	$('div.overlay_prompt ul li.cancel a').click(function() {
		$('.UIBlock').remove();
		$('.overlay_prompt').hide();
	});

	$('div.overlay_prompt ul li.continue a').click(function() {
		$('.UIBlock').remove();
		$('.overlay_prompt').hide();

		window.open(strExternalUrl);
	});

	if (location.hash == "#official-rules") {
	    showOverlay('.mastercard_overlay');
	}
});

if ($.browser.msie && $.browser.version < 7) {
} else {
	var flashvars = {};
	flashvars.path = '/page_templates/newmoon/swf/';
	flashvars.testvalue = '1';
	flashvars.siteSection = strSiteSection;
	var params = {};
	params.allowfullscreen = true;
	params.allowNetworking = true;
	params.allowscriptaccess = 'always';
	params.wmode = 'transparent';
	params.play = 'true';
	params.salign = 'tl';
	params.seamlesstabbing = 'true';
	var attributes = {};
	attributes.id = 'FlashContent';
	swfobject.embedSWF('/page_templates/newmoon/swf/new_forest.swf', 'htmlBody', '1000', '600', '9.0.115', false, flashvars, params, attributes);
}
