﻿
var headID = document.getElementsByTagName("head")[0];
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';

if (BrowserDetect.OS.indexOf("Windows") > -1 && BrowserDetect.browser.indexOf("Explorer") > -1 && BrowserDetect.version == "6") {
	cssNode.href = '/css/Default_ie6.css';
} else {
	cssNode.href = '/css/Default.css';
}
cssNode.media = 'screen';
headID.appendChild(cssNode);


function switchNav03Arrow() {
	$(document).ready(function() {

		var url = location.href.toLowerCase();
		if (url.indexOf("/progresso-beef-chicken-broth.aspx") > -1) {
			$("#nav03-arrow-01").css("margin-left", "38px");
			$("#nav03-arrow-01").css("display", "block");

		} else if (url.indexOf("/broth-tips.aspx") > -1) {
			$("#nav03-arrow-02").css("margin-left", "0px");
			$("#nav03-arrow-02").css("display", "block");

		} else if (url.indexOf("/broth-recipes.aspx") > -1) {
			$("#nav03-arrow-03").css("margin-left", "15px");
			$("#nav03-arrow-03").css("display", "block");

		} else if (url.indexOf("/progresso-broth-story.aspx") > -1) {
			$("#nav03-arrow-04").css("margin-left", "60px");
			$("#nav03-arrow-04").css("display", "block");
		}
	});
}
switchNav03Arrow();


function switchTab(id) {
	$(document).ready(function() {

		$("#tab_01").css("background-image", "url(./images/tab_01_off.jpg)");
		$("#tab_01").css("background-repeat", "no-repeat");

		$("#tab_02").css("background-image", "url(./images/tab_02_off.jpg)");
		$("#tab_02").css("background-repeat", "no-repeat");

		$("#tab_03").css("background-image", "url(./images/tab_03_off.jpg)");
		$("#tab_03").css("background-repeat", "no-repeat");

		switch (id) {
			case "01":
				$("#tab_01").css("background-image", "url(./images/tab_01_on.jpg)");
				$("#tab_01").css("background-repeat", "no-repeat");
				break;
			case "02":
				$("#tab_02").css("background-image", "url(./images/tab_02_on.jpg)");
				$("#tab_02").css("background-repeat", "no-repeat");
				break;
			case "03":
				$("#tab_03").css("background-image", "url(./images/tab_03_on.jpg)");
				$("#tab_03").css("background-repeat", "no-repeat");
				break;
		}

		$(".tab_content").css("display", "none");
		$("#tab_content_" + id).css("display", "block");

	});
}


function showRecipe(id) {
	$(document).ready(function() {
		$("#show_recipe_" + id).css("display", "none");
		$("#recipe_" + id).css("display", "block");
	});
}

function hideRecipe(id) {
	$(document).ready(function() {
		$("#show_recipe_" + id).css("display", "block");
		$("#recipe_" + id).css("display", "none");
	});
}

function getNutritionFacts(id) {
	var img = document.images["NutritionFactsImage"];

	var newImg = new Image();
	newImg.src = "images/nutritionFacts/" + id;

	newImg.onload = function() {

		var newWidth = newImg.width * .8;
		var newHeight = newImg.height * .8;
		img.width = newWidth;
		img.height = newHeight;
		img.src = newImg.src;

		var obj = $("#NutritionFactsData");
		obj.css("visibility", "visible");
		obj.css("left", ($(window).width() - (newWidth + 25)) / 2);
		obj.css("top", $(window).scrollTop() + 25);
		//showNutritionFacts();
	}
}
function shareOnFacebook(item) {
	var width = 626;
	var height = 436;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	var u = location.href + "?item=" + item;
	var t = document.title;
	window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	return false;
}
function emailRecipe(item) {
	var subject = "Progresso Recipe: " + item.replace(/-/g, " ");
	var body = "\n" + location.href + "#" + item;
	location.href = "mailto:?subject=" + escape(subject) + "&body=" + escape(body);
}

var _w = null;
function printRecipe(id) {

	var width = 626;
	var height = 436;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	_w = window.open('about:blank', 'test', 'scrollbars=1,toolbar=0,status=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	//_w = window.open();

	_w.document.open();
	_w.document.write('<html><head><title>Progresso Broth Recipe: ' + document.getElementById("recipe" + id + "Title").innerHTML + '</title><link href="css/print.css" rel="stylesheet" type="text/css" /></head><body onload="window.print();">');
	_w.document.write('<div id="logo"><img src="images/logo.png"/></div>');
	_w.document.write('<h1>' + document.getElementById("recipe" + id + "Title").innerHTML + '</h1>');
	//_w.document.write('<br/>');
	_w.document.write('<div>' + document.getElementById("recipe" + id + "Image").innerHTML + '</div>');
	//_w.document.write('<br/><br/>');
	_w.document.write('<strong>' + document.getElementById('recipe' + id + 'Description').innerHTML + '</strong>');
	_w.document.write('<hr class="hr1"/>');
	_w.document.write(document.getElementById("recipe" + id + "Content").innerHTML);
	_w.document.write('<hr class="hr1"/>');
	_w.document.write('<a href="javascript:window.close()">Close window.</a>');
	_w.document.write('</body></html>');
	_w.document.close();
	if (!_w.closed) {
		_w.focus();
	}
}
$(document).ready(function() {
	if (BrowserDetect.OS.indexOf("Windows") > -1 && BrowserDetect.browser.indexOf("Explorer") > -1 && BrowserDetect.version == "6") {
		$("#nav03-arrow-01").css("margin-left", "53px");
		$("#nav03-arrow-02").css("margin-left", "9px");
		$("#nav03-arrow-03").css("margin-left", "19px");
		$("#nav03-arrow-04").css("margin-left", "65px");
	}
});

