// JavaScript Document

if (document.getElementById("PleaseWait") != null) document.getElementById("PleaseWait").style.display = "none";

// update to true if the deal of the week coupon is showing
var dowCoupon = false
var ci_dealofweekpid
var gInitAdSource = false;
var gContext = "";



// SET GLOBAL HEADER
		
function SetNavMenuLinks(actNavMenu, showCpnCarrier)
{

	// create featured today section
	if ((actNavMenu == "bd-printable") && (typeof(ci_FeaturedPrograms) !="undefined")) 
		SetFeaturedToday()
	
	// hidde Holiday Tabs	
	if (document.getElementById('NavTabContainerTable') != null ) 
	{
		document.getElementById('NavTabContainerTable').style.display = "none";
		document.getElementById('NavTabContainerTable').style.height = "0px";
		
	}
	
// Login / Register links at the page header:
	 
	var queryString = GetQueryString();


	var fName = GetWelcomeName()

	
    if( fName != null )
       {
		  if (fName == "") 
			   personalization = "Welcome&nbsp;" 
		  else
          	   personalization = "Welcome, " + fName + "&nbsp;<em>(<a href='/couponweb/Login.aspx?" + queryString + "'>I'm not " + fName + "</a>)</em>" 
				
		  personalization += "&nbsp;|&nbsp;<a href='/couponweb/Login.aspx?" + queryString + "'>Sign Off</a>";
       }
    else
       {
          personalization = "<a   href='/couponweb/Login.aspx?" + queryString + "'>Sign In</a> | <a href='/couponweb/Register.aspx?" + queryString + "'>Sign Up</a>";
       }	
	document.getElementById("user").innerHTML = personalization 

// top navigation menu links:

<!-- LOCAL updates: top navigation image -->

	
	var CookieLocal = "cpnLocalTab" +GetQueryStringValue('pid')
	
	var showLocal = false	
	var addLocalTab = ""
	
    var bLocalTab = GetCookie(CookieLocal)
	
    if (bLocalTab != null)
	{
		addLocalTab =  "_Local"
		showLocal = true
	}
	else if (document.getElementById('localOfferTabOff') != null)
	{
		showLocal = true
		addLocalTab =  "_Local"			
		SetCookie(CookieLocal,1,0,"/",null,null)
		
	}
<!-- END LOCAL updates: top navigation image -->

<!-- Savings Cards updates: top navigation image -->

		
	var CookieCard = "cpnCardsTab" +GetQueryStringValue('pid')

	var showSavCards = false
	var addSavCardsTab = ""
	
    var bSavCardsTab = GetCookie(CookieCard)
	
    if (bSavCardsTab != null)
	{
		addSavCardsTab =  "_Cards"
		showSavCards = true
	}

	else if (document.getElementById('eOfferTabOff') != null)
	{
		showSavCards = true
		addSavCardsTab =  "_Cards"			
		SetCookie(CookieCard,1,0,"/",null,null)
		
	}

<!-- END Savings Cards updates: top navigation image -->
<!-- Coupon Codes tab: top navigation image -->

		
	var CookieCodes = "cpnCodesTab" + GetQueryStringValue('pid')

	var showCpnCodes = false
	var addCodesTab = ""
	
    var bCodesTab = GetCookie(CookieCodes)
	
    if (bCodesTab != null)
	{
		addCodesTab = '_Codes'
		showCpnCodes = true
	}

	else if (typeof(CouponsCodesTab) != "undefined" && CouponsCodesTab )
	{
		showCpnCodes = true
		addCodesTab = '_Codes'			
		SetCookie(CookieCodes,1,0,"/",null,null)		
	}

<!-- END Coupon Codes updates: top navigation image -->

	var strPageHeader


	
   strPageHeader = '<div id="navWrap' + addSavCardsTab  + addLocalTab + addCodesTab + '">'
   strPageHeader +='<ul id="nav' + addSavCardsTab  + addLocalTab + addCodesTab + '">'
   strPageHeader +='<div id="pageNavMenu' + addSavCardsTab + addLocalTab + addCodesTab + '" class="' + actNavMenu + '">'
   strPageHeader +='<li id="nav1' + addSavCardsTab + addLocalTab + addCodesTab + '"><a href="/couponweb/offers.aspx?' + queryString + '" accesskey="2">Coupons</a></li>'

   if (showSavCards) 
{
   strPageHeader +='  <li id="nav2' + addSavCardsTab + addLocalTab + addCodesTab + '"><a href="/couponweb/eoffers.aspx?' + queryString + '" accesskey="3">Savings Cards</a></li>'
}

   if (showLocal) 
{
   strPageHeader +='  <li id="nav3' + addSavCardsTab + addLocalTab + addCodesTab + '"><a href="/couponweb/localoffers.aspx?' + queryString + '" accesskey="3">Local Coupons</a></li>'
}

   if (showCpnCodes) 
{
   strPageHeader +='  <li id="nav4' + addSavCardsTab + addLocalTab  + addCodesTab + '"><a href="/couponweb/couponcode.aspx?' + queryString + '" accesskey="3">Coupon Codes</a></li>'
}

if (! showSavCards && !showLocal && !showCpnCodes)
{
	strPageHeader +='  <li id="nav4"><a href="/couponweb/Recipes/Main.aspx?' + queryString + '" accesskey="4">Recipes</a></li>'
}
	strPageHeader +='  <li id="nav5' + addSavCardsTab + addLocalTab + addCodesTab + '"><a href="/couponweb/register.aspx?' + queryString + '" accesskey="5">Members Center</a></li>'
	strPageHeader +='  <li id="nav6' + addSavCardsTab + addLocalTab + addCodesTab + '"><a href="/couponweb/aboutus.aspx?' + queryString + '" accesskey="6">More</a></li>'
	
	strPageHeader +='  </div>'
	strPageHeader +='  </ul>'
	strPageHeader +='</div>'


	document.getElementById("navWrapArea").innerHTML = strPageHeader;
	



    var strSidebarNav = "" 
	
<!-- Gift Card center Flyout -->	
	if (typeof(ci_GiftCardInfo) !="undefined" && ci_GiftCardInfo.length > 0 && actNavMenu == 'bd-printable' && showCpnCarrier == 1)
		strSidebarNav = DisplayGiftCards()

	if (typeof(DailyDealLnk) != "undefined" && DailyDealLnk  && actNavMenu == 'bd-printable' && showCpnCarrier == 1)
	strSidebarNav += '<div onclick="var e = arguments[0] || window.event; OpenDealyDealFlyOut(e.clientX,e.clientY); return false;" style="cursor: hand; cursor: pointer;"><img src="http://download1.coupons.com/7/19/7125/1450/print.coupons.com/CouponWeb/Themes/CM_BigBlue/_images/DailyDeal_lnk.jpg"></div>'


	strSidebarNav += '<li id="accCoupons"><h4><a href="/couponweb/offers.aspx?' + queryString + '" ' + (actNavMenu == 'bd-printable' ? 'class="selected"' : '' ) + ' >COUPONS</a></h4><div id="listCategory"></div></li>'
	
	
	if (showSavCards)
	{
		strSidebarNav +=  '<li id="accCards"><h4><a href="/couponweb/eoffers.aspx?' + queryString + '" ' + (actNavMenu == 'bd-cards' ? 'class="selected"' : '' ) + ' >SAVINGS CARDS</a></h4><div id="listCardsCategory"></div></li>'
		
	}
	
	if (showLocal)
	{
		strSidebarNav +=  '<li id="accLocal"><h4><a href="/couponweb/localoffers.aspx?' + queryString + '" ' + (actNavMenu == 'bd-local' ? 'class="selected"' : '' ) + ' >LOCAL COUPONS</a></h4><div id="listLocalCategory"></div></li>'
	}
	
	
	if (showCpnCodes)
	{
		strSidebarNav +=  '<li id="accOnlineSavings"><h4><a href="/couponweb/couponcode.aspx?' + queryString + '" ' + (actNavMenu == 'bd-codes' ? 'class="selected"' : '' ) + ' >COUPON CODES</a></h4></li>'
	}
	
	if (actNavMenu == 'bd-about' || actNavMenu == 'bd-members' || actNavMenu == 'bd-recipes')
	{
		strSidebarNav +=  '<li id="accRecipes"><h4><a href="/couponweb/Recipes/Main.aspx?' + queryString + '" ' + (actNavMenu == 'bd-recipes' ? 'class="selected"' : '' ) + ' >RECIPES</a></h4><div id="listRecipes"></div></li>'
	}

	
	document.getElementById("sidebarNav").innerHTML = strSidebarNav
	

	if (actNavMenu == "bd-cards")
	{
		document.getElementById("dvPrintBtn").innerHTML = "<h5><a href='javascript:btnWhatonCard()' title='What is on my card?'>What is on my card? &raquo</a></h5>"
		
	}
		 
	if (showCpnCarrier == 0 ){
		
		document.getElementById("util").style.display = "none"
		document.getElementById("sbH4-FeaturedToday").style.display = "none"
		document.getElementById("featuredBrends").style.display = "none"
		document.getElementById("zip").style.display = "none"
		
		}
		
}


