//	functions.js

//	Version 1.1
//	Dated	22 August 2008

// Copyright (c) 2000 internet.com Corp. 
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.  (for launch)

function launch(newURL, newName, newFeatures, orgName) {
  var remote = window.open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}

function openNewWindow (newURL, newWidth, newHeight) {
  newWindow = launch(newURL, 
  		   "myRemote", 
		   "height=" + newHeight + ",width=" + newWidth + ",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=no,resizable=0,scrollbars=yes,status=no,toolbar=0", 
		   "myWindow");
}

function openNewMainWindow (newURL, newWidth, newHeight) {
  newWindow = launch(newURL, 
  		   "myRemote", 
		   "height=" + newHeight + ",width=" + newWidth + ",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes", 
		   "myWindow");
}

// the following is written by gkirk

function openOneWindow(fileURL) {
	// to open the left window when there are no frames
	newWidth = window.outerWidth;
	newHeight = window.innerHeight + 60;
	newWindowL = launch(fileURL, "myRemoteL", 
	    "height=" + newHeight + ",width=" + newWidth +
		",channelmode=0,dependent=0,directories=0," +
		"fullscreen=0,location=0,menubar=no,resizable=1," +
		"scrollbars=yes,status=no,toolbar=yes", 
	    "myWindowL");
	newWindowL.moveBy(10,0);
	return;
}
 
function swapPicture(imageIndex, pictureSource, width, height) {
    // to swap a picture from a thumbnail to the main picture
	document.images[imageIndex].width=width;
	document.images[imageIndex].height=height;
	document.images[imageIndex].src=pictureSource;
	return;
}

// used in GkSelector
var scrollToSelectionEntryCount = 0;		// do this only once
function scrollToSelection(formname, selname) {
// to bring the selected item into view
// activated onmouseover
	if (scrollToSelectionEntryCount > 0) return;
	scrollToSelectionEntryCount++;
	var myList = document.getElementById(formname);
	// get the element index for the selector
	for (var i=0; i<myList.elements.length; i++) {
		if (myList.elements[i].name == selname) {
			if(myList.elements[i].selectedIndex >= 0) {
				indexToShow = myList.elements[i].selectedIndex ;
				myList.elements[i].selectedIndex = indexToShow;
			}
		}
	}
}
