﻿var player1, 
    player2;
    
var videoID1 = "Z15eC1v4PZk", 
    videoID2 = "sCAJl50vjn4", 
    videoID3 = "gWphyGzeWBU",
    videoID7 = "qcf8sNK8YqA",
    videoID5 = "5UVf3fpcQGc",
    videoID6 = "cX9OkExrxn0",
    videoID4 = "DZhxlJaxmAo";

var currentVideo = videoID5;
    

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.




      var tag = document.createElement('script');
      tag.src = "http://www.youtube.com/player_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.

      function onYouTubePlayerAPIReady() {
        player1 = new YT.Player("player1", {
            height: "518",
            width: "960",
            videoId: currentVideo,
            events: {
            "onReady": showReady
            
            }
        });
      }
      
// 4. The API will call this function when the video player is ready.
      function onPlayerReady(event) {
        event.target.playVideo();
      }

      // 5. The API calls this function when the player's state changes.
      //    The function indicates that when playing a video (state=1),
      //    the player should play for six seconds and then stop.
      var done = false;
      
      function stopVideo() {
        
//            if(!$.browser.mozilla){player1.stopVideo();}
//            console.log("stop video called");
            //player2.stopVideo();
      }
      
    function showReady(){
        player1.cueVideoById(currentVideo);
        videoReady = true;
    }
    
$(document).ready(function(){
    $(".close-btn").click(function(){
        $('#iframe').hide();
        $('#videoWholePage').hide();
        player1.stopVideo();
    });
});

