///////////////////////////////////////////////////////////////////////////////////
////////                  Begin Operating System Checker                 //////////
///////////////////////////////////////////////////////////////////////////////////

function getOS(obj) {

    var os=new Array("unknown", "unknown");

    (isEmpty(obj) ? brs=navigator.userAgent.toLowerCase() : brs=obj);

    if (brs.search(/windows\sce/) != -1) {
        os[0]="wince";
        try {
            os[1]=brs.match(/windows\sce\/(\d+(\.?\d)*)/)[1];
        } catch (e) { }
        return os;
    } else if ( (brs.search(/windows/) !=-1) || ((brs.search(/win9\d{1}/) !=-1))
) {
        os[0]="Windows";
        if (brs.search(/nt\s5\.1/) != -1) {
            os[1]="XP";
        } else if (brs.search(/nt\s5\.0/) != -1) {
            os[1]="2000";
        } else if ( (brs.search(/win98/) != -1) || (brs.search(/windows\s98/)!=
-1 ) ) {
            os[1]="98";
        } else if (brs.search(/windows\sme/) != -1) {
            os[1]="ME";
        } else if (brs.search(/nt\s5\.2/) != -1) {
            os[1]="Windows 2003";
        } else if ( (brs.search(/windows\s95/) != -1) || (brs.search(/win95/)!=
-1 ) ) {
            os[1]="95";
        } else if ( (brs.search(/nt\s4\.0/) != -1) || (brs.search(/nt4\.0/) ) !=
-1) {
            os[1]="NT 4.0";
        }

        return os;
    } else if (brs.search(/linux/) !=-1) {
        os[0]="linux";
        try {
            os[1] = brs.match(/linux\s?(\d+(\.?\d)*)/)[1];
        } catch (e) { }
        return os;
    } else if (brs.search(/mac\sos\sx/) !=-1) {
        os[0]="macosx";
        return os;
    } else if (brs.search(/freebsd/) !=-1) {
        os[0]="freebsd";
        try {
            os[1] = brs.match(/freebsd\s(\d(\.\d)*)*/)[1];
        } catch (e) { }
        return os;
    } else if (brs.search(/sunos/) !=-1) {
        os[0]="sunos";
        try {
            os[1]=brs.match(/sunos\s(\d(\.\d)*)*/)[1];
        } catch (e) { }
        return os;
    } else if (brs.search(/irix/) !=-1) {
        os[0]="irix";
        try {
            os[1]=brs.match(/irix\s(\d(\.\d)*)*/)[1];
        } catch (e) { }
        return os;
    } else if (brs.search(/openbsd/) !=-1) {
        os[0]="openbsd";
        try {
            os[1] = brs.match(/openbsd\s(\d(\.\d)*)*/)[1];
        } catch (e) { }
        return os;
    } else if ( (brs.search(/macintosh/) !=-1) || (brs.search(/mac\x5fpowerpc/)
!= -1) ) {
        os[0]="macclassic";
        return os;
    } else if (brs.search(/os\/2/) !=-1) {
        os[0]="os2";
        try {
            os[1]=brs.match(/warp\s((\d(\.\d)*)*)/)[1];
        } catch (e) { }
        return os;
    } else if (brs.search(/openvms/) !=-1) {
        os[0]="openvms";
        try {
            os[1]=brs.match(/openvms\sv((\d(\.\d)*)*)/)[1];
        } catch (e)  { }
        return os;
    } else if ( (brs.search(/amigaos/) !=-1) || (brs.search(/amiga/) != -1) ) {
        os[0]="amigaos";
        try {
            os[1]=brs.match(/amigaos\s?(\d(\.\d)*)*/)[1];
        } catch (e) { }
        return os;
    } else if (brs.search(/hurd/) !=-1) {
        os[0]="hurd";
        return os;
    } else if (brs.search(/hp\-ux/) != -1) {
        os[0]="hpux";
        try {
            os[1]=brs.match(/hp\-ux\sb\.[\/\s]?(\d+([\._]\d)*)/)[1];
        } catch (e) { }
        return os;
    } else if ( (brs.search(/unix/) !=-1) || (brs.search(/x11/) != -1 ) ) {
        os[0]="unix";
        return os;
    } else if (brs.search(/cygwin/) !=-1) {
        os[0]="cygwin";
        return os;
    } else if (brs.search(/java[\/\s]?(\d+([\._]\d)*)/) != -1) {
        os[0]="java";
        try {
            os[1]=brs.match(/java[\/\s]?(\d+([\._]\d)*)/)[1];
        } catch (e) { }
        return os;
    } else if (brs.search(/palmos/) != -1) {
        os[0]="palmos";
        return os;
    } else if (brs.search(/symbian\s?os\/(\d+([\._]\d)*)/) != -1) {
        os[0]="symbian";
        try {
            os[1]=brs.match(/symbian\s?os\/(\d+([\._]\d)*)/)[1];
        } catch (e) { }
        return os;
    } else {
        os[0]="unknown";
        return os;
    }
}

