
var canOpen = true
var llWindow

function checkLLReqs(){

	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);
	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_ie3    = (is_ie && (is_major < 4));
	var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
	var is_ie4up  = (is_ie && (is_major >= 4));
	var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
	var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
	var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
	var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
	var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
	var isnotMac=(navigator.appVersion.indexOf("Mac") != -1) ? 0 : 1;

	var is_goodversion = false

	var acc = ''

	if (is_ie5up && isnotMac){is_goodversion = true}
// fHasWMP7=false
	if (is_goodversion){
		if (document.location.toString().indexOf("demo") != -1){
			h = '<span class="linklib" onClick="startLib(0)">Generic Lifetime Library</span><br><br>'
			h += '<span class="linklib" onClick="startLib(1)">Army Demonstration</span><br><br>'
			h += '<span class="linklib" onClick="startLib(2)">Los Angeles Unified</span><br><br>'
			h += '<span class="linklib" onClick="startLib(3)">KET</span><br><br>'
			h += '<span class="linklib" onClick="startLib(4)">Compaq</span><br><br>'
			h += '<span class="linklib" onClick="startLib(5)">MSN</span><br><br>'
			h += '<span class="linklib" onClick="startLib(6)">Best Buy</span>'
		} else {
			h = '<span class="linklib" onClick="startLib(0)">Start the Lifetime Library</span>'
		}
		if (!fHasWMP7){
			if (acc!=''){acc += '<br><hr>'}
			acc += 'The Lifetime Library requires Windows Media Player 7.'
			t = '<br>'
			t += '<A HREF="http://windowsmedia.com/download">'
			t += '<IMG SRC="http://www.microsoft.com/windows/windowsmedia/images/GetWinMPsquareB.gif" WIDTH="68"HEIGHT="56" BORDER="0"'
			t += 'ALT="Get Windows Media Player" VSPACE="7">'
			t += '</A>'
			acc += t
//			document.all.wmLogo.innerHTML = t
		}
		if ((screen.width < 1024)||(screen.colordepth < 16)){
			if (acc!=''){acc += '<br><hr>'}
			acc += 'The Lifetime Library requires at least 1024x768 screen resolution and 16 bit color.'
			acc += '<br><br>This computer is set to ' + screen.width.toString() + 'x' + screen.height.toString() + ' and '
			acc += screen.colordepth.toString() +' bit color.'
		}
		if (document.all.clf.clientWidth > 210){
			if (acc!=''){acc += '<br><hr>'}
			acc += 'The Lifetime Library requires the computer be set to display Small Fonts.'
		}
//		if (document.all.clf10.clientWidth != 151){
//			if (acc!=''){acc += '<br><hr>'}
//			acc += 'The Lifetime Library requires its own font styles.  Please adjust your Accessibility settings to allow web pages to use their own font styles.'
//		}
		if (document.all.clf10.clientWidth == document.all.clf.clientWidth){
			if (acc!=''){acc += '<br><hr>'}
			acc += 'The Lifetime Library requires its own font sizes.  Please adjust your Accessibility settings to allow web pages to use their own font sizes.'
		}

//if (acc!=''){acc += '<br><hr>'}
//acc += 'The Lifetime Library requires at least 1024x768 screen resolution and 16 bit color.'
//acc += '<br><br>This computer is set to 800x600 and '
//acc += screen.colordepth.toString() +' bit color.'
			if (acc==''){acc=h + '<br>'} else {
			z = '<table border="1" cellspacing="0" cellpadding="10" bordercolor="red" >'
			z += '<tr><td style="color:red; background:white; font-size:18pt; ">You need to change some settings before you can start the Library.</td></tr>'
			z += '<tr><td style="background:rgb(255,255,204); text-align:center; ">' + acc + '</td></tr>'
			z += '</table>'
			acc = z
//			acc = '<span style="color:red; font-size:18pt; ">You need to change some settings before you can start the Library.</span><br><br>' + 
//				'<div style="background:rgb(255,255,204); padding:5px; width:80%; border-style:outset; ">' + acc + '</div>'
		}
		document.all.mess.innerHTML = acc
//		document.all.sysreq.innerHTML = "<span class='srlink' onClick='replaceReq()'>Click to see Lifetime Library System Requirements</span>"
	} else {
		window.location = 'startnet.htm'
	}
}

function popupSettings(w,h,borderless){
	if (screen.width < 1100){
		rv = 'fullscreen'
	} else {
		wl = (screen.width-w)/2
		wh = (screen.height-h)/2
		if (borderless){
			rv = "fullscreen=1,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=1,width=" + w.toString()
			//rv = "fullscreen=0,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizeable=1,width=" + w.toString()
		} else {
			rv = "fullscreen=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=0,width=" + w.toString()
			//rv = "fullscreen=0,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizeable=1,width=" + w.toString()
		}
		rv = rv + ',height=' + h.toString()
		rv = rv + ',left=' + wl.toString()
		rv = rv + ',top=' + wh.toString()
	}
	return rv
}

function startA(p){
	if (p.indexOf('http:')==-1){ p = 'http://'+ipa+'/' + p }
	window.open(p)
}

function startLib(v){

	if (!canOpen){return false}
//	canOpen = false
	try {
		if (llWindow.opener.canOpen){
			llWindow.focus()
			return true
		}
	} catch(e) {}

	hf = 'main.htm'
	if (v>0){ hf = 'demo_bg.asp?dt=' + v.toString()	}
	hf = 'http://'+ipa+'/ll_web5/sys5053/' + hf

	w = 1024
	h = 768
	borderless = false

	try {
		llWindow = window.open(hf,"lifetimeLibrary",popupSettings(w,h,borderless),true)

		if (borderless){
			wl = (screen.width-w)/2
			wh = (screen.height-h)/2
			llWindow.resizeTo( Math.ceil( w )       , Math.ceil( h ) )
			llWindow.moveTo  ( Math.ceil( wl ) , Math.ceil( wh ) )
		}
//		closeMe()
	} catch(e) {
		alert("The Library can't be started./n/nThe Library is trying to open a pop-up window.  Something is preventing this.")
	}
}

function replaceReq(){
	t = "<table cellspacing='1' cellpadding='10' border='1'>"
	t += "<tr>"
	t += "<td colspan='2' class='tdt'><center>Lifetime Library System Requirements</center></td>"
	t += "</tr>"
	t += "<tr>"
	t += "<td class='tda'>Operating system</td>"
	t += "<td class='tdb'>Windows XP<br>Windows 2000<br>Windows ME<br>Windows 98</td>"
	t += "</tr>"
	t += "<tr>"
	t += "<td class='tda'>Browser</td>"
	t += "<td class='tdb'>Internet Explorer version 5.0 or better<br>JavaScript must be turned on</td>"
	t += "</tr>"
	t += "<tr>"
	t += "<td class='tda'>Media player</td>"
	t += "<td class='tdb'>Windows Media Player version 7.0 or better</td>"
	t += "</tr>"
	t += "<tr>"
	t += "<td class='tda'>Screen size</td>"
	t += "<td class='tdb'>At least 1024 x 768 and 16 bit color and<br>the Display font size must be set to 'small fonts'</td>"
	t += "</tr>"
	t += "</table>"
	document.all.sysreq.innerHTML = t
}

function bookmarkMe(){
	external.AddFavorite(location.href,'Start the Lifetime Library')
}

