var agent=navigator.userAgent.toLowerCase();
if(agent.indexOf('iphone')==-1 && agent.indexOf('android')==-1 && agent.indexOf('ipad')==-1) {
if (!!document.createElement('video').play) {



	window.addEventListener('load',function() {

		var video=document.getElementById('player');

	

		/* remove the controls attribute */

		video.removeAttribute('controls');

	

		/* wrap the video in a div, so we can absolutely position the new controller in there */

		var container=document.createElement('div');

		container.style.position='relative';

		video.parentNode.insertBefore(container,video);

		video.parentNode.removeChild(video);

		container.appendChild(video);

		

		/* create the controller - we're using innerHTML here for expediency */

		var controller = document.createElement('div');

		controller.id="controls";

		video.parentNode.appendChild(controller);
		/* old:
		controller.innerHTML='<button id="playpause"><img src="images/video%20carousel/video%20controls/play.png" width="21" height="14" alt="play"></button><button id="prev"><img src="images/video carousel/video controls/prev.png" width="21" height="14" alt="prev"></button><button id="next"><img src="images/video carousel/video controls/next.png" width="21" height="14" alt="next"></button><img src="images/video carousel/video controls/vol5.png" width="21" height="14" alt="volume" id="volumeicon"><input type="range" min="0" max="1" step="0.1" id="volume">';
		*/
		
		controller.innerHTML='<div class="divider"></div><div class="vidctrl"><button id="playpause"><img src="/images/vidcontrols/play.png" alt="play"></button></div><div class="divider"></div>';


		/* set the value of the volume slider to match that of the video (should be 1, but just in case) 

		document.getElementById('volume').value = video.volume;

		

		/* listen for timeupdate and update the time display in the controller

		video.addEventListener('timeupdate',function(e) {

			/* split currentTime (seconds) into separate hour/minute/second strings

			var s=e.target.currentTime;

			var h=Math.floor(s/3600);

			s=s%3600;

			var m=Math.floor(s/60);

			s=Math.floor(s%60);


			if (s.toString().length < 2) s="0"+s;

			if (m.toString().length < 2) m="0"+m;

			

			document.getElementById('display').innerHTML = h+":"+m+":"+s;

		}, true);
 */


		/* when video actually starts playback, update the play/pause button */

		video.addEventListener('play',function(e) {

			document.getElementById('playpause').innerHTML='<img src="/images/vidcontrols/pause.png" width="21" height="14" alt="pause">';

		}, true);



		/* when video actually pauses, update the play/pause button */	

		video.addEventListener('pause',function(e) {

			document.getElementById('playpause').innerHTML='<img src="/images/vidcontrols/play.png" width="21" height="14" alt="play">';

		}, true);



		/* when video reahes the end, update the play/pause button */		

		video.addEventListener('ended',function(e) {

			document.getElementById('playpause').innerHTML='<img src="/images/vidcontrols/play.png" width="21" height="14" alt="play">';

		}, true);



		/* determine what to do if the play/pause button has been clicked */

		document.getElementById('playpause').addEventListener('click',function() {

			

			if (document.getElementById('player').paused) {

				/* if video is currently paused, play it */

				document.getElementById('player').play();

			} else {

				/* video isn't paused... */

				if (document.getElementById('player').ended) {

					/* if we're at the end, reset currentTime and play */

					document.getElementById('player').currentTime=0;

					document.getElementById('playpause').innerHTML='<img src="/images/vidcontrols/pause.png" width="21" height="14" alt="pause">';

					document.getElementById('player').play();

				} else {

					/* otherwise, just pause */

					document.getElementById('player').pause();

				}

			}

		}, true);

		

	}, true);

}	
}
