/* This js handles the rounded corners formatting, and dynamic text that is dependent on the current video playing in the youtube playlist */

$(document).ready(function() {
	Nifty("h2", "small normal");
	Nifty("#pdf_sidebar div", "big bottom tl");
}); 
/* ==================================== 
 Youtube API Javascript stuff
====================================*/
google.load("swfobject", "2.1");

// Update a particular HTML element with a new value
function updateHTML(elmId, value) {
document.getElementById(elmId).innerHTML = value;
}

// This function is called when an error is thrown by the player
function onPlayerError(errorCode) {
alert("An error occured of type:" + errorCode);
}

// This function is called when the player changes state
function onPlayerStateChange(newState) {
updateHTML("playerState", newState);
}

// Display information about the current state of the player, the file size by bytes is used to identify what text to display
function updatePlayerInfo() {

// Also check that at least one function exists since when IE unloads the
// page, it will destroy the SWF before clearing the interval.
	if(ytplayer && ytplayer.getDuration) {
		switch (ytplayer.getVideoBytesTotal())
		{
			case 9581099:
				updateHTML("vidtext", "<strong>Discovering People's Needs to Get What You Want</strong><p> See how Alan describes how you negotiate in every aspect of your life. When you know how to discover other people's needs, you also discover that you can also get what you want. Alan begins to tell the audience the three things they need to get what they want.</p>");
				break;
			case 2303807:
				updateHTML("vidtext", "<strong>Change Results in Growth</strong><p>Dealing with change is good business. Businesses need to face change head on by helping their employees learn communication tools to push through anxiety and conflict. When your business is prepared for change you have the opportunity to move forward.</p>");
				break;
			case 1045033:
				updateHTML("vidtext", "<strong>A Commitment to Understanding How Others Think </strong><p>How we see is different from how others see. To effectively communicate with others we must be able to understand they way they see things. Everyone has different filters and perceptions and once you recognize their outlook, it becomes much easier for you to communicate with them.</p>");
				break;
			case 838826:
				updateHTML("vidtext", "<strong>Quick Thinking When Things Inevitably Go Wrong</strong><p>See how Alan Ovson responds positively when things inevitable go wrong. While delivering a keynote speech to over 400 people, Alan kept the audience focused and entertained despite continuous amplification difficulties. He demonstrates the need for businesses to improvise so they too can respond positively to difficult situations.</p>");
				break;
			default:
				updateHTML("vidtext", "Please play a video to see more details");
		}
	}
}

// This function is automatically called by the player once it loads
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("ytPlayer");
// This causes the updatePlayerInfo function to be called every 250ms to
// get fresh data from the player
setInterval(updatePlayerInfo, 250);
updatePlayerInfo();
ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
ytplayer.addEventListener("onError", "onPlayerError");
}

// The "main method" of this sample. Called when someone clicks "Run".
function loadPlayer() {
// The video to load
var videoID = "6A8B5C9775F4652A"
// Lets Flash from another domain call JavaScript
var params = { allowScriptAccess: "always" };
// The element id of the Flash embed
var atts = { id: "ytPlayer" };
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
swfobject.embedSWF("http://www.youtube.com/p/" + videoID + 
				   "&amp;enablejsapi=1&amp;playerapiid=player1", 
				   "videoDiv", "300", "250", "8", null, null, params, atts);
}
function _run() {
loadPlayer();
}
google.setOnLoadCallback(_run);
//End Youtube API code
