﻿$(document).ready(function() {
	$('#header .page_header li a').mouseover(function() {
		if (!$(this).hasClass('active')) {
			$(this).stop().animate({
				'background-position': '0 -16px'
			}, 250);
		}
	});
	$('#header .page_header li a').mouseout(function() {
		if (!$(this).hasClass('active')) {
			$(this).stop().animate({
				'background-position': '0 0'
			});
		}
	});
	
	$('a.toggle-intn-locations').click(function(e) {
		e.preventDefault();
		$('#international-locations').css({ 'display': 'block' });
		$('#domestic-locations').css({ 'display': 'none' });
		$('#us-location-title').hide();
		$(this).hide();
		$('#intn-location-title').css({ 'display': 'block' });
		$('a.toggle-us-locations').css({ 'display': 'block' });
	});

	$('a.toggle-us-locations').click(function(e) {
		e.preventDefault();
		$('#international-locations').css({ 'display': 'none' });
		$('#domestic-locations').css({ 'display': 'block' });
		$('#intn-location-title').css({ 'display': 'none' });
		$(this).hide();
		$('#us-location-title').show();
		$('a.toggle-intn-locations').css({ 'display': 'block' });

	});
});

/* external link pop up */
$(function() {
	$(".externalLink").bind("click", function(e) {
		e.preventDefault();
		var url = $(this).attr("href");
		$("body").append($("<div id='uiOverlay'></div><div id='uiLinkDialogue'><img src='/page_templates/whopperbar/images/redirect_header.jpg' alt='You are Being Redirected'/><p>You are now leaving a Burger King Corporation website. The policies including the privacy policy, on the website or websites you are going to may vary from Burger King Corporation's policies. Please be sure to review the policies of every website you visit as Burger King Corporation is not responsible for the policies and practices of other companies.</p><p><a href='#' class='cancelLink'><img src='/page_templates/whopperbar/images/redirect_cancel_btn.jpg' alt='Cancel Button'/></a><a href='#' class='okLink'><img src='/page_templates/whopperbar/images/redirect_ok_btn.jpg' alt='OK Button'/></a></p></div>"));
		if ($.browser.msie && $.browser.version == 6) {
			scroll(0, 0);
		}

		$("#uiOverlay").css({
			height: $("#pageWrapper").outerHeight(),
			width: $("#pageWrapper").outerWidth(),
			opacity: 0.8
		});
		$("#uiOverlay, #uiLinkDialogue").fadeIn("fast")
		var t = setTimeout(function() { window.open(url) }, 5000);
		$(".cancelLink").bind("click", function(e) {
			e.preventDefault();
			$("#uiOverlay, #uiLinkDialogue").fadeOut("fast", function() {
				$(this).remove();
				clearTimeout(t);
			})
		})
		$(".okLink").bind("click", function(e) {
			e.preventDefault();
			window.open(url);
			$("#uiOverlay, #uiLinkDialogue").fadeOut("fast", function() {
				$(this).remove();
				clearTimeout(t);
			})
		})

		return false;
	});
});
