// Allows easy embedding of the Newstex video interface.
// Copyright 2009-2010 Newstex - Content On Demand http://newstex.com/
var newstex_player=null;function playerReady(d){newstex_player=document.getElementById(d.id)}
function newstexPlayer(d,j,q){var a={};a.video_id=d;a.client_id=j;a.base_url="http://static.newstex.com";a.base_video_url="http://video.newstex.com";a.ga_key="UA-331997-3";a.flash_url=a.base_url+"/flash/player.swf";if(window.location.hostname.indexOf("dev.video.newstex.com")>=0){a.base_url="http://dev.static.newstex.com";a.base_video_url="http://dev.video.newstex.com";flash_player_url=gup("player");if(flash_player_url!="")a.flash_url=flash_player_url}a.sem={};a.build_player=function(b){a.require("http://www.google-analytics.com/ga.js",
function(){try{var g=b.client_name||a.client_id,h=b.provider_name||a.video_id,o=_gat._getTracker(a.ga_key);o._trackPageview();o._trackEvent(g,h,a.video_id)}catch(m){}});var c=a.create().cls("nv__header"),e=["client_logo","provider_logo"];for(var l in e)b[e[l]]&&c.add(a.create("a").cls("nv__"+e[l]).attr("href",b[e[l].replace("logo","url")]).add(a.create("img").attr("src",b[e[l]])));a.root.add(c);b.headline&&a.root.add(a.create().txt(b.headline).cls("nv__headline"));if(b.pub_date&&/^(\d+)-(\d+)-(\d+)/.test(b.pub_date)){c=
new Date(RegExp.$1,RegExp.$2-1,RegExp.$3);a.root.add(a.create().txt(c.toLocaleString().replace(/ \d+:.*/,"")).cls("nv__pub_date"))}if(b.file_url){var p="embed_"+a.video_id.replace(/\W/g,"");a.root.add(a.create().cls("nv__player").add(a.create().attr("id",p)));a.root.style.width=(a.width?a.width:640)+"px";var f=b.file_url.replace("https:","http:");c=f.split(".");a.file_url=f;file_ext=c[c.length-1];var s={allowfullscreen:"true",allowscriptaccess:"always"},n={plugins:"gapro-1","gapro.accountid":a.ga_key,
autostart:true,file:f,playerready:"playerReady"},t={id:"player_"+a.video_id,name:"player_"+a.video_id};try{var u=function(){$.ajax({type:"HEAD",url:f,complete:function(g){f=g.getResponseHeader("Location");n.type="http";n["http.startparam"]="start";n.start=0;n.file=f;swfobject.embedSWF(a.flash_url,p,"400","300","9.0.115",false,n,s,t,function(h){if(!h.success&&f&&f.indexOf(".flv")<0&&a.create("video").play)a.byId(p).attr("id","").html('<video src="'+f+'" id="'+p+'" width="400" height="300" controls="controls"></video>');
else a.byId("get_flash_"+a.video_id).className+="_off"})}})};file_ext=="xml"||f.indexOf("youtube")>0?swfobject.embedSWF(a.flash_url,p,"400","300","9.0.115",false,n,s,t,function(g){if(!g.success){f=f.replace(".xml","");u()}}):u()}catch(x){typeof console!="undefined"&&console.error(x)}}c=a.create().cls("nv__content");a.root.add(c);if(b.description){var r=a.create().txt(b.description).cls("nv__description  nv__hidden_off");c.add(r);if(b.description.length>150){var v=a.create().txt(b.description).cls("nv__description nv__hidden");
r.txt(b.description.replace(/^((?:&lt;.*?&gt;|[\s\S]){140,150}\w+)[\s\S]*$/,"$1&hellip;")).add(a.create("a").txt("Full&nbsp;description").cls("nv__show").attr({href:"#",onclick:function(){v.toggle();r.toggle();return false}}));c.add(v)}}if(b.transcript){c.add(a.create().cls("nv__ts_headline").add(a.create("input").cls("nv__ts_search nv__prompt").attr({type:$.browser.msie?"text":"search",results:5,value:"Search...",onblur:function(){if(this.value==""){this.value="Search...";$(this).addClass("nv__prompt")}else $(this).removeClass("nv__prompt")},
onfocus:function(){$(this).removeClass("nv__prompt");if(this.value=="Search...")this.value=""},onkeyup:function(){var g=this.value;$(this).parents(".nv__content").find(".nv__transcript p").each(function(){$(this).text().toLowerCase().indexOf(g.toLowerCase())<0?$(this).hide():$(this).show()})},onclick:function(){this.onkeyup()}}),a.create("span").txt("Transcript")));e=a.create().txt(b.transcript).cls("nv__transcript");c.add(e);$("div.nv__transcript p").each(function(g){$(this).addClass("nv__row_"+
g%2);g=$(this).text();var h=$(this).attr("begin");if(h){var o=h;try{var m=h.split(".")[0].split(":");h=parseInt(m[0]*60*60)+parseInt(m[1]*60)+parseInt(m[2]);o=m[1]+":"+m[2]}catch(y){}$(this).html("<small>"+o+"</small><a href=\"javascript:newstex_player.sendEvent('SEEK','"+h+"');\">"+g+"</a>")}})}a.footer&&a.root.add(a.create().cls("nv__footer").add(a.create().txt("Newstex ID: "+a.video_id),a.create().cls("nv__rights").html('<a href="http://www.newstex.com/trademarks-and-disclaimers/" target="_blank">All Rights Reserved</a>'),
a.create().html('<img src="http://newstex.com/img/n.gif" alt="" /> &copy; 2009&ndash;'+(new Date).getFullYear()+'. <a href="http://www.newstex.com/" target="_blank">Newstex LLC</a>.')),a.create().cls("nv__clear"))};a.error=function(b){a.root.add(a.create().txt("The video could not be loaded.").cls("nv__headline"),a.create().txt("<strong>The following error occurred while attempting to find the requested video:</strong>\n"+b).cls("nv__description")).style.width="640px"};a.node=function(b){if(!b)return b;
b.attr=function(c,e){if(typeof c!="object"){var l={};l[c]=e;c=l}for(i in c)this[i]=c[i];return this};b.toggle=function(){b.className=b.className.replace(/_off$/,"X").replace(/([^X])$/,"$1_off").replace(/X$/,"");return b};b.html=function(c){b.innerHTML=c;return b};b.txt=function(c){b.innerHTML=c.replace(/\n/g,"<br />").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&#34;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&");return b};b.cls=function(c){b.className+=" "+c;return b};b.add=function(){for(var c=
0;c<arguments.length;c++)b.appendChild(arguments[c]);return b};return b};a.byId=function(b){return a.node(document.getElementById(b))};a.byTag=function(b){return a.node(document.getElementsByTagName(b)[0])};a.create=function(b){return a.node(document.createElement(b||"div"))};a.require=function(b,c){var e=a.create("script").attr({type:"text/javascript",src:b});if(c){e.onload=function(){if(!a.sem[b]){a.sem[b]=true;c()}};e.onreadystatechange=function(){if(!a.sem[b])if(this.readyState=="loaded"||this.readyState==
"complete"){a.sem[b]=true;c()}}}a.byTag("head").add(e)};j="client_id video_id layout show_provider_logo show_client_logo show_headline show_description show_transcript show_footer".split(" ");var w=[];for(i in j)try{var k=j[i];a[k]=eval("newstex_"+k);eval("delete newstex_"+k);if(/str|bool/.test(typeof a[k])){if(a[k]=="false")a[k]=false}else a[k]+="";w.push(j[i]+"="+escape(a[k]||""))}catch(z){}if(!a.layout||a.layout>3)a.layout=3;if(a.show_footer||a.layout==3&&a.show_footer!=false)a.footer=1;if(typeof q==
"undefined"){q="newstex_video_"+d;a.byTag("body").add(a.create().attr({id:q}))}a.root=a.byId(q);a.root.className="nv__embed";a.root.add(a.create().cls("nv__clear"));if(!a.css){a.byTag("head").add(a.create("link").attr({type:"text/css",rel:"stylesheet",href:a.base_url+"/style/video_embed.css"}));a.css=1}if(!a.client_id||!a.video_id)return a.error("Incorrect Newstex video configuration, missing <em>newstex_client_id</em> or <em>newstex_video_id</em>.");a.require(a.base_url+"/javascript/jquery.js",function(){a.require(a.base_url+
"/javascript/jquery.media.js",function(){a.require(a.base_url+"/javascript/swfobject2.js",function(){a.require(a.base_video_url+"/videos/player/"+a.video_id+".js?p="+a.client_id+"&player=internal&"+w.join("&"),function(){a.build_player(newstex_data)})})})});return a}
if(typeof newstex_video_id!="undefined"){document.write('<div id="newstex_player_'+newstex_video_id+'"><a id="get_flash_'+newstex_video_id+'" href="http://www.adobe.com/go/getflashplayer" class="nv__get_flash nv__hidden" target="_blank">&nbsp;</a></div>');setTimeout(function(){var d=document.getElementById("newstex_player_"+newstex_video_id),j;if(d)j=d.id;newstexPlayer(newstex_video_id,newstex_client_id,j)},100)}
function gup(d){d=d.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");d=(new RegExp("[\\?&]"+d+"=([^&#]*)")).exec(window.location.href);return d==null?"":d[1]};

