﻿/**
* @fileoverview This is the core for the NFK (Not For Kids) Javascript library.
*
* @author Andrew Garvin andrew_garvin@pokerstars.com
* @version 1.0
*/

/**
* Create core NFK singleton class
* Holds core NFK Functions and Variables
* These can be accessed by all other modules using window.nfk
*/
nfk = {
	UID: 0,
	gUID: function () {
		nfk.UID++;
		return "nfk" + nfk.UID.toString(16);
	},
	dic: null,
	windowHeight: function () { return !window.opera ? document.documentElement.clientHeight : window.innerHeight; },
	windowWidth: function () { return !window.opera ? document.documentElement.clientWidth : window.innerWidth; },
	ie: navigator.userAgent.indexOf("MSIE") != -1 ? true : false,
	ieFix: ((navigator.userAgent.indexOf("MSIE") != -1 && parseInt(navigator.userAgent.substr(30, 3)) <= 6) ? true : false)
};
function gUID() {
	nfk.UID++;
	return "nfk" + nfk.UID.toString(16);
};
function lS(a, b, d) { var c = cE("script", { src: a, type: "text/javascript" }); sO(c, { nfk: { parent: d} }); addEvent(c, nfk.ie ? "readystatechange" : "load", nfk.ie ? function () { if (c.readyState == 'complete' || c.readyState == "loaded") b(); } : b); gES("body")[0].appendChild(c); }
/**
* Shorthand for document.getElementByID
* @param {string} id ID string of the element to get
* @return {HTMLElement} | {null} The Element if it is found or null it is not found
*/
function gE(id) {
	return document.getElementById(id);
};

/**
* Shorthand for document.getElementsByTagName
* @param {string} tag to search for
* @return	{HTMLElementCollection} Collection of {HTMLElement}s found
*/
function gES(id) {
	return document.getElementsByTagName(id);
};

/**
* Adds an event to an object
* @param {HTMLElement} Obj HTMLElement to add the event to
* @param {string} Event Type of event ot add
* @param	{function} handler Function to trigger when event fires
* @return	{null}
*/
function addEvent(Obj, Event, handler) {
	if (Obj.addEventListener) { //FF,Opera
		Obj.addEventListener(Event, handler, false);
	} else if (Obj.attachEvent) { //IE
		Obj.attachEvent("on" + Event, handler);
	} else { //Fallback
		Obj.setAttribute("on" + Event, handler);
	};
};
/**
* Removes an event from an object
* @param {HTMLElement} Obj HTMLElement from which to remove the event
* @param {string} Event Type of Event to remove
* @param {function} handler Function to remove
* @return {null}
*/
function delEvent(element, eventName, handler) {
	if (element.addEventListener) { //FF,Opera
		element.removeEventListener(eventName, handler, false);
	} else if (element.detachEvent) { //IE
		element.detachEvent('on' + eventName, handler);
	} else { //Fallback
		element['on' + eventName] = null;
	};
};
/**
* Stops the Bubbling/Propagation of events 
* @param {event} e Event to cancel
* @return	{null}
*/
function sB(e) {
	if (e.preventDefault) { //FF,Opera
		e.preventDefault(); e.stopPropagation(e);
	} else { //IE
		e.cancelBubble = true;
	};
	return false; //Fallback
};
/**
* Checks an Element for a class name
* @param {string} strClassName Classname to test for
* @param {HTMLElement} Element to check for the class
* @return {collection} | {boolean} Returns false is no match found otherwise returns collection of results
*/
function matchClass(strClassName, Element) {
	var c = Element.className.match(new RegExp("(^|\\s)" + strClassName + "(\\s|$)", "g"));
	return (c) ? c : false;
};
/**
* Strips leading Zerors from a string
* @param {string} strNumber Variable to strip leading zeros from
* @return {integer} Integer value returned with no leading zeros
*/
function sZ(strNumber) {
	var b = strNumber.replace(/^[0]+/g, "");
	return parseInt(b === "" ? 0 : b); // test check that the string consisted only of zeros
};
/**
* Add a class to an Element
* @param {HTMLElement} Element to assign class to
* @param {string} ClassName Name of the class to add
* @return {null}
*/
function aC(Element, ClassName) {
	if (!matchClass(ClassName, Element)) {
		Element.className += (Element.className.length > 0) ? " " + ClassName : ClassName;
	};
};
/**
* Add a class to an Element
* @param {HTMLElement} Element from which to remove class
* @param {string} ClassName Name of the class to remove
* @return {null}
*/
function rC(Element, ClassName) {
	if (Element.className.match(new RegExp(ClassName))) {
		Element.className = Element.className.replace(new RegExp("[ \t]*" + ClassName), "");
	};
};

