function showPromotion() {

document.writeln("<div class='flyoutPromoArea'>");
document.writeln("<img src='/pvnstatic-assets/common/images/promotion_flyout_arrow.gif' alt='Promotion' class='promoFlyoutArrow' height='11' width='4' />");
document.writeln("<div class='flyoutPromo'>");
document.writeln("<div><!-- empty DIV needed for IE -->");
document.writeln("<a href='http://www.prevention.com/cda/categorypage.do?channel=weight.loss&category=flat.belly.diet'><img src='/pvnstatic-assets/common/images/promotion_bgtm.png' alt='Flat Belly Diet' width='136' height='187' /></a>");
document.writeln("<div class='promo1'><a href='http://www.prevention.com/cda/categorypage.do?channel=weight.loss&category=flat.belly.diet'>&nbsp;</a></div>");
document.writeln("<div class='promo2'><a href='http://www.prevention.com/cda/categorypage.do?channel=weight.loss&category=flat.belly.diet&topic=belly.flattening.exercises'>&nbsp;</a></div>");
document.writeln("<div class='promo3'><a href='http://www.prevention.com/cda/categorypage.do?channel=weight.loss&category=flat.belly.diet&topic=flat.belly.diet.success.stories'>&nbsp;</a></div>");
document.writeln("<div class='promo4'><a href='http://www.prevention.com/cda/categorypage.do?channel=weight.loss&category=flat.belly.diet&topic=flat.belly.diet.food'>&nbsp;</a></div>");
document.writeln("<div class='promo5'><a href='http://www.flatbellydiet.prevention.com/default.asp?cm_sp=FBD-_-sign_me_up_now-_-http%3a%2f%2fflatbellydiet.com'>&nbsp;</a></div>");
document.writeln("</div>");
document.writeln("</div>");
document.writeln("</div>");

}

try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}



var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?

////NO NEED TO EDIT BELOW////////////////////////
var tabcontentIDs=new Object()

function expandcontent(linkobj){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs
if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
}
linkobj.parentNode.className="selected"  //highlight currently clicked on tab
document.getElementById(linkobj.getAttribute("rel")).style.display="" //expand corresponding tab content
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel"))
expandcontent(thetab)
}

function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
if (enabletabpersistence==1) //if persistence feature turned on
setCookie(ulid, selectedtabid)
}

function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(tabcontentId){
var objName = tabcontentId;
var ulobj=document.getElementById(objName)
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
	var ulistlink=ulist[x].getElementsByTagName("a")[0]
	if (ulistlink.getAttribute("rel")){
	savetabcontentids(objName, ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
	ulistlink.onmouseover=function(){
	expandcontent(this)
	}
	}
} //end inner for loop
var ran_number=Math.floor(Math.random()*ulist.length); 
expandcontent(ulist[ran_number].getElementsByTagName("a")[0]) //just auto load first tab instead
}

/* this function hide the select option elements when shtml dropdown shows */
function showOrHideAllDropDowns(newState,start,end) {
    var elements = document.documentElement.getElementsByTagName('select');
    if (elements.length >end){
    for (var i=start; i<end; i++) {
        elements[i].style.visibility = newState;
    }
	}else{
	for (var i=start; i<elements.length; i++) {
        elements[i].style.visibility = newState;
    }
	}
}

sfHoverTop = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHoverTop);
 
<!-- the next 2 functions are for the image rollovers -->
var selected = "x";

function imgRollIn(imgName) {
	document[imgName].src = eval(imgName + "on.src");
}

function imgRollOut(imgName) {
    if (imgName != selected){
		 document[imgName].src = eval(imgName + "off.src");
	}
}

<!-- This is to clear the input default content  -->
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 


// BEGIN : Mimic the javaScript function "encodeURIComponent"

var hexchars = "0123456789ABCDEF"; 
var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"; 

function utf8(wide) { 
	var c, s; 
	var enc = ""; 
	var i = 0; 
	
	while(i<wide.length) { 
		c= wide.charCodeAt(i++); 
		// handle UTF-16 surrogates 
		if (c>=0xDC00 && c<0xE000) continue; 
		if (c>=0xD800 && c<0xDC00) { 
			if (i>=wide.length) continue; 
			s= wide.charCodeAt(i++); 
			if (s<0xDC00 || c>=0xDE00) continue; 
			c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000; 
		} 
		// output value 
		if (c<0x80) enc += String.fromCharCode(c); 
		else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F)); 
		else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F)); 
		else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F)); 
	}
	
	return enc; 
} 

function toHex(n) { 
	return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF); 
}

function encodeURIComponentNew(s) { 
	var s = utf8(s); 
	var c; 
	var enc = ""; 
	for (var i= 0; i<s.length; i++) { 
		if (okURIchars.indexOf(s.charAt(i))==-1) {
			enc += "%"+toHex(s.charCodeAt(i)); 
		} else  {
			enc += s.charAt(i); 
		}
	}
	return enc; 
} 

function URLEncode(fld) { 
	if (fld == "") return false;
	
	var encodedField = ""; 
	var s = fld; 
	encodedField = encodeURIComponentNew(s); 
	return encodedField; 
}

// END : mimic the javaScript function "encodeURIComponent"


