 var bNow = new Date();
 var bNum = bNow.getTime();
 
  var peapodMaster;

 setLocation();

  function setLocation()
 {
  if (opener !=null)
	{    
	   if (opener.top.mainWin != null)
	   {
    	 peapodMaster = opener.top.mainWin;
	   }
	   else
	   {
	     if ((opener.top.opener != null) && (opener.top.opener.top.mainWin != null) )
	     {
   	     peapodMaster = opener.top.opener.top.mainWin;
	     }
	   }
	}
	else
	{
	  peapodMaster = top;
	}
 }
 

// moved from fr4_main.jhtml
function showUpromiseItems()
{
   var newLoc = 'processShowUpromise.jhtml?NUM1=' + bNum;
   bNum = bNow.getTime();

   var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=750,height=490,top=1,left=1';
   var agent = navigator.userAgent;

   if ( agent.indexOf( 'Mozilla' ) != -1 )
   {
      top.uWin = window.open( newLoc, 'UPromiseItems', options);
      if ( top.uWin != null )
         top.uWin.focus();
   }
}

// moved from fr4_main.jhtml
function tonysBlog() 
{
   var newLoc = 'http://tony.peapod.com';

   var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=800,height="100%",top=1,left=1';
   var agent = navigator.userAgent;

   if ( agent.indexOf( 'Mozilla' ) != -1 )
   {
      top.naWin = window.open( newLoc, 'TonysBlog', options);
      if ( top.naWin != null )
        top.naWin.focus();
   }
}

