function subwindow(url, width, height) {
    var scrollbar=1;
    var resizable=0;
    popup = window.open(url, "subwin", "scrollbars="+scrollbar+",resizable="+resizable+",status=0,location=0,width="+width+",height="+height);
    popup.focus();
}

function popup_recipe(recipe)
{
	subwindow("/recipe.php?index="+recipe, 436, 730);
}

function popup_recipe2(recipe)
{
	subwindow("/recipe_set2.php?index="+recipe, 436, 730);
}

function popup_avail_sizes(product)
{
	subwindow("/avail_sizes.php?product="+product, 425, 393);
}
function popup_cooking_chart(product)
{
	subwindow("/cooking_chart.php?product="+product, 600, 767);
}
function removeExitPopup() {
	document.getElementById("exitglad").style.display = 'none';
}

function exitGlad() {
	document.getElementById("exitglad").style.display = 'block';
	document.getElementById("exitglad").style.position = 'absolute';
}

function removeExitPopup2() {
	document.getElementById("exitglad2").style.display = 'none';
}

function exitGlad2() {
	document.getElementById("exitglad2").style.display = 'block';
	document.getElementById("exitglad2").style.position = 'absolute';
}


function popup_martha_winners(page)
{
	subwindow(page, 500, 396);
}


function subwindow_alt(url, width, height) {
    popup = window.open(url, "subwin", "scrollbars=1,status=0,location=1,toolbar=1,width="+width+",height="+height);
    popup.focus();
}

function popup_top_chef()
{
	subwindow_alt("/top_chef/", 1000, 594);
}

// function call to replace HPTO with standard nav/homepage content
function write_wheel_homepage_token()
{
	thisHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"767\" height=\"103\">";
	thisHTML = thisHTML + "<param name=\"movie\" value=\"/swf/nav_homepage.swf\">";
	thisHTML = thisHTML + "<param name=\"quality\" value=\"high\">";
	thisHTML = thisHTML + "<embed src=\"/swf/nav_homepage.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"767\" height=\"103\"></embed>";
	thisHTML = thisHTML + "</object>";
	
	thisHTML = thisHTML + "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"767\" height=\"327\">";
	thisHTML = thisHTML + "<param name=\"movie\" value=\"/swf/glad_homepage_r5ra1.swf\">";
	thisHTML = thisHTML + "<param name=\"quality\" value=\"high\">";
	thisHTML = thisHTML + "<embed src=\"/swf/glad_homepage_r5ra1.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"767\" height=\"327\"></embed>";
	thisHTML = thisHTML + "</object>";
	
	document.getElementById("nav_and_wheel_container").innerHTML = thisHTML;
}

// one day cookie to only show HPTO to returning user one time per day
function createHPTOCookie()
{
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "gladHPTO=viewed"+expires+"; path=/";
}

// check if user has seen HPTO in past 24 hours
function checkHPTOCookie() {
	var cookieExists = false;
	var nameCookie = "gladHPTO";
	var cookieArray = document.cookie.split(';');
	for(var i=0;i < cookieArray.length;i++) {
		var c = cookieArray[i];
		while (c.charAt(0)==' ') {
			c = c.substring(1,c.length);
			if (c.indexOf(nameCookie) == 0) {
				if (c.substring(nameCookie.length,c.length) == "=viewed") {
					write_wheel_homepage_token();
					cookieExists = true;
				}
				break;
			}
		}
	}
	if (cookieExists == false) {
		createHPTOCookie();
	}
}

// New Page for External Links	
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;