// -- set cookie for user name to user at Welcome message

function GetWelcomeName()
{
	
    var strUser = GetCookie("cpnUser")
	
    if (typeof(ci_regObj) !="undefined")
	{
	
	
		if( ci_regObj.isLoggedIn > 0 && ci_regObj.email != '')
		{
			var user = ci_regObj.user.replace(/^\s+/,'').replace(/\s+$/,'');
			//if ( ci_regObj.isAutoreg <= 0 )
			//{
				if (strUser == null) SetCookie("cpnUser",user,0,"/",null,null); 
				return user
			//}
				
		}
		else if (strUser != null)
		{
				DeleteCookie( "cpnUser", "/", "" );
				return null
		}
	}
	else
		return strUser
	 

}


// TESTIMONIALS
// display the testimonials randomly from four fixed arrays

function DisplayTestimonials() 
{
	var arrayNames = ["Tonie H.","Karen C.","Carla D.","Marilyn B.","Heather S.","Mike W.","Robin W.","Zarina P.","Anne S."];
	var arrayLocations = ["St. Louis, MO","San Francisco, CA","Ashville, NC","Philadelphia, PA","Seattle, WA","Palm Beach Gardens, FL","Boston, MA", "Plymouth, MI", "Cleveland, OH"];
	var arrayImages = ["_test1_TonieH_StLouisMO.jpg","_test2_KarenC_SanFranciscoCA.jpg","_Test3_CarlaD_AshvilleNC.jpg","_Test6_MarilynB_PhiladelphiaPA.jpg","_Test7_HeatherS_SeattleWA.jpg","_Test8_MikeW_PalmBeachGardensFL.jpg",
		"_Test9_RobinW_BostonMA.jpg", "_test10_MooseM.jpg", "_test11_AnneS_ToledoOH.jpg"];
	var arrayTestimonials = ["Coupons.com makes it so easy to print the coupons I want then head out to shop.  Too sweet!  I was never a coupon person before Coupons.com.","Coupons.com has the best coupons on products that I want to buy.  They have all the really big brand names that I know and trust.",
		"We all need a little help stretching our dollars, and Coupons.com is a great place to get it.",
		"It's easy to use coupons.com and it saves my family a lot of money.","Coupons.com is super convenient. I just print my coupons before I go shopping each week.","Coupons.com offers excellent coupons. Better than everywhere else.","Love the RSS feed. I added it to my iGoogle homepage.  Big fan!", "I love how easy it is to look through the products on Coupons.com.  It's easy to find just what I'm looking for.","It is easy to print and save with Coupons.com. I get the weekly email newsletter to remind me to check the site at least once a week for new coupons."];

	var intIndex = Math.round(Math.random()*100) % 9;
	
	var whichPage = document.URL;
	if (whichPage.indexOf("FAQ") != -1) imagePath = "../_images/"
	else if (whichPage.indexOf("Recipes") != -1) imagePath = "../Themes/CM_BigBlue/_images/"
	else imagePath = "Themes/CM_BigBlue/_images/"
	imagePath = "http://a19.g.akamai.net/7/19/7125/1452/print.coupons.com/Couponweb/Themes/CM_BigBlue/_images/"

	document.getElementById("testimonialBox").innerHTML = '<div class="testimonialInfo clearfix"><img src="' + imagePath + arrayImages[intIndex] + '" width="68" height="68" alt="Customer Photo" /><h3>' +
		arrayNames[intIndex] + '</h3><br><h4>' + arrayLocations[intIndex] + '</h4></div><p>' +
		arrayTestimonials[intIndex] + '</p>';
}