function showNewArrivals() 
{
   var newLoc = 'processShowNewArrivals.jhtml?NUM1=' + bNum;
   newLoc += '&showAll=y';
   bNum = bNow.getTime();

   var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=750,height=490,top=1,left=1';
   var agent = navigator.userAgent;

   if ( agent.indexOf( 'Mozilla' ) != -1 )
   {
      top.naWin = window.open( newLoc, 'NewArrivals', options);
      if ( top.naWin != null )
        top.naWin.focus();
   }
}

   // moved from fr4_main.jhtml
   function showNewArrivalsCategory( catid )
   {
      var newLoc = 'processChangeNewArrivalsCategory.jhtml?CATID=' + catid;
      bNum = bNow.getTime();
      newLoc += "&NUM1=" + bNum;
      newLoc += "&NAV=0";

      var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=750,height=490,top=1,left=1';
      var agent = navigator.userAgent;

      if ( agent.indexOf( 'Mozilla' ) != -1 )
      {
        top.naWin = window.open( newLoc, 'NewArrivals', options);
        if ( top.naWin != null )
          top.naWin.focus();
      }
   }

   // moved from fr4_main.jhtml
   function shopSpecialProductFromCart( prodId, prodDesc, salePrice )
   {
      prodDesc=prodDesc.replace(/\%/gi, "%25");
      prodDesc=prodDesc.replace(/\&/gi, "%26");
      
      salePrice=salePrice.replace(/\%/gi, "%25");	 
      salePrice=salePrice.replace(/\&/gi, "%26");

      var newLoc = 'processShowSpecialProductFromCart.jhtml?PRODID=' + prodId;
      newLoc += "&PRODDESC=" + prodDesc;
      newLoc += "&SALEPRICE=" + salePrice;
      bNum = bNow.getTime();
      newLoc += "&NUM1=" + bNum;

      var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=750,height=490,top=1,left=1';
      var agent = navigator.userAgent;

      if ( agent.indexOf( 'Mozilla' ) != -1 )
      {
        top.specialsWindow = window.open( newLoc, 'WeeklySpecials', options);
        if ( top.specialsWindow != null )
          top.specialsWindow.focus();
      }
    }
 

  function shopSpecialProductFromSpecials( prodId, prodDesc, salePrice )
   {
      prodDesc=prodDesc.replace(/\%/gi, "%25");
      prodDesc=prodDesc.replace(/\&/gi, "%26");   

      salePrice=salePrice.replace(/\%/gi, "%25");
      salePrice=salePrice.replace(/\&/gi, "%26");


      var newLoc = 'processShowSpecialProductFromSpecials.jhtml?PRODID=' + prodId;
      newLoc += "&PRODDESC=" + prodDesc;
      newLoc += "&SALEPRICE=" + salePrice;
      bNum = bNow.getTime();
      newLoc += "&NUM1=" + bNum;

      var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=750,height=490,top=1,left=1';
      var agent = navigator.userAgent;

      if ( agent.indexOf( 'Mozilla' ) != -1 )
      {
        top.specialsWindow = window.open( newLoc, 'WeeklySpecials', options);
        if ( top.specialsWindow != null )
          top.specialsWindow.focus();
      }
   }
   
 function showAllSpecialsCategory( catid )
 {
    var newLoc = 'allSpecials.jhtml?CATID=' + catid;
    bNum = bNow.getTime();
    newLoc += "&NUM1=" + bNum;

    var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=750,height=490,top=1,left=1';
    var agent = navigator.userAgent;

    if ( agent.indexOf( 'Mozilla' ) != -1 )
    {
      top.specialsWindow = window.open( newLoc, 'AllSpecials', options);
      if ( top.specialsWindow != null )
        top.specialsWindow.focus();
    }
 }

 function showAllSpecials()
 {
    var newLoc = 'allSpecials.jhtml';
    bNum = bNow.getTime();
    newLoc += '?NUM1=' + bNum
    newLoc += '&currentCatNo=0'
    newLoc += '&showAll=y'

    var options = 'resizable=yes,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=750,height=490,top=1,left=1';
    var agent = navigator.userAgent;

    if ( agent.indexOf( 'Mozilla' ) != -1 )
    {
      top.specialsWindow = window.open( newLoc, 'AllSpecials', options);
      if ( top.specialsWindow != null )
        top.specialsWindow.focus();
    }
 }

 function checkCutoff()
 {
    var newLoc = 'processCutoffPopup.jhtml?NUM=' + bNum;
    peapodMaster.frame6.location.replace(newLoc);
    bNum++;
 }

  
  function init()
  {
     peapodMaster.refreshCartItems = 'true';
     peapodMaster.refreshCartTotals = 'false';
  }

  // moved from fr4_main.jhtml
  function newImage(arg)
  {
     if (document.images)
     {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
     }
  }

  function preloadImages( Img_3247, Img_3248 )
  {
     if (document.images) 
     {           
        image_grocery_cart_visible = newImage(Img_3247);  
        image_grocery_cart_invisible = newImage(Img_3248);       
        image_grocery_cart_visible_src = Img_3247;
        image_grocery_cart_invisible_src = Img_3248;
        preloadImagesFlag = true;     
     }
  }
  
  function ntn( prodId, storeId )
  {
     peapodMaster.refreshCartItems = 'false';
     peapodMaster.refreshCartTotals = 'false';
     peapodMaster.szItemDetailCalledFrom = 'ItemShelf';
     newLoc = 'itemDetail_frame.jhtml?productId=' + prodId;
     newLoc += "&storeId=" + storeId;
     newLoc += '&NUM=' + bNum;
	 
     var remote = window.open(newLoc,'NutritionInfo','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=no,width=450,height=550,top=50,left=300');
     
     if ( remote != null )
        remote.focus();
	
	 bNum++;
  }

  function y2k(number)
  {
     return (number < 1000) ? number + 1900 : number;
  }


   function setReviewOrderShelf ( value )
   {
      bReviewOrderShelf = value;
   }
   
  function openLaborDay(newLoc)
  {
     window.open(newLoc,'','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=300,height=200,top=50,left=300');
  }

  function DisplaySpecialNoticePopup()
  {
     var URL;
     var Height  = 275;   // Height and Width of popup window
     var Width   = 400;

     var agent = navigator.userAgent;
     if ( agent.indexOf( 'Mozilla' ) != -1 && top.cnt==0 )
     {
        top.cnt=1;
        URL= "hurricaneShortagePopup.jhtml";
        window.open( URL, 'lostOrders',
        'toolbar=no,titlebar=no,location=no,directories=no,' +
        'status=no,scrollbars=no,menubar=no,' +
        'width=' + Width + ',height=' + Height);
     }
  }

  function DisplaySnowDeliveryPopUp()
  {
     var URL;
     var Height  = 300;   // Height and Width of popup window
     var Width   = 384;

     var agent = navigator.userAgent;
     if ( agent.indexOf( 'Mozilla' ) != -1 && top.cnt==0 )
     {
        top.cnt=1;
        URL= "snowDelivery.jhtml";
        window.open( URL, 'SnowDelivery',
        'toolbar=no,titlebar=no,location=no,directories=no,' +
        'status=no,scrollbars=no,menubar=no,' +
        'width=' + Width + ',height=' + Height);
     }
  }
  

   function addlInfo(newLoc)
   {
      window.open(newLoc,'','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=400,height=400,top=50,left=300');
   }
   

   function forgotPwd()
   {
      // window.open('forgotPwdNonSecure.jhtml?c=pwd', '', 'dependent=no,resizable=no,scrollbars=no,width=575,height=315,top=50,left=50')
      
	  var newLoc = 'forgotPwdNonSecure.jhtml' + '?NUM1=' + bNum;
	  newLoc += '&c=pwd';
	  location=newLoc;
	  bNum++;	   
   }
   
   function forgotUser()
   {
     // window.open('forgotPwdNonSecure.jhtml?c=user', '', 'dependent=no,resizable=no,scrollbars=no,width=575,height=315,top=50,left=50')
      
	  var newLoc = 'forgotPwdNonSecure.jhtml' + '?NUM1=' + bNum;
      newLoc += '&c=user';
	  location=newLoc;
	  bNum++;	   
   }

   
   function loadRefresh()
   {
      var bNum = bNow.getTime();      
	  var newLoc = 'refreshSession.jhtml?NUM=' + bNum
	  newLoc +='&counter=0';
      peapodMaster.frame6.location.replace(newLoc);	  
   }
   
    function unloadRefresh()
   {
      var bNum = bNow.getTime();      
	  var newLoc = 'frame6.jhtml?NUM=' + bNum;
      peapodMaster.frame6.location.replace(newLoc);	  
   }
   
   function goToPage( p )
   {   
	  var newLoc = p + '?NUM1=' + bNum;
	  top.frame4.location=newLoc;
	  bNum++;
   }
   
   function goToMailInformation()
{
   var newLoc = 'processShowMyEmailPage.jhtml?NUM1=' + bNum;
   top.frame4.location=newLoc;
   bNum++;
}

