Btv.Templating.Register([{id:"Common.BreakingNews",fnc:function($data){var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};with($data){ _write('\n');Main = function(o) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\n<div ');_write(o.Elem('ticker'));_write(' class=\"breakingNews_shell\">\n<div ');_write(o.Elem('tickerMask'));_write(' class=\"breakingNews_mask\">\n<div ');_write(o.Elem("tickerMove"));_write(' class=\"breakingNews_ticker\">');_write(o.InnerHTML());_write('</div>\n</div>\n<div ');_write(o.Elem("allTopics"));_write(' class=\"ticker-drop\" style=\"display:none;\">\n<div class=\"breaking-drop-head\"></div>\n<div class=\"ticker-drop-top\"></div>\n<div class=\"ticker-drop-body\">\n<span class=\"breaking-news-drop-headers\">Breaking News</span>\n');if(o.d.breakingNews  instanceof Array) {for(var i=0; i<o.d.breakingNews .length; i++) {_write('\n<a class=\"ticker-link-icon\" href=\"/breaking-news/');_write(o.d.breakingNews[i].Url);_write('\">');_write(o.d.breakingNews[i].Title);_write('</a>\n');}} else {for(var i in o.d.breakingNews ) {_write('\n<a class=\"ticker-link-icon\" href=\"/breaking-news/');_write(o.d.breakingNews[i].Url);_write('\">');_write(o.d.breakingNews[i].Title);_write('</a>\n');}}_write('\n<span class=\"breaking-news-drop-all\"><a href=\"/breaking-news/news.aspx\">More breaking news &raquo;</a></span>\n<span class=\"breaking-news-drop-headers\">Featured</span>\n');if(o.d.featuredLinks  instanceof Array) {for(var i=0; i<o.d.featuredLinks .length; i++) {_write('\n<a rel=\"nofollow\" href=\"');_write(o.d.featuredLinks[i].Link);_write('\">');_write(o.d.featuredLinks[i].Text);_write('</a>\n');}} else {for(var i in o.d.featuredLinks ) {_write('\n<a rel=\"nofollow\" href=\"');_write(o.d.featuredLinks[i].Link);_write('\">');_write(o.d.featuredLinks[i].Text);_write('</a>\n');}}_write('\n</div>\n<div class=\"ticker-drop-bottom\"></div>\n</div>\n</div>\n');;return($text.join(""));};_write(' \n');
var breakingNewsCST = new (function(d, fncMain)
{
var s, oThis = Btv.Lang.Extend(this, Btv.Cst.BaseTemplate, arguments);
oThis.d = d;
oThis.Render = function()
{
if (!s) s = fncMain(oThis);
return (s);
}
oThis.Init = function(){
var num = d.breakingNews.length + d.featuredLinks.length;
Btv.Ticker.Init(oThis.htIds['tickerMove'], "tick", num, 0);
//YAHOO.util.Event.addListener($(oThis.htIds['ticker']), 'mouseover', Btv.Ticker.Pause);
//YAHOO.util.Event.addListener($(oThis.htIds['ticker']), 'mouseout', $OG(oThis.DoTwo));
}
YAHOO.util.Event.onDOMReady(oThis.Init);
oThis.ElementProps = function(id, scope, name, isInit, params, ht)
{
switch(scope)
{ 
case "allTopics":
ht.attr.onmouseover = $F('{0}();', $OG(oThis.DisplayHover));
ht.attr.onmouseout = $F('{0}();', $OG(oThis.UndisplayHover));
break;
case "ticker":
if(isInit){
ht.attr.onmouseover = $F('{0}(this, event, {1});', $OG(oThis.OnMouseOverride), $OG(Btv.Ticker.Pause));
ht.attr.onmouseout = $F('{0}(this, event, {1});', $OG(oThis.OnMouseOverride), $OG(Btv.Ticker.Resume));
}
break;
case "tickerMove":
if(isInit){
ht.innerHTML = oThis.GetLinks();
}
break;
}
}
oThis.GetLinks = function(){
var html = "";
for(var i = 0; i < d.breakingNews.length; i++){
var tickNum = i + 1;
html += '<div class="breakingNews_ticker-breaking" id="tick' + tickNum + '">';
html += $F('<a href="/breaking-news/news.aspx" class="breaking-news-link" onmouseover="{0}()"></a>', $OG(oThis.DisplayHover));
//html += '<a href="/breaking-news/news.aspx" class="breaking-news-link"></a>';
html += $F('<a href="/breaking-news/{0}">{1}</a>', d.breakingNews[i].Url, d.breakingNews[i].Title);
html += '</div>';
}
for(var i = 0; i < d.featuredLinks.length; i++){
var tickNum = d.breakingNews.length + (i + 1);
html += '<div class="breakingNews_ticker-featured" id="tick' + tickNum + '">';
html += $F(' <span class="breaking-news-link" onmouseover="{0}()"></span>', $OG(oThis.DisplayHover));
html += $F(' <a rel="nofollow" href="{0}">{1}</a>', d.featuredLinks[i].Link, d.featuredLinks[i].Text);
html += '</div>';
}
return html;
}
oThis.OnMouseOverride = function(elem, e, fnc){
var currentMouseElem = null;
if(e.toElement){
currentMouseElem = e.toElement;
}
else{
currentMouseElem = e.relatedTarget;
}
if(!oThis.IsChild(elem, currentMouseElem) && elem != currentMouseElem){
fnc();
}
}
oThis.IsChild = function(parentElem, childElem){
if(childElem != null){
while(childElem.parentNode){
childElem = childElem.parentNode;
if(childElem == parentElem){
return true;
}
}
}
return false;
}
oThis.DisplayHover = function(){
var headerDDElement = $(oThis.htIds['allTopics']);
if (headerDDElement != null) {
headerDDElement.style.display = 'block';
}
}
oThis.UndisplayHover = function(){
var headerDDElement = $(oThis.htIds['allTopics']);
if (headerDDElement != null) {
headerDDElement.style.display = 'none';
}
}
oThis.DoTwo = function(){
oThis.UndisplayHover();
Btv.Ticker.Resume();
}
})($data, Main);
_write('\n');_write(breakingNewsCST.Render());_write('\n');}return $text.join("");}},{id:"Navigation.NumericPager",fnc:function($data){var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};with($data){ _write('\n');Main = function(o) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\n<div ');_write(o.Elem('pager'));_write(' class=\"dropPager\" style=\"position:relative; zoom:1; ');_write(o.Style());_write('\">\n<div ');_write(o.Elem('controlsRegion'));_write(' style=\"zoom:1; ');_write(o.Style());_write('\">\n<span ');_write(o.Elem('backRegion'));_write(' style=\"');_write(o.Style());_write('\">\n<a ');_write(o.Elem('lnkFirst'));_write('><img src=\"/images/double-left.png\" style=\"width:13px; height:9px; margin-right:15px; border-width:0px;\"></a>\n<a ');_write(o.Elem('lnkBack'));_write(' style=\"padding-right:12px;\"><img src=\"/images/single-left.png\" style=\"width:6px; height:9px; padding-right:4px; border-width:0px;\">');_write(o.Labels['Back']);_write('</a>\n</span>\n<span ');_write(o.Elem('photoNumRegion'));_write(' style=\"min-width:120px; text-align:center;\">\n<span style=\"margin-right:2px;\">');_write(o.Labels['Page']);_write('&nbsp;</span><span ');_write(o.Elem('pagePickerHandler'));_write(' style=\"');_write(o.Style());_write('\"><span ');_write(o.Elem('currentPage'));_write(' style=\"margin-right:0px;\">');_write(o.InnerHTML());_write('</span><img src=\"/images/inverted-arrow.png\" style=\"width:13px; height:12px; border-width:0px; vertical-align:middle;\"></span><span style=\"margin-left:2px;\">&nbsp;of&nbsp;</span><span ');_write(o.Elem('totalPages'));_write('>');_write(o.InnerHTML());_write('</span>\n</span>\n<span ');_write(o.Elem('nextRegion'));_write(' style=\"');_write(o.Style());_write('\">\n<a ');_write(o.Elem('lnkNext'));_write(' href=\"#\" style=\"padding-left:12px;\">');_write(o.Labels['Next']);_write('<img src=\"/images/single-right.png\" style=\"width:6px; height:9px; padding-left:4px; border-width:0px;\"></a>\n<a ');_write(o.Elem('lnkLast'));_write(' href=\"#\"><img src=\"/images/double-right.png\" style=\"width:13px; height:9px; margin-left:15px; border-width:0px;\"></a>\n</span>\n<div style=\"clear:both;\"></div>\n</div>\n<div ');_write(o.Elem('pagePickerRegion'));_write(' style=\"display:none; width:100%; position:absolute;\">\n<div style=\"height:5px;\"></div>\n<div class=\"dropPager_PagePicker\" style=\"background-color:#e0e0e0; border:solid 1px #999999; padding:5px;\">\n<div ');_write(o.Elem('pagePickerBackRegion'));_write(' style=\"text-align:left; margin:3px 0px; background-color:#e0e0e0;\"><a ');_write(o.Elem('lnkPagePickerBack'));_write('>&lt;&lt;&nbsp;');_write(o.Labels['Pages']);_write(' <span ');_write(o.Elem('pagePickerBackFirst'));_write('></span>-<span ');_write(o.Elem('pagePickerBackLast'));_write('></span></a></div>\n<table ');_write(o.Elem('tblPagePicker'));_write(' cellpadding=\"0\" cellspacing=\"3\" style=\"zoom:1;\"><tr>\n'); for (var i = 0; i < o.oPagePicker.GetGridSize(); i++)
{
if ((i > 0) && ((i % o.oPagePicker.GetColCount()) == 0))
{
_write('\n</tr><tr>\n'); } _write('\n<td ');_write(o.Elem('dropPager_span.' + i, i));_write('></td>\n'); } _write('\n</script>\n</tr></table>\n<div ');_write(o.Elem('pagePickerNextRegion'));_write(' style=\"text-align:right; margin:3px 0px; background-color:#e0e0e0;\"><a ');_write(o.Elem('lnkPagePickerNext'));_write('>');_write(o.Labels['Pages']);_write(' <span ');_write(o.Elem('pagePickerNextFirst'));_write('></span>- <span ');_write(o.Elem('pagePickerNextLast'));_write('></span>&nbsp;&gt;&gt;</a></div>\n</div>\n</div>\n</div>\n');;return($text.join(""));};_write('\n');
new (function(d, fncMain)
{
var s, oThis = Btv.Lang.Extend(this, Btv.Cst.BaseTemplate, arguments);
var iPages = d.iPageCount;
var iPage = d.iPageStart || 1;
oThis.debugID = 'pager';
d.align = d.align || 'center';
d.labels = d.labels || {};
d.labels.Back = d.labels.Back || 'Back';
d.labels.Next = d.labels.Next || 'Next';
d.labels.Page = d.labels.Page || 'Page';
d.labels.Pages = d.labels.Pages || 'Pages';
oThis.Labels = d.labels; 
oThis.onChange = new Btv.Event();
function GoBy(i)
{
GoTo(iPage + i);
}
oThis.ChangeBy = GoBy;
function Refresh()
{
oThis.UpdateElements();
oPagePicker.SetData(iPages, iPage);
}
function GoTo(i, blnNoEvent)
{
if (iPage == i) return;
if (d.blnLoop) i = (((i-1) + iPages) % iPages) + 1;
iPage = Math.max(1, Math.min(iPages, i));
if (!blnNoEvent) oThis.onChange.Fire(iPage);
oThis.StateChanged(Refresh);
}
oThis.GoTo = GoTo;
oThis.SetPageCount = function(i)
{
d.iPageCount = iPages = i;
Refresh();
}
oThis.SetPage = function(i)
{
GoTo(i, true);
}
function PagePicker(iColCount, iRowCount, iOpenDelay, iCloseDelay, fncGoTo)
{
var oPagePicker = this;
var iPagePickerGridCount = iColCount * iRowCount;
var iPickerActive = -1;
var iPickerCurrent = -1;
var iPagePage = -1;
var iNumPagePages = -1;
var iNumPages = -1;
var iCurrentPage = -1;
var iVisibleRows = -1;
var blnDirty = true;
oPagePicker.ChangeBy = function(iAmount)
{
Prepare(Math.max(0, Math.min(Math.ceil(iPages / iPagePickerGridCount), iPagePage + iAmount)));
oPagePicker.oPickerTracker.Out();
}
oPagePicker.GetGridSize = function()
{
return(iPagePickerGridCount);
}
oPagePicker.GetColCount = function()
{
return(iColCount);
}
oPagePicker.SetData = function(iNumPages_, iCurrentPage_)
{
if (iNumPages != iNumPages_)
{
blnDirty = true;
iNumPages = iNumPages_;
iNumPagePages = Math.ceil(iNumPages / iPagePickerGridCount);
}
iCurrentPage = iCurrentPage_;
}
function Prepare(iPagePage_)
{
function GetChildNodes(elparent, astrTagNames)
{
var a = [];
if (elparent)
{
var ht = Btv.Util.ArrayToHash(astrTagNames, Btv.Util.ToLowerCase);
var aNodes = elparent.childNodes;
for (var i=0; i < aNodes.length; i++)
{
var oNode = aNodes[i];
if (oNode.tagName && ht[oNode.tagName.toLowerCase()])
{
a.push(elparent.childNodes[i]);
}
}
}
return(a);
}
function SaveReferences()
{
if (!aelRows)
{
aelRows = GetChildNodes($(oThis.htIds['tblPagePicker']).childNodes[0], ['tr']);
aelCells = GetChildNodes(aelRows[0], ['td']);
}
}
var aelRows;
var aelCells;
function GetRowElements()
{
SaveReferences();
return(aelRows);
}
function GetFirstRowCells()
{
SaveReferences();
return(aelCells);
}
function PrepareGrid()
{
// only need to do this if the data is dirty
if (!blnDirty) return;
blnDirty = false;
var aelRows = GetRowElements();
iVisibleRows = Math.min(iRowCount, Math.ceil(iNumPages / iColCount));
// reset all the nodes
for (var i=0; i < aelRows.length; i++)
{
for (var j=0; j < aelRows[i].childNodes.length; j++)
{
aelRows[i].childNodes[j].className = '';
}
}
// remove all the current rows, and add back only the ones we need 
var tbody = $(oThis.htIds['tblPagePicker']).childNodes[0];
var aCurrentRows = tbody.childNodes;
for (var i=aCurrentRows.length-1; i >= 0; i--) tbody.removeChild(aCurrentRows[i]);
for (var i=0; i < Math.min(iVisibleRows, aelRows.length); i++) tbody.appendChild(aelRows[i]);
// remove all the current cells from first row, and add back only the ones we need 
if (aCurrentRows.length > 0)
{
var aelCells = GetFirstRowCells();
for (var i=aCurrentRows[0].childNodes.length-1; i >= 0; i--) aCurrentRows[0].removeChild(aCurrentRows[0].childNodes[i]);
for (var i=0; i < Math.min(iNumPages, aelCells.length); i++)
{
aCurrentRows[0].appendChild(aelCells[i]);
} 
}
}
function ClearHighlightedBoxes()
{
function ResetBox(i)
{
if (i != -1) $(oThis.htIds['dropPager_span.' + i]).className = '';
}
ResetBox(iPickerActive);
iPickerActive = -1;
ResetBox(iPickerCurrent);
iPickerCurrent = -1;
}
function SetBoxesData(iFirstPage, iLastPage)
{
var iCount = (iVisibleRows > 1) ? (iVisibleRows * iColCount) : iNumPages;
for (var i = 0; i < iCount; i++)
{
var iPageNum = i + iFirstPage;
var el = $(oThis.htIds['dropPager_span.' + i]);
el.innerHTML = iPageNum;
el.style.visibility = (iPageNum <= iNumPages) ? 'visible' : 'hidden';
if (iCurrentPage == iPageNum)
{
el.className = 'current';
iPickerCurrent = i;
}
}
}
function SetPagingRegions(iFirstPage, iLastPage)
{
function PageSet(str, bln, iFirst, iLast)
{
if (bln)
{
$(oThis.htIds['pagePicker' + str + 'First']).innerHTML = iFirst;
$(oThis.htIds['pagePicker' + str + 'Last']).innerHTML = iLast;
}
$(oThis.htIds['pagePicker' + str + 'Region']).style.display = (iNumPages <= iPagePickerGridCount) ? 'none' : 'block';
$(oThis.htIds['pagePicker' + str + 'Region']).style.visibility = bln ? 'visible' : 'hidden';
}
PageSet('Back', (iFirstPage > 1), iFirstPage - iPagePickerGridCount, iFirstPage - 1);
PageSet('Next', (iNumPages > iLastPage), iLastPage + 1, Math.min(iNumPages, iLastPage + iPagePickerGridCount));
}
function SetSizeAndVisibility()
{
var elPickerRegion = $(oThis.htIds['pagePickerRegion']);
var elControlsRegion = $(oThis.htIds['controlsRegion']);
elPickerRegion.style.visibility = 'hidden';
elPickerRegion.style.display = 'block';
elPickerRegion.style.width = 'auto';
var tbl = $(oThis.htIds['tblPagePicker']);
elPickerRegion.style.right = "";
tbl.style.width = 'auto';
if (iNumPagePages > 1)
{
var iPickerRegionWidth = Math.max(elControlsRegion.clientWidth, elPickerRegion.clientWidth);
elPickerRegion.style.width = iPickerRegionWidth + "px";
tbl.style.width = '100%';
}
var iDiff = elControlsRegion.clientWidth - elPickerRegion.clientWidth;
if (elPickerRegion.parentNode)
{
elPickerRegion.parentNode.removeChild(elPickerRegion);
var pt = Btv.Dom.GetAbsPos(elControlsRegion);
document.body.appendChild(elPickerRegion);
}
elPickerRegion.style.top = (pt.y + elControlsRegion.clientHeight + 10) + 'px';
if ((d.align == 'center') || ((iNumPagePages == 1) && (iDiff > 0)))
{
elPickerRegion.style.left = (pt.x + Math.floor(iDiff / 2)) + "px";
}
else if (d.align == 'left')
{
elPickerRegion.style.left = pt.x + 'px';
}
else
{
elPickerRegion.style.left = (pt.x + elControlsRegion.clientWidth - elPickerRegion.clientWidth) + "px";
}
elPickerRegion.style.visibility = 'visible';
}
iPagePage = iPagePage_;
var iFirstPage = (iPagePage * iPagePickerGridCount) + 1;
var iLastPage = iFirstPage + iPagePickerGridCount - 1;
PrepareGrid();
ClearHighlightedBoxes();
SetBoxesData(iFirstPage, iLastPage);
SetPagingRegions(iFirstPage, iLastPage);
SetSizeAndVisibility();
}
function PickerDisplayHandler(bln)
{
if (bln)
{
Prepare(Math.floor(iCurrentPage / iPagePickerGridCount));
}
else
{
$(oThis.htIds['pagePickerRegion']).style.display = 'none';
}
}
oPagePicker.SetActive = function(i)
{
if (iPickerActive != i)
{
if (iPickerActive != -1)
{
$(oThis.htIds['dropPager_span.' + iPickerActive]).className = '';
}
if (i != iPickerCurrent)
{
iPickerActive = i;
if (iPickerActive != -1)
{
$(oThis.htIds['dropPager_span.' + i]).className = 'active';
}
}
}
}
oPagePicker.Pick = function(i)
{
var iNewPage = (iPagePage * iPagePickerGridCount) + i + 1;
if (iNewPage != iCurrentPage)
{
oPagePicker.oPickerTracker.Out(true);
fncGoTo(iNewPage);
}
}
oPagePicker.oPickerTracker = new Btv.UI.MouseInRegionTracker(PickerDisplayHandler, iOpenDelay, iCloseDelay);
}
var blnBackOn = true; 
var blnNextOn = true; 
oThis.ElementProps = function(id, scope, name, isInit, params, ht)
{
switch(scope)
{
case "pager":
ht.style.display = ((iPage > 0) && (iPages > 1)) ? 'block' : 'none';
if (isInit)
{
ht.style['margin-left'] = ht.style['margin-right'] = 'auto';
if (d.align)
{
if (d.align == 'left') ht.style['margin-left'] = '0px';
if (d.align == 'right') ht.style['margin-right'] = '0px';
}
}
break;
case "currentPage":
ht.innerHTML = iPage;
break;
case "totalPages":
ht.innerHTML = iPages;
break;
case "dropPager_span":
if (isInit)
{
ht.attr.onmouseover = $F('{0}({1})', $OG(oPagePicker.SetActive), params);
ht.attr.onmouseout = $F('{0}({1})', $OG(oPagePicker.SetActive), -1);
ht.attr.onclick = $F('{0}({1})', $OG(oPagePicker.Pick), params);
} 
break;
case "controlsRegion":
ht.style['text-align'] = d.align;
break;
case "backRegion":
if (isInit) ht.style.zoom = 1;
var blnOn = ((iPage > 1) || d.blnLoop);
if (blnBackOn != blnOn) Btv.UI.Opacity.Set(ht, (blnOn ? 100 : 40))
blnBackOn = blnOn;
//if (!isInit) ht.style.visibility = ((iPage > 1) || d.blnLoop) ? 'visible' : 'hidden';
break;
case "nextRegion":
if (isInit) ht.style.zoom = 1;
var blnOn = ((iPage < iPages) || d.blnLoop);
if (blnNextOn != blnOn) Btv.UI.Opacity.Set(ht, (blnOn ? 100 : 40))
blnNextOn = blnOn;
//if (!isInit) ht.style.visibility = ((iPage < iPages) || d.blnLoop) ? 'visible' : 'hidden';
break;
case "lnkFirst":
if (isInit)
{
ht.attr.href = $F('javascript:{0}(1)', $OG(GoTo));
if (d.classes && d.classes['NavFirst']) ht.attr['class'] = d.classes['NavFirst'];
} 
break;
case "lnkLast":
if (isInit)
{
ht.attr.href = $F('javascript:{0}(Number.MAX_VALUE)', $OG(GoTo));
if (d.classes && d.classes['NavLast']) ht.attr['class'] = d.classes['NavLast'];
} 
break;
case "lnkNext":
if (isInit) ht.attr.href = $F('javascript:{0}(1)', $OG(GoBy));
break;
case "lnkBack":
if (isInit) ht.attr.href = $F('javascript:{0}(-1)', $OG(GoBy));
break;
case "pagePickerHandler":
if (isInit) ht.style.cursor = "pointer";
case "pagePickerRegion":
if (isInit) ht.attr.onmouseout = $F('{0}()', $OG(oPagePicker.oPickerTracker.Out));
if (isInit) ht.attr.onmouseover = $F('{0}()', $OG(oPagePicker.oPickerTracker.In));
break;
case "lnkPagePickerBack":
if (isInit) ht.attr.href = $F('javascript:{0}(-1)', $OG(oPagePicker.ChangeBy));
break;
case "lnkPagePickerNext":
if (isInit) ht.attr.href = $F('javascript:{0}(1)', $OG(oPagePicker.ChangeBy));
break;
}
}
oThis.DeclareVirtualMethods({
Render: fncMain
});
var oPagePicker = oThis.oPagePicker = new PagePicker(10, 10, 250, 200, GoTo);
oPagePicker.SetData(iPages, iPage);
})($data, Main);
_write('\n');}return $text.join("");}},{id:"Common.CommentViewer",fnc:function($data){var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};with($data){ Main = function(o) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\r\n\n<div class=\"temp-push-fix\">\n<div ');_write(o.Elem('commentHead'));_write('  class=\"comment_head\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('Displaying comments <span ');_write(o.Elem('firstIndex'));_write('  style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</span>-<span ');_write(o.Elem('lastIndex'));_write('  style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</span>&nbsp;of&nbsp;<span ');_write(o.Elem('totalComments'));_write('  style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</span></div>\n<div class=\"discussion-post-top\"><div class=\"c\"></div></div>\n<div class=\"discussion-post-body\">\n<div ');_write(o.Elem('pager1'));_write('  class=\"comments-pager1\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</div>\n<div ');_write(o.Elem('commentWrapper'));_write('  style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('\n<div ');_write(o.Elem('comments'));_write('  style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</div>\n<div ');_write(o.Elem('pager2'));_write('  style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</div>\n<div ');_write(o.Elem('addComment'));_write('  style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</div>\n</div>\n</div>\n<div class=\"discussion-post-bottom\"><div class=\"c\"></div></div>\n</div>\n');;return($text.join(""));};Comment = function(o, ht) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\r\n\n<div id=\"comment_block_id_');_write(ht.commentId);_write('\" class=\"discussion-post\">\n<div class=\"discussion-post-left\">\n<a href=\"/tvjhome.aspx?tvjid=');_write(ht.userId);_write('\"><img src=\"');_write(ht.userAvatar);_write('\" alt=\"');_write(ht.username);_write('\" /></a>\n<a href=\"/tvjhome.aspx?tvjid=');_write(ht.userId);_write('\">');_write(ht.username);_write('</a>\n<div class=\"small2_star_pointsHOLD\">');_write(Btv.String.FormatNumber(ht.userPoints));_write(' pts</div>\n<div style=\"display:none;\">joined: <b>');_write(ht.userJoinDate.format("m/dd/yy"));_write('</b></div>\n</div>\n<div class=\"discussion-post-right\">\n<div class=\"comment_ranker\">\n<a id=\"voteUp-');_write(ht.commentId);_write('\" class=\"up\" onclick=\"');_write(ht.voteOnclick);_write('(');_write(ht.commentId);_write(', 1)\"></a>\n<a id=\"voteDown-');_write(ht.commentId);_write('\" class=\"down\" onclick=\"');_write(ht.voteOnclick);_write('(');_write(ht.commentId);_write(', -1)\"></a>\n<span Id=\"commentScore-');_write(ht.commentId);_write('\" class=\"');_write(ht.commentRatingClass);_write('\">');_write(ht.commentRating);_write('</span>\n</div>\n<div class=\"date-report\">');_write(ht.postDate.format("m/dd/yy h:MM TT"));_write('&nbsp;<span id=\"report-');_write(ht.commentId);_write('\"><a onclick=\"');_write(ht.reportCommentOnclick);_write('(');_write(ht.commentId);_write(');\">Report</a></span></div>\n<div class=\"discussion-post-text\">');_write(ht.comment);_write('</div>\n</div>\n<div class=\"discussion-post-options\">\n<span class=\"d-option-interact\">\n<span id=\"wink-');_write(ht.commentId);_write('\" class=\"comment-wink-action\"><a onclick=\"');_write(ht.winkOnclick);_write('(');_write(ht.commentId);_write(', ');_write(ht.userId);_write(');\">;-) Wink at me</a></span>\n<span id=\"remove-');_write(ht.commentId);_write('\" style=\"display: ');_write(ht.displayRmvLink);_write('\"><a onclick=\"');_write(ht.removeCommentOnclick);_write('(');_write(ht.commentId);_write(')\">Delete</a>&nbsp;|&nbsp;</span>\n</span>\n</div>\n<div style=\"clear:both;\"></div>\n</div>\n');;return($text.join(""));};AddComment = function(o, ht) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\r\n\n<div id=\"add_comment_block_id\" class=\"discussion-reply\">\n<div class=\"discussion-reply\">Reply to the topic</div>\n<div ');_write(o.Elem('embedImage'));_write('  class=\"cst-img-embed\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('\n</div>\n<textarea ');_write(o.Elem('commentBox'));_write('  Rows=\"5\" class=\"discussion-text\" MaxLength=\"1000\" style=\"width:100%; margin:5px 0px;');_write(o.Style());_write('\" onFocus=\"this.style.borderColor=\'#000000\';this.style.borderWidth=\'1px\';\" onkeypress=\"this.onclick=null;\">');_write(o.InnerHTML());_write('</textarea>\n<div ');_write(o.Elem('embedLink'));_write('  style=\"clear:both;');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</div>\n<a onclick=\"');_write(ht.submitCommentOnclick);_write('();\" class=\"context-button context-button-right context-submit-button\"><span>Submit</span></a> \n<div class=\"embed-comment-options\">Embed: <a onclick=\"');_write(ht.fncDisplayEmbedImage);_write('\">Image</a>&nbsp;</div>\n<div class=\"clear-fix\"></div>\n</div>\n');;return($text.join(""));};
new (function(d, ui) {
var oThis = Btv.Lang.Extend(this, Btv.Cst.BaseTemplate, [$data, true]);
var htUI = ui;
var $el = oThis.El;

    var oElMan = oThis.ElMan();
    var oPager, oPager2, iContentTypeId, iContentId, iPage, iFirstIndex, iLastIndex, iNumComments;
    var oThread, aComments, oCurrentUser, blnSelectNewestFirst, blnIsUserProfilePage;
    var sEmbedImage, sEmbedLink;
    var fncGetComments = Btv.Ajax.MakeFunction(Btv.Discussion.DataQueries, 'GetComments');
    var fncSaveComment = Btv.Ajax.MakeFunction(Btv.Discussion.DataQueries, 'CreateNewPostWithMedia');
    var fncVoteComment = Btv.Ajax.MakeFunction(Btv.Discussion.DataQueries, 'VoteOnPost')
    var fncRemoveComment = Btv.Ajax.MakeFunction(Btv.Discussion.DataQueries, 'RemovePost')
    var oEmbedImage = Btv.Templating.GetInstance('Dialog.EmbedImage', {});
    var oEmbedLink = Btv.Templating.GetInstance('Dialog.EmbedLink', {});
    var blnFirstCommentFetch = true;

    oThis.ResetContent = function(contentTypeId, contentId) {
        iContentTypeId = contentTypeId;
        iContentId = contentId;
        iPage = 1;
        oPager.SetPage(iPage);
        oPager2.SetPage(iPage);

        GetComments();
    }

    function PageChange(page){
        iPage = page;
        GetComments();
    }

    function PopulateComments() {
        aCommentsHtml = new Array();
        for (var i = 0; i < aComments.length; i++) {
            var iCommentRating = aComments[i].NumAgree - aComments[i].NumDisagree;
            var iCurrentUserId = -1;
            if (oCurrentUser) {
                iCurrentUserId = oCurrentUser.Id;
            }
            var html = htUI.Comment(oThis, {
                                            commentId: aComments[i].Id
                                            ,comment: aComments[i].Body
                                            ,postDate: aComments[i].CreationDate
                                            ,commentRating: iCommentRating
                                            ,commentRatingClass: (iCommentRating >= 0 ? 'comment_positive' : 'comment_negative')
                                            ,voteOnclick: $OG(VoteComment)
                                            ,winkOnclick: $OG(WinkAtUser)
                                            ,reportCommentOnclick: $OG(ReportComment)
                                            ,removeCommentOnclick: $OG(RemoveComment)
                                            ,userId: aComments[i].PublicUser.Id
                                            ,username: aComments[i].PublicUser.Username
                                            ,userAvatar: aComments[i].PublicUser.Avatar
                                            ,userPoints: aComments[i].PublicUser.StarPoints
                                            ,userJoinDate: aComments[i].PublicUser.JoinDate
                                            ,displayRmvLink: (iCurrentUserId == aComments[i].PublicUser.Id ? 'inline' : 'none')
                                        });
            aCommentsHtml.push(html);
        }

        if (aCommentsHtml.length == 0) {
            aCommentsHtml.push("Be the first to comment");
        }

        if (oThread.PostCount > 0) {
            oElMan.InnerHTML('firstIndex', iFirstIndex);

            if (iLastIndex < oThread.PostCount) {
                oElMan.InnerHTML('lastIndex', iLastIndex);
            }
            else {
                oElMan.InnerHTML('lastIndex', oThread.PostCount);
            }
            oElMan.InnerHTML('totalComments', oThread.PostCount);
            oElMan.Style('commentHead', 'display', 'block');
        }
        else {
            oElMan.Style('commentHead', 'display', 'none');
        }
        oElMan.InnerHTML('comments', aCommentsHtml.join(''));

        if (!blnFirstCommentFetch && blnSelectNewestFirst) {
            if (window.location.indexOf('#comments') > 0) {
                window.location = window.location;
            }
            else {
                window.location = window.location + "#comments";
            }
        }
        else {
            blnFirstCommentFetch = false;
        }
    }

    function GetComments(fnc) {
        function haveData(data){
            if (data) {
                oThread = data.Thread;
                aComments = data.Posts;
                
                var iPageCount = Math.ceil(oThread.PostCount / iNumComments);
                oPager.SetPageCount(iPageCount);
                oPager2.SetPageCount(iPageCount);
                oPager.SetPage(iPage);
                oPager2.SetPage(iPage);
                
                if (fnc) {
                    fnc();
                }
                else {
                    PopulateComments();
                }
            }
        }
        
        iFirstIndex = ((iPage - 1) * iNumComments) + 1;
        iLastIndex = (iFirstIndex - 1) + iNumComments;

        var iCurrentUserId = -1;
        if (oCurrentUser) {
            iCurrentUserId = oCurrentUser.Id;
        }

        fncGetComments(iContentTypeId, iContentId, iFirstIndex, iLastIndex, iCurrentUserId, blnSelectNewestFirst, haveData);
    }

    function SaveComment() {
        function haveData(msg) {
            if (msg && msg.length > 0) {
                alert(msg);
            }
            else {
                //$(oThis.htIds['commentBox']).value = '';
                oElMan.Attribute('commentBox', 'value', '');
                oElMan.InnerHTML('embedImage', '');
                oElMan.InnerHTML('embedLink', '');
                sEmbedImage = '';
                sEmbedLink = '';

                var iPageCount = 1;
                
                if (!blnSelectNewestFirst) {
                    iPageCount = Math.ceil((oThread.PostCount + 1) / iNumComments);    
                }
                
                PageChange(iPageCount);
            }
        }

        if (!Btv.User.IsLoggedIn()) {
            Btv.User.InitLogin(SaveComment);
        }
        else {
            var commentText = $(oThis.htIds['commentBox']).value;

            if (commentText.length == 0) {
                alert('Must type in a comment before submitting.');
            }
            else {
                fncSaveComment(oThread.Id, commentText, sEmbedImage, sEmbedLink, haveData);
            }
        }
    }

    function RemoveComment(iCommentId) {
        function haveData(msg) {
            if (msg) {
                alert(msg);
            }
            else {
                var iPageCount = Math.ceil((oThread.PostCount - 1) / iNumComments);
                if (iPage > iPageCount) {
                    PageChange(iPageCount);
                }
                else {
                    PageChange(iPage);
                }
            }
        }
        
        function SubmitRemove(){
            fncRemoveComment(oThread.Id, iCommentId, oCurrentUser.Id, haveData);
        }
        
        if (!Btv.User.IsLoggedIn()) {
            Btv.User.InitLogin(SubmitRemove);
        }
        else {
            SubmitRemove();
        }            
    }
    
    function VoteComment(iCommentId, iVote){
        function fnc(data) {
            if (data == null) {
                data = 0;
            }

            var commentScore = $('commentScore-' + iCommentId);
            if (commentScore) {
                if (data < 0) {
                    commentScore.className = "comment_negative";
                }
                else {
                    commentScore.className = "comment_positive";
                }
                commentScore.innerHTML = data;
            }
        }

        function SubmitVote() {
            fncVoteComment(iCommentId, (iVote > 0), fnc);
        }

        if (!Btv.User.IsLoggedIn()) {
            Btv.User.InitLogin(SubmitVote);
        }
        else {
            SubmitVote();
        }
    }

    function WinkAtUser(iCommentId, iUserId){
        function fnc() {
            var winkDiv = $('wink-' + iCommentId);
            if (winkDiv) {
                winkDiv.innerHTML = 'Thanks! ;-)';
            }
        }

        function SubmitWink() {
            Btv.User.Wink(iUserId, fnc);
        }

        if (!Btv.User.IsLoggedIn()) {
            Btv.User.InitLogin(SubmitWink);
        }
        else {
            SubmitWink();
        }        
    }
    
    function ReportComment(iCommentId){
        function fnc() {
            var reportDiv = $('report-' + iCommentId);
            if (reportDiv) {
                reportDiv.innerHTML = 'Report has been submitted.';
            }
        }

        function SubmitReport() {
            var oReport = new Btv.Report();
            oReport.Report(9997, iCommentId, fnc);
        }
    
        if (!Btv.User.IsLoggedIn()) {
            Btv.User.InitLogin(SubmitReport);
        }
        else {
            SubmitReport();
        }
    }
    
    function DisplayEmbedImageDialog(){
        oEmbedImage.Display(DisplayImage);
    }

    function BuildImageInfo(oImg) {
        if (oImg) {
            return ({ Src: oImg.src, Size: { width: oImg.width, height: oImg.height} });
        }
        return (null);
    }
    
    function DisplayImage(oImg){
        var oSmartImg = Btv.Templating.GetInstance("SmartImage", {
            sizeBounds: { width: 90, height: 90 }
                    , doCrop: true
                    , ImageInfo: BuildImageInfo(oImg)
                    , oCropAnchor: { width: .5, height: .25 }
                    , link: null
        });

        sEmbedImage = oImg.src;

        oElMan.InnerHTML('embedImage', oSmartImg.Render());
        oElMan.Attribute('commentBox', 'className', 'discussion-text discussion-text-image');
    }

    function DisplayEmbedLinkDialog() {
        oEmbedLink.Display(DisplayLink);
    }

    function DisplayLink(link) {
        sEmbedLink = link;
        oElMan.InnerHTML('embedLink', sEmbedLink);
    }

    function UserChanged() {
        function fnc() {
            if (aComments) {
                for (var i = 0; i < aComments.length; i++) {
                    if (((aComments[i].PublicUser.Id == oCurrentUser.Id && oCurrentUser.Id != -1) || (blnIsUserProfilePage)) && $('remove-' + aComments[i].Id)) {
                        $('remove-' + aComments[i].Id).style.display = 'block';
                    }
                }
            }
        }

        oCurrentUser = Btv.User.GetUser();

        if($(oThis.htIds['comments']) == null){
            YAHOO.util.Event.onDOMReady(fnc);        
        }
        else{
            fnc();
        }
    }

    function ToggleDisplayRemoveComment() {
        if (aComments) {
            for (var i = 0; i < aComments.length; i++) {
                if ($('remove-' + aComments[i].Id).style.display == 'block') {
                    $('remove-' + aComments[i].Id).style.display = 'none';
                }
                else {
                    $('remove-' + aComments[i].Id).style.display = 'block';
                }
            }
        }
    }

    var blnAdminMode = false;
    function AdminData(blnAdminMode_, oPermissions) {
        var bln = blnAdminMode_ && oThread && oPermissions.HasPermission(1, 'DeletePost');
        if (blnAdminMode != bln) {
            blnAdminMode = bln;

            ToggleDisplayRemoveComment();
        }
    }
    Btv.Admin.Subscribe(AdminData);

    function InitElements() {
        function PostDeclare() {
            PopulateComments();
            
            // Sometimes the Btv GetCurrentUser call fires before
            // CST has been loaded. This is to enable the remove feature
            // in case the Btv.User.onChange event fires before CST is loaded.
            if (Btv.User.GetUser()) {
                UserChanged(Btv.User.GetUser());
            }
        }
        
        Btv.User.onChange.Attach(UserChanged);

        if (d.isContextPage) {
            oElMan.Attribute('commentWrapper', 'class', 'context-comments');
        }

        oElMan.Style('commentHead', 'display', 'none');

        iContentTypeId = d.contentTypeId;
        iContentId = d.contentId;
        blnSelectNewestFirst = d.selectNewestFirst;
        blnIsUserProfilePage = d.isUserProfilePage;

        if (d.page) {
            iPage = d.page
        }
        else {
            iPage = 1;
        }

        if (d.numComments) {
            iNumComments = d.numComments;
        }
        else {
            iNumComments = 25;
        }

        if (d.thread) {
            oThread = d.thread;

            if (d.comments) {
                aComments = d.comments;
                PostDeclare();
            }
            else {
                GetComments(PostDeclare);
            }
        }
        else {
            GetComments(PostDeclare);
        }

        InitPaging();
        BuildAddCommentUI();
    }

    function BuildAddCommentUI() {   
        var sAddCommentHtml = htUI.AddComment(oThis, { submitCommentOnclick: $OG(SaveComment)
                                                        , fncDisplayEmbedImage: $F('{0}();', $OG(DisplayEmbedImageDialog))
                                                        , fncDisplayEmbedLink: $F('{0}();', $OG(DisplayEmbedLinkDialog))});
        oElMan.InnerHTML('addComment', sAddCommentHtml);
    }

    function InitPaging() {
        var iPageCount = 0;
        if (oThread) iPageCount = Math.ceil(oThread.PostCount / iNumComments);
        iFirstIndex = ((iPage - 1) * iNumComments) + 1;
        iLastIndex = (iFirstIndex - 1) + iNumComments;

        oPager = Btv.Templating.GetInstance("Navigation.NumericPager", {
            iPageCount: iPageCount
                                                                , iPageStart: iPage
                                                                , align: 'center'
                                                                , labels: {
                                                                    Back: 'Prev'
                                                                    , Next: 'Next'
                                                                    , Page: 'Page'
                                                                    , Pages: 'Pages'
                                                                }
                                                                , blnLoop: false
        });
        oPager.onChange.Attach(PageChange);

        oPager2 = Btv.Templating.GetInstance("Navigation.NumericPager", {
            iPageCount: iPageCount
                                                                , iPageStart: iPage
                                                                , align: 'center'
                                                                , labels: {
                                                                    Back: 'Prev'
                                                                    , Next: 'Next'
                                                                    , Page: 'Page'
                                                                    , Pages: 'Pages'
                                                                }
                                                                , blnLoop: false
        });
        oPager2.onChange.Attach(PageChange);

        oElMan.InnerHTML('pager1', oPager.Render());
        oElMan.InnerHTML('pager2', oPager2.Render());
    }

    function Render() {
        InitElements();

        return (htUI.Main(oThis));
    }
    
    oThis.DeclareVirtualMethods({
        Render: Render
    });
})($data, {Main:Main,Comment:Comment,AddComment:AddComment});
}return $text.join("");}},{id:"Dialog.EmbedImage",fnc:function($data){var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};with($data){ Main = function(o, ht) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\r\n\n<div>\n<div class=\"embed-tool\">\n<div class=\"embed-tool-option\">\n<h2>Specify a image url:</h2>\n<span><input type=\"button\" class=\"input-button\" value=\"Attach\" onclick=\"');_write(ht.fncImageUrlChange);_write('\" /> <input ');_write(o.Elem('imageUrl'));_write('  type=\"text\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</input> </span>\n</div>\n<span class=\"embed-tool-or\"></span>\n<div class=\"embed-tool-or-text\">Or</div>\n<div class=\"embed-tool-option\">\n<h2>Upload an image:</h2>\n<iframe id=\"imageUpload\" name=\"imageUpload\" frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" width=\"350px\" height=\"50px\" src=\"/upload-image/addimageframe2.aspx?sf=');_write(ht.callbackFnc);_write('\"></iframe>\n</div>\n</div>\n<div ');_write(o.Elem('embedImageDiv'));_write('  class=\"embed-tool-img\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('\n<img ');_write(o.Elem('embedImage'));_write('  src=\"\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</img>\n</div>\n</div>\n');;return($text.join(""));};
new (function(d, ui) {
var oThis = Btv.Lang.Extend(this, Btv.Cst.BaseTemplate, [$data, true]);
var htUI = ui;
var $el = oThis.El;

    var oElMan = oThis.ElMan();
    var dialog, fncCallback, oImg;

    function ImageUrlChange() {
        function fnc(oImg, bln) {
            if (bln) {
                DisplayImage(oImg.src);
            }
            else {
                alert('Not a valid image.');
            }
        }
        
        var imageUrl = $(oThis.htIds['imageUrl']).value;
        Btv.UI.Imaging.Load(imageUrl, fnc);
    }

    function DisplayImage(imageUrl) {
        oElMan.Style('embedImageDiv', 'display', 'block');
        if ($(oThis.htIds['embedImage'])) {
            $(oThis.htIds['embedImage']).src = imageUrl;
            oImg = $(oThis.htIds['embedImage']);
        }
    }

    function ShowDialog(callback) {
        function Callback(bln) {
            if (bln) {
                fncCallback(oImg);
                ResetValues();
            }
        }
    
        dialog.Show("Embed Image", null, Btv.SimpleDialog.buttonsCancelOK, null, Callback);
    }

    function ResetValues() {
        oImg = null;
        $(oThis.htIds['imageUrl']).value = '';
        oElMan.Style('embedImageDiv', 'display', 'none');
    }

    function InitElements() {}
    
    function Render()
    {
        InitElements();
        dialog = Btv.SimpleDialog.GetInstance();
        dialog.SetBody(htUI.Main(oThis, { callbackFnc: $OG(DisplayImage)
                                        , fncImageUrlChange: $F('{0}();', $OG(ImageUrlChange))
        }));
    }

    oThis.Display = function(fnc) {
        fncCallback = fnc;
        ShowDialog();
    }

    oThis.DeclareVirtualMethods({
        Render: Render
    });

    oThis.Render();
})($data, {Main:Main});
}return $text.join("");}},{id:"Dialog.EmbedLink",fnc:function($data){var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};with($data){ Main = function(o, ht) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\r\n\n<div>\n<span>Link:</span>\n<span><input ');_write(o.Elem('link'));_write('  type=\"text\" value=\"http://\" onfocus=\"');_write(ht.fncClearValue);_write('\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('</input></span>\n</div>\n');;return($text.join(""));};
new (function(d, ui) {
var oThis = Btv.Lang.Extend(this, Btv.Cst.BaseTemplate, [$data, true]);
var htUI = ui;
var $el = oThis.El;

    var oElMan = oThis.ElMan();
    var dialog, fncCallback, sLink;

    function ShowDialog(callback) {
        function Callback(bln) {
            if (bln) {
                sLink = oElMan.Attribute('link', 'value');
                fncCallback(sLink);
                ResetValues();
            }
        }
    
        dialog.Show("Embed Link", null, Btv.SimpleDialog.buttonsCancelOK, null, Callback);
    }

    function ResetValues() {
        sLink = '';
        oElMan.Attribute('link', 'value', 'http://');
    }

    function ClearValue() {
        var linkValue = oElMan.Attribute('link', 'value');
        if (linkValue == 'http://') oElMan.Attribute('link', 'value', '');
    }

    function InitElements() {}
    
    function Render()
    {
        InitElements();
        dialog = Btv.SimpleDialog.GetInstance();
        dialog.SetBody(htUI.Main(oThis, { fncClearValue: $F('{0}();', $OG(ClearValue))}));
    }

    oThis.Display = function(fnc) {
        fncCallback = fnc;
        ShowDialog();
    }

    oThis.DeclareVirtualMethods({
        Render: Render
    });

    oThis.Render();
})($data, {Main:Main});
}return $text.join("");}},{id:"Common.Share",fnc:function($data){var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};with($data){ Main = function(o, ht) {var $text = [];var _write = function(text) {$text.push((typeof text == "number")?text:(text||""));};_write('\r\n\n<div ');_write(o.Elem('Root'));_write('  class=\"share-section\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('\n<div class=\"share-text\">Share this ');_write(ht.shareWhat);_write(':</div>\n<div class=\"share-buttons\">\n<a href=\"javascript:');_write(ht.fncBtvShare);_write('\" title=\"Share with your BuddyTV Friends\"><img src=\"/new-html/images/share_btv.png\"></a>\n<a href=\"javascript:');_write(ht.fncFacebookShare);_write('\" title=\"Share on Facebook\"><img src=\"/new-html/images/share_fb.png\"></a>\n<a href=\"javascript:');_write(ht.fncTwitterShare);_write('\" title=\"Share on Twitter\"><img src=\"/new-html/images/share_twitter.png\"></a>\n<a href=\"javascript:');_write(ht.fncEmailShare);_write('\" title=\"Email a Friend\"><img src=\"/new-html/images/share_email.png\"></a>\n</div>\n<div ');_write(o.Elem('moreShareOptions'));_write('  class=\"share-more\" style=\"');_write(o.Style());_write('\">');_write(o.InnerHTML());_write('\n<a class=\"a2a_dd\" href=\"http://www.addtoany.com/share_save\">More</a>\n<script type=\"text/javascript\">a2a_linkname = document.title; a2a_linkurl = location.href;</script>\n<script type=\"text/javascript\" src=\"http://static.addtoany.com/menu/page.js\"></script>\n</div>\n<div style=\"clear:both\"></div>\n</div>\n');;return($text.join(""));};
new (function(d, ui) {
var oThis = Btv.Lang.Extend(this, Btv.Cst.BaseTemplate, [$data, true]);
var htUI = ui;
var $el = oThis.El;

    var oElMan = oThis.ElMan();
    var iContentTypeId = 0;
    var iContentId, oContentData, sShareWhat;
    var sGATrackEventCategory = 'BTV Share';
    var oBtvShareFriends = new Btv.ShareFriends();
    var oBtvShareEmail = new Btv.ShareEmail();
    var oBtvShareTwitter = new Btv.ShareTwitter();
    var blnCheckForDisplayTweetBox = false;

    function BtvShare() {
        oBtvShareFriends.Initialize(iContentTypeId, iContentId, oContentData);
        TrackEvent('BTV Friend Share');
    }

    function EmailShare() {
        oBtvShareEmail.Init(iContentTypeId, iContentId, oContentData);
        TrackEvent('Email');
    }

    function FacebookShare() {
        var url = window.location.href;
        window.open($F('http://www.facebook.com/sharer.php?u={0}&t={1}', encodeURIComponent(url), encodeURIComponent(oContentData.Title)), 'sharer', 'toolbar=0, status=0, width=626, height=436');
        TrackEvent('Facebook');
    }

    function TwitterShare() {
        oBtvShareTwitter.Init(iContentTypeId, oContentData.Title, window.location.href);
        TrackEvent('Twitter');
    }

    function TrackEvent(sAction) {
        if (iContentTypeId > 0) {
            Btv.GoogleAnalytics.TrackEvent(sGATrackEventCategory, sAction, window.location, iContentTypeId);
        }
        else {
            Btv.GoogleAnalytics.TrackEvent(sGATrackEventCategory, sAction, window.location);
        }        
    }

    function InitElements(){
        if(d.contentTypeId && d.contentId && d.contentData && d.shareWhat){
            iContentTypeId = d.contentTypeId;
            iContentId = d.contentId;
            oContentData = d.contentData;
            sShareWhat = d.shareWhat

            if (d.checkForDisplayTweetBox) {
                blnCheckForDisplayTweetBox = true;
            }
            

            if (d.miniVersion) {
                oElMan.Attribute('Root', 'class', 'share-section-mini');
                oElMan.Style('moreShareOptions', 'display', 'none');
            }
        }
        else {
            oElMan.Style('Root', 'display', 'none');
        }

        var htQuerystringParams = Btv.Url.GetQuerystringParams(window.location.href);

        if (blnCheckForDisplayTweetBox && htQuerystringParams['OpTwtBx']) {
            TwitterShare();
        }
    }

    function Render() {
        InitElements();
    
        return (htUI.Main(oThis, { fncBtvShare: $F('{0}();', $OG(BtvShare))
        , fncEmailShare: $F('{0}();', $OG(EmailShare))
        , fncFacebookShare: $F('{0}();', $OG(FacebookShare))
        , fncTwitterShare: $F('{0}();', $OG(TwitterShare))
        , shareWhat: sShareWhat
        }));
    }

    oThis.DeclareVirtualMethods({
        Render: Render
    });
})($data, {Main:Main});
}return $text.join("");}}]);
