

// String Pedagogy script file

// written by Jason Marsh, MarshWorks

//   version 7_27_99







var bWin32IE;



if ((navigator.userAgent.indexOf("IE") != -1) && (navigator.userAgent.length > 1)) {

	bWin32IE = true;

} else {

	bWin32IE = false;

}

function doNothing(){};



var exerWindow;



function openExerWin(URL){

	if (!bWin32IE) {

	exerWindow = window.open(URL,'exerWindow','scrollbars=no,resizable=no,width=634,height=430');

		exerWindow.focus();

	}else{

		exerWindow = window.open(URL,'exerWindow','scrollbars=no,resizable=no,width=634,height=430');

		setTimeout("exerWindow.focus()",250);

	}

}



function goMain(){

	parent.opener.document.location = "../mainmenu.htm";

}



function goSection(URL){

	parent.opener.document.location = "../" + URL;

}



//var doSubSection;



function goSubSection(URL, whichLayer){

	//doSubSection = "whichLayer";

	parent.opener.document.location = "../" + URL;

}





var subMenuSetting = "both";

var currentMenu = "";



function showSubmenu( whichmenu ) {

	text = getSubMenu( whichmenu );

	//alert( "showSubMenu " + text );

	layerWrite("submenu", null, text);

	currentMenu = whichmenu;

	showLayers("submenu");

}



function setSubSetting( whichSetting ){

	subMenuSetting = whichSetting;

	if ( currentMenu != "" ){

		showSubmenu( currentMenu );

	}

	if (bWin32IE) {

		if ( whichSetting == "upper" ){

			document.images['upper'].src = upperHImg.src;

			document.images['lower'].src = lowerImg.src;

			document.images['both'].src = bothImg.src;

		} else if ( whichSetting == "lower" ){

			document.images['upper'].src = upperImg.src;

			document.images['lower'].src = lowerHImg.src;

			document.images['both'].src = bothImg.src;

		} else if ( whichSetting == "both" ){

			document.images['upper'].src = upperImg.src;

			document.images['lower'].src = lowerImg.src;

			document.images['both'].src = bothHImg.src;

		}

	}else{

			if ( whichSetting == "upper" ){

			document.showBtn.document.images['upper'].src = upperHImg.src;

			document.showBtn.document.images['lower'].src = lowerImg.src;

			document.showBtn.document.images['both'].src = bothImg.src;

		} else if ( whichSetting == "lower" ){

			document.showBtn.document.images['upper'].src = upperImg.src;

			document.showBtn.document.images['lower'].src = lowerHImg.src;

			document.showBtn.document.images['both'].src = bothImg.src;

		} else if ( whichSetting == "both" ){

			document.showBtn.document.images['upper'].src = upperImg.src;

			document.showBtn.document.images['lower'].src = lowerImg.src;

			document.showBtn.document.images['both'].src = bothHImg.src;

		}

	}

}



function getSubMenu( whichMenu ){

	var menuText = "<table width=\"302\" border=\"0\"><tr><td height=\"229\" valign=\"top\">";

	menuText += "<br><br><div align=\"center\" class=\"menutext\">\n";

	//alert( subMenuSetting );

	for ( var i = 0; i < subItems.length; i++ ){

		if ( subItems[i].whichMenu == whichMenu && ( subMenuSetting == "both" ||

		     subItems[i].section == subMenuSetting ||

		     subItems[i].section == "both" ) ){

			menuText += "<a href=\"javascript:openExerWin('" + subItems[i].link + "')\">" + subItems[i].itemText + "</a><br>\n";

		}

	}

	menuText += "</div></td></tr></table>\n";

	return menuText;

}

 



var lastButtonText = "";