// FEATURED BRANDS FLYOUTS

function SetFeaturedToday()
{
   var i=0;
   var strFeaturedBrand = ""
   var actCpn
 
 
 if(typeof(ci_FeaturedPrograms) !="undefined")
  {
          var progArr = ci_FeaturedPrograms.ReturnFeaturedPrograms();  
          if( typeof(progArr)!="undefined" && progArr !=null )
          {
               //for (var i = 0;i< progArr.length;i++)
			   for (var i = progArr.length-1; i>-1;i--)

               {
					 actCpn = 0;				   
                     if(progArr[i].ProgramCoupons.length > 1)
                     {
                           for(var j=0; j< progArr[i].ProgramCoupons.length ; j++)
                           {   
						   	  if (progArr[i].ProgramCoupons[j].Status != 3)	
                               	actCpn++                  
                           }
						   if (actCpn > 1)
						   {
							   
		 strFeaturedBrand +=' <div class="fbrand"  onclick="var e = arguments[0] || window.event; OpenBrandFlyOut(e.clientX,e.clientY,' + i + '); return false;">'
		 +'            <div class="brandWrap"><img src="' + progArr[i].ProgramImgURL + '" />'
		 +'                <div class="brandTxt">'
		 +'                    <h4>' + progArr[i].programText + '</h4>'
		 +'                     <h3>Savings</h3>'
		 +'                     <h3>Center</h3>'
		 +'               </div>'
		 +'           </div>'
		 +'      </div>';
					 	   }
		 
                    }
              } 
         }
    }
 

	if (strFeaturedBrand != "") 
	{
		document.getElementById("sbH4-FeaturedToday").style.display = "block"
		document.getElementById("featuredBrends").innerHTML = strFeaturedBrand
	}
}
 
 
// -------------------------------
function OpenBrandFlyOut(xPos,yPos,arrId)
{   

 
   var TAFDiv = document.getElementById('BrandFlyOutDiv');    
   var FlyoutHTMLheader;
   var FlyoutHTMLcpns	

   var i = arrId
					//-----------flyout HTML begins
   var objBrand = ci_FeaturedPrograms.FeaturedPrograms[i];
   var objBrandCpn = objBrand.ProgramCoupons
//alert(objBrandCpn[0].couponID)

				
		FlyoutHTMLheader =' 	<p class="closeX"><a href="javascript:CloseBrandFlyoutWin(0)" class="close">Close</a></p>'			
					+' 	<div class="flyHeader clearfix" style="height:100px">'
	
	if (objBrand.ProgramPillowImgURL != '')
		FlyoutHTMLheader +=' 		<img src="' + objBrand.ProgramPillowImgURL + '" alt="' + objBrand.programText + '" /> '
		
	if (objBrand.ProgramAdditionalText != '#')	
	
		FlyoutHTMLheader +='<div class="flyText">'
					+' 			<h6>' + objBrand.programText + '</h6>'
					+' 			<h2>' + objBrand.ProgramAdditionalText + '</h2>'
					+' 		</div>'
					
	FlyoutHTMLheader +=' 	</div>'
					
	FlyoutHTMLcpns =' <div class="cps147">	'
	
 						   
   var pageHTML 
   var i=0;
   var cpnNum = 0; 	
	
   while(i < ci_sortedPods.length)
   {
	    
       var obj = ci_sortedPods[i];
       if (obj==undefined)
          break;

         
       var dynPODPropObj = GetDynPODProps(obj); 
       var isChecked = IsPODChecked(obj.id);

		for ( var j=0; j<objBrandCpn.length; j++ )
		{
 			if (   obj.id ==  objBrandCpn[j].couponID) {
			
     		  	FlyoutHTMLcpns  += brandFlyOutPodHTML(obj, objBrandCpn[j], dynPODPropObj.allowPrint, isChecked);
				cpnNum++
 			}
		}
       i++;
	   
	  // if ( cpnNum == 6 ) 
		//	break
 
   } // end while	
   
	// --- build flyoutout					   
 FlyoutHTMLcpns += '</div>'
 
 
				//---------- end
if (cpnNum > 3)
{
	if  (cpnNum > 6)
	{
		FlyoutHTML = '<div class="flyout500" style="z-index:100000000;">' + FlyoutHTMLheader
//srrollbar starts					
				   + '<div class="flyout500scroll">'
				   + 	FlyoutHTMLcpns
				   + '</div>'
		
	}
	else
		FlyoutHTML = '<div class="flyout500" style="z-index:100000000;">' + FlyoutHTMLheader + FlyoutHTMLcpns
	
}
else
{
	FlyoutHTML = '<div class="flyout" style="z-index:100000000;">' + FlyoutHTMLheader + FlyoutHTMLcpns
}

FlyoutHTML += '<p class="moreCps2"><a href="javascript:CloseBrandFlyoutWin(0)" class="arrOrgRt">Close window & return to coupons</a></p>'
 + '</div>'
 
 TAFDiv.innerHTML = FlyoutHTML;

var scrollYPos = ( window.pageYOffset || document.documentElement.scrollTop );       
        // if( ci_bSafari ) scrollYPos = 0;
		
        xPos = 200
        if (!ci_bIE) xPos = 200;
		
		//yPosDiff = 1440
		//if (!dowCoupon) yPosDiff = 1310
		
		yPosDiff = 525
		if (!dowCoupon) yPosDiff = 380
		
        TAFDiv.style.left = (xPos - 200) + 'px';
        TAFDiv.style.top  = (yPos - yPosDiff +scrollYPos) + 'px';
		
        if( yPos-290 < 0 )
        {
            window.scrollTo(0,scrollYPos+(yPos-295));
        }  
	

 
/*	*/

} 
 // --------------------------------------------------------


