/*  general cookie functions in bigbowl and dynamoney */
function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {              
        begin = document.cookie.indexOf(NameOfCookie+"=");       
        if (begin != -1) {           
            begin += NameOfCookie.length+1;       
            end = document.cookie.indexOf(";", begin);
            if (end == -1) end = document.cookie.length;
                return unescape(document.cookie.substring(begin, end));
        } 
    }
    return null;
}

function setCookie(NameOfCookie, value, expiredays) {
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    document.cookie = NameOfCookie + "=" + escape(value) + 
    ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString())+"; path=/";
}

function delCookie (NameOfCookie) {
    if (getCookie(NameOfCookie)) {
        document.cookie = NameOfCookie + "=" +
        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
/* end: existing cookie functions block */

/* iPhone DailyFinance app promo */
var ipL = 	'<div id="iphoneDFbanner">'
			+ '<div style="position:relative;z-score:1;"><a href="http://www.dailyfinance.com/to-go/blackberry/" title="Take a look"><img src="http://www.aolcdn.com/ch_pf/spacer" width="980px" height="148px" /></a></div>'
			+ '<div style="position:relative;left:923px;top:-24px;width:53px;z-score:10000;"><a href="#" onclick="nomoreipDF();return false;" title="Remove this promo and do not show it any more"><img src="http://www.aolcdn.com/ch_pf/spacer" width="53px" height="22px" /></a></div>'

var ipS =	'<div id="iphoneDFbanner_sm">'
			+ '<div id="ipDFsm">'
			+ '<div style="position:relative;z-score:1;"><a href="http://www.dailyfinance.com/to-go/blackberry/" title="Take a look"><img src="http://www.aolcdn.com/ch_pf/spacer" width="980px" height="60px" /></a></div>'
			+ '<div style="position:relative;left:923px;top:-24px;width:53px;<!--[if IE]>top:-224px;<![endif]-->"><a href="#" onclick="nomoreipDF();return false;" title="Remove this promo and do not show it any more"><img src="http://www.aolcdn.com/ch_pf/spacer" width="53px" height="22px" /></a></div>'
			+ '</div>'
			+ '</div>';

function showDFpromo() {	
	try { dgbid = document.getElementById('dfAppPromo');
		if(getCookie('iPromo')==null){/* if no cookie, show full promo */
			dgbid.innerHTML = ipL;
			setCookie('iPromo','SEEN',90);
		}
		else {
			theCookie = document.cookie;
			if(theCookie.indexOf("DONT")== -1) {
				dgbid.innerHTML = ipS;
			}
			else {return;}			
		}	
	}
	catch (e) {}
}

function nomoreipDF() {
	/* user collapsed the promo banner. set cookie to never show it again */
	setCookie('iPromo','DONT',90);
	dgbid.style.display = "none";
}
/* end: iPhone App promo */
