function fireAtlasTag(tag){
	var trackingImage = document.getElementById('ClickTrackingImage');
    trackingImage.src = 'http://view.atdmt.com/action/' + tag;
}

function FireActionTag(tag){
    //alert('test');
    var trackingImage = document.getElementById('action_tag');
    trackingImage.src = 'http://view.atdmt.com/action/' + tag;
}

function clearField(field,defaultMsg){
	if(field.value == defaultMsg){
		field.value = '';
	}
}
function defaultField(field,defaultMsg){
	if(field.value == ''){
		field.value = defaultMsg;
	}
}


/* CONDENSED SOUPS rollover code */
function imageChange(imageID,imageName) {
  document.images[imageID].src= eval(imageName + ".src");
}

delicious = new Image();
delicious.src = "images/condensed/navbar_delicious.png";
delicious_over = new Image();
delicious_over.src = "images/condensed/navbar_delicious-over.png";
classic = new Image();
classic.src = "images/condensed/navbar_classic.png";
classic_over = new Image();
classic_over.src = "images/condensed/navbar_classic-over.png";
taste = new Image();
taste.src = "images/condensed/navbar_taste.png";
taste_over = new Image();
taste_over.src = "images/condensed/navbar_taste-over.png";
kids = new Image();
kids.src = "images/condensed/navbar_kids.png";
kids_over = new Image();
kids_over.src = "images/condensed/navbar_kids-over.png";
/* end CONDENSED SOUPS rollover code */

if (document.images) {
	var imageNames = new Array("tn_home","tn_recipes","tn_recipebox","tn_collections");
	var imagePath = "images/";
	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 = "";
	}
}


//Updated by dmast at 4:59 3/26
// The TrackTag variable refers to the location of the
// base action tag. In the actual implementation this 
// action tag will point to a 1x1 pixel GIF.

var TrackTag = "http://view.atdmt.com/action/";

function GetActionTag(URL)
{
	document.action_tag.src = TrackTag + URL;	
}

// The URL passed from the SWF will be appended to TrackTag.
// The image will be loaded into the img src tags below the 
// Flash ad's OBJECT tag.
	


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;
	myObj = document.getElementById("RecipeDetail_LargerImageLink");
	myObj.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();
}

function openVideo() {
	var videoPopup = window.open('lowersodiumvideo.aspx','lowersodiumvideo','width=400,height=345,scrollbars=no,menubar=no,resizable=no,toolbar=no,location=no,status=no');
}

function openTSNrules() {
	var wt=807;
	var ht=560;
	var str="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,screenx=30,screeny=20,width="+wt+",height="+ht+",top=50,left=50";
	TSNrulesPop=window.open("http://campbellsoup.promotionexpert.com/trycampbellsoup/official_rules.html","TSNrulesPop",str);
	TSNrulesPop.focus();
}


/**
 *  Global Calls
 */
(function()
{    
    linkExternal = function(obj, linkName)
    {
        omnitureTag(obj, 'e', linkName);
    };

    linkCustom = function(obj, linkName)
    {
        omnitureTag(obj, 'o', linkName);
    }

    linkDownload = function(obj, linkName)
    {
        omnitureTag(obj, 'd', linkName);
    }
    
    omnitureTag = function(obj, type, linkName)
    {
        var s = s_gi(s_account);
        s.linkTrackVars = 'None';
        s.linkTrackEvents = 'None';
        var lt = (obj.href != null) ? s.lt(obj.href) : '';
        if (lt == '') s.tl(obj, type, linkName);
    };
})();

