var ads = [
	'<a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">Capital CFDs</a> offers security and very competitive margin requirements<br>for instance FTSE just $30 per $1 trade, Dow $30 per $1 trade are amongst the best...<br> &amp; together with simplicity and tighter spreads...<br> means you are getting a service second to none. <br> <a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">...so click here if you want to open your real money or demo account.</a>',	   
	'Trade CFDs at <a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">IG Markets</a> Near-INSTANT fills plus EXCELLENT PRO Charts,<br>Small Margin requirements - Full range of Markets - Trailing Stop Loss Orders.<br>INSTANT responses to EMAIL. <a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">Apply for an Account</a>.',
		'<a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">Capital CFDs</a> offers security and very competitive margin requirements<br>for instance FTSE just $30 per $1 trade, Dow $30 per $1 trade are amongst the best...<br> &amp; together with simplicity and tighter spreads...<br> means you are getting a service second to none. <br> <a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">...so click here if you want to open your real money or demo account.</a>',
	'Trade CFDs using Direct Market Access via PureDMA at <a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">IG Markets</a><br>Transparent market prices from just 0.1% commission.<br>Over 7000 shares worldwide, plus forex, indices, commodities and options...<br><a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">Apply for an Account.</a> ',
	'<a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">Capital CFDs</a> offers just 5 pips spreads on the Rolling Gold Daily<br>5 tick Brent Crude and 4 tick Rolling S&amp;P are amongst the best in the market...<br> &amp; I like the auto generated stop losses which help to maintain discipline...<br> and that\'s good for beginners I think <br> <a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">...so click here if you want to open your account.</a>',
	'I wanted a platform that was easy to use and had a good support desk.<br>I wanted a platform that had easy to access data and tic charting.<br>I searched for a platform that was web based and also offered a desktop application.<br> I wanted a firm that offered both DMA and Market Maker functionality.<br><a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">I chose IG Markets</a> ',
	'<a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">Capital CFDs</a> offers just 5 pips spreads on the Rolling Gold Daily<br>5 tick Brent Crude and 4 tick Rolling S&amp;P are amongst the best in the market...<br> &amp; I like the auto generated stop losses which help to maintain discipline...<br> and that\'s good for beginners I think <br> <a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">...so click here if you want to open your account.</a>',
	'<a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">IG Markets</a> part of the IG Group. Well-respected and long-established public company.<br>A true pioneer in taking markets to the masses.  Offer DMA level 2 book trading for CFD\'s,<br>by doing this NO ONE can manipulate the price you are deciding on!<br><a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">Apply for an Account</a>.',
	'<a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">Capital CFDs</a> offers security and very competitive margin requirements<br>for instance FTSE just $30 per $1 trade, Dow $30 per $1 trade are amongst the best...<br> &amp; together with simplicity and tighter spreads...<br> means you are getting a service second to none. <br> <a href="http://www.contracts-for-difference.com/ccount/click.php?id=23" target="_blank">...so click here if you want to open your real money or demo account.</a>',
	'Whether you trade oil, FTSE, &pound;/$ or shares <a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">IG Markets</a> delivers near-instant execution,<br>very few re-quotes and you can even trade inside the spread with DMA Access!<br><a href="http://www.contracts-for-difference.com/ccount/click.php?id=11" title="IG Markets" target="_blank" class="text">Apply for an Account</a>.'
];

var randomAds = {
	write: function () {
		var e = Number(this.checkCookie());
		document.write(ads[e]);
	},
	
	checkCookie : function () {
		var margin=this.getCookie('margin');
		if (margin >= ads.length - 1)
			this.setCookie('margin',0,365);
		else if (margin!=null && margin!="")
		  this.setCookie('margin',Number(margin)+1,365);
		else
			this.setCookie('margin',0,365);
		
		return this.getCookie('margin');
	},
	
	setCookie : function (c_name,value,expiredays) {
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	},
	
	getCookie : function (c_name) {
		if (document.cookie.length>0) {
			c_start=document.cookie.indexOf(c_name + "=");
			if (c_start!=-1) {
				c_start=c_start + c_name.length+1;
				c_end=document.cookie.indexOf(";",c_start);
				if (c_end==-1)
					c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
			}
		}
		return "";
	}
}
