//newImage and switchImage are all common functions for the rollover functionality		   
var preloadFlag = false;
var timer = 0;

function AlertBox2() 
{
	if(confirm("Switching to a different mode will reset any previous work you have done."))
	{
		window.location.href=alertPageSrc;
	}
}

function pageTimer()
{
    timer++;
    
    if (timer == 16)
    {
        window.clearInterval("pageTimer()");
        legendCollapse();
    }
}

function legendCollapse()
{
    var legend = document.getElementById("legend");
    var legendButton = document.getElementById("legendButton");
    
    legend.style.height = 0 + "px";
    legend.innerHTML = "";
    legendButton.innerHTML = "<a href='javascript:legendExpand();'><img src='image/legendExpand.gif' alt='Expand the What&apos;s Included section' title='Expand the What&apos;s Included section'></a></a>";
}

function legendExpand()
{
    var legend = document.getElementById("legend");
    var legendButton = document.getElementById("legendButton");
    
    legend.style.height = 200 + "px";
    legend.innerHTML = "<iframe src='legend.html' height='200px' width='100%' marginwidth='0' marginheight='0' frameborder='0' scrolling='no'></iframe>";
    legendButton.innerHTML = "<a href='javascript:legendCollapse();'><img src='image/legendCollapse.gif' alt='Collapse the What&apos;s Included section' title='Collapse the What&apos;s Included section'></a>";
}

function embedFlash(asset, name, color) 
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	document.write('height="100%"');
	document.write('width="100%">');
	document.write('<param name="src" value="' + asset + '">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="align" value="middle">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="bgcolor" value="' + color + '">');
	document.write('<param name="menu" value="false">');
	document.write( '<embed ' );
	document.write( '  src="' + asset + '" ' );
	document.write( '  name="' + name + '"' );
	document.write( '  width="100%" ' );
	document.write( '  height="100%" ' );
	document.write( '  align="middle" ' );
	document.write( '  quality="high" ' );
	document.write( '  allowScriptAccess="sameDomain" ' );
	document.write( '  scale="aspect" ' );
	document.write( '  pluginspage="http://www.macromedia.com/go/getflashplayer" ' );
	document.write( '  bgcolor="' + color + '" ' );
	document.write( '  menu="false"' );
	document.write( '  type="application/x-shockwave-flash">' );
	document.write( '</embed>' );
	document.write('</object>');
}

function embedIFrame(source)
{
	document.write( ' <iframe src="' + source + '" height="100%" width="100%" scrolling="no" frameborder="no"></iframe> ' );
}

function embedMovieResource(movieSrc,bcgColor) 
{
	document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" ');
	document.write('height="100%"');
	document.write('width="100%">');
	document.write('<param name="src" value="' + movieSrc + '">');
	document.write('<param name="autoplay" value="true">');
	document.write('<param name="controller" value="true">');
	document.write('<param name="scale" value="aspect">');			
	document.write('<param name="bgcolor" value="' + bcgColor + '">');							
	document.write( '<embed ' );
	document.write( '  src="' + movieSrc + '" ' );
	document.write( '  width="100%" ' );
	document.write( '  height="100%" ' );
	document.write( '  quality="high" ' );
	document.write( '  scale="aspect" ' );
	document.write( '  type="video/quicktime" ');
	document.write( '  enablejavascript="true" ');
	document.write( '  pluginspace="http://www.apple.com/quicktime/download/" ' );
	document.write( '  bgcolor="' + bcgColor + '" ' );
	document.write( '  autoplay="true">' );
	document.write( '</embed>' );
	document.write('</object>');
}