/**
* Create an Element 
* @param {string} Element Name of the element to create
* @param {object} Properties Object fo properties to assign to the created Element
* @return {HTMLElement} Returns an HTML Element Object
*/
function cE(Element, Properties) {
	var c = document.createElement(Element);
	if (Properties) { sO(c, Properties) };
	return c;
};
/**
* Set Properties of an Object
* @param {object} Obj Object to which to assign Properties
* @param {object} Properties Object of propertiesa to assign to refering object
* @return {null}
*/
function sO(Obj, Properties) {
	if (Properties) {
		if (Properties.opacity) {
			var t = Properties.opacity / 100;
			Properties.MozOpacity = t;
			Properties.KhtmlOpacity = t;
			Properties.filter = "alpha(opacity=" + Properties.opacity + ")";
			Properties.opacity = t;
			Properties.zoom = 1; //fix for ie
		}
		for (var i in Properties) {
			if (typeof Obj[i] === "object" && typeof Obj[i] != "function") {
				sO(Obj[i], Properties[i]);
			} else {
				Obj[i] = Properties[i];
			}
		}
	}
	return Obj
};
/**
* Normalises an Event Object
* @param {event} e Event to normalise
* @return {HTMLElement}
*/
function nE(e) {
	return (e.target) ? e.target : e.srcElement;
};
/**
* Normalises an the target of an event
* @param {event} e Event to normalise
* @return {HTMLElement}
*/
function nET(e) {
	return (e.toElement) ? e.toElement : e.relatedTarget;
};
/**
* Checks to see if the element is a child of the parent element
* @param {HTMLElement} a Child Element 
* @param {HTMLElement} b Parental Element to test for
* @return {boolean} returns true if a is a child of b
*/
function cP(a, b) {
	if (a) {
		while (a.parentNode) {
			if ((a = a.parentNode) == b) { return true; }
		}
	}
	return false;
};
/**
* Find the first parent that has the nfk property set
* @param {HTMLElement} a Child Element 
* @param {HTMLElement} b Parental Element to test for
* @return {boolean} returns true if a is a child of b
* @deprecated
*/
function fN(a) { if (!a.nfk) { while (a.parentNode) { if (a.nfk) { return a; } else { a = a.parentNode }; } return a; } else { return a; } };
/**
* Converts 2010-12-09T14:00:00-05:00 string to date object
* @param {string} DateString Holds the original string to parse
* @return {date} returns date object
*/
function cD(DateString) {
	var t = DateString.split("T"); // Splits the date and time on the letter T
	var b = t[0].split("-"); // Splits the Year-Month-Day on -
	var c = t[1].substr(0, 8).split(":"); //Splits the time on :
	return new Date(b[0], sZ(b[1]) - 1, sZ(b[2]), sZ(c[0]), sZ(c[1]), sZ(c[2])); //strips leading 0's and takes off one month for JS date object
};
/**
* Used by the xml object to determine the type or request to use
* @return {XMLHttpRequest} | {ActiveXObject} returns the object to use for XMLHttpRequests
*/
function ajaxRequest() {
	var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
	if (window.ActiveXObject) {
		for (var i = 0; i < activexmodes.length; i++) {
			try {
				return new ActiveXObject(activexmodes[i]);
			} catch (e) { }
		}
	} else { return (window.XMLHttpRequest) ? new XMLHttpRequest() : false; }
};
/**
* Used to get information with XMLHttpRequest
* @requires ajaxRequest This requires the ajaxRequest() function
* @param {string} url URL to perform XMLHttpRequest with
* @param {function} SuccessFunction Function to call if the request is successful
* @param {function} FailFunction Function to call if the request fails
* @param {object} ObjectReference Optional reference to the calling object
* @return {null} does not directly return any variables
*/
function xml(url, SuccessFunction, FailFunction, ObjectReference) {
	if (!url) { return false }
	if (!ObjectReference) { ObjectReference = null; };
	var s = this;
	this.XMLHTTP = new ajaxRequest();
	this.Fail = function () { if (FailFunction) { eval(FailFunction(this.XMLHTTP, ObjectReference)); } };
	this.Success = function () { eval(SuccessFunction(this.XMLHTTP, ObjectReference)); };
	this.XMLHTTP.onreadystatechange = function () { stateChange(s.XMLHTTP, s); };
	this.XMLHTTP.open("GET", url, true);
	this.XMLHTTP.send(null);
	function stateChange(d, e) { if (d.readyState === 4) { (d.status === 200 | d.status === 0) ? e.Success() : e.Fail() } };
};
/**
* Add a style to the stylesheet
* @param {array} a Array containing style declarations to add
* @return {null} 
*/
function addStyles(a) {
	var b = document.getElementById("nfkCustomStyles");
	var s = (b) ? b : cE("style", { id: "nfkCustomStyles", type: "text/css" });
	if (!b) document.getElementsByTagName("head")[0].appendChild(s);
	for (var x = 0, xl = a.length; x < xl; x++) {
		(s.styleSheet) ? s.styleSheet.cssText += "\n" + a[x] : s.appendChild(document.createTextNode(a[x]));
	};
};
/**
* Default class for screen takeovers
* @param {object} Props Customised object used to override any part of the base class
* @return {object}
*/
sO(nfk, { screentakeover: function (Props) {
	var me = this;
	this.body = null;
	this.AutoInit = false;
	this.DimBG = true;
	this.bgDiv = cE("div", { style: { backgroundColor: "#000000", overflow: "hidden", position: (nfk.ieFix ? "absolute" : "fixed"), top: "0px", left: "0px", opacity: 85, zIndex: 10000} });
	this.WindowTitle = "&nbsp";
	this.Container = cE("div");
	this.RenderWindow = function () { var newRoot = cE("div", { className: "nfkTO" }); var title = cE("div", { className: "title", innerHTML: me.WindowTitle }); var btnClose = cE("div", { className: "close", innerHTML: "X" }); addEvent(btnClose, "click", me.Close); title.appendChild(btnClose); newRoot.appendChild(title); var contentContainer = me.Container; sO(contentContainer, { style: { position: "relative"} }); newRoot.appendChild(contentContainer); me.Container = newRoot; sO(me.Container, { style: { width: parseInt(contentContainer.style.width) + "px"} }); };
	this.init = function () {
		me.body = document.getElementsByTagName("body")[0];
		sO(window, { nfk: { takeover: { close: null}} });
		if (typeof window.nfk.takeover.active == "undefined") sO(window, { nfk: { takeover: { active: false}} });
		if (!window.nfk.takeover.active) {
			if (me.RenderWindow) { me.RenderWindow() };
			window.nfk.takeover.close = me.Close;
			sO(me.Container, { style: { position: (nfk.ieFix ? "absolute" : "fixed"), zIndex: 10010} });
			addEvent(me.bgDiv, "click", window.nfk.takeover.close);
			me.Draw();
			window.nfk.takeover.active = true;
		}
	};
	this.Close = function () {
		try { me.body.removeChild(me.Container); if (me.DimBG) me.body.removeChild(me.bgDiv) } catch (e) { }
		window.nfk.takeover.active = false;
		delEvent(window, "resize", me.resize);
		if (nfk.ieFix) delEvent(window, "scroll", me.resize);
		delete me.bgDiv; delete me.Container; delete me;
	};
	this.resize = function () {
		if (me) {
			me.Container.style.left = (Math.floor((nfk.windowWidth() - parseInt(me.Container.offsetWidth)) / 2)) + "px";
			me.Container.style.top = (Math.floor((nfk.windowHeight() - parseInt(me.Container.offsetHeight)) / 2)) + ((nfk.ieFix) ? document.body.parentElement.scrollTop : 0) + "px";
			sO(me.bgDiv, { style: { height: nfk.windowHeight() + "px", width: nfk.windowWidth() + "px", top: (nfk.ieFix) ? document.body.parentElement.scrollTop : 0, position: (nfk.ieFix ? "absolute" : "fixed")} });
		}
	};
	this.Draw = function () {
		me.body.insertBefore(me.bgDiv, me.body.firstChild);
		me.body.appendChild(me.Container);
		if (me.render) me.render();
		me.resize();
		addEvent(window, "resize", me.resize);
		if (nfk.ieFix) addEvent(window, "scroll", me.resize);
	};
	sO(me, Props);
	if (me.AutoInit) me.init();
}
});