function brandFlyOutPodHTML(podObj, podObjFP, allowPrint,isChecked){
	
   var actionJS = GetAction(podObj.type, allowPrint, 2);
   var bPodLinkEnabled = ( actionJS.indexOf("void") == -1 );
   var actionHTML = (bPodLinkEnabled ? " onclick='<#GetAction#>'" : "");
   var cursorStyle = (bPodLinkEnabled ? "cursor: hand; cursor: pointer;" : "");
   
   var podDescTextLength = 95

   var podHTML

var cpnImage = podObjFP.couponImgURL
if (cpnImage == '') cpnImage = podObj.imgURL



if ( allowPrint == 1 ){

	podHTML = "<div class='" + (isChecked ? "cp clipped" : "cp") + "' id='fb_POD" + podObj.id  + "' >"

	}
else
{
	podHTML = "<div class='cp limit' id='fb_POD" + podObj.id  + "'>"
	
	}

  podHTML += "<div class='prodWrap'" + (isChecked ? "" : actionHTML ) +" style='" + cursorStyle + "'>"
		  +"      <img id='ImageID<#CID#>' src='" + cpnImage + "'  alt='Item'  style='width:48px; height:60px' />"
          +"  <div class='prodTxt'>"
  
  var allowClip  = bPodLinkEnabled
  
  
    if (podObjFP.prgmCpnDesc == '')
	{
		podDescTextLength = 50
		
		if (allowClip)
		   podHTML += "<a href=\"<#GetAction#>\" ><h3>" + podObj.summ +  "</h3></a>";
		else
			podHTML +=  "<h3>" + podObj.summ + "</h3>"
	}
	
	
  podHTML +=  "<p style='max-height: 10px;'>" + ReturnCouponDesc(podObj,bPodLinkEnabled) + "</p>"
  +"      </div>"
  +"  </div>"
  +   ShowPrint2(allowPrint,podObj.id,isChecked,1)
  +" </div>"
  
       
    
  	  while (podHTML.indexOf("<#GetAction#>")>-1)
        podHTML =  podHTML.replace("<#GetAction#>",actionJS)
		
      while (podHTML.indexOf("<#CID#>")>-1)
        podHTML =  podHTML.replace("<#CID#>",podObj.id)
		
	var cpnInfo = podObjFP.prgmCpnDesc
	if (cpnInfo == '') 	cpnInfo = podObj.prodInfo
	if ( cpnInfo.length > podDescTextLength)
	{
		cpnInfo = cpnInfo.substring(0,podDescTextLength);	
		cpnInfo = cpnInfo.substring(0,cpnInfo.lastIndexOf(' ')) + " ..."
	}
	
    while (podHTML.indexOf("<#DisplayText#>")>-1)
        podHTML = podHTML.replace("<#DisplayText#>",cpnInfo)
   

   podHTML =  podHTML.replace("<#podInfoLink#>","");

//	if( podHTML.indexOf("<#podInfoLink#>")>-1 )
//   {
//       if (podObj.infoUrl.length > 0)  
//         podHTML =  podHTML.replace("<#podInfoLink#>","<a href=javascript:PopInfo('"+ podObj.infoUrl +"')>Product Info</a>")
//       else
//         podHTML =  podHTML.replace("<#podInfoLink#>","");
//   }
        
      
   return podHTML
  
}

