//OMNITURE STUFF
function trim(objText)
{
  objText= objText.replace(/^\s+|\s+$/g,""); 
  return objText;
}
//get the path name and convert it to lower case
var theURLPath = window.location.pathname.toLowerCase();
//clean up the path by replacing //+ with /
theURLPath = theURLPath.replace(/\/(\/)*/g, "/");
theURLPath = trim(theURLPath);
//generate the random number
var rnum=Math.floor(99999999 * Math.random());

//split the folders into an array
sectLevel=theURLPath.split("/"); 
//for omniture
var firstFolderSect="";
var hierSections = "ttv";
//check if this is root folder or domain only
if (sectLevel.length > 1 && sectLevel[1] != "" && sectLevel[1] != " " && sectLevel[1].lastIndexOf('.') == -1)
{
	//not root, assign first folder
	firstFolderSect = sectLevel[1];
	//hierarchy variable, default it to first folder
	hierSections = hierSections + "," + sectLevel[1];
	//loop through the directory path from url
	for (var isect2 = 2; isect2 < sectLevel.length; isect2 ++)    
	{
		//if it is not empty and not a file then add it to the list
		if (sectLevel[isect2] != "" && sectLevel[isect2] != " " &&  sectLevel[isect2].lastIndexOf('.') == -1)
		{
			hierSections = hierSections + "," + sectLevel[isect2]        
		}
	}
}
else
{
	//is root, set it to static name
	firstFolderSect = "root";
}


//Below are percentage for 24/7 ad server per section and position, 0-100 range
lpathname = document.location.pathname.toLowerCase();

//***************************************
//DO NOT EDIT BELOW
//***************************************
//advertising.com functions

function setCookie24(NameOfCookie, value, expirehours) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expirehours * 3600 * 1000));
document.cookie = NameOfCookie + "=" + escape(value) + ((expirehours == null) ? "" : "; expires=" + ExpireDate.toGMTString()) + "; path=/;" ;
}
 
function getCookie24(name) {
 var beg = document.cookie.indexOf(name+"=");
 var len = beg+name.length+1;
 var end = document.cookie.indexOf(";",len);
 if (end == -1){
  end = document.cookie.length;
 }
 return unescape(document.cookie.substring(len,end));
}
var ACE_AR = "";
function openWin24(site){ 
}
function openWin120(site){
}
function openWin300(site){
}
 
//end advertising.com functions

function getCookie(name)
{
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1)
  {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  }
  else begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1) end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path, domain, secure)
{
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
function setCookieNoescape( name, value, expires, path, domain, secure ) { 

  var today = new Date(); 
  today.setTime( today.getTime() ); 
  
  // expires in days
  if ( expires ) { 
    expires = expires * 24 * 60 * 60 * 1000; 
  } 
  var expires_date = new Date( today.getTime() + (expires) ); 
  
  document.cookie = name + "=" + value + 
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
    ( ( path ) ? ";path=" + path : "" ) + 
    ( ( domain ) ? ";domain=" + domain : "" ) + 
    ( ( secure ) ? ";secure" : "" ); 
} 
function fixDate(date) 
{
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0) date.setTime(date.getTime() - skew);
}

//not used
function incAdView(pos)
{	
}

function saveIt(theSize)
{
	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
	setCookie("fontSize", theSize, now, "/");	
}

function setSize(theSize)
{
	stObj = (document.getElementById) ? document.getElementById('articlecontent') : document.all('articlecontent');
	stObj.style.fontSize = curSize + 'pt';
}

var defaultSize = 10;
var curSize=getCookie("fontSize");
if (curSize == null || curSize == "") curSize = 10;
curSize = parseInt(curSize);
var maxSize = 12;
var minSize = 8;
function changeSize(whatToDo)
{
	(whatToDo == "2")? curSize = defaultSize : ((whatToDo == "1")? curSize -= 1 : curSize += 1);
	if (curSize < minSize) curSize = minSize;
	if (curSize > maxSize) curSize = maxSize;
	setSize(curSize);
	saveIt(curSize);
}