function showButtonText( whichText ){

   layerText = "<table width=\"248\" heigth=\"90\"><tr><td>";

	if ( whichText == "attribute" ){

		msg = attribution;

	} else if ( whichText == "refinement" ){

		msg = refinement;

	} else if ( whichText == "look" ){

		msg = lookFor;

	}

	if ( msg != "" ){

		

		layerText += msg;

		if ((navigator.appName == 'Netscape') ) {

			layerText += "<p align=center><a href=\"#\" onClick=\"showHideButtons('buttonText')\">Close</a></p>"

		} else {

			layerText += "<p align=center><a href=\"#\">Close</a></p>"

		}

		layerText += "</td></tr></table>";

		

		layerWrite( "buttonText", null, layerText );

		

		if ( lastButtonText == "" || lastButtonText == whichText ){

			//showHideLayers( "buttonText" );

			if ( lastButtonText != "" ){

				

				lastButtonText = ""

			} else {

				showHideLayers( "buttonText" );

				lastButtonText = whichText;

			}

		} else {

			lastButtonText = whichText;

		}

		

	}

}



function mouseTracker(e) {

	e = e || window.Event || window.event;

	window.pageX = e.pageX || e.clientX;

	window.pageY = e.pageY || e.clientY;

}



if (window.captureEvents) {

	window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);

	window.onmousemove = mouseTracker;

} //else {

	//document.onmousemove = mouseTracker;

//}



function setLayerPosition(theObj){

    // pops up window at mouseLoc

	if (navigator.appName == 'Netscape'){

		ourX = window.pageX - theObj.clip.width;

		if (ourX<10) {ourX=10};

	   theObj.left = ourX;

	   theObj.top = window.pageY - 270;

	}else{

	   ourX = window.event.clientX - theObj.clientWidth;

	   if (ourX<10) {ourX=10};

	   //ourY = window.event.y; //IE4

	   ourY = event.screenY- window.screenTop +document.body.scrollTop; //IE 5.0 fix!

	   //alert(window.event.offsetY);

	   theObj.style.left = ourX;

	   theObj.style.top = ourY - 270;

	}

}



function layerWrite(id,nestref,text) {



	if ((navigator.appName == 'Netscape') ) {

		//alert( "layerWrite" );

		if (! (document.layers[id])) {return}

		if (nestref) var lyr = eval('document.'+nestref+'.document.'+id+'.document')

		else var lyr = document.layers[id].document

		

		lyr.open()

		lyr.write(text)

		lyr.close()

	}

	else  {document.all[id].innerHTML = text}

}	





function showLayers(objName) { 

	if (navigator.appName == 'Netscape') {

		theObj = eval('document.layers.' + objName );

		if (theObj) {

			visStr = "show";

			theObj.visibility = visStr;

			

		}

		

	} else if (document.all != null) { //IE

		theObj = eval('document.all.' + objName );

		if (theObj) {

			visStr = "visible";

			theObj.style.visibility = visStr;

			

		}

		

	}

}



function showHideButtons(objname){

	showHideLayers(objname);

	lastButtonText ="";

}



function showHideLayers(objName) { 

	if (navigator.appName == 'Netscape') {

		theObj = eval('document.layers.' + objName );

		

		if (theObj) {

			if (theObj.visibility == "hide") {

				visStr = "show";

			}

			else {visStr = "hide";}

			theObj.visibility = visStr;

			setLayerPosition( theObj );

		}

	} else if (document.all != null) { //IE

		theObj = eval('document.all.' + objName );

		if (theObj) {

			if (theObj.style.visibility == "hidden") {

				visStr = "visible";

			} else {

				visStr = "hidden";

				//alert( "hidding layer" );

			}

			theObj.style.visibility = visStr;

			setLayerPosition( theObj );

		}

	}

}



function swapCorrect(){

	if (bWin32IE) {

		document.images['exerImage'].src = incorrectImg.src;

	}else{

		document.media.document.images['exerImage'].src = incorrectImg.src;

	}

}



function swapIncorrect(){

	if (bWin32IE) {

		document.images['exerImage'].src = correctImg.src;

	}else{

		document.media.document.images['exerImage'].src = correctImg.src;

	}



}