function ShowPrint2(allowPrint,CouponID,isChecked,actionTaken)
{
   var actionJS = GetAction(0, allowPrint, 2);
   var bPodLinkEnabled = ( actionJS.indexOf("void") == -1 );
   var actionHTML = (bPodLinkEnabled ? " onclick='<#GetAction#>'" : "");

	
if ( allowPrint == 1 )
    {
		return "  <div class='bar'>"
  		 +"    <div id='featuredCpn<#CID#>'><input onclick='TglPod(<#CID#>)' type='checkbox' id=fc_cpcartchk<#CID#> name='fc_cpcartchk<#CID#>' " + (isChecked ? 'checked=true' : '') + " ></div>"
  		 +"    <p class='clip' " + (isChecked ? "" : actionHTML ) +">CLIP</p>"
  		 +"    <p class='icnMail' id='Email" + CouponID + "'>"
		 +"    <a href='#'  onclick='var e = arguments[0] || window.event; OpenEmailWin(e.clientX,e.clientY," + CouponID + "); return false;'>E-Mail this Coupon</a></p>"
  		 +"  </div>";
 			
	}
	// print limit reached
    else
    {

	  	// return "<p align='right' style='padding-right: 15px; padding-top: 10px;'><span style='color:red'><b>Print Limit Reached</b></span></p><div class='bar' style='display:none'>"
	  	 return "<div class='bar'>"
  		 //+"    <input onclick='TglPod(<#CID#>)' type='checkbox' id=fc_cpcartchk<#CID#> name='fc_cpcartchk<#CID#>' " + (isChecked ? 'checked=true' : '') + " >"
  		 +"    <p class='clip'>CLIP</p>"
 		 +"    <p class='icnMail' id='Email" + CouponID + "'><a href='#'  onclick='var e = arguments[0] || window.event; OpenEmailWin(e.clientX,e.clientY," + CouponID + "); return false;'>E-Mail this Coupon</a></p>"
  		 +"  </div>";

    }
}
// ----- end deal of the week coupon

function CloseBrandFlyoutWin(delay)
{ 
    if( delay > 0 )
    {
        setTimeout("CloseBrandFlyoutWin(0);",delay);
    }
    else
    {
        var BrandFlyOutDiv = document.getElementById('BrandFlyOutDiv');
        BrandFlyOutDiv.style.left = "-2000px";
		        CloseEmailWin();
    }
}


<!-- DEAL OF THE WEEK COUPON -->


function SetDealOfWeek()
{

	if(typeof(ci_DealsOftheWeek) !="undefined")
	  {
			  var progArr = ci_DealsOftheWeek.ReturnDealsOftheWeek(); 
			  if( typeof(progArr)!="undefined" && progArr !=null )
			  {
				   for (var i = 0; i < progArr.length; i++)
				   {
					   if ( progArr[i].dowCoupons.length > 0)
						{
								 
					    	var j=0; 
							if (progArr[i].dowCoupons[j].Status != 3)
							{
								var cpnID = progArr[i].dowCoupons[j].couponID 
										
								var allowPrint = progArr[i].dowCoupons[j].Status; 
								var isChecked = IsPODChecked(cpnID);
										
								dowCoupon = true
								ci_dealofweekpid = cpnID
								podHTML  = ReturnFeaturedNormalPodHTML(progArr[i], allowPrint, isChecked);
								return podHTML;
							}
						}
					   
				   }
			   }
	}
	
   return ""

}

