	/** ULTRA-SIMPLE EVENT ADDING **/
	
function addEventSimple(obj,evt,fn)	{
	if (obj.addEventListener) {
		obj.addEventListener(evt,fn,false);
	} else if (obj.attachEvent)	{
		obj.attachEvent('on'+evt,fn);
		}			
	}
	
	function removeEventSimple(obj,evt,fn) {
		if (obj.removeEventListener)
			obj.removeEventListener(evt,fn,false);
		else if (obj.detachEvent)
			obj.detachEvent('on'+evt,fn);
	}
/* 
	These are the cookie scripts used to get, set, and delete cookies.
	You shouldn't have to make any edits here. If you do, do so at your own risk.
	
*/

	function getNumberOfInstances(str, chr){
		var counter = 0;
		var url = str.toString();
		for(var i=0; i < url.length; i++){
			if(url.charAt(i) == chr){
				counter ++;
				}
			}
		return counter;
	}
/**
 *	addAffs()
 *	This is a useful script to add the aff ids to urls to paddypower navigation 
 *	author: john
 */
		//var footerLinks = document.getElementById("")
		var odCookie = getCookie("AFF_ID"); //Check to see if there is an AFF_ID cookie set
		//Check for cookies and add to Players Club link in the main navigation
		var tdCookie = getCookie("TDAFFID");
		var adCookie = getCookie("AID");
		var sdCookie = getCookie("SID");
		var pdCookie = getCookie("PID");
		var arCookie = getCookie("ARRID");
		var prCookie = getCookie("PRMID");
		var tuCookie = getCookie("TDUID");
		var bCookie = getCookie("BTAG");
		var comCookie;
 function addAffs(){
 	// Check for top nav channel links
		if (!document.getElementById('topnav')) {
			return;
		}
		//var links = document.getElementById('topnav').getElementsByTagName('a');
		var links = document.getElementsByTagName('a');
		
		
		
		
		if (adCookie || sdCookie || pdCookie) {
			comCookie = "AID=" + adCookie + "&SID=" + sdCookie + "&PID=" + pdCookie;
		}
		for (var i = 0; i < links.length; i++) {
			/* *
		 * 	Check the value of tdCookie and create links accordingly
		 **/
			if (links[i].className == "affiliate") {
				if (tdCookie != null) {
					if (getNumberOfInstances(links[i].href, '?') == '0' && links[i].href.indexOf("javascript") == -1) {
						links[i].href = links[i].href + '?TDAFFID=' + tdCookie;
					}
					else 
						if (getNumberOfInstances(links[i].href, '?') == 1 && links[i].href.indexOf('dest=') > 1) {
							links[i].href = links[i].href + '?TDAFFID=' + tdCookie;
						}
						else 
							if (links[i].href != 'javascript:open_game_account();' && links[i].href.indexOf('dest=') == -1) {
								links[i].href = links[i].href + '&TDAFFID=' + tdCookie;
							}
					
				}
				if (tuCookie != null) {
					if (getNumberOfInstances(links[i].href, '?') == '0' && links[i].href.indexOf("javascript") == -1) {
						links[i].href = links[i].href + '?TDUID=' + tuCookie;
					}
					else 
						if (getNumberOfInstances(links[i].href, '?') == 1 && links[i].href.indexOf('dest=') > 1) {
							links[i].href = links[i].href + '?TDUID=' + tuCookie;
						}
						else 
							if (links[i].href != 'javascript:open_game_account();' && links[i].href.lastIndexOf() == -1) {
								links[i].href = links[i].href + '&TDUID=' + tuCookie;
							}
				}
				
				if (arCookie != null) {
					if (getNumberOfInstances(links[i].href, '?') == '0' && links[i].href.indexOf("javascript") == -1) {
						links[i].href = links[i].href + '?ARRID=' + arCookie;
					}
					else 
						if (getNumberOfInstances(links[i].href, '?') == 1 && links[i].href.indexOf('dest=') > 1) {
							links[i].href = links[i].href + '?ARRID=' + arCookie;
						}
						else 
							if (links[i].href != 'javascript:open_game_account();') {
								links[i].href = links[i].href + '&ARRID=' + arCookie;
							}
				}
				if (bCookie != null) {
					if (getNumberOfInstances(links[i].href, '?') == '0' && links[i].href.indexOf("javascript") == -1) {
						links[i].href = links[i].href + '?BTAG=' + bCookie;
					}
					else 
						if (getNumberOfInstances(links[i].href, '?') == 1 && links[i].href.indexOf('dest=') > 1) {
							links[i].href = links[i].href + '?BTAG=' + bCookie;
						}
						else 
							if (links[i].href != 'javascript:open_game_account();') {
								links[i].href = links[i].href + '&BTAG=' + bCookie;
							}
				}
				if (prCookie != null) {
					if (getNumberOfInstances(links[i].href, '?') == '0' && links[i].href.indexOf("javascript") == -1) {
						links[i].href = links[i].href + '?PRMID=' + prCookie;
					}
					else 
						if (getNumberOfInstances(links[i].href, '?') == 1 && links[i].href.indexOf('dest=') > 1) {
							links[i].href = links[i].href + '?PRMID=' + prCookie;
						}
						else 
							if (links[i].href != 'javascript:open_game_account();') {
								links[i].href = links[i].href + '&PRMID=' + prCookie;
							}
				}
				/* *
			 * 	Check the value of comCookie and create links accordingly
			 **/
				if (comCookie != null) {
					if (getNumberOfInstances(links[i].href, '?') == '0' && links[i].href.indexOf("javascript") == -1) {
						links[i].href = links[i].href + '?' + comCookie;
					}
					
					else 
						if (getNumberOfInstances(links[i].href, '?') == 1 && links[i].href.indexOf('dest=') > 1) {
							links[i].href = links[i].href + '?' + comCookie;
						}
						else 
							if (links[i].href != 'javascript:open_game_account();') {
								links[i].href = links[i].href + '&' + comCookie;
							}
				}
				if (odCookie != "1000" && odCookie != null) {
					if (getNumberOfInstances(links[i].href, '?') == '0' && links[i].href.indexOf("javascript") == -1) {
						links[i].href = links[i].href + '?AFF_ID=' + odCookie;
					}
					else 
						if (getNumberOfInstances(links[i].href, '?') == 1 && links[i].href.indexOf('dest=') > 1) {
							links[i].href = links[i].href + '?AFF_ID=' + odCookie;
						}
						else 
							if (links[i].href != 'javascript:open_game_account();') {
								links[i].href = links[i].href + '&AFF_ID=' + odCookie;
							}
				}
			}
		}
	}
	function addCarousel(){	
		/*****
	 * This is for the carousel iframe
	 * all affiliate cookies will be appended to the iframe src for ppy to pull and parse
	 */
	if ($('carousel')) {
		var iframeSRC = $('carousel').src;
	
		if (tdCookie != null) {
			if (iframeSRC.indexOf('?') == -1 && iframeSRC.indexOf("javascript") == -1) {
				iframeSRC += '?TDAFFID=' + tdCookie;
			}
			else if (iframeSRC != 'javascript:open_game_account();') {
					iframeSRC += '&TDAFFID=' + tdCookie;
				}
		}
		if (odCookie != "1000" && odCookie != null) {
			if (iframeSRC.indexOf('?') == -1 && iframeSRC.indexOf("javascript") == -1) {
				iframeSRC += '?AFF_ID=' + odCookie;
			}
			else if (iframeSRC != 'javascript:open_game_account();') {
					iframeSRC += '&AFF_ID=' + odCookie;
				}
		}
		if (comCookie != null) {
			if (iframeSRC.indexOf('?') == -1 && iframeSRC.indexOf("javascript") == -1) {
				iframeSRC += '?' + comCookie;
			}
			else if (iframeSRC != 'javascript:open_game_account();') {
					iframeSRC += '&' + comCookie;
				}
		}
		if (prCookie != null) {
			if (iframeSRC.indexOf('?') == -1 && iframeSRC.indexOf("javascript") == -1) {
				iframeSRC += '?PRMID=' + prCookie;
			}
			else if (iframeSRC != 'javascript:open_game_account();') {
					iframeSRC += '&PRMID=' + prCookie;
				}
		}
		
		if (arCookie != null) {
			if (iframeSRC.indexOf('?') == -1 && iframeSRC.indexOf("javascript") == -1) {
				iframeSRC += '?ARRID=' + arCookie;
			}
			else if (iframeSRC != 'javascript:open_game_account();') {
					iframeSRC += '&ARRID=' + arCookie;
				}
		}
		if (tuCookie != null) {
			if (iframeSRC.indexOf('?') == -1 && iframeSRC.indexOf("javascript") == -1) {
				iframeSRC += '?TDUID=' + tuCookie;
			}
			else if (iframeSRC != 'javascript:open_game_account();') {
					iframeSRC += '&TDUID=' + tuCookie;
				}
		}
		if (bCookie != null) {
			if (iframeSRC.indexOf('?') == -1 && iframeSRC.indexOf("javascript") == -1) {
				iframeSRC += '?BTAG=' + bCookie;
			}
			else if (iframeSRC != 'javascript:open_game_account();') {
					iframeSRC += '&BTAG' + bCookie;
				}
		}
		
		
		$('carousel').src = iframeSRC;
	}
		
	}
//Ends addAffs()
//document.observe("dom:loaded", addAffs);
//addEventSimple(window,"load",addAffs);