
var ttt,ttt2;

<!-- Standard GA Page Tag -->


function setCookie2(c_name,value)
{
var expiredays=999;
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie2(c_name)
    {
      try {
      if (document.cookie.length>0)
      {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        {
          c_start=c_start + c_name.length+1;
          c_end=document.cookie.indexOf(";",c_start);
          if (c_end==-1) c_end=document.cookie.length;
          cook=unescape(document.cookie.substring(c_start,c_end));
          return cook;
        }
      }
      } catch (ex) {}
      return ''; //100
    }


/**
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); 
  document.write("<script src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>" + "</sc" + "ript>");
**/ 



/**
        var pageTracker = _gat._getTracker("UA-30208-1");
        pageTracker._initData();
        pageTracker._trackPageview();
        var ytpEventTracker = pageTracker._createEventTracker("YouTube Video Player");

*/
  var vidp='';
var vids=0;
var vidstop=0;
var mini=false;
        // Create the event tracking object
        var eventLabel;
	var nowPlaying;
/**/


function setMini() {
  mini=true;
}


function setMiniOff() {
  mini=false;
}


        function updateHTML(elmId, value) {
          ///document.getElementById(elmId).innerHTML = value;
if (mini==false) adju(value*320/getDuration());
        }

        function setytplayerState(newState) {
          ///updateHTML("playerstate", newState);
	  if (translateYTPState(newState) == 'ended' && parseInt(getCurrentTime()) > 0) { 
            recordEnd(eventLabel,parseInt(getCurrentTime()));
          }
        }

        function onYouTubePlayerReady(playerId) {
          ytplayer = document.getElementById("myytplayer");
///          ytplayer = document.getElementById(playerId);
//alert(playerId);
if (vids==1) mini=true;

//alert(ytplayer);
//ytplayer.setPlaybackQuality("hd720");
          setInterval(updateytplayerInfo, 1000);
          updateytplayerInfo();
          ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
/*          ytpEventTracker._trackEvent("Player Loaded", eventLabel);
*/
//var ytQuality = '&amp;ap=%2526fmt%3D18';
//alert(vidp);
///if (mini==false) 
{
setVolume(0);
startNewVideo(vidp,vids); //('fPuUHtoRBUE');
setVolume(0);
}
//ytplayer.setPlaybackQuality("hd720");
///setTimeout('abc()',10000);
	}

function goVideo() {
setVolume(0);
startNewVideo(vidp,vids); //('fPuUHtoRBUE');
setVolume(0);
}

        function onytplayerStateChange(newState) {
          setytplayerState(newState);

if (newState==1) {
  setVolume(0);
  fadeVolUp();
 try {
   //showCont();
   if (mini==false) document.getElementById('cont').style.visibility='';
 } catch (exx) {}
}

//alert(newState);
if (newState==0) {
//alert("end");
try {
  fadeVolDown();
  if (mini==false) setTimeout('closeP()',700);
} catch (exx) {}
}
        }

        function translateYTPState(state) {
/**/
if ((state==1) || (state==59)) {
  //alert(ytplayer.getAvailableQualityLevels()[1]);
  ////////////setTimeout('abc()',300);
}
/**/



          switch (state) {
            case -1: return "unstarted";
            case 0 : return "ended";
            case 1 : return "playing";
            case 2 : return "paused";
            case 3 : return "buffering";
            case 5 : return "video cued";
          }
          return;
        }

/**/
function abc() {
  if (mini==false) ytplayer.setPlaybackQuality("large");
  //alert('abc');
}
/**/

        function onPlayerError(errorCode) {
          alert("An error occurred: "+ errorCode);
/*          ytpEventTracker._trackEvent("Error: " + errorCode, eventLabel);
*/
        }

var zzz=0;

        function updateytplayerInfo() {
if ((vidstop>0) && (getCurrentTime()>=vidstop-3)) {
  fadeVolDown();
  setTimeout('closeP()',1000);
}

if (getCurrentTime()>getDuration()-3) {
  fadeVolDown();
}
zzz++;
if (zzz>=10) {
zzz=0;
          //updateHTML("bytesloaded", getBytesLoaded());
          //updateHTML("bytestotal", getBytesTotal());
          //updateHTML("videoduration", getDuration());
///////          if (mini==false) updateHTML("videotime", getCurrentTime());
          //updateHTML("startbytes", getStartBytes());
          //updateHTML("volume", getVolume());
}
        }

        // functions for the api calls
        function loadNewVideo(id, startSeconds) {
          if (ytplayer) {
            setVolume(0);
//alert(ytplayer.getAvailableQualityLevels()[1]);

/**/
if (mini) {
  ytplayer.loadVideoById(id, startSeconds, 'small');
} else 
/**/
{

/*
if (getCookie2('vq')=="LQ") {
ytplayer.loadVideoById(id, startSeconds);//,'hd720');
document.getElementById("lq").style.color="white";
document.getElementById("hq").style.color="#aaaaaa";
} else {
ytplayer.loadVideoById(id, startSeconds,'large');
document.getElementById("hq").style.color="white";
document.getElementById("lq").style.color="#aaaaaa";
}
*/

if (getCookie2('vq')=="HQ") {
ytplayer.loadVideoById(id, startSeconds,'large');
document.getElementById("hq").style.color="white";
document.getElementById("lq").style.color="#aaaaaa";
} else {
ytplayer.loadVideoById(id, startSeconds);//,'hd720');
document.getElementById("lq").style.color="white";
document.getElementById("hq").style.color="#aaaaaa";
}

}

	  }
        }

        function cueNewVideo(id, startSeconds) {
          if (ytplayer) {
            
//alert(ytplayer.getAvailableQualityLevels()[1]);
if (getCookie2('vq')=="HQ") {
ytplayer.cueVideoById(id, startSeconds,'large');
document.getElementById("hq").style.color="white";
document.getElementById("lq").style.color="#aaaaaa";
} else {
ytplayer.cueVideoById(id, startSeconds);//,'hd720');
document.getElementById("lq").style.color="white";
document.getElementById("hq").style.color="#aaaaaa";
}
          }
        }

	function startNewVideo (a,b) {
	  // if there is a current video playing, record the end
	  var oldTime = parseInt(getCurrentTime());
          var oldEventLabel = eventLabel;

          if (oldTime > 0) { 
	    recordEnd(oldEventLabel, oldTime);
	  }	

	  ///eventLabel = document.getElementById('loadvideoid').options[document.getElementById('loadvideoid').selectedIndex].text;
	  loadNewVideo(a, b);
/*          ytpEventTracker._trackEvent("Video Started", eventLabel);
*/
	}

        function recordEnd(l,t) {
/*            ytpEventTracker._trackEvent("Ended", l, parseInt(t));
*/
        }

        function play() {
          if (ytplayer) {
            ytplayer.playVideo();
/*            ytpEventTracker._trackEvent("Play",eventLabel);
*/
          }
        }

function playvid() {
          if (ytplayer) {
            ytplayer.playVideo();
/*            ytpEventTracker._trackEvent("Play",eventLabel);
*/
          }
        }

        function pause() {
          if (ytplayer) {
            ytplayer.setVolume(0);
            ytplayer.pauseVideo();
/*            ytpEventTracker._trackEvent("Pause",eventLabel);
*/
	  }
        }



        function stop() {
          if (ytplayer) {
            ytplayer.stopVideo();
/*            ytpEventTracker._trackEvent("Stop",eventLabel);
*/
          }
        }

        function getPlayerState() {
          if (ytplayer) {
            return ytplayer.getPlayerState();
          }
        }


function seek(value) {
  //value=value-10; 
  if (value<0) value=0;
  x=value*getDuration()/320;
  if (x<0) x=0;
  if (x>getDuration()-5) x=getDuration()-5;
  seekTo(x);
  updateytplayerInfo();
}

        function seekTo(seconds) {
          if (ytplayer) {
            ytplayer.seekTo(seconds, true);
/*            ytpEventTracker._trackEvent("Seek To: " + seconds, eventLabel); 
*/
          }
        }

        function getBytesLoaded() {
          if (ytplayer) {
            return ytplayer.getVideoBytesLoaded();
          }
        }

        function getBytesTotal() {
          if (ytplayer) {
            return ytplayer.getVideoBytesTotal();
          }
        }

        function getCurrentTime() {
          if (ytplayer) {
            return ytplayer.getCurrentTime();
          }
        }

        function getDuration() {
          if (ytplayer) {
            return ytplayer.getDuration();
          }
        }

        function getStartBytes() {
          if (ytplayer) {
            return ytplayer.getVideoStartBytes();
          }
        }

        function mute() {
          if (ytplayer) {
            ytplayer.mute();
/*            ytpEventTracker._trackEvent("Mute",eventLabel);
*/
          }
        }

        function unMute() {
          if (ytplayer) {
            ytplayer.unMute();
/*            ytpEventTracker._trackEvent("Unmute",eventLabel);
*/
          }
        }
        
        function getEmbedCode() {
          alert(ytplayer.getVideoEmbedCode());
/*	  ytpEventTracker._trackEvent("Get Embed Code", eventLabel); 
*/
        }

        function getVideoUrl() {
          alert(ytplayer.getVideoUrl());
/*          ytpEventTracker._trackEvent("Get Video URL", eventLabel); 
*/
	}
        
        function setVolume(newVolume) {
          if (ytplayer) {
            ytplayer.setVolume(newVolume);
          }
        }

function fadeVolUp() {  try {clearTimeout(ttt2);} catch (exxx) {}
  vol=getVolume();
  if (vol<100) {
    vol=vol+6; if (vol>100) vol=100;
    setVolume(vol);
    if (vol<100) ttt=setTimeout('fadeVolUp()',120);
  }
}

function fadeVolDown() {  try {clearTimeout(ttt);} catch (exxx) {}
  vol=getVolume();
  if (vol>0) 
  {
    ///vol=vol-8; 
    vol=3*vol/4;
    if (vol<2) vol=0;
    setVolume(vol);
    if (vol>0) ttt2=setTimeout('fadeVolDown()',75);
  }
}

        function getVolume() {
          if (ytplayer) {
            return ytplayer.getVolume();
          }
        }

        function clearVideo() {
          if (ytplayer) {
            ytplayer.clearVideo();
          }
        }
        

function closePlayer() {
  try {
    stop();
    ytplayer=null;
  } catch (exx) {}
}

	function lq() {
if (mini==false) {
fadeVolDown();
setTimeout('lq2()',900);
}
	}

	function lq2() {
  ytplayer.setPlaybackQuality('medium');
   //alert('LQ');
      document.getElementById("lq").style.color="white";
document.getElementById("hq").style.color="#aaaaaa";
setCookie2('vq','LQ');
}

	function hq() {
if (mini==false) {
fadeVolDown();
setTimeout('hq2()',900);
}
	}

function hq2() {
  ytplayer.setPlaybackQuality('large');
    document.getElementById("hq").style.color="white";
document.getElementById("lq").style.color="#aaaaaa";
setCookie2('vq','HQ');
}
    