var Videos={id:"Videos",title:"Videos",image:"videos16.png",allowItems:true,allowFolders:true,allowDrag:true,itemName:"Video",UpdateYouTubeDialog:"updateyoutubedialog/60102079.js",UpdateYahooDialog:"updateyahoodialog/60102044.js",UpdateGoogleDialog:"updategoogledialog/60101826.js",UpdateDialog:"updatedialog/60101759.js",AddDialog:"adddialog/48533051.js",itemTagName:"SPAN",itemClassName:"videosItem",init:function(){var a=Styles.add;},yahooVideoRefererExceptions:{"broadbandsports.com":true},renderEmpty:function(w,s){Section.renderEmpty(w,s)},addItems:function(id,beforeId){if(!beforeId)beforeId=-1;Module.showDialog(Videos,"AddDialog",{parentId:id,beforeId:beforeId})},insertItem:function(parentId,beforeId,item){var msg;if(item.nodeType=="youTubeItem"){msg={parent:parentId,beforeId:beforeId,id:item.sourceId,author:item.author,title:item.title,duration:item.duration,rating:item.rating,tags:item.tags,thumbnail:item.thumbnail,text:item.text};C.beginExec("videos/addyoutube",msg)}else if(item.nodeType=="yahooItem"){msg={parent:parentId,beforeId:beforeId,url:item.url,title:item.title,text:item.text,refererUrl:item.refererUrl,fileSize:item.fileSize,fileFormat:item.fileFormat,height:item.height,width:item.width,duration:item.duration,streaming:item.streaming,thumbnail:item.thumbnail,thumbnailHeight:item.thumbnailHeight,thumbnailWidth:item.thumbnailWidth,publisher:item.publisher,restrictions:item.restrictions};C.beginExec("videos/addyahoo",msg)}else if(item.nodeType=="googleItem"){msg={parent:parentId,beforeId:beforeId,id:item.sourceId,url:item.url,title:item.title,text:item.text,thumbnail:item.thumbnail,thumbnailHeight:item.thumbnailHeight,thumbnailWidth:item.thumbnailWidth,publisher:item.publisher,published:item.published,duration:item.duration};C.beginExec("videos/addgoogle",msg)}else{C.beginExec("videos/add",{parent:parentId,beforeId:beforeId,url:item.url,title:item.title})}},updateItem:function(id){if(id){var item=page.nodes[id];if(item.nodeType=="youTubeItem"){Module.showDialog(Videos,"UpdateYouTubeDialog",{item:item})}else if(item.nodeType=="yahooItem"){Module.showDialog(Videos,"UpdateYahooDialog",{item:item})}else if(item.nodeType=="googleItem"){Module.showDialog(Videos,"UpdateGoogleDialog",{item:item})}else{Module.showDialog(Videos,"UpdateDialog",{item:item})}}},deleteItem:function(id){ContentItem.deleteItem(id)},sendContentItem:function(item,dlg){dlg.subject=item.title;dlg.body="<img src='"+item.thumbnail+"' />"+"<br/><br/>"+Html.a(Videos.formatHref(item),item.title)+Html.div(item.text)},sendUpdateRequest:function(item,dlg){dlg.fields=[{name:"title",label:"Title",value:item.title},{name:"text",label:"Description",value:item.text,type:"TextArea"},{name:"comments.add",label:"Comments",type:"TextArea"}]},defaultLayout:"List",detailLayout:"ItemDetail",layouts:{Compact:{itemTagName:"LI",renderItemsHeader:function(w,s,items){w("<ul class='contentList bullet1'>")},renderItemsFooter:function(w,s,items){w("</ul>")},renderItemContent:function(w,item){Videos.renderItemContent(w,item)}},List:{itemTagName:"DIV",itemClassName:"videosDetailItem",renderItemContent:function(w,item){var duration=Videos.formatSeconds(item.duration);if(duration.length>0){duration=" <span class='videosDuration color-red'>("+duration+")</span>"}var url=Videos.formatHref(item);w("<table cellspacing=3px>","<tr valign=top>","<td>","<div style='position:relative;' width=100px height=70px>");var link;if(item.nodeType=="youTubeItem"){link="<a href='' onclick='PageNode.open("+item.nodeId+");return false;'>"}else{link="<a href='"+url+"' target='"+A.targetWindowName+"'>"}w(link,"<img src='"+item.thumbnail+"' width=100px height=70px style='border:0; background-image:url("+ImgSrc.progress+");background-repeat:no-repeat;background-position:center;' onerror='Videos.imgError(this);' onload='Videos.imgLoad(this);'/>","<img src='"+A.imagesBase,"playsmall.gif' width=18px height=15px  style='border:0;position:absolute;left:77px;top:47px;' />","</a>","</div>","</td>","<td>",link,item.title,"</a>",duration,"<br/>",item.text,"</td>","</tr>","</table>")}},Details:{itemTagName:"DIV",itemClassName:"videosDetailItem",renderItemContent:function(w,item){var t=Videos;t._2(w,item);var duration=t.formatSeconds(item.duration);if(duration.length>0){duration=" ("+duration+")"}if(item.nodeType=="youTubeItem"){w("<a href='' onclick='PageNode.open(",item.nodeId,");return false;'>")}else{w("<a href='"+t.formatHref(item)+"' target='",A.targetWindowName,"'>")}w(item.title,duration,"</a>","<br/>",item.text,"<div class=clear>&nbsp;</div>")}},ItemDetail:{kind:1,renderItemContent:function(w,item,index){var t=Videos;var width=425;var height=350;var p=new ItemPanel(w,item);p.property("Title",item.title);if(item.nodeType=="youTubeItem"){var sb=new StringBuilder();t._0(sb.write,"http://www.youtube.com/v/"+item.sourceId,width,height);p.property("Video",sb.toString(),{"vertical-align":"top"})}else if(item.nodeType=="yahooItem"||item.nodeType=="googleItem"){var html="<a href=\""+t.formatHref(item)+"\" target='"+A.targetWindowName+"'>"+"<img src='"+A.imagesBase+"play.gif' style='vertical-align:middle; text-align:center;'/>"+"<span> Play Video</span>"+"</a>";p.property("Video",html);html="<img src="+item.thumbnail+" width="+width+" height="+height+" style='border:0; background-image:url("+ImgSrc.progress+");background-repeat:no-repeat;background-position:center;' onerror='Videos.imgError(this);' onload='Videos.imgLoad(this);'/>";p.property("Preview",html,{"vertical-align":"top"})}p.property("Description",item.text);p.property("Duration",t.formatSeconds(item.duration));p.created();p.modified();p.close()}}},imgError:function(el){el.src=A.imagesBase+"imagenotavailable.gif";el.style.backgroundImage=""},imgLoad:function(el){el.style.backgroundImage=""},renderItemContent:function(w,item){var atts=(item.text)?{tip:Html.escapeAttributeValue(item.text)}:null;w(Html.targetA(Videos.formatHref(item),item.title||item.url,atts))},_2:function(w,item){var t=Videos;var width=425;var height=350;if(item.nodeType=="youTubeItem"){t._0(w,"http://www.youtube.com/v/"+item.sourceId,width,height)}else if(item.nodeType=="yahooItem"||item.nodeType=="googleItem"){t._1(w,item,width,height)}},_1:function(w,item,width,height){var url=Videos.formatHref(item);var uri=new Uri(url);w("<div style='position:relative;width:100%;overflow:hidden;' tip='id:"+item.nodeId+"'>","<img src=",item.thumbnail," width=",width," height=",height," style='position:relative;border:0; background-image:url("+ImgSrc.progress+");background-repeat:no-repeat;background-position:center;' onerror='Videos.imgError(this);' onload='Videos.imgLoad(this);'/>","<div id=neo style='position:absolute; left:0px; top:120px; height:110px; width:",width,"px; background-color:#000;opacity:.65;filter: alpha(opacity=65); -moz-opacity:0.5; border-top:1px solid #fff; border-bottom:1px solid #fff;'>","</div>","<div id=neoc style='position:absolute; left:0px; top:140px; height:70px; width:",width,"px; text-align:center'>","<a href=\"",url,"\" target='",A.targetWindowName,"'>","<img src='"+A.imagesBase+"play.gif' style='vertical-align:middle; text-align:center;'/>","</a>","<h4 style='display:inline;font-size:114%;'>","<a href=\"",url,"\" style='color:#94a2ff;' target='",A.targetWindowName,"'>","&nbsp;Play Video","</a>","</h4>","<p style='color:#fff; font-size:85%; display:block; margin:7px 15px 3px 15px;'>","This video will be played from <em>"+uri.authority+"</em>.","</p>","</div>","</div>")},_0:function(w,url,width,height){w("<div style='width:100%;overflow:hidden;'>","<div  style='width:",width,"px; background-image:url(",ImgSrc.progress,");background-repeat:no-repeat;background-position:center;'>","<object width=",width," height=",height," >","<param name=movie value=\"",url,"\"></param>","<param name=wmode value=transparent></param>","<embed src=\"",url,"\" type=\"application/x-shockwave-flash\" width=",width," height=",height," wmode=transparent ></embed>","</object>","</div>","</div>")},_4:function(w,url,width,height){w("<object width=",width," height=",height," classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' ","codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' ","standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject' >","<param name=fileName value=\"",url,"\"></param>","<embed type='application/x-mplayer2' src=\"",url,"\" width=",width," height=",height," ></embed>","</object>")},formatHref:function(item){if(item.nodeType=="yahooItem"){var uri=new Uri(item.url);if(Videos.yahooVideoRefererExceptions[uri.authority]){return item.refererUrl}else{return item.url}}else if(item.nodeType=="youTubeItem"){return"http://www.youtube.com/watch?v="+item.sourceId}else if(item.nodeType=="googleItem"&&item.sourceId){return"http://video.google.com/videoplay?docid="+item.sourceId}else if(item.url){return Html.escapeAttributeValue(item.url)}else{return null}},_3:function(label,value){if(value){return"<span class=output-label>"+label+": </span>"+value+""}else{return""}},formatSeconds:function(duration){var s="";if(duration){var hours=Math.round((duration/3600));var minutes=Math.round(((duration%3600)/60));var seconds=(duration%3600)%60;s=(hours>0)?hours+":":""+((minutes>0)?minutes:"0")+":";if(seconds>=10){s+=seconds}else if(seconds>0){s+="0"+seconds}else{s+="00"}}return s},onTip:function(evt){if(evt.tip.startsWith("id:")){var nodeId=evt.tip.substring(3);var item=page.nodes[nodeId];if(item&&item.type==ContentItem){var desc=(item.text)?"<br/>"+item.text:"";var html="<b>"+item.title+"</b> "+desc+"<div class=clear>&nbsp;</div>";var f=Videos._3;html+=StringEx.joinOptional("<br/>",f("Author",item.author),f("Publisher",item.publisher),f("Duration",Videos.formatSeconds(item.duration)),f("Tags",item.tags));evt.tip=html}}}};Module.add(Videos);