
function isArray(v)
{return v&&typeof v.pop=="function";}
function urlEncode(o)
{if(!o)
{return"";}
var buf=[];for(var key in o)
{var ov=o[key],k=encodeURIComponent(key);var type=typeof ov;if(type=="undefined")
{buf.push(k,"=&")}
else
{if(type!="function"&&type!="object")
{buf.push(k,"=",encodeURIComponent(ov),"&")}
else
{if(isArray(ov))
{if(ov.length)
{for(var i=0,len=ov.length;i<len;i++)
{buf.push(k,"=",encodeURIComponent(ov[i]===undefined?"":ov[i]),"&")}}
else
{buf.push(k,"=&")}}}}}
buf.pop();return buf.join("");}
function getIcon(basePath,fileUrl,mediaType,iconUrl)
{return(mediaType==1?fileUrl:(iconUrl&&iconUrl.length>0?iconUrl:(mediaType==1?fileUrl:basePath+"/common/playbutton_60x60.png")));}
function getEntryHtml(videoId,videoWidth,videoHeight,imgWidth,imgHeight,fileUrl,basePath,mediaType,imgAttributes,isIcon,iconUrl,updateProgress,allowFullScreen,styleParams,playerBgColor)
{var html=null;if(isIcon)
{fileUrl=getIcon(basePath,fileUrl,mediaType,iconUrl);mediaType=1;}
if(mediaType==2)
{var flashvars="file="+fileUrl;flashvars=flashvars+"&width="+videoWidth+"&height="+videoHeight;var url=basePath+"/common/mediaplayer1.swf?"+flashvars;var fileParam=null;html=getPlayerHtml(videoId,videoWidth,videoHeight,url,fileParam,isIcon,flashvars,null,updateProgress,allowFullScreen,styleParams,playerBgColor);}
else if(mediaType==4)
{var url=fileUrl;var fileParam=null;html=getPlayerHtml(videoId,videoWidth,videoHeight,url,fileParam,isIcon,"",null,updateProgress,allowFullScreen,styleParams,playerBgColor);}
else
{html="<img border='0' src='"+fileUrl+"'"+
(imgWidth?" width='"+imgWidth+"'":"")+
(imgHeight?" height='"+imgHeight+"'":"")+" "+
(imgAttributes?imgAttributes:"")+"></img>";}
return html;}
function getPlayerHtml(idObject,width,height,url,fileParam,isIcon,flashvars,appendFileUrl,updateProgress,allowFullScreen,styleParams,playerBgColor)
{if(fileParam!=null)
{url=url+((url.indexOf('?')==-1)?"?":"&")+"file="+fileParam;}
else if(appendFileUrl)
{url=url+((url.indexOf('?')==-1)?"?":"&")+appendFileUrl;}
var updateProgressStr=(updateProgress&&updateProgress==true?"&updateprogress=true":'');var allowFullScreenStr=(allowFullScreen&&allowFullScreen==true?"&allowfullscreen=true":'');var allowFullScreenTag=(allowFullScreen&&allowFullScreen==true?"<PARAM NAME='allowfullscreen' VALUE='true'>":'');playerBgColor=(playerBgColor?playerBgColor:"#000000");var autoplay=(isIcon?"false":"true");var html="<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "+"codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' "+"WIDTH='"+width+"' "+"HEIGHT='"+height+"' "+"autoplay='"+autoplay+"' "+"id='"+idObject+"'  "+
(fileParam?"        file='"+fileParam+"'  ":"")+"ALIGN='middle' "+(styleParams?"style='"+styleParams+"'":"")+"> "+"<PARAM NAME='movie' "+"VALUE='"+url+"'>"+"<PARAM NAME='FlashVars' "+"VALUE='"+flashvars+updateProgressStr+allowFullScreenStr+"'>"+"<PARAM NAME='quality' VALUE='high'> "+"<PARAM NAME='bgcolor' VALUE='"+(playerBgColor)+"'> "+
allowFullScreenTag+"<PARAM NAME='wmode' VALUE='transparent'> "+"<PARAM NAME='allowScriptAccess' VALUE='always'> "+" <EMBED src='"+url+updateProgressStr+allowFullScreenStr+"' quality='high' bgcolor='"+(playerBgColor)+"' WIDTH='"+width+"' FlashVars='"+flashvars+"' HEIGHT='"+height+"' autoplay='"+autoplay+"' NAME='"+idObject+(fileParam?"' file='"+fileParam:"")+"' wmode='transparent' allowScriptAccess='always' "+(allowFullScreenStr.length>1?allowFullScreenStr.substring(1):allowFullScreenStr)+" TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'>"+" </EMBED>"+"</OBJECT>";return html;}
function getEntryEnclosure(fileUrl,basePath,mediaType,mediaContentType)
{var url,type;if(mediaType==2)
{var flashvars="file="+fileUrl;url=basePath+"/common/mediaplayer1.swf?"+flashvars;type="application/x-shockwave-flash";}
else
{url=fileUrl;type=mediaContentType;}
return[url,type];}
function getFlashMovieObject(movieName)
{var flashObj=null;if(window.document[movieName])
{flashObj=window.document[movieName];}
else if(navigator.appName.indexOf("Microsoft Internet")==-1)
{if(document.embeds&&document.embeds[movieName])
flashObj=document.embeds[movieName];}
else
{flashObj=document.getElementById(movieName);}
return flashObj;}
function htmlEncode(strHtml)
{return xhtmlEncode(strHtml,true);}
function xmlEncode(s)
{return xhtmlEncode(s,false);}
function xhtmlEncode(s,isHtml)
{var str=null;if(s)
{var strBuf=null;var c,ic;for(var i=0;i<s.length;i++)
{c=s.charAt(i);ic=s.charCodeAt(i);if(c=='&'||c=='"'||c=='\''||c=='<'||c=='>'||c=='?'||ic>127||ic<32)
{if(strBuf==null)
{strBuf=s.substring(0,i);}
if(c=='&')
{strBuf+="&amp;";}
else if(c=='"')
{strBuf+="&quot;";}
else if(c=='\'')
{strBuf+="&#39;";}
else if(c=='<')
{strBuf+="&lt;";}
else if(c=='>')
{strBuf+="&gt;";}
else if(c=='?')
{strBuf+="&#63;";}
else if(ic>127||ic<32)
{strBuf+="&#";strBuf+=ic;strBuf+=';';}}
else if(strBuf!=null)
{strBuf+=c;}}
str=(strBuf==null?s:strBuf);}
return str;}