function goToChangePasswordPage()
{
   top.frame4.location='processShowMyPasswordPage.jhtml';
}

function goToGuestHandlePage()
{
   top.frame4.location='processShowGuestHandlePage.jhtml';
}

function goToChangeUsernamePage()
{
   top.frame4.location='changeUsername.jhtml';
}


function goToCreditCardPage()
{
   top.frame4.location='updateCCDecision.jhtml';
}

function pwdPref()
{
  var newLoc = 'processPwdPref.jhtml?NUM=' + bNum;
  top.frame6.location=newLoc;
  bNum++;
}

function privacy(newLoc)
{
   newLoc = 'privacyPolicyPopup.jhtml';
   window.open(newLoc,'','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=400,height=400,top=50,left=300');
 }

function goToImagesNotificationsPage()
{
   top.frame4.location='imagesNotifications.jhtml';
}


function goToShelfPreferencesPage()
{
   top.frame4.location='shelfDisplayPreferences.jhtml';    
}

function goToSubsPage()
{
   top.frame4.location='substitutionPreferences.jhtml';     
}

function kidsProfile()
{
  var popup = 'kidsYourAccount.jhtml?NUM1=' + bNum;
  bNum++;
  window.open(popup,'','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=429,height=440,top=100,left=200');
}

function togglePref(type)
{
  
  newLoc = 'processUpdEmailPref.jhtml?NUM1='+bNum;
  newLoc += '&type=' + type;
  top.frame6.location.replace(newLoc);
  bNum++;
}
 
 function d()
{
    var TabImgFld = eval("'tab1'");
    if ( top.frame1.document.images[TabImgFld] )
    {
      top.frame1.document.images[TabImgFld].src = top.tab_img7;
    }
    top.location = 'processShowDeliveryTimes.jhtml?NUM1='+bNum;
    bNum++;
}

function DisplayOrderInfoAutoPane()
{
 var agent = navigator.userAgent;
 if ( top.orderInfoCnt==0 )
 {
  top.orderInfoCnt=1;
  new net.ContentLoader('orderInfoAutoPane.jhtml',showOrderInfo, null, 'GET' );
 }
}

function DisplayOrderInfoPane()
{
 new net.ContentLoader('orderInfoPane.jhtml',showOrderInfo, null, 'GET' );
}


 function goToGateway()
  {
    var bNow = new Date();
    var bNum = bNow.getTime();
    top.location.replace( 'processGoToGatewayPage.jhtml?NUM1=' + bNum );
    bNum++;
  }

function activateTab( tabNo )
{
   if ( tabNo == '2' )
      activateTab2();
   else if ( tabNo == '6' )
      activateTab6();
   else if ( tabNo == '3' )
      activateTab3();
   else if ( tabNo == '4' )
      activateTab4();
   else if ( tabNo == '5' )
      activateTab5();
   else if ( tabNo == '7' )
      activateTab7();
   else
      activateTab1();
}

function activateTab1()
{
   var TabImgFld = eval("'tab1'");
   if ( top.frame1.document.images[TabImgFld] )
   {
      top.frame1.document.images[TabImgFld].src = top.tab_img1;
   }
}

function activateTab2()
{
   var TabImgFld = eval("'tab1'");
   if ( top.frame1.document.images[TabImgFld] )
   {
      top.frame1.document.images[TabImgFld].src = top.tab_img2 ;
   }
}

function activateTab3()
{
   var TabImgFld = eval("'tab1'");
   if ( top.frame1.document.images[TabImgFld] )
   {
      top.frame1.document.images[TabImgFld].src = top.tab_img3 ;
   }
}

