
function confVideo() {
	flowplayer("player", "/player/flowplayer-3.1.0.swf", {
			clip: {
				scaling: 'fit',
				autoplay: false
			},
			plugins: {
				controls: {
					time: false,
					fullscreen: false
				}
			}
		});
}


 var checkBandwidth = function(result) {
 		if(result){
			// bandwidthCheck is done. Second Class call
			var checkObj = document.getElementById('checkBandwidth');
			//checkObj.removeChild(checkObj.firstChild);
			result = Math.ceil(result);
			if(result < 700){
				var bitrate = '_350.flv';
				var quality = 'LQ';
			}
			if(result > 700 && result < 1300){
				var bitrate = '_700.flv';
				var quality = 'MQ';
			}
			if(result > 1300){
				var bitrate = '_950.flv';
				var quality = 'HQ';
			}

			checkObj.appendChild(document.createTextNode(quality + ': ' + result));
			var playerURL = document.getElementById('player').href;
			document.getElementById('player').href = playerURL + bitrate;
			confVideo();
		}
		else {
  			// writing iFrame with check_b.html
			var tempCheckObj = document.createElement('iframe');
			tempCheckObj.setAttribute('height','0');
			tempCheckObj.setAttribute('width','0');
			tempCheckObj.setAttribute('visibility','hidden');
			tempCheckObj.setAttribute('id','bandCheckIFrame');
			tempCheckObj.setAttribute('src','/check/check_b.html?' + Math.random());
   			//detecting free space for iFrame
			if(document.getElementById('checkFrame')) {
				var iFrameObj = document.getElementById('checkFrame');
			    iFrameObj.appendChild(tempCheckObj);
			}
			//Workaround IE
			document.getElementById('bandCheckIFrame').style.visibility = "hidden";
		}
 }

checkBandwidth(); 


