function tp_openWin(u,title,options)
  {
  var win;
  var o=""
  if (tp_openWin.arguments[2]){o=options;}
  var t = "linkwin"
  if (tp_openWin.arguments[1]){t=title;}
  win=window.open(u,t,o);
  win.focus()
 }		
 
function tp_setCookie (name,value,domain,expires) {
	var doc = document;
	//try{if (top != self){doc=top.document}} catch(e){}	
	//try{if (top != self){doc=doc.parent}} catch(e){}	
	doc.cookie = name + "=" + value +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((domain) ? "; domain=" + domain : "") +
		"; path=/";

	try{if (top != self){doc=top.document}
		doc.cookie = name + "=" + value +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((domain) ? "; domain=" + domain : "") +
			"; path=/";
		} catch(e){}	
	}
	
function tp_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 tp_trim(s){
		if(s.length < 1){
		return"";
		}
		s = RTrim(s);
		s = LTrim(s);
		if(s==""){
		return "";
		}
		else{
		return s;
		}
		} //End Function

		function tp_rTrim(VALUE){
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0){
		return"";
		}
		var iTemp = v_length -1;

		while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
		}
		iTemp = iTemp-1;

		} //End While
		return strTemp;

		} //End Function

		function tp_lTrim(VALUE){
		var w_space = String.fromCharCode(32);
		if(v_length < 1){
		return"";
		}
		var v_length = VALUE.length;
		var strTemp = "";

		var iTemp = 0;

		while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
		}
		iTemp = iTemp + 1;
		} //End While
		return strTemp;
		} //End Function



function tp_removeCookie(name){
	var date = new Date();
	date.setTime(date.getTime()+(-1*24*60*60*1000));

	var sDomain = document.domain;
	var sDomain2 = '';
	var aDomain = sDomain.split('.');
	if (aDomain.length > 0) {
		sDomain2 = aDomain[aDomain.length-2] + '.' + aDomain[aDomain.length-1];
	} else {
		sDomain2 = sDomain;
	}

if (IsIE==true) { 
				tp_setCookie(name," ","",date);
				tp_setCookie(name," ",sDomain2,date);
	}		
//else if (IsSafari()) document.cookie =  name+"=; expires=Tue, 1 Jan 1980 00:00:00 UTC; path=/";
//    else {tp_setCookie(name," ",document.domain,date);}
  else {
		document.cookie =  name+"=; expires=Tue, 1 Jan 1980 00:00:00 UTC; path=/";
		document.cookie =  name+"=; expires=Tue, 1 Jan 1980 00:00:00 UTC; domain=" + sDomain2 + "; path=/";
	}
}	

function IsSafari()
{
  appVer = new String(navigator.appVersion);
  appVer = appVer.toLowerCase();
  if (instr(0,appVer,'safari')) {return true;}
  return false;
}

function IsIE()
{
if (navigator.userAgent.indexOf('MSIE')>-1)
{
if (navigator.userAgent.indexOf("Opera") == (-1))
{
return true;
}
}
return false;
}
function tp_PosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function tp_fixObjOnScroll(o)
{try{
	var pv=$(o);
	if(pv!=null)
	{
		var s;

		if (self.pageYOffset){s = self.pageYOffset;}
		else if (document.documentElement && document.documentElement.scrollTop) {	s = document.documentElement.scrollTop; }
		else if (document.body) {	s = document.body.scrollTop; }

		if (is_ie == true)
			{
			if (s > origPos){pv.style.top= s + 20;} 
			else if (s <= origPos){pv.style.top= origPos;} 
			}
		else
			{
			if (s > origPos){if (isSet==false){pv.style.top = 20; isSet=true; }pv.style.position="fixed";}
			else{isSet=false;pv.style.top = origPos;pv.style.position="absolute";}
			}
	}
	}catch(e){}	
 }
 	function tp_replace(expression,find,replacement){
			var e = new String(expression)
			rExp = eval('/' + find + '/gi');
			var n = e.replace(rExp,replacement)
			return n;
		}
		
	function tp_left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function tp_right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
    }
		
//*****************************************************************************
// JScript Code to launch the PodCastPlayer.
//*****************************************************************************
//
//*****************************************************************************
function GetPlayerAXCode (playerWidth, playerHeight, rssFileUrl, configFileUrl)
{
	flashCode = '<center>';
	flashCode += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'  width='"+playerWidth+"' height='"+playerHeight+"' id='player' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'>"
	flashCode += "<param name='movie' value='/reader/podplayer/mp3player.swf?file="+rssFileUrl+"&config="+configFileUrl+"'/>"
//	flashCode += "<param name='movie' value='mp3player.swf?config="+configFileUrl+"&file="+rssFileUrl+"'/>"
	flashCode += "<param name='allowScriptAccess' value='always'>"
//	flashCode += "<embed src='mp3player.swf?file="+rssFileUrl+"&config="+configFileUrl+"' allowScriptAccess='always' width='"+playerWidth+"' height='"+playerHeight+"' name='player'"
	flashCode += "<embed src='/reader/podplayer/mp3player.swf?config="+configFileUrl+"&file="+rssFileUrl+"' allowScriptAccess='always' width='"+playerWidth+"' height='"+playerHeight+"' name='podCastPlayer'"
  flashCode += "type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
  flashCode += "</object>"
	flashCode += '</center>';
  return flashCode;
}


//*****************************************************************************
//
//*****************************************************************************
function GetPlayerHTML(width,height,fssFeed,controlFile)
{
   var rssUrl 	  =  encodeURI(fssFeed);
   var controlUrl =  encodeURI(controlFile); 
   var html = this.GetPlayerAXCode(width,height,rssUrl,controlUrl);
   return html;
}


//*****************************************************************************
//
//*****************************************************************************
function EmitPlayer(streamName, winWidth, winHeight)
{
  var podCastWin=window.open('','PodCastWin','width='+winWidth+',height='+winHeight);
  if (podCastWin) {
    podCastWin.document.write('<html><head><title>PodCast Player</title>');
    podCastWin.document.write('<link rel="stylesheet" href="style.css">');
    podCastWin.document.write('</head><body>');
    podCastWin.document.write(GetPlayerHTML(winWidth-4,winHeight-20,streamName,'/reader/podplayer/config.xml'));
    podCastWin.document.write('</body></html>');
    podCastWin.document.close();
    }
}
