
countFullScreen = 0

function setFullScreen(){
	countFullScreen++

	setVideoFullScreen()

	var cover = document.getElementById('koya_elem_25_0')
	if(cover && !cover.fullscreenregged){ //yotube
		cover.fullscreenregged = true
		/*cover.addEventListener('click',function(){
			setVideoFullScreen()
		},false)*/
		cover.addEventListener('click',function(){
			setVideoFullScreen()
			var videos = document.getElementsByTagName('VIDEO');
			if(videos[0]) {
				videos[0].pause()
			}
			setTimeout(function(){
				var videos = document.getElementsByTagName('VIDEO');
				if(videos[0]) {
					videos[0].play()
				}
			},200)
		},false)
	}

	
}

function setVideoFullScreen(){

	var videos = document.getElementsByTagName('VIDEO');

	for(var i=0;i<videos.length;i++){
		if(!videos[i].fullscreenregged){
			videos[i].fullscreenregged = true
			videos[i].addEventListener('play',function(e){
				this.webkitEnterFullscreen()
			},false)
			

			/*videos[i].addEventListener('click',function(e){
				console.log(this)
				//alert('this script to fix airplay iOS8')

				this.webkitEnterFullscreen()
			},false)*/

			videos[i].addEventListener('loadstart',function(e){
				console.log(this)
				//alert('this script to fix airplay iOS8')

				this.webkitEnterFullscreen()
			},false)
		}

		if(!videos[i].paused){
			videos[i].webkitEnterFullscreen()
		}
	}

	if(countFullScreen<10){
		setTimeout(setFullScreen,500)
	}

}

setFullScreen()
//(function() { var s = document.createElement("script"); s.src="http://dev.slidego.com/test/airplay.js";document.getElementsByTagName("head")[0].appendChild(s)})()