if (document.images) {
	var imageNames = new Array("tn_home","tn_recipes","tn_recipebox","tn_whatsnew","tn_collections","tn_producttips","tn_catererscorner");
	var imagePath = "images/summer/";
	var imageExtension = ".gif";
	var allMyImages = new Array(imageNames.length);
	var curName = "";
	var gWhichGlowing = "";
	
	for (var i=0; i<imageNames.length; i++) {
		curName = imageNames[i];
		allMyImages[curName] = new Array("over","out");
		allMyImages[curName]["out"] = new Image();
		allMyImages[curName]["out"].src = imagePath+curName+imageExtension;
		allMyImages[curName]["over"] = new Image();
		allMyImages[curName]["over"].src = imagePath+curName+"-over"+imageExtension;
	}
}

function Glow(whichImage) {
	if (document.images) {
		document[whichImage].src = allMyImages[whichImage]["over"].src;
		gWhichGlowing = whichImage;
	}
}

function DeGlow(){
	if (document.images) {
		document[gWhichGlowing].src = allMyImages[gWhichGlowing]["out"].src;
		gWhichGlowing = "";
	}
}

function windowPop(url, name, width, height, scrollboolean) {
	var params;
	if (scrollboolean != "") {
		params = "scrollbars="+scrollboolean;
	} else {
		params = "scrollbars=0";
	}
	params= params + ",location=0,menubar=0,status=0,toolbar=0,resizable=1,top=40,left=40,";
	params = params + "width=" + width + ",height=" + height; 
	window.open(url, name, params).focus();
}

function recipePopUp(id) {
	var name = "recipezoom";
	var width = 300;
	var height = 327;
	var url = "recipezoom.asp?recipeID=" + id;
	var params="scrollbars=0,location=0,menubar=0,status=0,toolbar=0,resizable=1,top=40,left=40,";
	var params = params + "width=" + width + ",height=" + height; 
	window.open(url, name, params).focus();
}

function toggleDiv(itemid) {
	var changeMe = document.getElementById(itemid);
	if ((changeMe.style.display == "none") || (changeMe.style.display == "")) {
		changeMe.style.display="block";
	} else {
		changeMe.style.display="none";
	}
}
function hideLink() {
	var myObj;
	var imageMaskLarge;
	var imageMaskSmall;
	
	myObj = document.getElementById("RecipeDetail_LargerImageLink");
	imageMaskLarge = document.getElementById("recipelarger");
	imageMaskSmall = document.getElementById("recipesmaller");
	
	myObj.style.display="none";
	imageMaskLarge.style.display="inline";
	imageMaskSmall.style.display="none";
}

function openUPC() {
	var wt=325;
	var ht=195;
	var str="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,screenx=30,screeny=20,width="+wt+",height="+ht+",top=50,left=50";
	HomePop=window.open("upc.aspx","upcPop",str);
	HomePop.focus();
}

function openManu() {
	var wt=450;
	var ht=300;
	var str="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,screenx=30,screeny=20,width="+wt+",height="+ht+",top=50,left=50";
	HomePop=window.open("manufacturingcode.aspx","manuPop",str);
	HomePop.focus();
}

var liveWorldURL = "http://community.campbellkitchen.com/entry.jsp";        // PROD
//var liveWorldURL = "http://kitchenscc.stage.liveworld.com/entry.jsp";     // STAGING

function alterFormAction() {
	//alert(document.body.innerHTML);
	document.forms[0].submit();
}

