var TVS=null;var videoResults=null;function video(C){this.fullTitle=C.title;this.title=C.title;if(C.title.length>36){this.title=C.title.substring(0,33);this.title+="..."}if(C.category){this.category=C.category}else{this.category="None"}if(C.channel){this.channel=C.channel}else{this.channel="None"}if(C.videoPlayerEmbedTag){this.player=C.videoPlayerEmbedTag}else{this.player="Sorry, this channel video cannot be loaded in this window. Please try this <a href='";this.player+=C.videoUrl;this.player+="' target='_blank'>link</a><br/>"}this.thumbnail=C.thumbnailUrl;if(C.tags){this.tags=C.tags}else{this.tags="None"}if(C.description){this.description=C.description}else{this.description=""}this.duration="";if(C.runtime){var B=Math.round(C.runtime/60);var A=C.runtime%60;if(A<10){this.duration+=B+":0"+A}else{this.duration+=B+":"+A}}else{this.duration+="N/A"}}function videoSearch(){TVS=new TruveoVideoSearch("c2ff6ff9d970152d6");TVS.attachEvent("onload","handleVSLoad();");TVS.attachEvent("onupdate","handleUpdate();");TVS.initialize();return false}function handleVSLoad(){var A=document.getElementById("search_txt").value;document.getElementById("indicator").style.display="block";TVS.results=50;if(A.length>0){TVS.getVideos(A)}else{TVS.getVideos()}}function handleUpdate(){var B=0;var A=0;videoResults=new Array();if(TVS.VideoSet){B=TVS.VideoSet.totalResultsReturned}for(var C=0;C<B;C++){videoResults[C]=new video(TVS.VideoSet.Video[C])}A=Math.min(10,videoResults.length);renderResults(0,A,B)}function renderResults(G,C,B){var F="";F+="<div><table class='sv-result-table'>";for(var D=G;D<G+C;D++){F+="<tr>";F+="<td>";F+="<table class='sv-result-inner-table'>";F+="<tr>";F+="<td rowspan='8' width='105'>";F+="<a onclick='playVideo(";F+=D;F+=");'><img height='75' width='105' src='"+videoResults[D].thumbnail+"' alt='Preview not available'/></a>";F+="</td>";F+="</tr>";F+="<tr>";F+="<td class='sv-result-title'><a onclick='showDesc(";F+=D;F+=");'>";F+=videoResults[D].title;F+="</a></td>";F+="</tr>";F+="<tr>";F+="<td><span class='sv-attrs'>Channel: </span>";F+=videoResults[D].channel;F+="</td>";F+="</tr>";F+="<tr>";F+="<td><span class='sv-attrs'>Category: </span>";F+=videoResults[D].category;F+="</td>";F+="</tr>";F+="</table>";F+="</td>";F+="</tr>"}F+="<tr>";F+="<td>";F+="<a target='_blank' href='http://www.truveo.com'>Powered by TRUVEO</a>";if(G>0){var A=G-10;F+="&nbsp;&nbsp;&nbsp;<a onclick='renderResults(";F+=A;F+=",";F+=10;F+=",";F+=B;F+=");'><<< back</a>"}if(B>G+C){var A=G+C;var E=Math.min(10,B-A);F+="&nbsp;&nbsp;&nbsp;<a onclick='renderResults(";F+=A;F+=",";F+=E;F+=",";F+=B;F+=");'>more >>></a>"}F+="</td>";F+="</tr>";F+="</table></div>";document.getElementById("results").innerHTML=F;document.getElementById("indicator").style.display="none"}function playVideo(A){var B=A+"_"+Math.random();document.mochaUI.newWindow({id:B,title:videoResults[A].fullTitle,content:videoResults[A].player,modal:false,width:460,height:380})}function showDesc(A){var B="";B+="<table class='sv-result-desc-table'>";B+="<tr>";B+="<td rowspan='8' width='25%'>";B+="<img height='75' width='105' src='"+videoResults[A].thumbnail+"'/>";B+="</td>";B+="</tr>";B+="<tr>";B+="<td><span class='sv-attrs'>Channel: </span>";B+=videoResults[A].channel;B+="</td>";B+="</tr>";B+="<tr>";B+="<td><span class='sv-attrs'>Category: </span>";B+=videoResults[A].category;B+="</td>";B+="</tr>";B+="<tr>";B+="<td><span class='sv-attrs'>Tags: </span>";B+=videoResults[A].tags;B+="</td>";B+="</tr>";B+="<tr>";B+="<td><span class='sv-attrs'>Duration: </span>";B+=videoResults[A].duration;B+="</td>";B+="</tr>";B+="</table>";B+="<br />";B+="<span class='sv-attrs'>Description: </span>";B+=videoResults[A].description;document.mochaUI.newWindow({id:"Video Details",title:videoResults[A].fullTitle,content:B,modal:true,width:500,height:220})}function loadCheat(){document.mochaUI.newWindow({id:"Cheat Sheet",title:"Video Search Cheat Sheet",loadMethod:"iframe",contentURL:"cheat.html",modal:true,scrollbars:false,width:800,height:420})}function initSearch(A){var B;if(A&&A.which){B=A.which}else{B=A.keyCode}if(B==13){videoSearch()}};