function isEmpty(input) {
    return (input==null || input =="")
}

// Does this string contain a dot?
function hasDot(input) {
    return (input.search(/\./) == -1)
}
function getVersion()
{	var os=new Array(2);
	os=getOS();
	document.write("<b>Operating System: </B><br>"+os[0] + " " + os[1] + "<br />");
	document.write("<br><b>WMP Versions Installed:</b><br>");
}


///////////////////////////////////////////////////////////////////////////////////
////////                  End Operating System Checker                   //////////
///////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////
////////               Begin Windows Media Player Checker                //////////
///////////////////////////////////////////////////////////////////////////////////

var fHasMP1  = false;	// Your Version Is Here
var fHasMP2  = false;	// Intended values for WMP 10
var fHasMP   = false;	// What you have compared to WMP 10
var fHasMP3  = false;	// Intended values for WMP 9
var fHasMP4  = false;	// What you have compared to WMP 9

function ignoreerror()
	{	return true;
	}
	
window.onerror=ignoreerror; 
fHasMP1  =  navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"]     &&  
navigator.mimeTypes["video/x-ms-wm"].enabledPlugin;

//Compare to WMP 10
if (typeof(WMPlay10) != "undefined")
	{	fHasMP2 = (WMPlay10.FileName == "");
	}
fHasMP  = fHasMP1  || fHasMP2;

//Compare to WMP 9
if (typeof(WMPlay9) != "undefined")
	{	fHasMP4 = (WMPlay9.FileName == "");
	}
fHasMP3  = fHasMP1  || fHasMP4;

