',{'class':'vid-frame'});\r\n player = ytEmbed(vid,1);\r\n\tframe.append(player);\r\n lightBox(frame,function(){\r\n \tframe.fitVids();\r\n });\r\n}\r\n\r\nvar internalVideoBox = function(vid){\r\n\tvar player = document.createElement('source');\r\n\tplayer.setAttribute('src', vid);\r\n\tplayer.setAttribute('type', 'video/mp4');\r\n\tvar\tvideo = document.createElement('video');\r\n\tvideo.setAttribute(\"controls\", '');\r\n\tvideo.setAttribute(\"autoplay\", '');\r\n\tvideo.append(player);\r\n\tvar\tframe = $('
',{'class':'vid-frame'});\r\n\tframe.append(video);\r\n lightBox(frame,function(){\r\n \tframe.fitVids();\r\n });\r\n}\r\n\r\n// -------------------------\r\n// POPUP VIDS\r\n// -------------------------\r\n$(function(){\r\n\t$('.video-popup-button.video-popup').on('click', function() {\r\n\t\tinternalVideoBox($(this).attr('data-video'));\t\r\n\t});\r\n})\r\n\r\n\r\nwindow.onYouTubeIframeAPIReady = function() {\r\n\t// -------------------------\r\n\t// YT POPUP VIDS\r\n\t// -------------------------\r\n\tvar videoPops = $('.video-popup-button.youtube-popup');\r\n\tvideoPops.click(function(){\r\n\t\tvideoBox($(this).attr('data-video'));\r\n\t});\r\n\r\n\t// -------------------------\r\n\t// INLINE VIDEOS\r\n\t// -------------------------\r\n\tvar videoInline = $('.video-inline');\r\n\tvideoInline.each(function(i){\r\n\t\tvar vid = $(this),\r\n\t\t\tvidID = 'player_' + i,\r\n\t\t\tvidSrc = vid.attr('data-video'),\r\n\t\t\tframe = $('
',{'id':vidID}),\r\n\t\t\tplayer;\r\n\t\tvid.click(function(){\r\n\t\t\tif(!vid.hasClass('active')){\r\n\r\n\t\t\t\tvid.append(frame)\r\n\t\t\t\tframe.fitVids();\r\n\t\t\t\tinlinePlayer[i] = new YT.Player(vidID, {\r\n\t\t\t\t\t\theight: '390',\r\n\t\t\t\t\t\twidth: '640',\r\n\t\t\t\t\t\tvideoId: vidSrc,\r\n\t\t\t\t\t\tplayerVars: {\r\n\t\t \t\t'rel': 0,\r\n\t\t\t 'modestbranding': 1,\r\n\t\t\t\t\t\t\t'disablekb': 1,\r\n\t\t\t\t\t\t\t'controls': 1,\r\n\t\t\t\t\t\t\t'playlist': vidSrc,\r\n\t\t \t\t'fs':0,\r\n\t\t \t\t'autoplay': 1,\r\n\t\t \t\t'autohide': 1,\r\n\t\t \t\t'color': 'white',\r\n\t\t \t\t'ecver':2\r\n\t\t\t },\r\n\t\t\t\t\t\tevents: {\r\n\t\t\t\t\t\t\t'onReady': onPlayerReady,\r\n\t\t \t\t'onPlaybackQualityChange': onPlayerPlaybackQualityChange,\r\n\t\t\t\t\t\t\t'onStateChange': onPlayerStateChange\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\tplayer = inlinePlayer[i];\r\n\t\t\t\tfunction onPlayerReady(event) {\r\n\t\t\t\t\tplayer.playVideo();\r\n\t\t\t\t\tplayer.setVolume(0);\r\n\t\t\t\t\tvid.addClass('active');\r\n\t\t\t\t}\r\n\t\t\t\tvar done = false;\r\n\t\t\t\tfunction onPlayerStateChange(data) {\r\n\t\t\t\t\tif(data.data === 1){\r\n\t\t\t\t\t\tframe.fitVids();\t\t\t\r\n\t\t\t\t\t\tvid.removeClass('paused')\r\n\t\t\t\t\t} else if (data.data === 2){\r\n\t\t\t\t\t\t// PAUSED\r\n\t\t\t\t\t\tvid.addClass('paused');\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tfunction onPlayerPlaybackQualityChange(){\r\n\t\t\t\t\t// \r\n\t\t\t\t}\r\n\t\t\t} else if(vid.hasClass('paused')){\r\n\t\t\t\tplayer.playVideo();\r\n\t\t\t} else{\r\n\t\t\t\tplayer.pauseVideo();\r\n\t\t\t}\r\n\t\t})\r\n\t});\r\n}\r\n\r\n$(function(){\r\n\r\n if($('video').length){\r\n video = document.getElementById(\"video\");\r\n \r\n //autoplay in edge\r\n setTimeout(function(){\r\n video.play();\r\n }, 3000);\r\n \r\n $(window).resize(function(){\r\n //if video container AR is less than 16/9 AR, then set height to make the height 100% of the video container and then overflow width\r\n if($('.background-video').width() / $('.background-video').height() < 16/9){\r\n $('.background-video').find('.video-wrapper').css('width', (16 * $('.background-video').height() / 9));\r\n }else{\r\n $('.background-video').find('.video-wrapper').css('width', \"100%\");\r\n }\r\n }).resize();\r\n }\r\n\r\n});"]}