if( ! pokernews ) {
	var pokernews = {};
}

if( ! pokernews.widget ) {
	pokernews.widget = {};
}

pokernews.widget.news = {
	settings : {
		category: "0",
		imageVisible: true,
		dateVisible: true,
		linkTargetBlank: true,
		width: "260",
		height: "226",
		linkColor: "#12478D",
		textColor: "#666666",
		borderColor: "#12478C",
		backgroundColor: "#FFFFFF",
		tableProperties: ""
	},

	recommendedSettings : {
		minWidth: "226",
		minHeight: "226"
	},

	customSettings : {},

	getHTML : function() {
		var _self = pokernews.widget.news;
		var html = "<table class=\"pn-wgt-widget\"{tableProperties}>"+"<tr>"+"<td class=\"pn-wgt-bg\" valign=\"top\">"+"<div class=\"pn-wgt-widget\">"+"<div class=\"pn-wgt-top\">"+"<img src=\"http:\/\/www.pokernews.com\/img\/widget\/s.gif\" width=\"105\" height=\"17\" style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( enabled=true, src='http:\/\/pokernews.com\/img\/widget\/pokernews.png'); margin-right: 5px\" alt=\"Pokernews.com\" \/>"+"<a href=\"http:\/\/www.pokernews.com\/poker-tools\/\" title=\"\">get this widget<\/a>"+"<\/div>"+"<div class=\"pn-wgt-wrap\">"+"<a href=\"http:\/\/www.pokernews.com\/news\/poker-events\/\"><b>Poker Events<\/b><\/a>"+"<div class=\"scroll\">"+"<table>"+"<tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2010\/02\/party-poker-premier-league-iv-set-to-heat-up-vegas-7894.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4b717da0158ae.jpg\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">February 09, 2010<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2010\/02\/party-poker-premier-league-iv-set-to-heat-up-vegas-7894.htm\" title=\"PartyPoker Premier League IV Set to Heat Up Vegas\" target=\"_blank\">PartyPoker Premier League IV Set to Heat Up Vegas<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2010\/02\/pokerstars-announces-nordic-poker-awards-7863.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4b66f40ce4326.png\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">February 01, 2010<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2010\/02\/pokerstars-announces-nordic-poker-awards-7863.htm\" title=\"PokerStars Announces Nordic Poker Awards\" target=\"_blank\">PokerStars Announces Nordic Poker Awards<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2010\/01\/doyle-brunson-added-to-party-poker-s-premier-league-iv-line-7854.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4b61504ae3956.jpg\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">January 28, 2010<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2010\/01\/doyle-brunson-added-to-party-poker-s-premier-league-iv-line-7854.htm\" title=\"Doyle Brunson Added to Party Poker's Premier League IV Line-up\" target=\"_blank\">Doyle Brunson Added to Party Poker's Premier League IV Line-up<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2010\/01\/trump-taj-mahal-throws-tournament-to-raise-scholarship-funds-7812.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4b55982fcaeb7.jpg\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">January 19, 2010<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2010\/01\/trump-taj-mahal-throws-tournament-to-raise-scholarship-funds-7812.htm\" title=\"Trump Taj Mahal Throws Tournament to Raise Scholarship Funds for Slain Worker's Son\" target=\"_blank\">Trump Taj Mahal Throws Tournament to Raise Scholarship Funds for Slain Worker's Son<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2009\/12\/top-ten-poker-stories-of-the-2009-9-mike-sexton-s-election-i-7686.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4b3272279626c.jpg\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">December 26, 2009<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2009\/12\/top-ten-poker-stories-of-the-2009-9-mike-sexton-s-election-i-7686.htm\" title=\"Top Ten Poker Stories of the 2009: #9, Mike Sexton's Election Into the Poker Hall of Fame\" target=\"_blank\">Top Ten Poker Stories of the 2009: #9, Mike Sexton's Election Into the Poker Hall of Fame<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2009\/12\/help-raise-money-for-aids-research-during-the-pokerstars-car-7653.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4b1fec01ae251.jpg\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">December 09, 2009<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2009\/12\/help-raise-money-for-aids-research-during-the-pokerstars-car-7653.htm\" title=\"Help Raise Money for AIDS Research During the PokerStars Caribbean Adventure\" target=\"_blank\">Help Raise Money for AIDS Research During the PokerStars Caribbean Adventure<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2009\/10\/the-road-2-recovery-charity-poker-tournament-raises-funds-fo-7389.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4ad61c822a75c.jpg\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">October 14, 2009<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2009\/10\/the-road-2-recovery-charity-poker-tournament-raises-funds-fo-7389.htm\" title=\"Road 2 Recovery Charity Tournament Raises Funds for Injured Racers\" target=\"_blank\">Road 2 Recovery Charity Tournament Raises Funds for Injured Racers<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2009\/09\/the-international-poker-players-association-announces-format-7166.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4aa166e7ea216.png\" width=\"60\" height=\"40\" alt=\"\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">September 05, 2009<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2009\/09\/the-international-poker-players-association-announces-format-7166.htm\" title=\"The International Poker Players Association Announces Format\" target=\"_blank\">The International Poker Players Association Announces Format<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2009\/08\/the-sports-legends-challenge-picks-up-momentum-7103.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4a92ee86439ce.jpg\" width=\"60\" height=\"40\" alt=\"SLC Logo\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">August 25, 2009<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2009\/08\/the-sports-legends-challenge-picks-up-momentum-7103.htm\" title=\"The Sports Legends Challenge Picks Up Momentum\" target=\"_blank\">The Sports Legends Challenge Picks Up Momentum<\/a>"+"<\/td>"+"<\/tr><tr>"+"<td><a href=\"http:\/\/www.pokernews.com\/news\/2009\/08\/pokernews-sponsors-sports-legends-challenge-7026.htm\" class=\"pn-wgt-news-image\" target=\"_blank\"><img src=\"http:\/\/www.pokernews.com\/files_en\/cnt\/thumb_4a7b0b1f97519.jpg\" width=\"60\" height=\"40\" alt=\"Sports Legends Challenge Logo\" \/><\/a><\/td>"+"<td>"+"<div class=\"pn-wgt-news-date\">August 09, 2009<\/div>"+"<a href=\"http:\/\/www.pokernews.com\/news\/2009\/08\/pokernews-sponsors-sports-legends-challenge-7026.htm\" title=\"PokerNews Sponsors Sports Legends Challenge\" target=\"_blank\">PokerNews Sponsors Sports Legends Challenge<\/a>"+"<\/td>"+"<\/tr>"+"<\/table>"+"<\/div>"+"<div class=\"bottom-text\"><\/div>"+"<\/div>"+"<\/div>"+"<\/td>"+"<\/tr>"+"<\/table>";
		var css = "<style type=\"text\/css\">"+".pn-wgt-widget {"+"width:{width};"+"border-collapse:collapse;"+"margin:0 auto;"+"padding:0;"+"}"+".pn-wgt-bg {"+"border:1px solid {borderColor};"+"background:{backgroundColor};"+"border-collapse:collapse;"+"margin:0;"+"padding:0;"+"text-align:left;"+"width:{width};"+"\/*height:{height};*\/"+"}"+".pn-wgt-wrap .scroll {"+"padding:0 5px;"+"height:{heightUL}px;"+"overflow:auto;"+"}"+".pn-wgt-wrap .scroll img {"+"border: 0;"+"margin-right: 5px;"+"}"+".pn-wgt-wrap .scroll table {"+"border-collapse: collapse;"+"}"+".pn-wgt-wrap {"+"padding:5px;"+"}"+".pn-wgt-top {"+"background:{borderColor};"+"text-align:right;"+"padding:0 5px 6px 5px;"+"line-height:110%;"+"}"+".pn-wgt-top img {"+"display:block;"+"float:left;"+"border:0 none;"+"margin:1px 0 0 0;"+"background:url(http:\/\/pokernews.com\/img\/widget\/pokernews.png) 0 0 no-repeat;"+"}"+"* html .pn-wgt-top img {"+"background:none;"+"}"+"*:first-child+html .pn-wgt-top img {"+"background:none;"+"}"+".pn-wgt-top a {"+"color:#FFF !important;"+"font-size:9px !important;"+"text-decoration:underline !important;"+"font-family:Verdana, Arial, Helvetica, sans-serif !important;"+"}"+".pn-wgt-wrap * {"+"color:{textColor};"+"line-height:130%;"+"}"+".pn-wgt-wrap a {"+"font-size:11px;"+"font-family:Tahoma, Arial;"+"color:{linkColor};"+"}"+".pn-wgt-wrap a b {"+"display:block;"+"font-size:12px !important;"+"font-family:Verdana, Arial, Helvetica, sans-serif !important;"+"font-weight:bold;"+"color:{linkColor} !important;"+"text-decoration:none !important;"+"}"+".pn-wgt-wrap .bottom-text {"+"font-size:11px;"+"font-family:Tahoma, Arial;"+"padding:0 5px;"+"margin:5px 0;"+"overflow:hidden;"+"line-height:130%;"+"}"+".pn-wgt-wrap .scroll td {"+"padding:3px 0;"+"font-size:9px;"+"font-family:Tahoma, Arial;"+"border-bottom:1px dotted #B7C7DD;"+"}"+"<\/style>";

		for (var i in _self.settings) {
			var property = _self.settings[i];
			if (_self.customSettings[i] !== undefined) {
				property = _self.customSettings[i];
			}
			if (i == "height") {
				css = css.replace(/\{heightUL\}/gi, parseInt(property) - 86);
			}
			if (i == "width" || i == "height") {
				if (property.indexOf('%') < 0 && property.indexOf('px') < 0) {
					property += 'px';
				}
			}
			if (i == "width" && property.indexOf('%') > 0) {
				property = parseInt(property);
				var re = new RegExp("{tableProperties}", "gi");
				var reReplace = '';
				if (property < 100) {
					reReplace = ' style="width: ' + property + '%"';
				}
				property = '100%';
				html = html.replace(re, reReplace);
			}
			if (i == "dateVisible") {
				if (!property) {
					css = css.replace(/<\/style>/gi, ' .pn-wgt-news-date {display:none;}</style>');
				}
			}
			if (i == "imageVisible") {
				if (!property) {
					css = css.replace(/<\/style>/gi, ' .pn-wgt-news-image {display:none;}</style>');
				}
			}
			if (i == "linkTargetBlank") {
				if (!property) {
					html = html.replace(/ target="_blank"/gi, '');
				}
			}

			var re = new RegExp("{" + i + "}", "gi");
			css = css.replace(re, property);
			html = html.replace(re, property);
		}

        for (var i in _self.settings) {
            var re = new RegExp("{" + i + "}", "gi");
			css = css.replace(re, '');
			html = html.replace(re, '');
		}

		return {
			html: html,
			css: css
		};
	},

	getElementsByClass : function(searchClass, node, tag) {
		var classElements = new Array();
		if ( node == null )
			node = document;
		if ( tag == null )
			tag = '*';
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
		for (i = 0, j = 0; i < elsLen; i++) {
			if ( pattern.test(els[i].className) ) {
				classElements[j] = els[i];
				j++;
			}
		}
		return classElements;
	},

	output : function(hash) {
		var container = document.getElementById(hash);
		var containerInnerHTML = container.innerHTML;
		if (container) {
			var _self = pokernews.widget.news;
			_self.hash = hash;
			var code = _self.getHTML();
			document.write(code.css);
			container.innerHTML = code.html;
			var footerElements = _self.getElementsByClass('bottom-text', null, 'div');
			for (var i in footerElements) {
				footerElements[i].innerHTML = containerInnerHTML;
			}
		}
	}
}