//XHTML compliant solution for embeding an object
function embedResource(objectSrc,bcgColor) 
{
	if (window.navigator.appName == "Microsoft Internet Explorer" && window.navigator.appVersion.indexOf("MSIE 5.0") > -1)
	{
		document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash /swflash.cab#version=6,0,0,0" id="JHM_LO" width="100%" height="384">');
		document.write( '<param name="allowScriptAccess" value="sameDomain"/>');
		document.write( '<param name="movie" value="' + objectSrc + '"/>');
		document.write( '<param name="quality" value="high"/>');
		document.write( '<param name="align" value="middle"/>');
		document.write( '<param name="bgcolor" value="' + bcgColor + '"/>');
		document.write( '<param name="menu" value="false">');
		document.write(		'<embed ');
		document.write(			' src="' + objectSrc + '" ' );
		document.write(			' width="100%" ' );
		document.write(			' height="100%" ' );
		document.write(			' quality="high" ' );
		document.write(			' name="JHM_LO" ' );
		document.write(			' align="middle" ' );
		document.write(			' salign="m" ' );
		document.write(			' bgcolor="' + bcgColor + '" ' );
		document.write(         ' menu="false"' );
		document.write(			' pluginspage="http://www.macromedia.com/go/getflashplayer" ' );
		document.write(			' allowScriptAccess="sameDomain" ' );
		document.write(			' type="application/x-shockwave-flash">' );
		document.write(		'</embed>' );
		document.write( '</object>' );
	}
	else
	{
		document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash /swflash.cab#version=6,0,0,0" id="JHM_LO" width="100%" height="100%">');
		document.write( '<param name="allowScriptAccess" value="sameDomain"/>');
		document.write( '<param name="movie" value="' + objectSrc + '"/>');
		document.write( '<param name="quality" value="high"/>');
		document.write( '<param name="align" value="middle"/>');
		document.write( '<param name="bgcolor" value="' + bcgColor + '"/>');
		document.write( '<param name="menu" value="false">');
		document.write(		'<embed ');
		document.write(			' src="' + objectSrc + '" ' );
		document.write(			' width="100%" ' );
		document.write(			' height="100%" ' );
		document.write(			' quality="high" ' );
		document.write(			' name="JHM_LO" ' );
		document.write(			' align="middle" ' );
		document.write(			' salign="m" ' );
		document.write(			' bgcolor="' + bcgColor + '" ' );
		document.write(         '  menu="false"' );
		document.write(			' pluginspage="http://www.macromedia.com/go/getflashplayer" ' );
		document.write(			' allowScriptAccess="sameDomain" ' );
		document.write(			' type="application/x-shockwave-flash">' );
		document.write(		'</embed>' );
		document.write( '</object>' );
	}
}

function embedResourceCircles(objectSrc,bcgColor) 
{
	if (window.navigator.appName == "Microsoft Internet Explorer" && window.navigator.appVersion.indexOf("MSIE 5.0") > -1)
	{
		document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash /swflash.cab#version=6,0,0,0" id="JHM_LO" width="100%" height="384">');
		document.write( '<param name="allowScriptAccess" value="sameDomain"/>');
		document.write( '<param name="movie" value="' + objectSrc + '"/>');
		document.write( '<param name="quality" value="high"/>');
		document.write( '<param name="align" value="middle"/>');
		document.write( '<param name="bgcolor" value="' + bcgColor + '"/>');
		document.write( '<param name="menu" value="false">');
		document.write( '<param name="flashvars" value="swfcache=1&mode=production"/>');
		document.write(		'<embed ');
		document.write(			' src="' + objectSrc + '" ' );
		document.write(			' width="100%" ' );
		document.write(			' height="100%" ' );
		document.write(			' quality="high" ' );
		document.write(			' name="JHM_LO" ' );
		document.write(			' align="middle" ' );
		document.write(			' salign="m" ' );
		document.write(			' bgcolor="' + bcgColor + '" ' );
		document.write(         ' menu="false"' );
		document.write(			' pluginspage="http://www.macromedia.com/go/getflashplayer" ' );
		document.write(			' allowScriptAccess="sameDomain" ' );
		document.write(         ' flashvars="swfcache=1&mode=production" ' );
		document.write(			' type="application/x-shockwave-flash">' );
		document.write(		'</embed>' );
		document.write( '</object>' );
	}
	else
	{
		document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash /swflash.cab#version=6,0,0,0" id="JHM_LO" width="100%" height="100%">');
		document.write( '<param name="allowScriptAccess" value="sameDomain"/>');
		document.write( '<param name="movie" value="' + objectSrc + '"/>');
		document.write( '<param name="quality" value="high"/>');
		document.write( '<param name="align" value="middle"/>');
		document.write( '<param name="bgcolor" value="' + bcgColor + '"/>');
		document.write( '<param name="menu" value="false">');
		document.write( '<param name="flashvars" value="swfcache=1&mode=production"/>');
		document.write(		'<embed ');
		document.write(			' src="' + objectSrc + '" ' );
		document.write(			' width="100%" ' );
		document.write(			' height="100%" ' );
		document.write(			' quality="high" ' );
		document.write(			' name="JHM_LO" ' );
		document.write(			' align="middle" ' );
		document.write(			' salign="m" ' );
		document.write(			' bgcolor="' + bcgColor + '" ' );
		document.write(         '  menu="false"' );
		document.write(			' pluginspage="http://www.macromedia.com/go/getflashplayer" ' );
		document.write(			' allowScriptAccess="sameDomain" ' );
		document.write(         ' flashvars="swfcache=1&mode=production" ' );
		document.write(			' type="application/x-shockwave-flash">' );
		document.write(		'</embed>' );
		document.write( '</object>' );
	}
}

