// JavaScript Document
var mode = "auto";						//inital mode for player, when any video is started it will continue to loop until it is paused once.
var video_cur = 0;
var vid_loop = 0;
var videos = new Array(5);
videos[0] = 'UXztfwVxpHs';
videos[1] = '9gCH4mvXlAI';
videos[2] = '4l6wIzg3SKI';
videos[3] = 'JcUPTHIupz0';
videos[4] = 'csF9Al8Y1go';

 function onYouTubePlayerReady(playerId) {
      ytplayer = document.getElementById("myytplayer");
	  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
    }

function video_change (vid_num) {
	if (ytplayer) {
		for (var i = 0; i < 5; i++) {
			if (i == vid_num) {
				document.getElementById('vid_btn'+i).className = "video-btn2";
			} else {
				document.getElementById('vid_btn'+i).className = "video-btn0";
			}
		} 
		ytplayer.loadVideoById(videos[vid_num]);
	}	
}

function onytplayerStateChange(newState) {
	//alert (newState);
   	if ((newState == 0) && (vid_loop == 0)) {
		if (video_cur == 4) {
			video_cur = 0;
			vid_loop=1;							//setup vid_loop =1 to stop auto-looping.
		} else {
			video_cur += 1;
		}
		video_change(video_cur);
	}
}

function video_resize (size) {
	switch (size) {
		case 'small' :
			ytplayer.width = "425";
			ytplayer.height = "344";
			document.getElementById('size_btn0').className = "video-btn2";
			document.getElementById('size_btn1').className = "video-btn0";
			document.getElementById('size_btn2').className = "video-btn0";
			break;
		case 'medium' :
			ytplayer.width = "800";
			ytplayer.height = "648";
			document.getElementById('size_btn0').className = "video-btn0";
			document.getElementById('size_btn1').className = "video-btn2";
			document.getElementById('size_btn2').className = "video-btn0";
			break;
		case 'large' :
			ytplayer.width = "1024";
			ytplayer.height = "828";
			document.getElementById('size_btn0').className = "video-btn0";
			document.getElementById('size_btn1').className = "video-btn0";
			document.getElementById('size_btn2').className = "video-btn2";
			break;
	}
	location.href = "#OpenBicVideo";
	//alert(size);
}

function video_mouseover (obj) {
	if (obj.className != "video-btn2") {
		obj.className = "video-btn1";
	}
}

function video_mouseout (obj) {
	//alert(obj.className);
	if (obj.className != "video-btn2") {
		obj.className = "video-btn0";
	}
}

function size_mouseover (obj) {
	if (obj.className != "video-btn2") {
		obj.className = "video-btn1";
	}
}
function size_mouseout (obj) {
	if (obj.className != "video-btn2") {
		obj.className = "video-btn0";
	}
}

function wmp_fs() {
	try {
		player1.fullScreen=true;
	}
	catch (e) { }
	//alert(vid.fullScreen);
}


