$(document).ready(function (){
	//MSIE version finder
	 function msieversion()
   {
      var ua = window.navigator.userAgent
      var msie = ua.indexOf ( "MSIE " )

      if ( msie > 0 )      // If Internet Explorer, return version number
         return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
      else                 // If another browser, return 0
         return 10
		 

   }
	
	//If IE is lower than 9 add flowplayer
	if( msieversion() <= 9){
	
	flowplayer("DNNfeatured",{src: '/portals/0/pages/home/videoplayer/video/DNN_featured.swf'}, {
		clip:  {
			onFinish: function(){
				videoEnd();
				}
		}

	});
	$('video').hide();
	}


	//video variable
	var vElement = document.getElementById('video-01');

	//close the video
	$('#featureVideoClose').click(function (){
		$('#featureVideoOverlay').css('display','none');
		if(msieversion() == 10){
		vElement.currentTime = 0;
		vElement.pause();
		}
		if( msieversion() <= 9){
		$f().unload().stop();
		}
	});

	//open the video
	$('#HomeBanner_right').click(function (){
		$('#featureVideoOverlay').css('display','block');
		if( msieversion() == 10){
		vElement.play();
		}
		if( msieversion() <= 9){
		$f().seek(2).play();
		}
	});
	
	//when the video ends
	$("#video-01").bind("ended", function() {
		$('#featureVideoOverlay').css('display','none');
		vElement.pause();
	});

	//set autobuffer to true for HTML5 video
	document.getElementById('video-01').autobuffer = true;
	
	//videoEnd
	function videoEnd(){
		$('#featureVideoOverlay').css('display','none');
		}

	
});