function afterLoad() {
	addStyles(["a:hover.videotakeover .videoHover,a:hover.video .videoHover, #gettingStarted:hover div.videoHover {display:none !important;}", ".nfkTO {border:groove 2px #333;width:400px;background:#000;}", ".nfkTO .title {font-family:Verdana;font-size:11px;padding:4px 3px 5px 23px;background:#000 url(http://www.psimg.com/img/nfk/window-icon.gif) 5px 4px no-repeat;color:#FFF;position:relative;border-bottom:groove 2px #333;}", ".nfkTO .close {position:absolute;padding:0px 3px;top:4px;right:2px;color:#FFF;cursor:pointer;border:outset 1px #FFF;}", ".nfkTO .close:hover {background:#333;}"]);
	var t = document.getElementsByTagName("ol");
	for (var x = 0, xl = t.length; x < xl; x++) {
		;
		if (t[x].className == "terms") { processTerms(t[x]); };
	};
	var aBlank = document.getElementsByTagName("a");
	for (var i = 0, il = aBlank.length; i < il; i++) {
		var anchor = aBlank[i];
		if (anchor.getAttribute("rel") == "external") anchor.setAttribute("target", "_blank");
		if (matchClass("video", anchor)) { var t = new processVideoLink(anchor); t.init(); };
		if (matchClass("videotakeover", anchor)) { var t = new processVideoLink(anchor, 1); t.init(); };
	};
	if (gE("hgFeatures")) {
		var hgFeatures = new TabObj();
		hgFeatures.TabDiv = "hgFeatures";
		hgFeatures.init();
	};
	if (typeof ps_FlashData != "undefined") {
		for (var z = 0, zl = ps_FlashData.length; z < zl; z++) {
			var m = ps_FlashData[z];
			var a = gE(m.id);
			if (a) {
				addEvent(a, "click", function () {
					var b = a.getElementsByTagName("img");
					var title = "";
					if (b) {
						var c = b[0].alt;
						title = (c) ? c : "PokerStars";
					};
					var myTake = new nfk.screentakeover({ Container: { style: { width: m.width + 'px', height: m.height + 'px'} }, WindowTitle: title });
					var tID = gUID();
					var flashContainer = cE("div", { id: tID });
					myTake.Container.appendChild(flashContainer);
					myTake.render = function () { swfobject.embedSWF(m.flashFile, tID, m.width, m.height, "7.0.0", "", m.flashVars, m.parameters); };
					myTake.init();
				})
			}
			//addEvent()
			/*test.RenderVideo = function () { 
    				
			};
			test.init();*/
		}
	};
	(PS.NewObject("SocialMedia", PS.Customisations["SocialMedia"])).Init();
	(PS.NewObject("Counter", PS.Customisations["Counter"])).init();
};
function ChangeVideo(id, n, w, h, addVars, AddParams) {
	var playerRootPath = "http://www.psimg.com/jw/";
	var Params = { wmode: "transparent", allowFullScreen: "true", allowscriptaccess: "always" };
	var addCaps = { 
	  "plugins": "captions-2, fbit-1",
		"captions.back": "false",
		"captions.fontsize": "12",
		"captions.state": "true"
	};
	var Vars = {
		autostart: "true",
		//file: "http://vod.pstv.videojuicer.com/pokerstars/16d95f8e-1a80-11e0-bf57-12313b041071.mp4",
		"skin": playerRootPath + "glow.zip",
		"dock": "false",
		"controlbar": "bottom"
	};
	if (addVars) { if (addVars["captions.file"]) { sO(Vars, addCaps); } sO(Vars, addVars); };
	swfobject.embedSWF(playerRootPath+"player.swf",
	"" + id,
	w,
	h,
	"7.0.0",
	false, Vars, Params);
}
function processVideoLink(objLink, to) {
	var me = this;
	this.myTitle = (objLink.title != "") ? objLink.title : objLink.innerHTML;
	this.takeover = (to) ? true : false;
	this.regGrabID = new RegExp("-[0-9]+");
	this.videoID = (objLink.href) ? objLink.href.match(this.regGrabID) : null;
	if (me.videoID) this.videoID = me.videoID[0].replace(/^-/, "");
	this.a = objLink.getElementsByTagName("img");
	this.LinkRef = objLink;
	this.w = 0;
	this.h = 0;
	this.id = gUID();
	this.caption = {};
	this.init = function () {
		if (typeof swfobject != "undefined") {
			//Check rel attribute
			if (objLink.rel) { var cA = objLink.rel.split(" "); for (var x = 0, xl = cA.length; x < xl; x++) { if (cA[x].match(/^caption=/)) { this.caption = { "captions.file": cA[x].substring(cA[x].indexOf("=") + 2, cA[x].length - 1) }; } } };
			if (me.a.length == 1) {
				var myCallback = gUID();
				var scriptNode = cE("script", { type: "text/javascript", src: "http://www.pokerstars.tv/mobile/videos/" + me.videoID + ".js?callback=" + myCallback });
				gES("body")[0].appendChild(scriptNode);
				window[myCallback] = function (a) { sO(me.LinkRef, { nfk: { video: a} }); setTimeout(function () { try{ gES("body")[0].removeChild(scriptNode);delete window[myCallback]; } catch(err){}}, 100) };
				myTitle = (me.a[0].alt != "undefined") ? me.a[0].alt : "&nbsp;";
				me.w = me.a[0].offsetWidth;
				me.h = me.a[0].offsetHeight;
				tI = me.a[0];
				var d = cE("div", { id: me.id, style: { position: "relative", display: "block", width: me.w + "px", height: me.h + "px", cursor: "pointer"} });
				var hov = cE("div", { title: me.myTitle, className: "videoHover", style: { position: "absolute", width: me.w + "px", height: me.h + "px", opacity: 50, background: "#000", display: "block", cursor: "pointer"} });
				var hovIco = cE("img", { title: me.myTitle, height: "50", width: "50", className: "videoIcoHover", src: "http://www.psimg.com/img/nfk/play-hg.png", style: { position: "absolute", top: Math.floor((me.h - 50) / 2) + "px", left: Math.floor((me.w - 50) / 2) + "px", display: "block"} });
				d.appendChild(hov); d.appendChild(hovIco); objLink.appendChild(d); d.appendChild(tI);
				objLink.showHide = function () { (hov.style.display == 'none') ? hov.style.display = '' : hov.style.display = 'none'; (hovIco.style.display == 'none') ? hovIco.style.display = '' : hovIco.style.display = 'none'; };
				sO(tI, { width: me.w, height: me.h });
				addEvent(tI, "click", function () { me.RenderVideo() });
				addEvent(hov, "click", function () { me.RenderVideo() });
				addEvent(hovIco, "click", function () { me.RenderVideo() });
				if (nfk.ieFix) { addEvent(objLink, "mouseover", objLink.showHide); addEvent(objLink, "mouseout", objLink.showHide); };
				sO(objLink, { href: "javascript:void(0)" });
			} else {
				me.RenderVideo();
			}
		};
	};
	this.RenderVideo = function () {
		sO(me.caption, { file: me.LinkRef.nfk.video.links[5].href });
		if (me.takeover) {
			objLink.href = "javascript:void(0)";
			addEvent(objLink, "click", function () {
				var myTake = new nfk.screentakeover({ Container: { style: { width: '600px', height: '337px'} }, WindowTitle: myTitle });
				var tID = gUID();
				var flashContainer = cE("div", { id: tID });
				myTake.Container.appendChild(flashContainer);
				myTake.render = function () { ChangeVideo(tID, me.videoID, 600, 337, me.caption); };
				myTake.init();
			});
		} else {
			ChangeVideo(me.id, me.videoID, me.w, me.h, me.caption);
		}
	}
};
function processTerms(Elem, sLevel, Sep) {
	if (Elem.className == "listA") { return; };
	var myCount = 1;
	var mySep = (Sep) ? Sep : ".";
	var myLevel = (sLevel) ? sLevel : "";
	var col = Elem.getElementsByTagName("li");
	for (var y = 0, yl = col.length; y < yl; y++) {
		if (col[y].parentNode == Elem) {
			col[y].insertBefore(cE("span", { className: ((myLevel == "") ? "rootlabel" : "label"), innerHTML: (myLevel + myCount.toString()) }), col[y].firstChild);
			col[y].style.listStyle = "none";
			var childOL = col[y].getElementsByTagName("ol");
			if (childOL.length > 0) {
				for (var z = 0, zl = childOL.length; z < zl; z++) {
					if (childOL[z].parentNode == col[y]) { processTerms(childOL[z], myLevel + myCount + mySep); }
				}
			}
			myCount++;
		}
	}
};
function TabObj() {
	var colTabs = [], colTbl = [];
	this.TabDiv = "";
	this.TabTag = "h3";
	this.TabContentTag = "div";
	this.init = function () {
		elementItem = document.getElementById(this.TabDiv);
		if (elementItem) {
			var theParent = elementItem.parentNode;
			var listH2 = elementItem.getElementsByTagName(this.TabTag);
			var colH2 = []; for (z = 0, zl = listH2.length; z < zl; z++) { colH2[colH2.length] = listH2[z]; };
			var listTables = elementItem.getElementsByTagName(this.TabContentTag);
			for (z = 0, zl = listTables.length; z < zl; z++) { if (listTables[z].parentNode === elementItem) { colTbl[colTbl.length] = listTables[z]; } };
			var navDiv = cE("div", { className: "TabNav" });
			var contentDiv = cE("div", { className: "TabContents" });
			for (x = 0, xl = colH2.length; x < xl; x++) {
				elA = cE('a', { href: "#" });
				elA.appendChild(cE("span", { className: "tl" }));
				linkText = cE("span", { className: "t", innerHTML: colH2[x].innerHTML });
				elA.appendChild(linkText);
				elA.appendChild(cE("span", { className: "tr" }));
				elA.appendChild(cE("span", { className: "tb" }));
				var thisClass = (x === 0 | x === xl - 1) ? (x === 0) ? 'first active' : 'last' : null;
				if (thisClass) { elA.className = thisClass; };
				var temp = this;
				addEvent(elA, 'click', (function (x) { return function (e) { temp.SwitchTab(x); if (e.preventDefault) { e.preventDefault(); return false } else { return false } } })(x));
				aC(elA, "th" + colTabs.length);
				colTabs[colTabs.length] = elA;
				navDiv.appendChild(elA);
			}
			navDiv.appendChild(cE("div", "clear"));
			for (x = 0, xl = colTbl.length; x < xl; x++) {
				colTbl[x].style.display = (x === 0) ? '' : 'none';
				contentDiv.appendChild(colTbl[x]);
			}
			elementItem.appendChild(navDiv);
			elementItem.appendChild(contentDiv);
			for (var b in colH2) { elementItem.removeChild(colH2[b]) };
		};
	};
	this.Tabs = colTabs;
	this.TabContents = colTbl;
	this.SwitchTab = function (index) {
		for (var i = 0, il = this.TabContents.length; i < il; i++) {
			this.TabContents[i].style.display = (i === index) ? '' : 'none';
			(i === index) ? aC(this.Tabs[i], "active") : rC(this.Tabs[i], "active");
		}
	}
};
function PopUp(a) {
	var b = (a.href) ? a.href : "http://qa.pokerstars.com/poker/real-money/processing-exchange-terms/";
	window.open(b, "PopUpWindow", "status = 1, height = 600, width = 500, resizable = 1, scrollbars=1");
	return false;
};
/*Social Media Script*/
var PS = { addBaseClass: function (a, b) { this.objects[a] = function () { return b } },
	addCustomisations: function (a, b) { this.Customisations[a] = b },
	Customisations: {},
	setObject: function (a, b) { if (b) { for (var c in b) { if (typeof a[c] === "object" && typeof a[c] != "function") { PS.setObject(a[c], b[c]); } else { a[c] = b[c]; } } } return a; },
	NewObject: function (a, b) { if (typeof PS.Objects[a] != "undefined") { return b ? PS.setObject(new PS.Objects[a](), b) : new PS.Objects[a]() }; return "Not Found" },
	Objects: { SocialMedia: function () {
		return {
			defaultLoc: window.location.toString(),
			sA: function (a, b) { for (var c in b) { a.setAttribute(c, b[c]) } },
			aS: function (a) { var b = document.getElementById("nfkCustomStyles"); var s = null; if (!b) { s = document.createElement("style"); this.sA(s, { id: "nfkCustomStyles", type: "text/css" }) } else { s = b }; if (!b) document.getElementsByTagName("head")[0].appendChild(s); for (var x = 0, xl = a.length; x < xl; x++) { (s.styleSheet) ? s.styleSheet.cssText += "\n" + a[x] : s.appendChild(document.createTextNode(a[x])); }; },
			RootElement: "socialmedia",
			CallToAction: "Tell your friends about PokerStars",
			Sprite: "http://www.psimg.com/img/social/socialmedia.png",
			Links: {
				Facebook: { name: "Facebook", text: "", href: "http://www.facebook.com/sharer.php?", parameters: { u: window.location.toString(), t: ""} },
				Twitter: { name: "Twitter", text: "", href: "http://twitter.com/share?",
					parameters: {
						url: window.location.toString(),
						counturl: window.location.toString(),
						lang: "en",
						via: "PokerStars",
						text: "Check out this from the Largest Online Poker site in the world!"
					}
				}
			},
			Styles: { items: ["#socialmedia a {background:url(http://www.psimg.com/img/social/socialmedia.png) no-repeat;height:30px;width:30px;display:block;padding:0;margin:0;float:right;}", "#socialmedia a.Twitter {background-position:0px 0px;padding:0;margin:0;}", "#socialmedia a.Facebook {background-position: -30px 0px;padding:0;margin:0;}", "#socialmedia span.CallToAction {float:right;padding:8px 5px 0 0;font-family:Verdana;font-size:11px;font-weight:700;color:#999}", "#socialmedia a:hover.Twitter {background-position:0px -30px;}", "#socialmedia a:hover.Facebook {background-position:-30px -30px;}"] }, BuildStyles: function () { this.aS(this.Styles.items); },
			RenderButtons: function () { var a = document.getElementById(this.RootElement); if (a) { for (var b in this.Links) { var c = this.Links[b]; var d = document.createElement("a"); var e = ""; for (var f in c.parameters) { var g = e ? "&" : ""; e = e + g + f + "=" + encodeURIComponent(c.parameters[f]); }; this.sA(d, { href: c.href + e, target: "_blank" }); d.className = b; a.appendChild(d); }; var cta = document.createElement("span"); cta.className = "CallToAction"; cta.innerHTML = this.CallToAction; a.appendChild(cta); }; },
			Init: function () { this.BuildStyles(); this.RenderButtons(); }
		}
	},
		Counter: function () {
			return {
				url: "http://www.psimg.com/datafeed/dyn_banners/summary.json.js?callback=var%20PS_counter%20=%20%20",
				init: function () { lS(this.url, this.processCounter, this); return this; },
				processCounter: function (a) {
					if (typeof PS_counter != "undefined") {
						var source = this.event ? this.event.srcElement.nfk.parent : this.nfk.parent;
						var b = source.data(PS_counter.tournaments.summary);
						//var c = ots(b);
						source.render(b);
					}
				},
				text: { Clubs: "Poker Clubs", Players: "Players" },
				spanID: "NumberOfClubs",
				code: "hg",
				render: function (b) {
					var a = gE(this.spanID);
					if (a) a.innerHTML = "<strong>" + this.formatNum(b.hg.clubs) + "</strong> " + this.text.Clubs + " | <strong>" + this.formatNum(b.hg.members) + "</strong> " + this.text.Players;
				},
				formatNum: function (a) { var x = (a + ' ').split('.'); var x1 = x[0]; var x2 = x.length > 1 ? "." + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + " " + '$2'); }; return x1 + x2; },
				data: function (a) {
					return { net: { players: a.play_money.players, tournaments: a.play_money.active_tournaments }, com: { players: a.players, tournaments: a.active_tournaments }, it: { players: a.site[0].players, tournaments: a.site[0].active_tournaments }, fr: { players: a.site[1].players, tournaments: a.site[1].active_tournaments }, hg: { clubs: a.clubs, members: a.club_members} }
				}
			}
		}
	}
};


addEvent(window, "load", afterLoad);
/*
<script type="text/javascript" src="http://qa.pokerstars.com/scripts/swfobject2.js"></script>
<script type="text/javascript" src="http://qa.pokerstars.com/poker/home-games/scripts/nfk-hg0.1-Dev.js"></script>
*/