///////////////////////////////////////////////////////////////////////////////////
////////               End Windows Media Player Checker                  //////////
///////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////
////////                Begin Newest WMP Version Checker                 //////////
///////////////////////////////////////////////////////////////////////////////////
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;
	
	function checkIt(string)
	{	place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}
	
	function setBrowserVar()
	{	var IE	= false;
		var NS	= false;
				
		if (checkIt(msie))
		{	IE = true;
		}
		else
		{	NS = true	
		}
	}
	
	function check_browser()
	{	if (IE)
		{	IE();
		}
		else if (NS)
		{	FF();
		}
	}
	
	

	function spawnUpdate()
	{	window.open("http://www.microsoft.com/windows/windowsmedia/player/download/download.aspx",'Update','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=531,height=307');
	}  
	
	function writeUpdate()
		{	var os=new Array(2);
			os=getOS();  
			if (os[0] =="Windows")
			{	if (checkIt('msie'))
				{	if (os[1] == "XP")
						{	if (fHasMP)	// Check if they have WMP 10
									{	document.write('<a href=javascript:help()>Having Trouble Connecting?</a> : ');
									}
							else
									{	document.write('<a href=javascript:help()>Having Trouble Connecting?</a> : <a href=javascript:spawnUpdate()>Please update Windows Media Player.</a> : ');
									}						
						}
						else
						{	if (fHasMP3)  // Check if they have WMP 9
									{	document.write('<a href=javascript:help()>Having Trouble Connecting?</a> : ');
									}
							else
									{	document.write('<a href=javascript:help()>Having Trouble Connecting?</a> : <a href=javascript:spawnUpdate()>Please update Windows Media Player.</a> : ');
									}
						}
				}
				else 
				{	document.write('<a href=javascript:help()>Having trouble connecting?</a>');
				}
			}
			else 
			{		document.write('<a href=#>We recommend Windows</a> : ');
			}
		}
	function checkUpdate()
		{	var os=new Array(2);
			os=getOS();  
			if (os[0] =="Windows")
			{	if (checkIt('msie'))
				{	if (os[1] == "XP")
						{	if (fHasMP)	// Check if they have WMP 10
									{	document.write("The script has determined you have the newest version, therefore you must have a different problem.<br>");
									}
							else
									{	document.write("<font color=\"#FF0000\"><center><a href=javascript:spawnUpdate()>Please update Windows Media Player.</a></center></font>");
									}						
						}
						else
						{	if (fHasMP3)  // Check if they have WMP 9
									{	document.write("The script has determined you have the newest version,  therefore you must have a different problem.<br>");
									}
							else
									{	document.write("<font color=\"#FF0000\"><center><a href=javascript:spawnUpdate()>Please update Windows Media Player.</a></center></font>");
									}
						}
				}
				else 
				{	document.write("<font color=\"#FF0000\"><center>You must run Internet Explorer to check your version of Windows Media Player.</center></font>");
				}
			}
			else 
			{		document.write("<font color=\"#FF0000\"><center>We recommend that you run Windows.</center></font>");
			}
		}
	
	function needToUpdate()
	{	if (fHasMP)
		{	document.write("Windows Media Player 10 is installed.");
		}
		else 
		{	document.write("Windows Media Player 10 is not installed.");
		}
		document.write("<br>");
		if (fHasMP3) 
		{	document.write("Windows Media Player 9 is installed.");
		}
		else 
		{	document.write("Windows Media Player 9 is not installed.");
		}
	}
	function FinishedLoading() 
	{	CurrentTime = new Date();
		ET		= CurrentTime.getTime();
		Factor	= 1000;
		DT = (ET - ST)/Factor;
		DataSize = 161;
		LS       = DataSize/DT;
		kbpsx    = Math.round((LS*8)*10*1.02);
		bandwidth= kbpsx/10;
		window.alert("test");
	}
///////////////////////////////////////////////////////////////////////////////////
////////                 End Newest WMP Version Checker                  //////////
///////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////
////////                      Load Special Windows                       //////////
///////////////////////////////////////////////////////////////////////////////////
	var height = 629;
	var width = 800;
	var maxResWidth = (window.screen.width);
	var maxResHeight = (window.screen.height);