function openNote(theURL){ 
 dimension="toolbar=no,status=no,scrollbars=yes,resizable=yes,width=350,height=320, top=0, left=0"; 
 win = window.open(theURL,'footnote',dimension); 
 win.focus();
} 

var TTV = {};
//utility functions
TTV.util = {	
	//javascript to parse a query string
	getQueryValue: function (variable) {
	  var query = window.location.search.substring(1);
	  var vars = query.split("&");
	  for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
		  return pair[1];
		}
	  } 
	  return ""
	},
	
	//javascript to parse a hash string, value pairs are broken up by ,
	getHashValue: function (variable) {
	  var hash = window.location.hash.substring(1);
	  var vars = hash.split(",");
	  for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
		  return pair[1];
		}
	  } 
	  return "";
	}, 
	
	highlightClNav: function(box) {			
		if (box != "")
		{
			alkobj = document.getElementById(box);
			if (alkobj != null) alkobj.className="highlight";
		}
	},
	
	highlightAboutNav: function() {
		var aboutrow = "";
	
		if( theURLPath.indexOf("/about/index.html") != -1) aboutrow="a_about";
		else if( theURLPath.indexOf("/about/zipcode") != -1) aboutrow="a_gettv";
		else if( theURLPath.indexOf("/about/faq") != -1) aboutrow="a_faq";		
		else if( theURLPath.indexOf("/about/international/") != -1) aboutrow="a_id";
		else if( theURLPath.indexOf("/press/") != -1) aboutrow="a_press";
		else if( theURLPath.indexOf("/contact/") != -1) aboutrow="a_contact";	
		else if( theURLPath.indexOf("/parental_controls/") != -1) aboutrow="a_parental";	
		
		if (aboutrow != "")
		{
			alkobj = document.getElementById(aboutrow);
			if (alkobj != null) alkobj.className="anavtexton";
		}
	},
	
	highlightMainNav: function() {
		var mainrow = "";
		if( document.domain.indexOf("blog.trutv") != -1) mainrow="mainNav-discuss";
		else if( theURLPath.indexOf("/library/") != -1 || document.domain.indexOf("boards.library") != -1 || document.domain.indexOf("boards.crimelibrary") != -1) mainrow="mainNav-newsletters";
		else if( theURLPath === "/" || theURLPath === "/index.html" ) { if(document.domain.indexOf("boards.") == -1) mainrow="mainNav-home"; }
		else if( theURLPath.indexOf("/shows/") != -1) mainrow="mainNav-shows";
		else if( theURLPath.indexOf("/video/") != -1) mainrow="mainNav-videos";		
		else if( theURLPath.indexOf("/schedule/") != -1) mainrow="mainNav-schedule";					
		
		if (mainrow != "")
		{
			var alkobj = document.getElementById(mainrow);												
			if (alkobj != null) {
					alkobj.className="current";					
			}
		}
		
	},
	openWindow: function (theURL,winName,features){
	  var theWindow = window.open(theURL,winName,features);
	  theWindow.focus();
	},
	openGallery: function (theURL){
	  this.openWindow(theURL,"gallery","width=800,height=705,resizable=yes,top=10,left=10,scrollbars=yes");
	},
	subNavCurrent: function(whichOne) {
		if (whichOne != "")
		{
			var alkobj = document.getElementById(whichOne);												
			if (alkobj != null) {
				if (whichOne == "showNav-main") alkobj.className="first current";
				else alkobj.className="current";					
			}
		}
	},

	highlightBGNav: function() {
		var mainrow = "";
	
		if(  unescape(theURLPath) === "/shows/black_gold/" || unescape(theURLPath) === "/shows/black_gold/index.html") mainrow="bgmain";
		else if( theURLPath.indexOf("about") != -1) mainrow="bgabout";
		else if( theURLPath.indexOf("episodes") != -1) mainrow="bgepisodes";		
		else if( theURLPath.indexOf("gallery") != -1) mainrow="bgphotos";
		else if( theURLPath.indexOf("video") != -1) mainrow="bgvideo";
		else if( theURLPath.indexOf("bio") != -1) mainrow="bgbios";
		else if( theURLPath.indexOf("oil") != -1) mainrow="bgoil";
		
		TTV.util.subNavCurrent(mainrow);		
	},	
	createBookmark: function() {
		var title = "truTV.com: Not Reality. Actuality"; 
		var url = "http://www.trutv.com";
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title); }	
	},

	highlightWWVVNav: function() {
		var mainrow = "";
	
		if(  unescape(theURLPath) === "/shows/worlds_wildest/vacation_videos/" || theURLPath.indexOf("worlds_wildest/vacation_videos/index.html") != -1) mainrow="showNav-main";
		else if( theURLPath.indexOf("about") != -1) mainrow="wwvvabout";
		else if( theURLPath.indexOf("episodes") != -1) mainrow="wwvvepisodes";
		else if( theURLPath.indexOf("flip_flop_and_fly_gallery.html") != -1) mainrow="wwvvphotos";
		
		TTV.util.subNavCurrent(mainrow);				
	},

	highlightShowNav:function(){
		//this function will check auto highlight the appropriate show nav based on url
		//the home page needs to have /index.html in the link.
		var matchPath = theURLPath.substring(theURLPath.length, theURLPath.indexOf("/shows"));
		var theTempLink = "";
		//incase we need to match a group of files inside a subfolder
		var findingFolders=matchPath.split("/"); 
		if (findingFolders.length === 5) matchPath = findingFolders[3];
		//search the box of links to see which one math		
		$("#showNav-c #showNav li").each(function(){												  
			theTempLink = $(this).find("a").attr('href').toLowerCase();
			if (theTempLink.indexOf(matchPath) >= 0)
			{
				$(this).addClass("current");
				return false;
			}
		});	
		//function repeated for new design
		$("#show-nav-wrap #show-nav li").each(function(){												  
			theTempLink = $(this).find("a").attr('href').toLowerCase();
			if (theTempLink.indexOf(matchPath) >= 0)
			{
				$(this).addClass("current");
				return false;
			}
		});	
	},
	writeBookMark: function() {
		if (window.external) {
			document.write("<li class=\"first\" id=\"conBook\"><a href=\"javascript:TTV.util.createBookmark();\" title=\"Bookmark This Page\">Bookmark This Page &raquo;</a></li>"); 
		} else  if (window.sidebar) {
			document.write("<li class=\"first\" id=\"conBook\"><a href=\"javascript:TTV.util.createBookmark();\" title=\"Bookmark This Page\">Bookmark This Page &raquo;</a></li>");
		}
	},
	pickFriends: function(howmany){	
		$('#ttv-friend-rand').shuffle(); //shuffle the list			
		$('.ttv-friends #loader').hide(); //hide the loader
		//loop to find out how many more we need to display
		for (var i = 0; i<(howmany-$('#ttv-friend-perm .ttv-friend').size()); i++){		
			//add picked class
			$('#ttv-friend-rand .ttv-friend').eq(i).addClass('picked').show();
		}
		//add picked class to perm list if any
		$('#ttv-friend-perm .ttv-friend').addClass('picked').show();
		//remove bottom border from the last picked item
		$('.ttv-friends .picked').filter(':last').addClass('last');	
	},		
	boxVidLogic: function(feedid, playlist){		
        var dompath = ".vidlist-wrap .vlitem";
		if (playlist) dompath = playlist+" "+dompath;		
        var flasharea = "vpflash";
        var found = false;
        var blockindex = 0;
        var nextclip = 0;
        var bvpid = "";
        
        //search the box of links to see which one matches	
        $(dompath).each(function(){		
          if (this.innerHTML.indexOf(theURLPath.substring(theURLPath.length, theURLPath.lastIndexOf("/",theURLPath.length))) >= 0) {		  	
            //set active class, copy description and show correct show block
            $(this).addClass("active");	
            $("#vpdesc .vdesc").html($(this).find("div.vdesc").html());	
            $("#vidshow .box-mid").html($("#"+$(this).find(".showblock").html()).html());
            //retrieve the pid
            bvpid = $(this).find(".t5-pid").html();
            return false;			
          }
          blockindex++;
        });	
        
        //if last clip then next clip is the first one
        if (blockindex === $(dompath).size()-1) nextclip = 0;
        else nextclip = blockindex+1;
        
        //get the href value of the next clip
        nextclip = $(dompath + ":eq(" +nextclip+") a").attr('href');
            
		var xCookie = "TTVcookieWMpromo";
		//Set cookie to expire in 24 hrs
		var expCookie = new Date();
		fixDate(expCookie);
		expCookie.setTime(expCookie.getTime() + 24 * 60 * 60 * 1000);
		if ((theURLPath.indexOf("/top5/2009/heroic_moments/") >=0)||(theURLPath.indexOf("/top5/2009/motorcycles/") >=0)||(theURLPath.indexOf("/top5/2009/sfb/") >=0)||(theURLPath.indexOf("/top5/2009/black_gold/") >=0)||(theURLPath.indexOf("/top5/2009/big_rigs/") >=0)||(theURLPath.indexOf("/top5/2009/speeders_moments/") >=0)||(theURLPath.indexOf("/top5/2009/parking_jobs/") >=0))
		{
			var countCookie;
			if(getCookie(xCookie)!=null){
				countCookie = getCookie(xCookie);
				countCookie = parseInt(countCookie);
				countCookie++;
				setCookie(xCookie, countCookie, expCookie, "/");
			} else {
				setCookie(xCookie, 1, expCookie, "/");
				countCookie = 1;
			}
			if((countCookie == 2)||((countCookie - 2)%3 == 0)){
				var so = new SWFObject("/graphics/top5/preroll-topfive-new.swf", "flashvid", "480", "377", "7", "#000000");
				so.addVariable("preRollURL", "http://www.trutv.com/includes/banners/de/top5/preroll.ad");
			} else {
				var so = new SWFObject("/graphics/top5/topFive.swf", "flashvid", "480", "377", "7", "#000000");
			}
		} else {
			var so = new SWFObject("/graphics/top5/topFive.swf", "flashvid", "480", "377", "7", "#000000");
		}
		so.addParam("wmode", "transparent");
	    so.addVariable("currentURL", theURLPath);
	    so.addVariable("feedID", feedid);
	    so.addVariable("PID", bvpid);
	    so.addVariable("nextClipURL", nextclip);
		so.addParam("allowFullScreen", "true"); 
		so.write(flasharea);	
		
		var tempemb = 'currentURL='+theURLPath+'&amp;feedID='+feedid+'&amp;PID='+bvpid+'&amp;nextClipURL='+nextclip;
		tempemb = '<object width="380" height="300"><param name="movie" value="http://i.cdn.turner.com/trutv/trutv.com/graphics/top5/shareTopFive.swf"></param><param name="flashvars" value="'+tempemb+'"><param name="wmode" value="transparent"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://i.cdn.turner.com/trutv/trutv.com/graphics/top5/shareTopFive.swf" type="application/x-shockwave-flash" wmode="transparent" width="380" height="300" allowscriptaccess="always" allowfullscreen="true" flashvars="'+tempemb+'"></embed></object>';
		
		$('#embed_code').attr("value", tempemb);
		
		if ($("div#embcode").is(":hidden")) {
        	$("div#embcode").slideDown("fast");
		}
	},
	//email write-out functions to avoid spammer pick-up
	writeEmail: function(name,domain){
		var at = '@';
		document.write(name + at + domain);
	},
	writeEmailLink: function(name,domain,text){
		var at = '@';
		var em = name + at + domain;
		if(text != '')
			document.write('<a href="mailto:' + em + '">' + text + '</a>');
		else
			document.write('<a href="mailto:' + em + '">' + em + '</a>');
	},
	updateMiddleAd: function(path){		
	   $("#vsync-300250").html('<iframe src="' + path + '" id="companion300x250" width="300" height="250" marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no></iframe>');
	}
};