function ReturnFeaturedNormalPodHTML(podObjDOW, allowPrint,isChecked)
{
   var actionJS = GetAction(0, allowPrint, 2);
   var bPodLinkEnabled = ( actionJS.indexOf("void") == -1 );
   var actionHTML = (bPodLinkEnabled ? " onclick='<#GetAction#>'" : "");
   var cursorStyle = (bPodLinkEnabled ? "cursor: hand; cursor: pointer;" : "");
   var j = 0

   var msgLeft = 'left:100px;'
   var msgTop = 'top:30px;'
   
	var podHTML = "<div class='cpsBG clearfix' id='cpwide'>"
	
	if ( allowPrint == 1 ){
	
		podHTML += "<div class='" + (isChecked ? "cpWide clipped" : "cpWide") + "' id='fc_POD" + podObjDOW.dowCoupons[j].couponID  + "'>"
	}
	else
	{
		podHTML += "<div class='cpWide limit' id='fc_POD" + podObjDOW.dowCoupons[j].couponID  + "'>"
		
	}

	var allowClip  = bPodLinkEnabled
  
    podHTML +="<p class='dealbadge' " + (isChecked ? "" : actionHTML ) +" style='" + cursorStyle + "'>DEAL of the WEEK</p>"
			+"  <div class='prodWrap' " + (isChecked ? "" : actionHTML ) +" style='" + cursorStyle + "'>"
	if (podObjDOW.dowImgURL != '')	
	{
 		   podHTML += "      <img id='ImageID<#CID#>' src='" + podObjDOW.dowImgURL + "' alt='Deal of the week item'/>"  // style='height:70px; width:80px'
	}
	else
 		   msgLeft = 'left:10px;'

	
	if (podObjDOW.dowAdditionalText != '' || podObjDOW.dowText.length > 25) msgTop = 'top:18px;' 
		  
    if (allowClip)
	{
	   if (podObjDOW.dowText != '')
	   {
      		 podHTML += "<a href=\"<#GetAction#>\" ><h2 style='" +  msgLeft + msgTop + "'>" + podObjDOW.dowText + "<br/> " + podObjDOW.dowAdditionalText + "</h2></a>";
	   }
	   else 
	         podHTML += "<a href=\"<#GetAction#>\" ><h2 style='" +  msgLeft + msgTop + "'>" +  podObjDOW.dowCoupons[j].prgmCpnDesc  + "</h2></a>";
	}
    else
	{
	   if (podObjDOW.dowText != '')
	   {
      		 podHTML += "<h2 style='" +  msgLeft + msgTop + "'>" + podObjDOW.dowText + "<br/>" + podObjDOW.dowAdditionalText + "</h2>";
	   }
	   else 
	         podHTML += "<h2 style='" +  msgLeft + msgTop + "'>" +  podObjDOW.dowCoupons[j].prgmCpnDesc  + "</h2>";

		}

  podHTML +="  </div>"
  +   ShowPrint2(allowPrint,podObjDOW.dowCoupons[j].couponID,isChecked,1)
  +"  </div>"
  +" </div>";
 
         
    
   while (podHTML.indexOf("<#GetAction#>")>-1)
        podHTML =  podHTML.replace("<#GetAction#>",actionJS)
      while (podHTML.indexOf("<#CID#>")>-1)
        podHTML =  podHTML.replace("<#CID#>",podObjDOW.dowCoupons[j].couponID)

          
   return podHTML
  
}

// Gift Cards


function DisplayGiftCards() 
{

	var strHTML = '<h4 class="sbH4" id="sbH4-GiftCard">Gift Card Center</h4>'
		+'	<div class="sbBox"  style="width:181px; height:120px; padding-right:0;" onclick="var e = arguments[0] || window.event; OpenGiftCardFlyOut(e.clientX,e.clientY); return false;" style="cursor: hand; cursor: pointer;">'
		+'		<div style="float:left; width:85px" style="cursor: hand; cursor: pointer;" title="Gift Card Center">'
		+'			<h3 style="cursor: hand; cursor: pointer;">Personalized<br> Holiday<br/> Gift Cards</h3>'
		+'			<p style="color:#0f94d2; cursor: hand; cursor: pointer;">Great Gifts! Great Deals!<br/>Give One. Get One. (Offer)'
		+'			&nbsp;<img src="http://download1.coupons.com/7/19/7125/1450/print.coupons.com/CouponWeb/Themes/CM_BigBlue/_images/arr_sm_orange.gif" style="cursor: hand; cursor: pointer;" alt="Gift Card Center"  title="Gift Card Center"/></p>'
		+'		</div>'
		+'		<div style="float:right; horizontal-align:right;">'
		+'			<img src="http://download1.coupons.com/7/19/7125/1450/print.coupons.com/CouponWeb/Themes/CM_BigBlue/_images/gc_giftcard3.png"  style="cursor: hand; cursor: pointer;" alt="Gift Card Center"  title="Gift Card Center"/>'
		+'		</div>'
		+'	</div>' 	


	return strHTML
}