function goEmail() {
	location.href= contextPath + '/' + url 
			+'&title=' + emailContentTitle
	   		+'&deck=' + jsDeck
   			+'&contentType=' + URLEncode(emailContentType)
   			+'&link='+ URLEncode(window.location.href);
}

function goPrint() {
	var preUrl = window.location.href
	// Replace the break TAGs with nothing.
	var newUrl = preUrl.replace(/#{1,6}/g, "");
	return contextPath + '/' + 'printfriendly.do?url='+ URLEncode(newUrl);
	
	
}


function setTitle(paramtitle,paramdeck)
{
	document.emailafriend.title.value=paramtitle;		
	document.emailafriend.deck.value=paramdeck;		
}

function fixIE6flicker(fix) {
		try {
			document.execCommand("BackgroundImageCache", false, fix);
		} catch(err) { }
	}
	fixIE6flicker(true);


function setCookieValue(name, value, expires, path, domain) {
		var today = new Date();
	  	today.setTime( today.getTime() );
	  	if ( expires ) {
	   		expires = expires * 1000 * 60 * 60 * 24;
		}
	  	var expires_date = new Date( today.getTime() + (expires) );
	  
	  	document.cookie = name + "=" + value + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		  ( ( path ) ? ";path=" + path : "" ) + 
	  	( ( domain ) ? ";domain=" + domain : "" );
	} 
	
	function getCookieValue(NameOfCookie) {
		if (document.cookie.length > 0) {
			begin = document.cookie.indexOf(NameOfCookie+"=");
			if (begin != -1) { // Note: != means "is not equal to"
				begin += NameOfCookie.length+1;
				end = document.cookie.indexOf(";", begin);
				if (end == -1) end = document.cookie.length;
				rawValue = unescape(document.cookie.substring(begin, end));
			   	return rawValue;
			}
		}
		return null;
	}
	
	/*
	 * Redirect the user to the CAS gateway login URL
	 *
	 */
	function performGateway()
	{
	   	var dateObject = new Date();;
    	var dateValue = dateObject.getTime();		
    	setCookieValue('PVNGWY', dateValue, 30, '/','.prevention.com');
		var casGatewayURL = 'https://member.rodale.com/cas/login?service=http%3A%2F%2Fwww.prevention.com%2Fcda%2Fgwlogin.do&gateway=true';
		var doPvnGateway = true
		try{
			var curPvnDomain = window.location.href;
			if(!curPvnDomain.match(/prevention.com/))
			{
				doPvnGateway = false;
			}
		}
		catch(ex){}
		
		if(doPvnGateway)
		{
			top.location.href=casGatewayURL;
		}
	}
	
	var localGateway = getCookieValue("PVNGWY");
	var gblGateway = getCookieValue("RODALEIC");
	var hdCkVal = getCookieValue("HD");
	
	/*
	 * Check if we need to do gateway and call performGateway
	 * 
	 * 0429 - mraja1 - Disabling gateway
	 *
	 */
	/*
	if(hdCkVal == null)
	{
		if(gblGateway==null)
		{
			gblGateway = 0;
		}
		if(localGateway==null)
		{
			performGateway();
		}
		else
		{
			if(gblGateway>localGateway)
			{
				performGateway();
			}
		}
	}
	*/
	
	/*
	 * Set the current URL in PVNCURURL Cookie
	 *
	 */
   	try
   	{
		var callBackURL = window.location.href;
    	setCookieValue('PVNCURURL', callBackURL, 1, '/','.prevention.com');
	}
	catch(e)
	{}

function getCookie(NameOfCookie) {
	if (document.cookie.length > 0) {
		begin = document.cookie.indexOf(NameOfCookie+"=");
		if (begin != -1) { // Note: != means "is not equal to"
			begin += NameOfCookie.length+1;
			end = document.cookie.indexOf(";", begin);
			if (end == -1) end = document.cookie.length;
			rawValue = unescape(document.cookie.substring(begin, end));
			/* reset the cookie with an unescaped value.  We couldn't set it unescaped on the Groupee server
			 * because the PHP version does not support unescaped cookies
			 */
			setCookie('HD', rawValue,30,'/','.prevention.com');
		   	return rawValue;
		}
	}
	return null;
}
 
function setCookie(name, value, expires, path, domain) {
	var today = new Date();
  	today.setTime( today.getTime() );
  	if ( expires ) {
   		expires = expires * 1000 * 60 * 60 * 24;
	}
  	var expires_date = new Date( today.getTime() + (expires) );
  
  	document.cookie = name + "=" + value + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	  ( ( path ) ? ";path=" + path : "" ) + 
  	( ( domain ) ? ";domain=" + domain : "" );
	} 

function replaceAll(oldStr,findStr,repStr) {
			  	var srchNdx = 0;  // srchNdx will keep track of where in the whole line of oldStr are we searching.
			  	var newStr = "";  // newStr will hold the altered version of oldStr.
			  	while (oldStr.indexOf(findStr,srchNdx) != -1)  {
                	newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
				    newStr += repStr;
				    srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
  				}
				newStr += oldStr.substring(srchNdx,oldStr.length); 
				return newStr;
			}
