var Vwv=function(user_custom_vwv){this.debug=false;this.lang="en";this.orderby="relevance";this.target_id="youtube-videos-component";this.video_query_escaped="Brasil";this.video_component_title="Videos De “"+htmlspecialchars(unescape(this.video_query_escaped))+"”";this.fullscreen_message="Full screen";this.max_displayed_videos=8;this.video_width=312;this.video_height=260;this.thumb_width=130;this.thumb_height=97;this.max_description_length=222;this.max_title_length=55;for(var p in user_custom_vwv){this[p]=user_custom_vwv[p]}this.video_query_escaped=toutf8(unescape(this.video_query_escaped));var c=navigator.userAgent.toLowerCase();var a=/msie/.test(c)&&!/opera/.test(c);if(a){this.video_query_escaped=escape(this.video_query_escaped)}this.start_index=1;this.url="http://gdata.youtube.com/feeds/api/videos?key=AI39si690xIAHp_8DqG5hEokggsUWQYd8E26Y3nJ-ipXXS4JuJcxDeWgQmmQGc15gHrvtPOfbytyohhWUeIuKukdP4TPBfUCVQ&category=Travel&v=2&q="+this.video_query_escaped+"&start-index="+this.start_index+"&max-results="+this.max_displayed_videos+"&lr="+this.lang+"&orderby="+this.orderby+"&format=5&alt=json-in-script&callback=?";this.total_videos=0;this.video_data=null};Vwv.prototype.fullscreen=function(video_url){var w=window.open(video_url,"FullScreenVideo","toolbar=no,width="+screen.availWidth+",height="+(screen.availHeight-50).toString()+",status=no,resizable=yes,scrollbars=no,top=0")};Vwv.prototype.render_nav_buttons=function(){if(this.total_videos<=this.max_displayed_videos){return""}var n=Math.ceil(this.start_index/this.max_displayed_videos);var total=Math.ceil(this.total_videos/this.max_displayed_videos);var html='<div id="youtube-videos-nav" style="display: inline; float: right; font-size: 85%; color: #000;"><span id="youtube-videos-nav-status"><strong>'+n+"</strong> / <strong>"+total+'</strong></span>&#xA0;<img width="21" height="15" border="0" src="/lib/images/prev_video.gif" style="cursor: pointer;" onmouseout="this.src=\'/lib/images/prev_video.gif\'" onmouseover="this.src=\'/lib/images/prev_video_on.gif\'" onclick="vwv.goto_prev_video()"/><img width="21" height="15" border="0" src="/lib/images/next_video.gif" style="cursor: pointer;" onmouseout="this.src=\'/lib/images/next_video.gif\'" onmouseover="this.src=\'/lib/images/next_video_on.gif\'" onclick="vwv.goto_next_video()"/>  </div>';return html};Vwv.prototype.render_pag_buttons=function(){html="";return html};Vwv.prototype.render_main_video_entry=function(entry,autoplayp){var src=(!entry.media$group.media$content)?"foo":entry.media$group.media$content[0].url;var src2=src.length;var p2=src.indexOf("?");var p3=src.substring(0,p2);src=p3;var title=htmlspecialchars(entry.title.$t,true);var duration=sec2minutes(entry.media$group.yt$duration.seconds);var descricao=(entry.media$group.media$description.$t);var txttags=(entry.media$group.media$keywords.$t);var linkvideo=entry.link[0].href;linkvideo=linkvideo.replace("http://www.youtube.com/watch?v=","http://www.youtube.com/comment_servlet?all_comments&v=");var thumbimg=entry.media$group.media$thumbnail[0].url;var other_params_s="rel=0&showsearch=0&fs=1&color1=0xc5c5c5&color2=0xdfdfec&showinfo=0&iv_load_policy=3";var thumb_video_autor=(entry.author[0].name.$t);var publicado=(entry.published.$t);var visitas=(entry.yt$statistics.viewCount);var txtcomentarios=(entry.gd$comments.gd$feedLink.countHint);var urlcomentarios=(entry.gd$comments.gd$feedLink.href);if(txtcomentarios>0){this.feed(urlcomentarios,txtcomentarios)}else{$("#feedcomentarios").html('<div id="post-comentario"><div class="icocomment"><img src="/lib/images/ico-comentario-video.gif" /></div><div id="txtlinkcoment"><h4>Nenhum Coment&aacute;rio</h4><p>Seja o primeiro a comentar esse v&iacute;deo, voc&ecirc; ser&aacute; redirecionado para a p&aacute;gina do v&iacute;deo no youtube.</p><p><a href="'+linkvideo+'" target="_blank">Clique aqui para postar seu coment&aacute;rio</a></p></div></div>')}publicado=publicado.substring(0,10);publicado=publicado.replace("-",",");publicado=publicado.replace("-",",");publicado=new Date(publicado);var dia=publicado.getDate();var mes=publicado.getMonth();mes++;var ano=publicado.getFullYear();if(dia<10){dia="0"+dia}if(mes<10){mes="0"+mes}publicado=dia+"/"+mes+"/"+ano;var txtautordata=publicado+" - Por: <a href='http://www.youtube.com/user/"+thumb_video_autor+"' target='_blank'>"+thumb_video_autor+"</a>";var thumb_video_rating="0";if(entry.gd$rating){thumb_video_rating=Math.round(entry.gd$rating.average)}var imgrating="<img src='/lib/images/star/"+thumb_video_rating+".gif'/>";if(autoplayp){other_params_s+="&autoplay=1"}if(!jQuery.browser.msie){other_params_s+="&ap=%2526fmt%3D18"}$("#videoPlayer").html("");$("#videoPlayer").append("<div id='player'></div>");$(".titulovideo").html(title);$(".description").html(descricao);$(".datarefautor").html(txtautordata);$(".rating").html(imgrating);$(".txtTags").html(txttags);$(".views").html("Visitas: "+visitas);$(".comments").html("Coment&aacute;rios: "+txtcomentarios);var flashvars={width:"700",height:"450",enablejs:"true",file:src,image:thumbimg,logo:"/lib/playerflv/logo.png",autostart:"true"};var params={allowfullscreen:"true",wmode:"transparent",allowscriptaccess:"true",autostart:"true"};var attributes={id:"video",name:"video"};return swfobject.embedSWF("/lib/playerflv/player.swf","player","545","445","9.0.0","expressInstall.swf",flashvars,params,attributes)};Vwv.prototype.feed=function(url,t){var feedControl=new google.feeds.FeedControl();feedControl.addFeed(url,"Coment&aacute;rios");feedControl.setNumEntries(t);feedControl.setLinkTarget(google.feeds.LINK_TARGET_BLANK);feedControl.draw(document.getElementById("feedcomentarios"))};Vwv.prototype.render_video_thumbnail=function(entry,thumb_ordinal){if(!entry.media$group.media$content){return""}var thumb_video_url=entry.media$group.media$content[0].url;var thumb_video_title=unhtmlspecialchars(entry.title.$t);var thumb_video_autor=(entry.author[0].name.$t);var publicado=(entry.published.$t);publicado=publicado.substring(0,10);publicado=publicado.replace("-",",");publicado=publicado.replace("-",",");publicado=new Date(publicado);var dia=publicado.getDate();var mes=publicado.getMonth();mes++;var ano=publicado.getFullYear();if(dia<10){dia="0"+dia}if(mes<10){mes="0"+mes}publicado=dia+"/"+mes+"/"+ano;var thumb_video_title_short=(thumb_video_title.length>this.max_title_length)?(thumb_video_title.substring(0,this.max_title_length)+"..."):thumb_video_title;var thumb_image_url=entry.media$group.media$thumbnail[0].url;var thumb_video_duration=sec2minutes(entry.media$group.yt$duration.seconds);var thumb_video_rating="0";if(entry.gd$rating){thumb_video_rating=Math.round(entry.gd$rating.average)}thumb_video_title=htmlspecialchars(thumb_video_title);thumb_video_title_short=htmlspecialchars(thumb_video_title_short);var td="<div class='thumb'><a onclick=\"return vwv.place_play_video("+thumb_ordinal+')" title="'+thumb_video_title+'" href="javascript:void(0);"><img width="'+this.thumb_width+'" height="'+this.thumb_height+'" title="'+thumb_video_title+'" src="'+thumb_image_url+'" class="video-thumb-image"/></a></div>';td=td+"<div class='desc-video'><h4>Por: <a href='http://www.youtube.com/user/"+thumb_video_autor+"' target='_blank'>"+thumb_video_autor+"</a></h4><p class='titulo'><a onclick=\"return vwv.place_play_video("+thumb_ordinal+')" title="'+thumb_video_title+'" href="javascript:void(0);"><strong>'+thumb_video_title_short+"</strong></a></p><p class='data'>"+publicado+" ("+thumb_video_duration+")</p><p class='rating'><img src='/lib/images/star/"+thumb_video_rating+".gif'/></p></div>";return td};Vwv.prototype.render_video_thumbnails=function(entries){var tds=[];for(var n=1;n<this.max_displayed_videos;++n){var td=(entries[n])?this.render_video_thumbnail(entries[n],n):"<td></td>";tds.push(td)}var s="<ul><li>"+tds[0]+"</li><li>"+tds[1]+"</li><li>"+tds[2]+"</li><li>"+tds[3]+"</li><li>"+tds[4]+"</li><li>"+tds[5]+"</li><li>"+tds[6]+"</li></ul>";return s};Vwv.prototype.decorate_youtube_video_component=function(data){if(data.feed.entry){var entries=data.feed.entry;var main_video_id="youtube-video-1";var video_thumbnails_id="listItems-videos";this.total_videos=Number(data.feed.openSearch$totalResults.$t);$("#"+this.target_id).removeClass("hidden");var e=$("#"+this.target_id+" > h3");e.empty();e.append(this.render_nav_buttons()+this.video_component_title);var e=$("#"+main_video_id);var e=$("#"+video_thumbnails_id);e.empty();e.append(this.render_video_thumbnails(entries))}};Vwv.prototype.place_play_video=function(video_index){if(vwv.video_data.feed.entry[video_index]){var e=$("#player");e.empty();e.append(this.render_main_video_entry(vwv.video_data.feed.entry[video_index],true));fixIEUnfocus(e.find("embed")[0])}};Vwv.prototype.goto_prev_video=function(){this.start_index-=this.max_displayed_videos;if(this.start_index<=0){this.start_index=1;return false}this.url="http://gdata.youtube.com/feeds/api/videos?key=AI39si690xIAHp_8DqG5hEokggsUWQYd8E26Y3nJ-ipXXS4JuJcxDeWgQmmQGc15gHrvtPOfbytyohhWUeIuKukdP4TPBfUCVQ&category=Travel&v=2&q="+this.video_query_escaped+"&start-index="+this.start_index+"&max-results="+this.max_displayed_videos+"&lr="+this.lang+"&orderby="+this.orderby+"&format=5&alt=json-in-script&callback=?";$.getJSON(this.url,function(data){vwv.video_data=data;vwv.decorate_youtube_video_component(data)})};Vwv.prototype.goto_next_video=function(){var a=this.start_index+this.max_displayed_videos;this.start_index=(a>this.total_videos)?(a%this.total_videos):a;this.url="http://gdata.youtube.com/feeds/api/videos?key=AI39si690xIAHp_8DqG5hEokggsUWQYd8E26Y3nJ-ipXXS4JuJcxDeWgQmmQGc15gHrvtPOfbytyohhWUeIuKukdP4TPBfUCVQ&category=Travel&v=2&q="+this.video_query_escaped+"&start-index="+this.start_index+"&max-results="+this.max_displayed_videos+"&lr="+this.lang+"&orderby="+this.orderby+"&format=5&alt=json-in-script&callback=?";$.getJSON(this.url,function(data){vwv.video_data=data;vwv.decorate_youtube_video_component(data)})};Vwv.prototype.debug_data=function(data){var entries=data.feed.entry;if(entries){var entry=entries[0];var s="title: "+entry.title.$t+"\nurl: "+entry.media$group.media$content[0].url+"\ndescription: "+entry.content.$t+"\nduration: "+entry.media$group.yt$duration.seconds+"\nthubnail url: "+entry.media$group.media$thumbnail[0].url+"\nthubnail width: "+entry.media$group.media$thumbnail[0].width+"\nthubnail height: "+entry.media$group.media$thumbnail[0].height+"\n";if(entry.gd$rating){s+="rating: "+entry.gd$rating.average+"\nrating count: "+entry.gd$rating.numRaters+"\n"}alert(s)}};Vwv.prototype.rgoto_next_video=function(){var a=this.rstart_index+1;this.rstart_index=(a>this.rtotal_videos)?1:a;this.rurl="http://gdata.youtube.com/feeds/api/videos?key=AI39si690xIAHp_8DqG5hEokggsUWQYd8E26Y3nJ-ipXXS4JuJcxDeWgQmmQGc15gHrvtPOfbytyohhWUeIuKukdP4TPBfUCVQ&category=Travel&v=2&q="+this.rvideo_query_escaped+"&start-index="+this.rstart_index+"&max-results=1&lr="+this.lang+"&orderby="+this.orderby+"&format=5&alt=json-in-script&callback=?";$.getJSON(this.rurl,function(data){vwv.rvideo_data=data;vwv.rdecorate_youtube_video_component(data)})};Vwv.prototype.rgoto_prev_video=function(){this.rstart_index-=1;if(this.rstart_index<=0){this.rstart_index=1;return false}this.rurl="http://gdata.youtube.com/feeds/api/videos?key=AI39si690xIAHp_8DqG5hEokggsUWQYd8E26Y3nJ-ipXXS4JuJcxDeWgQmmQGc15gHrvtPOfbytyohhWUeIuKukdP4TPBfUCVQ&category=Travel&v=2&q="+this.rvideo_query_escaped+"&start-index="+this.rstart_index+"&max-results=1&lr="+this.lang+"&orderby="+this.orderby+"&format=5&alt=json-in-script&callback=?";$.getJSON(this.rurl,function(data){vwv.rvideo_data=data;vwv.rdecorate_youtube_video_component(data)})};Vwv.prototype.rdecorate_youtube_video_component=function(data){if(data.feed.entry){this.rtotal_videos=Number(data.feed.openSearch$totalResults.$t);var entry=data.feed.entry[0];var e=$("#"+this.rtarget_id);e.empty();e.removeClass("hidden");fixIEUnfocus(e.find("embed")[0])}};var custom_vwv=custom_vwv||{};var vwv=new Vwv(custom_vwv);$(document).ready(function(){$.getJSON(vwv.url,function(data){if(vwv.debug){vwv.debug_data(data)}vwv.video_data=data;vwv.decorate_youtube_video_component(data)})});