/*
 * default theme
 * Copyright(c) 2008, BET.
 * 
 * This code is licensed under BSD license. Use it as you wish, 
 * but keep this copyright intact.
 */


function ceilingDivision(total,divisor)
{if(total%divisor==0)
{return total/divisor;}
else
{return(total+(divisor-total%divisor))/divisor;}}
function applyHeight(heightVal,table,row,perRow)
{var i=0;while(i<perRow)
{table.eq(row*perRow+i).height(heightVal);i++;}}
jQuery(document).ready(function(){jQuery('#primaryNavigation .navMenu li:nth-child(2)').addClass('selected');PC.makeBlockAnchors('dl.barkerList dl.barker','mouseover','overlay');var table=jQuery('dl.medium4PR_text3PR.barkerList .Group2 dl.barker');var num_of_rows=ceilingDivision(table.length,3);var row_height=0;var tableIndex=0;var rowIndex=0;while(tableIndex<table.length)
{if(table.eq(tableIndex).height()>row_height)
{row_height=table.eq(tableIndex).height();}
if(rowIndex+1==num_of_rows)
{table.eq(tableIndex).css('border-bottom','none');}
if(tableIndex+1==table.length||tableIndex%3==2)
{applyHeight(row_height,table,rowIndex,3);rowIndex++;row_height=0;}
tableIndex++;}
var itunesHtml='<img class="sponsorCorner" src="/includes/theme/default_v2/sub/channel-music/img/itunes_available.jpg" />'
jQuery('.qtrColLeft qtrCol_medium120_textLinks .firstCol .itunes').append(itunesHtml);jQuery('.medium120_4PR_Icon dd.itunes').append('<img class="itunesLogo" src="/includes/theme/default_v2/sub/channel-music/img/itunes_available.jpg" />');VideoBarkerListHeightAdjuster('.primaryContent .medium120_4PR_Icon .Medium120x70','itunes',4);jQuery('.medium120_4PR_Icon dd.itunes').append('<IMG SRC="http://ad.doubleclick.net/ad/N4873.BET.com/B4027986.13;sz=1x1;ord='+getTimeStamp()+'?" BORDER=0 WIDTH=1 HEIGHT=1 ALT="Click Here" />');addToQueryString('.medium120_4PR_Icon dd.itunes a','cid=itunesF');});function getTimeStamp(){var d=new Date();return d.getTime();}
function addToQueryString(selector,attributes){jQuery.each(jQuery(selector),function(){link=jQuery(this).attr('href');if(link.indexOf('?')!=-1){link=link+'&'+attributes;}
else{link=link+'?'+attributes;}
jQuery(this).attr('href',link);});}
function VideoBarkerListHeightAdjusterHelper(targetElement,fromIndex,toIndex,tallestInRow){while(fromIndex<toIndex){fromIndex++;jQuery(targetElement+':nth-child('+fromIndex+')').height(tallestInRow);}}
function VideoBarkerListHeightAdjuster(targetElement,withSponsor,numInRow)
{if(withSponsor=='itunes'){var offsetHeight=18;var sizeOfVideoList=jQuery(targetElement).length;var numberOfVideoListRows=ceilingDivision(12,4);var index=0;var tallestInRow=0;var currentElement;var currentRow=0;var currentHeight=0;while(index<sizeOfVideoList){index++;currentElement=jQuery(targetElement+':nth-child('+index+')');currentHeight=jQuery(currentElement).height();if(jQuery(targetElement+':nth-child('+index+') dd').hasClass('itunes')){currentHeight=currentHeight+offsetHeight;}
if(currentHeight>tallestInRow){tallestInRow=currentHeight;}
if(index%numInRow==0||index==sizeOfVideoList){VideoBarkerListHeightAdjusterHelper(targetElement,currentRow*numInRow,index,tallestInRow);tallestInRow=0;currentRow++;}}}}

