			
			
			
			var isArchive;			
			var nMediaPlayerVersion;
			var ProgressBar;
			var nAdditionWidth;
			var nAdditionHeight;
			
			var StatusBar = false; // a flag so we won't render more than one progress bar
			var oldValue = -1; // last status of progressbar (to compare with)
			var currFunc;
			var timeHandle; // used for the monitoring interval
			var counter=0;
			var nextFunc;
			
		


			
			// step 0 for both live and archived programs - start the process
			function manageInitBWCheck()
			{
				counter=0;
				initBWCheck();
			}
			
			
			// show splash screen
			// start the first step of each program type (loading GUI images/checking speed)
			function initBWCheck()
			{				
				drawSplashScreen();				
				
				var pNextFunc;
				if (isArchive)
				{
					pNextFunc= new Function("manageStartLoadingContent(50);");				
					startLoadingGuiImages();					
				}
				else
				{
					pNextFunc = new Function("manageSetBW(50);");				
					startSpeedCheck(); 		
				}
				startMonitoring(initBWCheck, pNextFunc);
			}

			
			
			// pFunc - the fucntion that we are monitoring
			// pNext - the function to which we will redirect if monitring fails
			function startMonitoring(pFunc, pNextFunc)
			{				
				currFunc = pFunc;
				nextFunc = pNextFunc;				
				oldValue = -1;
				clearInterval(timeHandle);
				timeHandle = setInterval(monitor,2000);	
			}
			
			// check if a process got stuck and if yes - restart it/skip it
			function monitor()
			{				
				if (oldValue == -1)
				{
					oldValue = ProgressBar.m_nCurrentValue;						
					return;
				}				
				
				// got stuck - restart process or skip				
				if (oldValue == ProgressBar.m_nCurrentValue)
				{					 
					if (counter>0)	// skip after 3 attempts
					{						
						counter=0;
						clearInterval(timeHandle);
						nextFunc(); //skip to the next function
						return;
					}				
					
					counter++;
					clearInterval(timeHandle);					 
					currFunc();
					return;
				}				
				oldValue = ProgressBar.m_nCurrentValue;
			}
			
			
			function drawSplashScreen()
			{
				document.body.all["SpashImage"].style.visibility="visible";	
				var DesieredWidth = 600;
				var DesieredHeight = 400;
				
				try {
					//window.resizeTo(DesieredWidth, DesieredHeight);
					nAdditionWidth = 10;//DesieredWidth - document.body.clientWidth;
					nAdditionHeight = 81;//DesieredHeight - document.body.clientHeight;
					//window.resizeBy(nAdditionWidth, nAdditionHeight);
				} catch (e) {
					// to prevent "access denied" message
				}
				
			
				if (!StatusBar)
				{
					ProgressBar = new ProgBar(260, 100, 42, 70, 38, document.body, false, "Checking your Network Connection");
					StatusBar = true;
				}
			}
			
			
			function setImagesNum(nNumOfImages)
			{
				ProgressBar.reset(nNumOfImages, 0, "Downloading Graphics - Step 1 of 2 <br>click <a href='javascript:skip2StartLoadingContent()'> here</a> to skip", document.body);
			}
			function startLoadModule(nNumOfImages)
			{				
				ProgressBar.reset(nNumOfImages, 0, "Downloading Graphics - Step 2 of 2 <br>click <a href='javascript:startApplication()'> here</a> to skip",  document.body);
			}
			
			function moduleImgLoaded()
			{
				ProgressBar.incValue(1, document.body);
			}
			function cachedImageLoaded()
			{
				try {
					ProgressBar.incValue(1, document.body);
				}
				catch(e)
				{
					top.status="Error in cached";
				}				
			}
			
			function posWindowReturnURL()
			{
				hideAllItems();
				var nAppWidth = 941 + nAdditionWidth;
				var nAppHeight = 656 + nAdditionHeight;
				var ScreenWidth = screen.width;
				var ScreenHeight = screen.height;
				var nXPos = (ScreenWidth - nAppWidth) / 2;
				var nYPos;
				if (ScreenWidth < 850)
					nYPos = ((nAdditionHeight - 2)* -1);
				else
					nYPos = (ScreenHeight - nAppHeight) / 2;
				try {
					window.moveTo(nXPos, nYPos);
					window.resizeTo(nAppWidth, nAppHeight);
				} catch (e) {
					// to prevent "access denied" message
				}
				
				var retVal;
				if (nVideoWidth>200)					
					retVal= "Student_big.aspx";
				else
					retVal= "Student.aspx";	
					
				return retVal;
			}
			
			function hideAllItems()
			{	
				document.body.style.backgroundImage="none";
				document.bgColor="white";
				var coll = document.body.all;

				if (coll != null) 
				{
					for (var i=0; i < coll.length; i++)
					{
						coll.item(i).style.visibility="hidden";
					}
				}
			}
			
			function incBWStatus()
			{		
				try
				{		
				ProgressBar.m_Obj = document.body;
				ProgressBar.incValue(1, document.body);
				}
				catch(err)
				{
				
				}
			}
			
			
			function setMPVersion()
			{
				nMediaPlayerVersion = 6;
				var pWMP=null;
				try
				{
					pWMP=new ActiveXObject("WMPlayer.OCX")
					if (pWMP != null)
					{
						if (pWMP.versionInfo.indexOf("9") == 0)
						{
							nMediaPlayerVersion = 9;
							return;
						}
						if (pWMP.versionInfo.indexOf("8") == 0)
						{
							nMediaPlayerVersion = 8;
							return;
						}
						if (pWMP.versionInfo.indexOf("10") == 0)
						{
							nMediaPlayerVersion = 10;
							return;
						}
						if (pWMP.versionInfo.indexOf("11") == 0)
						{
							nMediaPlayerVersion = 11;
							return;
						}
						if (pWMP.versionInfo.indexOf("12") == 0)
						{
							nMediaPlayerVersion = 12;
							return;
						} 								
						
						
					}
				}
				catch (Error)
				{
					nMediaPlayerVersion = 6;
				}
				
			}
			