// dropdownmenu script for episode guides
function jump(form) {var myindex=form.menu.selectedIndex
if(form.menu.options[myindex].value != "0") {window.open(form.menu.options
[myindex].value, target="_self");
}
}

var theWindow ="";
function openWindow(theURL,winName,features) 
{
  theWindow = window.open(theURL,winName,features);
  theWindow.focus();
}
function openNewWindow(clipID) 
{
  theURL = "/video/emailfriend/emailform.html?id=" + clipID
  theWindow = window.open(theURL,"efriend","width=340,height=350,resizable=no,top=250,left=250,scrollbars=no");
  if (theWindow == null)
  {
  	alert("please disable popup blockers");
  }
  else theWindow.focus();
}
function sendBlogVid(clipID,blogName){
  theURL = "http://www.trutv.com/blog/emailfriend/emailform.html?pid=" + clipID;
  if(blogName != null || blogName != "") theURL = theURL + "&blog=" + blogName;
  theWindow = window.open(theURL,"efriend","width=340,height=350,resizable=no,top=250,left=250,scrollbars=no");
  if(theWindow == null){
  	alert("please disable popup blockers");
  } else theWindow.focus();
}

//get all the links within a div block by id name and change all targets to _blank
function linksNewWin(theblock){
	var block = document.getElementById(theblock);
	if(block){
		var blocklinks = block.getElementsByTagName('a');
		for(var i=0; i<blocklinks.length; i++){
			var temphref = blocklinks[i].href;
			if(temphref.indexOf("http://") != -1 && temphref.indexOf("trutv.com") == -1)
	 			blocklinks[i].target = "_blank";
		}
	}
}

