var httpUrl = 'http://ostlendingen.no' var archiveUrl = 'http://ostlendingen.no/section/video/1175' var videos = {}; function loadVideo (id) { NettTv.API.addHook('play', startEvent); NettTv.API.addHook('next', nextEvent); NettTv.API.load(id, videoLoaded); } function videoLoaded (id) { var image = NettTv.API.getImage(id, 640); var title = NettTv.API.getTitle(id); var description = NettTv.API.getPreamble(id); videos[id] = { 'title' : title, 'image' : image, 'description' : description, 'url' : archiveUrl+'&id='+id, 'rating' : 0 }; if (typeof image === 'string') { //$('videoImg').src = 'http://dtimg.no.publicus.com/apps/pbcsi.dll/urlget?url='+image+'&MaxW=784&NoBorder'; $('videoImg').src = image; setImageWrapHeight(image); } if (typeof title === 'string') { $('titleOverlay').set('html', title); } loadVideoRating(); } function setImageWrapHeight (imageUrl) { var myImages = new Asset.images([imageUrl], { onComplete: function(){ $('videoImg').getParent('div').setStyle('height', $('videoImg').height); } }); } function rate (id) { if (videos[id]) { var rateId = new Date().getTime()+'-'+id; var jr = new Request.JSON({ url: httpUrl+'/templates/scripts/video/ajaxProxy.php', onComplete: function (r) { if (r) { setVideoRating(id, r.rating); //return r.rating; } } }).get({ 'rateId':rateId, 'action':'rate', 'id':id }); return videos[id].rating+1; } else { alert('Kan ikke anbefale video! PrÝv igjen senere!'); } } function loadVideoRating (id) { var rateId = new Date().getTime()+'-'+id; var jr = new Request.JSON({ url: httpUrl+'/templates/scripts/video/ajaxProxy.php', onComplete: function (r) { if (r) { setVideoRating(id, r.rating); } } }).get({ 'rateId':rateId, 'action':'xtras', 'id':id }); } function setVideoRating (id, rating) { if (rating) { videos[id].rating = rating; } else { videos[id].rating = 0; } } function startEvent (id) { if (!videos[id]) { loadVideo(id); } } function nextEvent (id) { startEvent(id); } /* function shareVideo (shareSite, id) { if (videos[id]) { var u = encodeURIComponent(videos[id].url); var t = encodeURIComponent(videos[id].title); var d = encodeURIComponent(videos[id].description); switch ( shareSite ) { case 'facebook': window.open('http://www.facebook.com/sharer.php?u='+u+'&t='+t, 'sharer', 'toolbar=0,status=0,width=626,height=436'); break; case 'kudos': t = encodeURIComponent( video.title.replace(/^\s*|\s*$/g,'') ); window.open('http://www.kudos.no/giKudos.php?tittel='+t+ '&url='+u, 'kudos', 'toolbar=yes,width=1000,height=700'); break; case 'delicious': window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+u+'&title='+t, 'delicious', 'toolbar=no,width=700,height=400'); break; case 'tips': window.open('/templates/scripts/tips.php?type=1&Url='+videos[id].link+'&Title='+video.title+'&Summary='+videos[id].description, 'Tips', 'height=550,width=305', false); break; case 'twitter': window.open('http://twitter.com/home?status='+videos[id].title+' '+videos[id].link, 'twitter', 'height=550,width=700', false); break; case 'linkedIn': window.open('http://www.linkedin.com/shareArticle?mini=true&url='+u+'&title='+t+'&summary='+d, 'Linkedin', 'height=550,width=600', false); break; case 'myspace': window.open('http://www.myspace.com/index.cfm?fuseaction=postto&t='+t+'&c='+d+'&u='+u, 'MySpace', 'height=550,width=600', false); break; default: break; } } else { alert('Kan ikke dele video! PrÝv igjen senere!'); } } */ function playVideo ( id ) { $('articleVideoBox').setStyle('height', '407px'); NettTv.API.play( id, 'articleVideoBox', 'article' ); } var videoImageArray = []; function loadVideoImage ( id, size, tagId ) { addVideoImagetag(tagId); var v = { 'id' : id, 'imageSize' : imageSize } NettTv.API.load( id, function (id, imageSize) { videoImageLoaded(this.id, this.imageSize); }.bind(v) ); } function videoImageLoaded (id, imageSize) { var image = NettTv.API.getImage(id, imageSize); if (typeof image === 'string') { $('videoImg').src = 'http://'+site+'img.no.publicus.com/apps/pbcsi.dll/urlget?url='+image+'&MaxW='+imageSize+'&NoBorder'; } } function addVideoImagetag ( tagId ) { videoImageArray.push(tagId); } function scaleVideoImageWraps () { videoImageArray.each(function (tagId) { var tag = $(tagId); tag.getParent('.image').setStyle('height', tag.height); }); } window.addEvent('domready', function() { scaleVideoImageWraps(); }); function shareVideo (shareSite, id) { if (videos[id]) { var u = encodeURIComponent(videos[id].link); var t = encodeURIComponent(videos[id].title); var d = encodeURIComponent(videos[id].description); switch ( shareSite ) { case 'facebook': window.open('http://www.facebook.com/sharer.php?u='+u+'&t='+t, 'sharer', 'toolbar=0,status=0,width=626,height=436'); break; case 'kudos': t = encodeURIComponent( video.title.replace(/^\s*|\s*$/g,'') ); window.open('http://www.kudos.no/giKudos.php?tittel='+t+ '&url='+u, 'kudos', 'toolbar=yes,width=1000,height=700'); break; case 'delicious': window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+u+'&title='+t, 'delicious', 'toolbar=no,width=700,height=400'); break; case 'tips': window.open('/templates/scripts/tips.php?type=1&Url='+u+'&Title='+t+'&Summary='+d, 'Tips', 'height=550,width=305', false); break; case 'twitter': window.open('http://twitter.com/home?status='+t+' '+u, 'twitter', 'height=550,width=700', false); break; case 'linkedIn': window.open('http://www.linkedin.com/shareArticle?mini=true&url='+u+'&title='+t+'&summary='+d, 'Linkedin', 'height=550,width=600', false); break; case 'myspace': window.open('http://www.myspace.com/index.cfm?fuseaction=postto&t='+t+'&c='+d+'&u='+u, 'MySpace', 'height=550,width=600', false); break; default: break; } } else { alert('Kan ikke dele video! PrÝv igjen senere!'); } } function getMostRatedLink () { return archiveUrl+'&categoryId=mostrated'; }