// Initialize YouTube player.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var done = false;
var player;
function onYouTubePlayerAPIReady() {
	player = new YT.Player('player', {
		height: '480',
		width: '810',
		videoId: 'b8Pz6Z7bDaA',
		events: {
			'onReady': onPlayerReady,
			'onStateChange': onPlayerStateChange
		}
	});
}

function onPlayerReady(evt) { }
function onPlayerStateChange(evt) { }

// Show/Hide main page video.
function showVideo() {
	$('#modal').css('display', 'inline');
	$('#video-wrapper').css('display', 'inline');
	player.playVideo();
}

function hideVideo() {
	$('#modal').css('display', 'none');
	$('#video-wrapper').css('display', 'none');
	player.stopVideo();
}

// Disable right click.
var clickmessage="Right click is disabled on images."

function disableclick(e) {
	if (document.all) {
		if (event.button==2||event.button==3) {
			if (event.srcElement.tagName=="IMG"){
				alert(clickmessage);
				return false;
			}
		}
	}
	else if (document.layers) {
		if (e.which == 3) {
			alert(clickmessage);
			return false;
		}
	}
	else if (document.getElementById){
		if (e.which==3&&e.target.tagName=="IMG"){
			alert(clickmessage)
			return false
		}
	}
}

function associateimages(){
	for(i=0;i<document.images.length;i++)
	document.images[i].onmousedown=disableclick;
}

if (document.all)
	document.onmousedown=disableclick
else if (document.getElementById)
	document.onmouseup=disableclick
else if (document.layers)
	associateimages()