/* 247 */
_version=11
// here are OAScentral site, page, and random number variables
var OAS='http://oascentral.trutv.com/RealMedia/ads/';
if (typeof thisPageName == "undefined") var sitepage = 'www.trutv.com' + window.location.pathname;
else var sitepage = 'www.trutv.com' + thisPageName;
var RN = new String (Math.random());
var RNS = RN.substring (2, 11);

// here is the ad insertion function
function DisplayAds (position, width, height)
{
	var OASpage= sitepage + '/1' + RNS + '@' + position;
	
	if (_version < 11) {
	document.write ('<A HREF="' + OAS + 'click_nx.ads/'+ OASpage + '" TARGET="_top" ><IMG SRC="' + OAS + 'adstream_nx.ads/' + OASpage + '" BORDER="0" WIDTH="' + width + '" HEIGHT="' + height + '"></' +'a>');
	} else {
	document.write ('<SCRI' + 'PT LANGUAGE="JavaScript1.1" SRC="' + OAS +
	'adstream_jx.ads/' + OASpage + '">');
	document.write ('\<\/SCR' + 'IPT\>');
	}
}

// tenm geo targetting
var cnnDEadDEonCookie=false;var alreadySwappedDETargetImage=false;var gdynDocDomain=gdyn_getTld(location.hostname);function gdyn_getTld(hostname){var data=hostname.split(".");if(data.length>=2){return(data[data.length-2]+"."+data[data.length-1]);}return(null);}function gdyn_readCookie(name){if(document.cookie==''){return false;}else{var firstChar,lastChar;var theBigCookie=document.cookie;firstChar=theBigCookie.indexOf(name);var NN2Hack=firstChar+name.length;if((firstChar!=-1)&&(theBigCookie.charAt(NN2Hack)=='=')){firstChar+=name.length+1;lastChar=theBigCookie.indexOf(';',firstChar);if(lastChar==-1)lastChar=theBigCookie.length;return unescape(theBigCookie.substring(firstChar,lastChar));}else{return false;}}}function gdyn_getDEAdHeadCookie(imageRef){if(typeof(gdyn_readCookie)!="undefined"){cnnDEadDEonCookie=gdyn_readCookie('adDEon');}var newSrc="http://gdyn."+gdyn_getTld(location.hostname)+"/1.1/1.gif?"+new Date().getTime();if(!alreadySwappedDETargetImage&&!cnnDEadDEonCookie){imageRef.src=newSrc;alreadySwappedDETargetImage=true;}}