function OpenGiftCardFlyOut(xPos,yPos)
{   

 
   var TAFDiv = document.getElementById('BrandFlyOutDiv');    
   var FlyoutHTML;


		FlyoutHTML =' 	<p class="closeX"><a href="javascript:CloseBrandFlyoutWin(0)" class="close">Close</a></p>'			
					+' 	<div class="flyHeader clearfix" style="height:100px">'	
	
					+' 		<div class="flyText" style=" width:450px">'
					+' 			<h2 style="color: #66ba2b; font-weight:bold; font-size: 1.5em;">eGift Card Center</h2>'
					+' 			<h6 style="font-size: 1.25em; font-weight: bold; color:#f07100; margin:5px 0;">E-mail or Print a Holiday Gift Card for Immediate Delivery!</h6>'
					+' 			<h6 style="color:#777777; font-size: 1.0em; margin-left:6px">'
					+'				<li style="margin-left:7px">Great offers: Give one. Get one FREE for YOU!'
					+'				<li style="margin-left:7px">Personalize with photograph. Customize with message.'
					+'				<li style="margin-left:7px">Choose from great retail and restaurant brands.'
					+			'</h6>'
					+' 		</div>'
					+' 	</div>'
					
					+ '<div style="position:relative;float:left; height:357px;width:488px; overflow: -moz-scrollbars-vertical;overflow:scroll; overflow-x:hidden; margin-top:10px; *margin-top:20px;  border-top-color:#CCCCCC; border-top-width:3px;border-top-style:solid;  border-bottom-color:#CCCCCC; border-bottom-width:3px;border-bottom-style:solid;">'
					
					+' <div class="cps147">	'
	
						   
   var pageHTML 


	

   var podHTML = ""      

		for ( var j=0; j<ci_GiftCardInfo.length; j++ )
		{
			
		   	var actionHTML = "javascript:PopGiftCardInfo('" + ci_GiftCardInfo[j].redirectURL + "')"
           		podHTML += '	<div class="cp" onClick=" ' + actionHTML + ' "  style="cursor: hand; cursor: pointer;">'
  
  			// Decide which badge (if any)to show
           		switch (ci_GiftCardInfo[j].gogo)
           		{
           			case 0: 
           				// No badge
           				break;
           			default:
           				// Calculate badge image name using gogo value
	         			podHTML +='<p class="badge" style="z-index:100; background: url(http://download1.coupons.com/7/19/7125/1450/print.coupons.com/CouponWeb/Themes/CM_BigBlue/_images/gcbadge_offer' + ci_GiftCardInfo[j].gogo + '.png) no-repeat;" title="' + ci_GiftCardInfo[j].gogotitle + '"></p>'
					break;
			}
			
           		podHTML +='<div class="prodWrap">'
          			+'				<img src="http://download1.coupons.com/7/19/7125/1450/print.coupons.com/CouponWeb/Themes/CM_BigBlue/_images/'+ ci_GiftCardInfo[j].logoURL +'" alt="Item" height="60" />'

          			+'				<div class="prodTxt" style="margin-top:7px ">'
          			+'					<h4 style="font-size: 1.0em; ">'+ ci_GiftCardInfo[j].brand + '</h4>'
		  
           		if (ci_GiftCardInfo[j].gogo != 0)
             		podHTML +='        <h3 style="color:#0b7aaf; font-size: 1.0em; ">' + ci_GiftCardInfo[j].summ + '</h3>'
            		podHTML +='	     	<p style="color:#0f94d2;">' + ci_GiftCardInfo[j].desc + '</p>'
         			+'				</div>'
         			+'			</div>'
         			+'			<div class="bar">'
         			+'				<p class="clip" style=" left: 4px; width: 128px; background-image: url(http://download1.coupons.com/7/19/7125/1450/print.coupons.com/CouponWeb/Themes/CM_BigBlue/_images/send_eCard.gif);">CLIP</p>'
         			+'			</div>'
         			+'		<hr />'
         			+'	</div>'
		}


   
	// --- build flyoutout					   
 FlyoutHTML += podHTML + '</div>'
            + '</div>'
				//---------- end
 FlyoutHTML = '<div class="flyout500" style="z-index:100000000;">' + FlyoutHTML

 FlyoutHTML += '<p class="moreCps2"><a href="javascript:CloseBrandFlyoutWin(0)" class="arrOrgRt">Close window & return to coupons</a></p>'
 + '</div>'
 
 TAFDiv.innerHTML = FlyoutHTML;

var scrollYPos = ( window.pageYOffset || document.documentElement.scrollTop );       
        // if( ci_bSafari ) scrollYPos = 0;
		
        xPos = 200
        if (!ci_bIE) xPos = 200;
		
		//yPosDiff = 1440
		//if (!dowCoupon) yPosDiff = 1310
		
		yPosDiff = 515
		if (!dowCoupon) yPosDiff = 370
		
        TAFDiv.style.left = (xPos - 200) + 'px';
        TAFDiv.style.top  = (yPos - yPosDiff +scrollYPos) + 'px';
		
        if( yPos-290 < 0 )
        {
            window.scrollTo(0,scrollYPos+(yPos-295));
        }  

} 