function writeWindowsMedia(strFileName, strAutoStart, intWidth, intHeight){
	document.write("<object ID=RVOCX CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" WIDTH=" + intWidth + " HEIGHT=" + intHeight + ">");
	document.write("<param NAME=\"SRC\" VALUE=\"" + strFileName + "\">");
	document.write("<param NAME=\"CONTROLS\" VALUE=\"ImageWindow\">");
	document.write("<param NAME=\"CONSOLE\" VALUE=\"one\">");
	document.write("<param NAME=\"CENTER\" VALUE=\"TRUE\">");
	document.write("<param NAME=\"MAINASPECT\" VALUE=\"false\">");
	document.write("<param NAME=\"AUTOSTART\" VALUE=\"" + strAutoStart + "\">");
	document.write("<embed type=\"audio/x-pn-realaudio-plugin\" SRC=\"" + strFileName + "\" WIDTH=" + intWidth + " HEIGHT=" + intHeight + " NOJAVA=true CONTROLS=ImageWindow CONSOLE=one AUTOSTART=" + strAutoStart + "></embed>");
	document.write("</object>");
	document.write("<br>");
	document.write("<object ID=RVOCX CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" WIDTH=" + intWidth + " HEIGHT=36>");
	document.write("<param NAME=\"CONTROLS\" VALUE=\"ControlPanel\">");
	document.write("<param NAME=\"CONSOLE\" VALUE=\"one\">");
	document.write("<embed type=\"audio/x-pn-realaudio-plugin\" SRC=\"" + strFileName + "\" WIDTH=" + intWidth + " HEIGHT=36 NOJAVA=true CONTROLS=ControlPanel CONSOLE=one></embed>");
	document.write("</object>");
	document.write("<br>");
	document.write("<object ID=RVOCX CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" WIDTH=" + intWidth + " HEIGHT=30>");
	document.write("<param NAME=\"CONTROLS\" VALUE=\"StatusBar\">");
	document.write("<param NAME=\"CONSOLE\" VALUE=\"one\">");
	document.write("<embed type=\"audio/x-pn-realaudio-plugin\" SRC=\"" + strFileName + "\" WIDTH=" + intWidth + " HEIGHT=36 NOJAVA=true CONTROLS=StatusBar CONSOLE=one></embed>");
	document.write("</object>");
}

function writeWindowsMedia(strFileName, strAutoStart, intWidth, intHeight){
	document.write("<object ID=\"MediaPlayer\" classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" standby=\"Loading Media Player\" width=" + intWidth + " height=" + intHeight + " type=\"application/x-oleobject\">");
	document.write("<param NAME=\"FileName\" VALUE=\"" + strFileName + "\">");
	document.write("<param NAME=\"AutoStart\" Value=\"" + strAutoStart + "\">");
	document.write("<param NAME=\"ShowControls\" VALUE=\"True\">");
	document.write("<param NAME=\"ShowStatusBar\" VALUE=\"True\">");
	document.write("<param NAME=\"ShowDisplay\" VALUE=\"False\">");
	document.write("<param NAME=\"AllowChangeDisplaySize\" VALUE=\"TRUE\">");
	document.write("<param NAME=\"DisplaySize\" VALUE=\"0\">");
	document.write("<param NAME=\"AutoSize\" VALUE=\"true\">");
	document.write("<embed type=\"application/x-mplayer2\" ");
	document.write("pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" ");
	document.write("SRC=\"" + strFileName + "\" ");
	document.write("width=" + intWidth + " ");
	document.write("height=" + intHeight + " ");
	document.write("name=\"MediaPlayer\" ");
	document.write("autostart=\"" + strAutoStart + "\" ");
	document.write("ShowStatusBar=1 ");
	document.write("ShowDisplay=0 ");
	document.write("ShowControls=1 ");
	document.write("AllowChangeDisplaySize=\"TRUE\" ");
	document.write("DisplaySize=\"0\" ");
	document.write("AutoSize=\"false\">");
	document.write("</embed>");
	document.write("</object>");
}

// This replaces sage_ev
function clickTag(n, v)
{
	sage_ev(n, v);
}

function tagDownload(obj, type){
	var s_click = s_gi(s_account);
	s_click.events='event14';
	s_click.linkTrackVars = 'events,eVar9';
	s_click.linkTrackEvents = 'event14';
	s_click.eVar9 = type;
	s_click.tl(this, 'd', type);
}

function tagExit(obj, type){
	var s_click = s_gi(s_account);
	s_click.tl(this, 'e', type);
}

function tagCustom(obj, type){
	var s_click = s_gi(s_account);
	s_click.tl(this, 'o', type);
}

function internalLink(linkName)
{
    var s=s_gi(s_account); 
    s.linkTrackVars='None'; 
    s.linkTrackEvents='None'; 
    var lt=this.href!=null?s.lt(this.href):""; 
    if (lt=="") { s.tl(this,'o','\'' + linkName + '\'') }; 
}

function checkLWAuthAndRedirect(liveWorldURL){
    lwapiAuth = new LWAPI("http://community.campbellkitchen.com");    //PROD
    //lwapiAuth = new LWAPI("http://kitchenscc.stage.liveworld.com"); //STAGING

    var communityURL = 'KitchenTable.aspx?redirect=' + encodeLiveWorldURL(liveWorldURL);
    
    lwapiAuth.callContentService("isAuthenticated", "",
          function(auth) { 
                if (eval(auth)) {
                    location.href=liveWorldURL; 
                } else {
                      // not logged in: prompt for login
                      location.href=communityURL;
                }
          });
}

function encodeLiveWorldURL(liveWorldURL)
{
    var encodedInputString=escape(liveWorldURL);
    
    encodedInputString = encodedInputString.replace(new RegExp("\/", "g"), "%2F");
    
    return encodedInputString;
}


/* Pop-up Survey */

/* SURVEY TAKEDOWN */
/*
function offerSurvey(){	
	// set cookie to expire in one year
	var now = new Date();
	now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365); // add a year
	document.cookie = "offeredSurvey=1;expires="+now;
	
	// when window is resized, the popup div needs to be recentered
	// and the page overlay height needs to be recalculated (IE6)
	window.onresize = function(){centerPopup();restretchOverlay();};
	
	// show the popup
	showPopupSurveyDiv();
}
function centerPopup(){
	if(document.getElementById){
		pgatts = getPageSize();
		popupLeft = Math.ceil((pgatts[0]-459)/2);
		
		var popupDiv = document.getElementById("takeSurvey");
		if(popupDiv)popupDiv.style.left = popupLeft + 'px';
	}
}
function restretchOverlay(){
	if(document.getElementById){
		pgatts = getPageSize();
		pageHeight = Math.ceil(pgatts[1]);
		
		var overlayDiv = document.getElementById("overlay");
		if(overlayDiv)overlayDiv.style.height = pageHeight + 'px';
	}
}
function showPopupSurveyDiv(){
	if(document.getElementById){		
		
		pgatts = getPageSize();
		popupLeft = Math.ceil((pgatts[0]-459)/2);
		pageHeight = Math.ceil(pgatts[1]);
		
		// grayed-out page overlay
		var objBody = document.getElementsByTagName("body")[0];
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.height = pageHeight+'px';
		objBody.appendChild(objOverlay);
		
		
		// pop up div
		var content = document.getElementById("content");
		var popupDiv = document.createElement("div")
		
		popupDiv.setAttribute("id","takeSurvey");
		popupDiv.style.left = popupLeft+'px';
		
		popupDiv.innerHTML = '';
		popupDiv.innerHTML += '<p class="closebar"><a href="#" onclick="closePopupSurveyDiv();return false;"><img src="images/icon_close_x.gif" width="14" height="14" alt="Close"></a></p>';
		popupDiv.innerHTML += '<p><img src="images/h_would_you_please_complete.gif" width="392" height="48" alt="Would you please complete a 3-minute survey at the end of your visit to PuffPastry.com?"></p>';
		popupDiv.innerHTML += '<a href="#" id="btnyes" onclick="launchSurvey();return false;"><img src="images/btn_survey_yes.gif" width="237" height="15" alt="YES, I\'ll take the survey at the end of my visit*"></a>';
		popupDiv.innerHTML += '<a href="#" id="btnno" onclick="closePopupSurveyDiv();return false;"><img src="images/btn_survey_no.gif" width="83" height="15" alt="NO thanks"></a>';
		popupDiv.innerHTML += '<p class="disclaimer"><strong>*Do not close the PuffPastry.com window.</strong> A second window with the survey will open on your desktop under this window if you click yes. Enjoy your visit and complete the brief survey when done.</p>';
		
		objBody.appendChild(popupDiv);
	}
}
function launchSurvey(){
	closePopupSurveyDiv();
	
	// launch survey as pop under
	windowHandle = window.open('sitesurvey.aspx','survey','toolbar=no,personalbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=636,height=500;');
	windowHandle.blur();
}
function closePopupSurveyDiv(){
	if(document.getElementById){
		var surveyDiv = document.getElementById("takeSurvey");
		if(surveyDiv!=null)surveyDiv.parentNode.removeChild(surveyDiv);
		
		var overlayDiv = document.getElementById("overlay");
		if(overlayDiv!=null)overlayDiv.parentNode.removeChild(overlayDiv);
	}
	window.onresize = null;
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
*/