function activateTab4()
{
   var TabImgFld = eval("'tab1'");
   if ( top.frame1.document.images[TabImgFld] )
   {
      top.frame1.document.images[TabImgFld].src = top.tab_img4 ;
   }
}

function activateTab5()
{
   var TabImgFld = eval("'tab1'");
   if ( top.frame1.document.images[TabImgFld] )
   {
      top.frame1.document.images[TabImgFld].src = top.tab_img5;
   }
}

function activateTab6()
{
   var TabImgFld = eval("'tab1'");
   if ( top.frame1.document.images[TabImgFld] )
   {
      top.frame1.document.images[TabImgFld].src = top.tab_img6;
   }
}

function activateTab7()
{
   var TabImgFld = eval("'tab1'");
   if ( top.frame1.document.images[TabImgFld] )
   {
      top.frame1.document.images[TabImgFld].src = top.tab_img7;
   }
}

function displayHomeTab()
{
  activateTab1();
}

function displayExpressShopTab()
{
  activateTab2();
}

function displayBrowseAislesTab()
{
  activateTab3();
}

function displayMyListsTab()
{
  activateTab4();
}

function displaySpecialsTab()
{
  activateTab5();
}

function displayRecipesTab()
{
  activateTab6();
}

function displayDeliveryTimesTab()
{
  top.exitFlag=false;
}

function DisplayETAPopup()
{
/*
   var URL;
   var Height  = 265;   // Height and Width of popup window
   var Width   = 335;

   {
      URL= "ETAPopup.jhtml";
      window.open( URL, 'ETAPopup',
         'toolbar=no,titlebar=no,location=no,directories=no,' +
         'status=no,scrollbars=no,menubar=no,' +
         'width=' + Width + ',height=' + Height);
   } */
   
   new net.ContentLoader('etaInformationPane.jhtml',showETAInfoPane, null, 'GET' ); 
}


function myacct()
{
   bNow = new Date();
   var bNum = bNow.getTime();
   top.frame4.location.replace('processShowMyAccountPage.jhtml?NUM1='+bNum);
   bNum++;
 }


function addlInfo(newLoc)
{
   window.open(newLoc,'','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=400,height=400,top=50,left=300');
}


function unattended(newLoc)
{
   window.open(newLoc,'','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=400,height=400,top=50,left=300');
}

function marketDayFAQ()
{
   var newLoc = 'marketDayFAQ.jhtml?NUM1=' + bNum;
   bNum = bNow.getTime();

   var options = 'resizable=no,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=740,height=425,top=1,left=1';
   var agent = navigator.userAgent;

   if ( agent.indexOf( 'Mozilla' ) != -1 )
   {
      remote = window.open( newLoc, 'MarketDayFAQ', options);
      if ( remote != null )
        remote.focus();
   }
 }


function closeme()
{
   window.close();
}

function goToDirectCheckPage( id )
{
   var newLoc = 'directCheckFrameset.jhtml';
   bNum = bNow.getTime();
   newLoc += '?' + bNum;
   newLoc += ';jsessionid='+id;
   top.frame4.location.replace( newLoc )
}

function showGiftcardTerms()
{
 var newLoc = 'giftCardTerms.jhtml?NUM1=' + bNum;
 bNum = bNow.getTime();
 var options = 'resizable=no,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=600,height=400,top=200,left=300';
 var agent = navigator.userAgent;

 if ( agent.indexOf( 'Mozilla' ) != -1 )
 {
   var remote = window.open( newLoc, 'TermsOfService', options);
   if ( remote != null )
   remote.focus();
 }
}

function goToMyAccount()
{
   var newLoc = 'processShowMyAccountPage.jhtml?NUM1=' + bNum;
   top.frame4.location=newLoc;
   bNum++;
}

function open_window(url)
{
  mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=0,resizable=0,width=446,height=362');
}

function redirectToForm( routing, recipient, subject, body )
{
  var bNow = new Date();
  var bNum = bNow.getTime();

  var newLocation = 'contactPeapodForm.jhtml?routing=' + routing;
  newLocation += "&recipient=" + recipient;
  newLocation += "&subject=" + subject;
  newLocation += "&body=" + body;
  self.location.replace(newLocation);
}

function DisplayUpromiseFAQ()
{
   var URL;
   var Height  = 425;   // Height and Width of popup window
   var Width   = 650;

   {
      URL= "upromiseFAQ.jhtml";
      window.open( URL, 'UpromiseFAQ',
      'toolbar=no,titlebar=no,location=no,directories=no,' +
      'status=no,scrollbars=yes,menubar=no,' +
      'width=' + Width + ',height=' + Height);
    }
}

 