function PopGiftCardInfo(Link)
{

   window.open(Link, "", "scrollbars=1,resizable=yes,location=1,toolbar=1");
   
}


function RotateAllAds(sContext,bInitAdSource)
{
	// Default to false if parameter is missing
	if (bInitAdSource == "undefined" || bInitAdSource == null ) bInitAdSource = false;
	// Default sContext if parameter is missing
	if (sContext == "undefined" || sContext == null ) sContext = "";
	// Put init flag in a global variable so it can be accessed by calls triggered by 
	// setTimeout
	gInitAdSource = bInitAdSource;
	// Do the same for the context identifier
	gContext = sContext
	//alert("RotateAllAds Context='" + sContext + "' bInitAdSource=" + bInitAdSource);
	// sContext is the context identifier indicating what page of the site is displaying
	// the ads
	// bInitSource calls AdBlob only for IFrames where the src has not yet been assigned.
	
	RotateAdPlacement("cimRightBanner",160,600,"INSERT_SECTION_CODE_HERE",bInitAdSource,gContext);
	setTimeout("RotateAdPlacement(\"cimBelowRightBanner\",160,210,\"INSERT_SECTION_CODE_HERE\",gInitAdSource,gContext)",1500);
	// Delay is shorter since there will never be a db delay for any placement other than the RightBanner
	setTimeout("RotateAdPlacement(\"cimFtrBanner\",728,90,\"INSERT_SECTION_CODE_HERE\",gInitAdSource,gContext)",2500);
}


function RotateAdPlacement(sPlacement,AdWidth,AdHeight,SectionCode,bInitAdSource,sContext)
{
// rotate ad banner. Parameters specify the location of the ad placement and 
// the dimensions of the Ad.
var rBannerFrame = document.getElementById(sPlacement);
if( rBannerFrame != null )
{
	var mac = "";
	var zip = "";
	var userInfo = GetCookie("UserInfo");
	if(userInfo != null)
	{
	mac = GetCookieVal(userInfo,"mac");
	zip = GetCookieVal(userInfo,"ZIP");
	}

	if(zip.length == 0)
	{
		var sessionInfo = GetCookie("SessionInfo");
		if(sessionInfo != null)
		{
			zip = GetCookieVal(sessionInfo,"ZIP");
		}
	}
	// See what page the ad is being displayed on. If is needed to handle mac urls
	var url = document.URL;
	var pg;
	if (url.indexOf("/") > -1)
            pg =(url.substring(url.lastIndexOf("\/")+1,url.lastIndexOf("\.")));
	else
            pg =(url.substring(url.lastIndexOf("\\")+1,url.lastIndexOf("\.")));
        
	var pzn = GetQueryStringValue ('pid') + GetQueryStringValue ('zid') + GetQueryStringValue ('nid');
	
	//alert("Displaying Placement=" + sPlacement + " sContext='" + sContext + "'" + " pg=" + pg);
	
	if (!bInitAdSource || rBannerFrame.src == "")
	{
		rBannerFrame.src = "http://couponbar.coupons.com/adblob.asp?AdSize=" + AdWidth + "x" + AdHeight + 
		                   "&pzn=" + pzn + 
		                   "&sectioncode=" + SectionCode + 
		                   "&req=" + (new Date()).getTime() + 
		                   "&zip=" + zip + 
		                   "&did=" + mac +
		                   "&spage=" + pg;
	}
	else
	{
		alert("Src already set");
	}
}
}

//Dealy Deal
function OpenDealyDealFlyOut(xPos,yPos)
{

 
   var TAFDiv = document.getElementById('BrandFlyOutDiv');    
   var FlyoutHTML;


		FlyoutHTML = '<div class="dealyDealFlyout">'
			+' 	<p class="closeX"><a href="javascript:CloseBrandFlyoutWin(0)" class="close">Close</a></p>'			
			+' <div class="flyiFrame">'
			+'<iframe id="ciContentFramecode" src="http://coupons.dailydealr.com/iframe/:zipcode?coupons_params" frameborder="0" width="670px" height="600px"></iframe>'
		    + '</div>'
		    + '</div>'
 
   TAFDiv.innerHTML = FlyoutHTML;

   var scrollYPos = ( window.pageYOffset || document.documentElement.scrollTop );       
		
        xPos = 200
        if (!ci_bIE) xPos = 200;
		
		//yPosDiff = 1440
		//if (!dowCoupon) yPosDiff = 1310
		
		yPosDiff = 415
		if (!dowCoupon) yPosDiff = 272 
		
        TAFDiv.style.left = (xPos - 200) + 'px';
        TAFDiv.style.top  = (yPos - yPosDiff +scrollYPos) + 'px';
		
        if( yPos-290 < 0 )
        {
            window.scrollTo(0,scrollYPos+(yPos-295));
        } 	
}
