function setLoginFocus() {
	document.getElementById("name").focus();
}

function doSelection(pagenumber, showTOC, view, searchView) {

	if (document.getSelection) txt = document.getSelection();
	else if (document.selection) txt = document.selection.createRange().text;
	else return;
	
	
	
	
	//strip off leading whitespace
	while (txt.substring(0,1) == ' ') 
        txt = txt.substring(1, txt.length);

	//strip off trailing whitespace
	while (txt.substring(txt.length-1,txt.length) == ' ')
        txt = txt.substring(0, txt.length-1);


	
	
	
	window.location="?phrase=" + txt + "&showTOC=" + showTOC + "&view=" + view + "&searchView=" + searchView;
	
	//highlight(txt, pagenumber, showTOC);

}

function jumpTo(pagenumber, phrase, showTOC, view, searchView) {

	ext=document.location.toString().match(/[^\/*.]*\?/)[0]
	ext = ext.substring(0, ext.length - 1);


	window.location= pagenumber + "." + ext + "?phrase=" + phrase + "&showTOC=" + showTOC + "&view=" + view + "&searchView=" + searchView;

}



function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  
 if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }

}

function tellMovie(movieName, argumentVar, actionVar) {


	
  if (movieIsLoaded(thisMovie(movieName))) {

	  thisMovie(movieName).SetVariable("argumentVar", argumentVar + "");
    thisMovie(movieName).SetVariable("actionVar", actionVar + "");
    
		if(thisMovie(movieName + "_zoom") != undefined) {
			 thisMovie(movieName + "_zoom").SetVariable("argumentVar", argumentVar + "");
			thisMovie(movieName + "_zoom").SetVariable("actionVar", actionVar + "");
		}
  }
}




// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {

  // First make sure the movie's defined.
  if (typeof(theMovie) != "undefined") {
    // If it is, check how much of it is loaded.
    return theMovie.PercentLoaded() == 100;
  } else {
    // If the movie isn't defined, it's not loaded.
    return false;
  }
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function zoomImage(imageID, anchorCorner) {



	zoomedImage = document.getElementById(imageID  + "_zoom");
	smallImage = document.getElementById(imageID + "_small");
	theDiv = document.getElementById(imageID + "_div");
	
	
	
	smallImage.style.visibility = "hidden";
	
	if(anchorCorner == "top-right") {
		theDiv.style.top=(findPosY(smallImage) ) + 'px';
		theDiv.style.left=findPosX(smallImage) - (zoomedImage.width - smallImage.width) + 'px';
	}
	else if(anchorCorner == "top-left") {
		theDiv.style.top=(findPosY(smallImage) ) + 'px';
		theDiv.style.left=findPosX(smallImage)  + 'px';
	}
	else if(anchorCorner == "top-center") {
		theDiv.style.top=(findPosY(smallImage) ) + 'px';
		theDiv.style.left=findPosX(smallImage) - ((zoomedImage.width - smallImage.width)/2) + 'px';
	}
	else if(anchorCorner == "bot-right") {
		theDiv.style.top=findPosY(smallImage)  - (zoomedImage.height - smallImage.height) + 'px';
		theDiv.style.left=findPosX(smallImage) - (zoomedImage.width - smallImage.width) + 'px';
	}
	else if(anchorCorner == "bot-left") {
		theDiv.style.top=findPosY(smallImage)  - (zoomedImage.height - smallImage.height) + 'px';
		theDiv.style.left=findPosX(smallImage)  + 'px';
	}
	else if(anchorCorner == "bot-center") {
		theDiv.style.top=findPosY(smallImage)  - (zoomedImage.height - smallImage.height) + 'px';
		theDiv.style.left=findPosX(smallImage) - ((zoomedImage.width - smallImage.width)/2) + 'px';
	}
	else if(anchorCorner == "mid-right" || anchorCorner == "") {
	
		theDiv.style.top=findPosY(smallImage)  - ((zoomedImage.height - smallImage.height)/2) + 'px';
		theDiv.style.left=findPosX(smallImage) - (zoomedImage.width - smallImage.width) + 'px';
	}
	else if(anchorCorner == "mid-left") {
		theDiv.style.top=findPosY(smallImage)  - ((zoomedImage.height - smallImage.height)/2) + 'px';
		theDiv.style.left=findPosX(smallImage)  + 'px';
	}
	
	else if(anchorCorner == "middle" ) {
		theDiv.style.top=findPosY(smallImage)  - ((zoomedImage.height - smallImage.height)/2) + 'px';
		theDiv.style.left=findPosX(smallImage) - ((zoomedImage.width - smallImage.width)/2) + 'px';
	}
	theDiv.style.visibility="visible";
	
	
}

function zoomOut(imageID) {

	zoomedImage = document.getElementById(imageID + "_zoom");
	smallImage = document.getElementById(imageID + "_small");
	theDiv = document.getElementById(imageID + "_div");
	
	
	theDiv.style.visibility = "hidden"; 
	smallImage.style.visibility = "visible";
	
	
}


function popupSWF(swf, width, height, zoom) {
	
	if(zoom != "") {
		width *= zoom;
		height *= zoom;
	}
	
	NewWindow=window.open("","newWin","width=" + width + " ,height=" + height + ",left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No"); 
	NewWindow.focus();
	NewWindow.document.open();
	
	var docString = "";
	
	docString += "<html><head><title>POPUP</title></head><body bottommargin='0' leftmargin='0' rightmargin='0' topmargin='0' marginwidth='0' marginheight='0'>";
	docString += " <OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' WIDTH='" + width + "' HEIGHT='" + height + "' id='myMovieName'>";
	docString += "<PARAM NAME=movie VALUE='" + swf + "'>";
	docString += "<PARAM NAME=quality VALUE=high>";
	docString += "<EMBED src='" + swf + "' quality=high bgcolor=#BDDBDE WIDTH='" + width + "' HEIGHT='" + height +"' NAME='myMovieName' ALIGN='' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>";
	docString += "</OBJECT></body></html>";
	
	//docString = "<html><body>" + swf + "</body></html>";
	
	NewWindow.document.write(docString);
	

	NewWindow.document.close(); 
	
	
	
}

function popupJPG(jpg, width, height, zoom) {
	
	if(zoom != "" && zoom != "0") {
		width *= zoom;
		height *= zoom;
	}
	
	NewWindow=window.open("","newWin","width=" + width + " ,height=" + height + ",left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No"); 
	NewWindow.focus();
	NewWindow.document.open();
	
	var docString = "";
	
	docString += "<html><head><title>POPUP</title></head><body bottommargin='0' leftmargin='0' rightmargin='0' topmargin='0' marginwidth='0' marginheight='0'>";
	docString += " <img src='" + jpg + "' width='" + width + "' height='" + height + "' />";
	docString += "</body></html>";
	
	//docString = "<html><body>" + swf + "</body></html>";
	
	NewWindow.document.write(docString);
	

	NewWindow.document.close(); 
}

function checkPasswords(password1, password2) {
	var invalid = " "; // Invalid character is a space
	var minLength = 4; // Minimum length


	if(password1 != password2) {
		alert("Your new password entries did not match.");
		return false;
	}
	
	if (password1.length < minLength) {
		alert("Your password must be at least " + minLength + " characters long.");
		return false;
	}
	

	if(password1.indexOf(invalid) != -1) {
		alert("Your password may not contain spaces.");
		return false;
	}

	

	return true;

}

function setFrameURL(frameID, url) {
	document.getElementById(frameID).src = url;
}

function updateUserList() {
	thisMovie("userList").refreshList();
}
/*
function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}*/

 