var iObj;
function showDDL(t,strObj) {
	var sObj = document.getElementById(strObj);
	iObj = t;
	
	sObj.style.top = ((t.offsetTop + t.offsetHeight) + 1) + "px";
	sObj.style.left = t.offsetLeft + "px";
	sObj.style.width = t.offsetWidth + "px";

	if((sObj.style.display == "none") || (sObj.style.display == "")) {
		sObj.style.display = "block";
	} else {
		sObj.style.display = "none";
	}
	
	sObj.onclick = setNav;
	
}
function setNav(evt) {
	e = (evt)?evt.target:event.srcElement;
	
	val = (e.innerText) ? e.innerText : e.text;
	id = e.getAttribute("CollectionId")
	
	
	
	e.parentNode.style.display = "none";
	iObj.value = val;
	document.forms[0].rc.value = id;
}
/*==============================================================================
  Cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
==============================================================================*/
function addEvent(element, eventType, functionToCall, useCapture) {
 	if (element.addEventListener) { // DOM standard
		element.addEventListener(eventType, functionToCall, useCapture);
		return true;
	} else if (element.attachEvent) { // IE's model
		var r = element.attachEvent('on' + eventType, functionToCall);
		return r;
	} else { // for browsers which support neither method
		element['on' + eventType] = functionToCall;
	}
}

/*==============================================================================
  Get source of event
==============================================================================*/
function getSource(e) {
	if (typeof e == 'undefined') {
	 	var e = window.event;
	}
	
	var source;
	if (typeof e.target != 'undefined') {
		source = e.target;
	} else if (typeof e.srcElement != 'undefined') {
		source = e.srcElement;
	} else {
		return;
	}
	
	return source;
}
	
/*==============================================================================
  StockPots
==============================================================================*/
function changeSoup(soupName) {
	var soups = ["adobechx","tomato","broccoli","potato","crabcorn","minestrone","chowder","chili","veggie","chixrice","noodle","tortilla"];

	//hide all soups
	for (i=0;i<soups.length;i++) {
		//soupID = soups[i];
		document.getElementById('stockpot_content_' + soups[i]).style.display = "none";
	}	

	//show soup
	document.getElementById('stockpot_content_' + soupName).style.display = "inline";
}

// IE6 bg flicker
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


/*==============================================================================
  Select Harvest Phase 2
==============================================================================*/
function showNutrition(productid){
	var win = window.open(('select-nutrition-popup.aspx?brand=select&prd_product_id=' + productid),'product_popup','width=600,height=475,menubar=no,resizable=no,status=no,toolbar=no');
	win.focus();
}

function productView(productName)
{
	var s_click = s_gi(s_account);
	s_click.events='event2';
	s_click.eVar28 = productName;
	s_click.prop28 = productName;
	s_click.t();
}

var holdOrigID;
function setTrapID(t,id) {
	if(typeof trapID == "string") {
		trapID = id;
	}
	t.onblur = function() {
		if(t.value=="") {
			trapID = holdOrigID;
		}
	}
}

// Media Mind Click Tag Function - OLD //
function ebConversionTracker(conv) {
	var ebConversionImg = new Image();
	var ebConversionURL = "HTTP://bs.serving-sys.com/BurstingPipe/ActivityServer.bs?";
	var ebRandClick = Math.random()+'';
    ebRandClick = ebRandClick * 1000000;
	
	ebConversionURL += "cn=as&ActivityID="+conv+ "&rnd=" + ebRandClick;
	ebConversionImg.src = ebConversionURL;
}

function ebConversionTrackerNew(conversionID, redirURL, targetWin)
{
	try
	{
		var elem = document.createElement("SCRIPT");
		elem.src = "http://bs.serving-sys.com/BurstingPipe/ActivityServer.bs?cn=as&ActivityID=" + conversionID + "&rnd=" + (Math.round(Math.random() * 1000000));
		document.body.appendChild(elem);
		
		if(typeof(redirURL) != "undefined")
		{
			if(typeof(targetWin) == "undefined" || targetWin == "_blank")
			{
				window.open(redirURL);
			}
			else
			{
				var redirFunction = function() {document.location.href = redirURL};
				setTimeout(redirFunction, 1000);
			}
		}
	}
	catch(e) {}
}