var rss_ie5=document.all && !window.opera;
var rss_ns6=document.getElementById	;

/*  rss fly out menu*/
//write out the style
document.write ('<style type="text/css">');
document.write ('#popitmenu{position: absolute;background-color: white;border:1px solid black;font: normal 12px Verdana;line-height: 18px;z-index: 100; display: none;padding:3px;font-size:10px;}');
document.write ('#popitmenu textarea{font-size:11px;}');
document.write ('#popitmenu img{ margin-bottom:5px; padding-left:5px;}');
document.write ('.rssgrplinks a{padding-right:10px;}');
document.write ('#rssindex .headline{font-size:13px;}');
document.write ('</style>');

/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var defaultWidth = "250"
var defaultHeight = "196"
var defaultMenuWidth=defaultWidth + "px" //set default menu width.


////No need to edit beyond here

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=writeButtons(which);
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=defaultWidth
menuobj.contentheight=defaultHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
eventX += 3;
eventY += 3;
//need to double check on safari
//scroll = different location
//alert(mouseX(e));
//alert(mouseY(e));
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.display="block"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while(b.parentNode) if ((b = b.parentNode) == a) return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.display="none"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

//disable hide onclick
//if (ie5||ns6) document.onclick=hidemenu;

function writeButtons(theFeed)
{
	var thistemp = "";
	thistemp += "<div><center><b>SUBSCRIBE</b></center></div>";
	thistemp += "<div>Copy the URL below and paste it into your RSS reader:</div>";
	thistemp += '<div id="rsstextblock" onClick="highlightText(\'rsstextblock\');">' + theFeed +'</div>';
	thistemp += '<div>or choose one of these readers:</div>';
	thistemp += '<a href="http://add.my.yahoo.com/rss?url=' + theFeed + '" target="_blank"><img src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif" border="0"></a>';
	thistemp += '<a href="http://client.pluck.com/pluckit/prompt.aspx?t=courttv.com&a=' + theFeed + '" target="_blank"><img src="http://www.pluck.com/images/rss-pluck.gif" border="0"></a>';
	thistemp += '<br />';
	thistemp += '<a href="http://fusion.google.com/add?feedurl=' + theFeed + '" target="_blank"><img src="http://buttons.googlesyndication.com/fusion/add.gif" border="0"></a>';
	thistemp += '<a href="http://www.bloglines.com/sub/' + theFeed + '" target="_blank"><img src="http://www.bloglines.com/images/sub_modern5.gif" border="0"></a>';
	thistemp += '<br />';
	thistemp += '<a href="http://feeds.my.aol.com/add.jsp?url=' + theFeed + '" target="_blank"><img src="http://o.aolcdn.com/myfeeds/vis/myaol_cta1.gif" border="0"></a>';
	thistemp += '<a href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=' + theFeed + '" target="_blank"><img src="http://www.newsgator.com/images/ngsub1.gif" border="0"></a>';	
	return thistemp;
}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

//highlight the text within a div, used for the rss layer
function highlightText(theid){
var obj = document.getElementById(theid);

if (obj){
if (document.selection) {
	var r1 = document.body.createTextRange();
	r1.moveToElementText(obj);
	r1.setEndPoint("EndToEnd", r1);
	r1.moveStart('character',0);
	r1.moveEnd('character',1);
	r1.select();
} else {
	s = window.getSelection();
	var r1 = document.createRange();
	r1.setStartBefore(obj);
	r1.setEndAfter(obj) ;
	s.addRange(r1);
}
}
}