﻿//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 showViewBy(id) {
	$(document).ready(function() {

		var url = location.href.toLowerCase();

		$("#soupFilterMiddle div .vb").css("display", "none");
		$("#viewByNav a").css("color", "#07589c");
		$("#viewByNav div").css("background-image", "");
		$("#ctl00_ContentPlaceHolder1_viewBy_" + id).css("display", "block");

		if (url.indexOf("/healthy-soup.aspx") > -1) {
			for (i = 0; i <= 7; i++) {
				$(".viewBy_0" + i).css("display", "none");
			}
		}
		if (url.indexOf("/soup.aspx") > -1) {
			getFirstDetailImage(id);
		}
		switch (id) {
			case "01":
				$("#vb_01").css("color", "#ffffff");
				$("#ctl00_ContentPlaceHolder1_div_01").css("background-image", "url(./images/bg-vb_01.gif)");
				$("#ctl00_ContentPlaceHolder1_div_01").css("background-repeat", "no-repeat");
				$("#td_detailImage").html($("#defaultImage").html());
				if (url.indexOf("/healthy-soup.aspx") > -1) {
					$(".viewBy_01").css("display", "block");
				}
				break;
			case "02":
				$("#vb_02").css("color", "#ffffff");
				$("#ctl00_ContentPlaceHolder1_div_02").css("background-image", "url(./images/bg-vb_02.gif)");
				$("#ctl00_ContentPlaceHolder1_div_02").css("background-repeat", "no-repeat");
				$("#td_detailImage").html($("#defaultImage").html());
				if (url.indexOf("/healthy-soup.aspx") > -1) {
					$(".viewBy_02").css("display", "block");
				}
				break;
			case "03":
				$("#vb_03").css("color", "#ffffff");
				$("#ctl00_ContentPlaceHolder1_div_03").css("background-image", "url(./images/bg-vb_03.gif)");
				$("#ctl00_ContentPlaceHolder1_div_03").css("background-repeat", "no-repeat");
				$("#td_detailImage").html($("#defaultImage").html());
				if (url.indexOf("/healthy-soup.aspx") > -1) {
					$(".viewBy_03").css("display", "block");
				}
				break;
			case "04":
				$("#vb_04").css("color", "#ffffff");
				$("#ctl00_ContentPlaceHolder1_div_04").css("background-image", "url(./images/bg-vb_04.gif)");
				$("#ctl00_ContentPlaceHolder1_div_04").css("background-repeat", "no-repeat");
				$("#td_detailImage").html($("#defaultImage").html());
				if (url.indexOf("/healthy-soup.aspx") > -1) {
					$(".viewBy_04").css("display", "block");
				}
				break;
			case "05":
				$("#vb_05").css("color", "#ffffff");
				$("#ctl00_ContentPlaceHolder1_div_05").css("background-image", "url(./images/bg-vb_05.gif)");
				$("#ctl00_ContentPlaceHolder1_div_05").css("background-repeat", "no-repeat");
				$("#td_detailImage").html($("#defaultImage").html());
				if (url.indexOf("/healthy-soup.aspx") > -1) {
					$(".viewBy_05").css("display", "block");
				}
				break;
			case "06":
				$("#vb_06").css("color", "#ffffff");
				$("#ctl00_ContentPlaceHolder1_div_06").css("background-image", "url(./images/bg-vb_06.gif)");
				$("#ctl00_ContentPlaceHolder1_div_06").css("background-repeat", "no-repeat");
				$("#td_detailImage").html($("#defaultImage").html());
				if (url.indexOf("/healthy-soup.aspx") > -1) {
					$(".viewBy_06").css("display", "block");
				}
				break;
			case "07":
				$("#vb_07").css("color", "#ffffff");
				$("#ctl00_ContentPlaceHolder1_div_07").css("background-image", "url(./images/bg-vb_07.gif)");
				$("#ctl00_ContentPlaceHolder1_div_07").css("background-repeat", "no-repeat");
				$("#td_detailImage").html($("#defaultImage").html());
				if (url.indexOf("healthy-soup.aspx") > -1) {
					$(".viewBy_07").css("display", "block");
				}
				break;
		}
	});
}


function switchNav03Arrow() {
	$(document).ready(function() {

		var url = location.href.toLowerCase();
		if (url.indexOf("/soup.aspx") > -1) {
			$("#nav03-arrow-01").css("margin-left", "3px");
			$("#nav03-arrow-01").css("display", "block");

		} else if (url.indexOf("/soup-recipes.aspx") > -1) {
			$("#nav03-arrow-02").css("margin-left", "10px");
			$("#nav03-arrow-02").css("display", "block");

			$("#tab_01").css("background-image", "url(./images/tab_01_on.jpg)");
			$("#tab_01").css("background-repeat", "no-repeat");
			$("#tab_content_01").css("display", "block");

		} else if (url.indexOf("/healthy-soup.aspx") > -1) {
			$("#nav03-arrow-03").css("margin-left", "18px");
			$("#nav03-arrow-03").css("display", "block");

		} else if (url.indexOf("/progresso-soup-story.aspx") > -1) {
			$("#nav03-arrow-04").css("margin-left", "70px");
			$("#nav03-arrow-04").css("display", "block");
		}

		else if (url.indexOf("/progresso-soup-news.aspx") > -1) {
			$("#nav03-arrow-05").css("margin-left", "3px");
			$("#nav03-arrow-05").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 showNutritionFacts() {
	var obj = $("#NutritionFactsData");
	obj.css("visibility", "visible");
	alert($(window).width())
	obj.css("left", ($(window).width() - obj.width() / 2));
	//document.getElementById("NutritionFactsData").style.visibility = "visible";
}


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 Soup 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.browser.indexOf("Explorer") > -1) {
		for (i = 1; i < 8; i++) {
			if (document.getElementById("recipe" + i + "UtilityNav")) {
				document.getElementById("recipe" + i + "UtilityNav").style.paddingRight = "100px";
			}
		}
	}
});
*/

function viewProduct(item) {
	var url = "";
	switch (item.toLowerCase()) {
		case "vegetableclassics":
			url = "/soup.aspx?soup=vegetable-classics";
			break;
		case "traditional":
			url = "/soup.aspx?soup=traditional";
			break;
		case "reducedsodium":
			url = "/soup.aspx?soup=reduced-sodium";
			break;
		case "richhearty":
			url = "/soup.aspx?soup=rich-and-hearty";
			break;
		case "highfiber":
			url = "/soup.aspx?soup=high-fiber";
			break;
		case "light":
			url = "/soup.aspx?soup=light";
			break;
		case "microwave":
			url = "/soup.aspx?soup=microwave";
			break;
	}
	location.href = url;
}

/*
function getNutritionFacts_old(url) {
document.getElementById("NutritionFactsData").innerHTML = "Loading...";
var data = $.ajax({
url: "/getNutritionFacts.ashx?url=" + escape(url) + "&dummy=" + Math.floor(Math.random() * 1000),
async: false
}).responseText;
document.getElementById("NutritionFactsData").innerHTML = data;
resizeImage();
var t = setTimeout("showNutritionFacts()", 1000);
}
function resizeImage() {
var img = document.images["NutritionFactsImage"];
var newWidth = img.width * .8;
var newHeight = img.height * .8;
img.width = newWidth;
img.height = newHeight;
document.getElementById("NutritionFactsData").style.width = newWidth + "px";
document.getElementById("NutritionFactsData").style.height = newHeight + "px";
}
*/