function LA_findObj(n, d) 
{ //v4.01
	var p,i,x;  
	
	if(!d) d=document; 
	
	if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
  
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=LA_findObj(n,d.layers[i].document);
  
	if(!x && d.getElementById) x=d.getElementById(n); 
	
	return x;
}

function LA_preloadImages() 
{ //v3.0
	var d=document; 
	
	if(d.images)
	{ 
		if(!d.LA_p) d.LA_p=new Array();
		
		var i,j=d.LA_p.length,a=LA_preloadImages.arguments; 
		
		for(i=0; i<a.length; i++)
    
		if (a[i].indexOf("#")!=0)
		{ 
			d.LA_p[j]=new Image; 
			d.LA_p[j++].src=a[i];
		}
	}
}

function LA_swapImage() 
{ //v3.0
	var i,j=0,x,a=LA_swapImage.arguments; document.LA_sr=new Array; 
	
	for(i=0;i<(a.length-2);i+=3)
	
	if ((x=LA_findObj(a[i]))!=null){document.LA_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function LA_swapImgRestore() 
{ //v3.0
	var i,x,a=document.LA_sr; 
	
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) 
{ //v4.01
	var p,i,x;  
  
	if(!d) d=document; 
  
	if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
		
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; 
	
	document.MM_sr=new Array; 
	
	for(i=0;i<(a.length-2);i+=3)
	
	if ((x=MM_findObj(a[i]))!=null)
	{
		document.MM_sr[j++]=x; 
		
		if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function MM_swapImgRestore() 
{ //v3.0
	var i,x,a=document.MM_sr; 
	
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function newImage(arg) 
{
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function OpenFooterAsset(URL)
{
	window.open(URL,"Junior_High_Math","toolbar=no,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,scrolling=yes,resizable=yes,width=750,height=550,left=0,top=0");
}

function OpenResource(URL)
{
	window.open(URL,"SupportDocument","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,scrolling=yes,resizable=yes,width=750,height=550,left=0,top=0");
}

function openViOiWin(URL) 
{	
	var browserName=navigator.appName; 

	if (browserName=="Microsoft Internet Explorer")
	{ 
		window.open(URL, "Junior_High_Math_VIOI_Resource", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,scrolling=yes,resizable=yes,width=770,height=680,left=0,top=0",true);
	}
	else 
	{ 
		window.open(URL, "Junior_High_Math_VIOI_Resource", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,scrolling=yes,resizable=yes,width=750,height=550,left=0,top=0",true);
	}
}

function openOiWin(URL)
{	
	 window.open( URL, "Junior_High_Math_OI_Resource", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,scrolling=yes,resizable=yes,width=800,height=600,left=0,top=0", true );
}

function openDocWin(URL)
{	
	window.open(URL,'Junior_High_Math_Doc_Resource','height=500,width=700,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,top=10,left=10')
}

function openHelpWin(URL) 
{
	var browserName=navigator.appName; 

	if (browserName=="Microsoft Internet Explorer")
	{ 
		window.open(URL,'helpWin','height=590,width=752,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,top=10,left=10');
	}
	else
	{
		window.open(URL,'helpWin','height=440,width=740,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,top=10,left=10');
	}
}

function preloadImages() 
{
	if (document.images) 
	{
		oi_green_nav_explore_it_Shape_6_over = newImage("../images/oi_green_nav_explore_it_-03.gif");
		preloadFlag = true;
	}
}

function reloadPage(init) 
{  //reloads the window if Nav4 resized
	if (init==true) with (navigator) 
	{
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
		{
			document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; 
		}
	}
	else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}

function switchImage(imgName, imgSrc) 
{
	if ((document.images) && (preloadFlag == true))
 	{
    	document.images[imgName].src = imgSrc;
 	}
}

function switchModes(url) 
{
	var reply = confirm("Switching to a different mode will reset any previous work you have done.");

	if(reply)
	{
		parent.window.location.href = url;
	}
}

function viSwitchModes(url)
{
    parent.window.location.href = url;
}

reloadPage(true);

//This function maximizes and minimizes the video.
function fullScreen()
{
    var header = document.getElementById("header");
	var drillDownPanel = document.getElementById("drillDownPanel");
	var resources5 = document.getElementById("resources5");
	var resources10 = document.getElementById("resources10");
	var resources11 = document.getElementById("resources11");
	var resources12 = document.getElementById("resources12");
	var minMax = document.getElementById("minMax");

	header.innerHTML = "";
	drillDownPanel.innerHTML = "";
	resources5.innerHTML = "";
	resources10.innerHTML = "";
	resources11.innerHTML = "";
	resources12.innerHTML = "";
	minMax.innerHTML = '<a href="javascript:smallScreen();"><img src="images/minimize.jpg" alt="Minimize" title="Minimize"></a>';
	
	header.style.height = 0 + 'px';
	drillDownPanel.style.width = 0 + 'px';
	resources5.style.height = 0 + 'px';
	resources10.style.height = 0 + 'px';
	resources11.style.height = 0 + 'px';
	resources12.style.height = 0 + 'px';
}

function smallScreen()
{
    var header = document.getElementById("header");
	var drillDownPanel = document.getElementById("drillDownPanel");
	var resources5 = document.getElementById("resources5");
	var resources10 = document.getElementById("resources10");
	var resources11 = document.getElementById("resources11");
	var resources12 = document.getElementById("resources12");
	var minMax = document.getElementById("minMax");
	
    header.innerHTML = '<img src="image/header.gif" title="Junior High Math">';
    drillDownPanel.innerHTML = '<table cellpadding="0" cellspacing="0"><tbody><tr><td class="menuBar">&nbsp;</td><td class="fullSize"><iframe src="drillDownPanel.html" marginwidth="0" marginheight="0" allowtransparency="true" scrolling="auto" width="100%" frameborder="0" height="100%"></iframe></td><td class="menuBar">&nbsp;</td></tr><tr><td colspan="3" class="drillDownSpacer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr><tr><td id="legendButton" colspan="3"><a href="javascript:legendCollapse();"><img src="image/legendCollapse.gif" alt="Collapse the What" s="" included="" section="" title="Collapse the What\'s Included section"></a></td></tr><tr><td id="legend" class="legend" colspan="3"><iframe src="legend.html" marginwidth="0" marginheight="0" allowtransparency="true" scrolling="no" width="100%" frameborder="0" height="200"></iframe></td></tr></tbody></table>';
    resources5.innerHTML = '<iframe src="breadcrumbs.html" marginwidth="0" marginheight="0" allowtransparency="true" scrolling="no" width="100%" frameborder="0" height="30"></iframe>';
    resources5.style.height = 30 + 'px';
    resources10.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    resources11.style.height = 10 + 'px';
    resources12.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    minMax.innerHTML = '<a href="javascript:fullScreen();"><img src="images/maximize.jpg" alt="Maximize" title="Maximize"></a>';

    header.style.height = 35 + 'px';
    //drillDownPanel.style.width = 380 + 'px';
}