function help()
	{	window.open("help.asp","Help",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=850,height=625');
	}
function FF()
	{	window.open("http://www.ehsports.com/mc2/","EHSports",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=625');
	}
function IE()
	{	window.open("http://www.ehsports.com/mc2/","EHSports",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=625');
	}
function IE2()
	{	window.open("http://www.ehsports.com/mc2/","EHSports",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=625');
	}

function to_regular()
	{	if (height < maxResHeight) { height = maxResHeight; }
		if (width < maxResWidth) { width = maxResWidth; }		
		window.close(window.open("http://www.ehsports.com/mc2/",'Small','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=800,height=629'));
	}

//Change window size to full screen
function to_fullscreen()
	{	createCookie('loadhere', 63541, 10);
		window.close(window.open("http://www.ehsports.com/mc2/",'Full','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=625,fullscreen=yes'));
	}
	
//Go to the ehsports.com home page.	
function home()
	{	window.open("http://www.ehsports.com/mc2/",'_self','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=625');
		window.close();
	}

//Change screen size to the regular size.
function to_regular()
	{	createCookie('loadhere', 63540, 10);
		window.close(window.open("http://www.ehsports.com/mc2/",'Small','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=625'));
	}
	
// Load in external window.
function to_wmp()
	{	window.close(window.open("towmp.asp",'WMP','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=480,height=100'));
	}
	
// Load in external window.
function to_lobby()
	{	window.close(window.open("tolobby.asp",'WMP','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=485,height=400'));
	}
	
// Load the WMP window.
function wmp()
	{	window.open("http://wli002.dc1.hwcdn.net/s5j5c7b2-wli-31435-eldersports.asx",'WMP','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=600,height=400');
	}

//Open the Ask Andy Section
function makeComment()
	{	window.close(window.open("./AskAndy.asp",'WMP','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=280'));
	}
	
// Check window size and determine which switch to make available, then switch.
function switchSize()
	{	var windowWidth = document.body.clientWidth;
		if (checkIt('msie'))
		{	if (maxResWidth < 801)
			{ document.write('<a href=#>We Recommend Higher Resolutions.</a> : ');
			}
			if ((windowWidth) < 851) 
			{	document.write('<a href=javascript:to_fullscreen()>Switch to Full Size</a>');
			}
			else 
			{	document.write('<a href=javascript:to_regular()>Switch to Regular Size</a>');
			}
		}
		else
		{	return;
		}
	}

// Give alert before exit
function warn()
{	window.onbeforeunload = warning;
			function warning()
			{	warning = "Are you sure you want to exit the EHSports.com Broadcast?";
				return warning;
			}
}
// Open the spawn page to load the main page
function spawn()
{		window.open("spawn.asp",'spawn','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=8,height=8');
}

// Give back time in 9 seconds
function inAFew()
{	var inAFew = new Date ();
	inAFew.setTime(inAFew.getTime() + (9000));
	document.write('<br><br>' + inAFew.toGMTString() + '<br><br>');
}

function setSize() 
{	var	y = 630;
	var x = 800;
				
	if (document.body.clientWidth != x || document.body.clientHeight != y) 
	{	try {	top.resizeTo(x,y);
				var deltaX = x - document.body.clientWidth;
				var deltaY = y - document.body.clientHeight;
				var newX = x + deltaX;
				var newY = y + deltaY;
				
				if (deltaY > 5) 
				{	top.resizeTo(newX, newY-14);
				}
				
				if(false)
				{ 	top.resizeTo(x, y-10)}
				} 
				catch (er) 
				{	return;
				}
	}
}
/*	if (!(window.outerHeight == window.innerHeight))
	{	IE2();
	}
	if (!(window.outerWidth == window.innerWidth))
	{	IE2();
	}
*/		


///////////////////////////////////////////////////////////////////////////////////
////////                      End Load Correct Browser                   //////////
///////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////
////////                           Cookie Stuff                          //////////
///////////////////////////////////////////////////////////////////////////////////

function createCookie(name,value,seconds)
{	if (seconds)
	{
		var date = new Date();
		date.setTime(date.getTime()+(seconds*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	document.cookie = ck;
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function readIt(name)
{
	alert('The value of the cookie is ' + readCookie(name));
}

function eraseIt(name)
{
	eraseCookie(name);
	alert('Cookie erased');
}
function secureSite()
{	//var cookieVal = (readcookie('loadhere'));
	if (!readCookie('loadhere'))
	{	spawn();
		close();
		return null
	}
	/*else if (readcookie('loadhere') == 63539)
	{	window.alert('Wrong Cookie Value');
		window.close();
	}
	window.alert('End of statements');*/
}


function cookieStatus(name)
{	if (!readCookie(name))
	{	document.write('There is no cookie stored.');
	}
	else 
	{	document.write('The cookie has a value of '+readCookie('loadhere'));
	}
}

///////////////////////////////////////////////////////////////////////////////////
////////                       End Cookie Stuff                          //////////
///////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////
////////                       Page Write Stuff                          //////////
///////////////////////////////////////////////////////////////////////////////////

function checkIE()
{	return checkit('msie')
}

function checkSize() 
{	y = 652;
	x = 850;
	
	if (!checkIt('msie'))
	{	window.scrollbars.visible = false;
		window.locationbar.visible=false;
		window.menubar.visible=false;
		window.personalbar.visible=false;
		window.scrollbars.visible=false;
		window.statusbar.visible=false;
		window.toolbar.visible=false;
	}
	
	if (document.body.clientWidth != x || document.body.clientHeight != y) {
	try {	top.resizeTo(x,y);
			var deltaX = x - document.body.clientWidth;
			var deltaY = y - document.body.clientHeight;
			var newX = x + deltaX;
			var newY = y + deltaY;
			if (deltaY > 5) {top.resizeTo(newX, newY-14);}
			if(false)
			{ top.resizeTo(x, y-10)}
			} 
			catch (er) 
			{return;
		}
	}
}

function header()
{	var top = ''
		top += '<center>';
		top += '<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">';
		top += '<tr>';
		top += '<td><a href="http://www.ehsports.com" target="_blank"><img src="images/Random/back-button.gif" alt="Back to EHSports.com" width="40" height="40" border="0"></img></a></br></td>';
		top += '<td  align="center"><img src="http://www.ehsports.com/Images/Banners/titlebar02.gif" width="700" height="110"></td>';
		top += '<td><a href="javascript:close();"><img src="images/Random/x_button.gif" alt="Exit" width="40" height="40" border="0"></img></a></br><a href="javascript:to_wmp();"><img src="images/Random/maximize.gif" border="0" alt="Open In Player"></img></a>';
		top += '</td></tr><tr><td colspan="3" align="center">';
	var navigation = ''	
		navigation += ': <a href="javascript:to_wmp()">Launch in External Player</a>';
		navigation += ': <a href="javascript:window.close()">Exit</a></td></tr></table></center></table>';
	
	document.write(top);
	writeUpdate();
	switchSize();
	document.write(navigation);	
}
function writeParts(part)
{	var one = ''	 
		one += '<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="15">';
		one += '  <tr align="center">';
		one += '    <td width="255" height="15" align="right" valign="top">';
	var two = '    </td><td align="center" height="15">';
	var three = '    </td><td width="255" align="left" height="15" valign="top">';
	var four = '  </td></tr></table>';
	document.write(part);
}

tabCount = 2;
var currentTab = 0;

function activateTab(i) 
{	currentTab += 1;
	/*	document.getElementById( "tab-left:"+i ).src="tab-left_active.gif";
	document.getElementById( "tab-bg:"+i ).style.background="url(tab-bg_active.gif)";
	document.getElementById( "tab-right:"+i ).src="tab-right_active.gif";*/
	document.getElementById( "tab-body:"+i ).style.display='block';
}
function deactivateTab(i) 
{	currentTab	-= 1;
	/*document.getElementById( "tab-left:"+i ).src="tab-left_inactive.gif";
	document.getElementById( "tab-bg:"+i ).style.background="url(tab-bg_inactive.gif)";
	document.getElementById( "tab-right:"+i ).src="tab-right_inactive.gif";*/
	document.getElementById( "tab-body:"+i ).style.display='none';
	
}
function changeActiveTab(i)
{	for( j=0; j < tabCount; ++j ) {
		if( j==i ) {
			activateTab(j);
		} else {
			deactivateTab(j);
		}
	}
}
function switchTab()
{	var inter = 0;
	var team1 = "<td id='tab-bg:0' style='cursor: pointer;' onclick='changeActiveTab(0)' align='center'>";
		team1 += "<a>View Elder's Roster</a>";
		team1 += "</td>";			
	var team2 = "<td id='tab-bg:1' style='cursor: pointer;' onclick='changeActiveTab(1)' align='center'>";
		team2 += "<a>View Oak Hills' Roster</a>";
		team2 += "</td>";
	if (inter == 1)
	{ 	document.write(team1);
	}
	else if (inter == 2)
	{	document.write(team2);
	}
	else
	{window.alert("Dummy");
	}
}

///////////////////////////////////////////////////////////////////////////////////
////////                       Page Write Stuff                          //////////
///////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////
////////                       WMP Embedded Controls                     //////////
///////////////////////////////////////////////////////////////////////////////////


function controlWMP(player, action)
{        /* Check first to be sure the operation is valid. */
        if (action == stop)
		{	if (Player.controls.isAvailable('Stop'))
			{   /* Stop the Player. */
				Player.controls.stop();
			}
		}
		if (action == pause)
		{	if (Player.controls.isAvailable('pause'))
			{   /* Stop the Player. */
				Player.controls.pause();
			}
		}
		
		
}

///////////////////////////////////////////////////////////////////////////////////
////////                   End WMP Embedded Controls                     //////////
///////////////////////////////////////////////////////////////////////////////////



