
<!-- Hide from older browsers....
//
// This is the article collection JavaScript source file.  If you
// have questions, address them to James Wonder....
//

// Load this image into the browser on the page load.
//
if( navigator.appName == "Netscape" && navigator.appVersion.charAt(0) != "3") {
	checkedImage = new Image( 23, 20);
	checkedImage.src = "/jimages/check.gif";
	}

// Set a cookie with name=value ; expires = expires....
function setCookie( name, value, expire)
{
	document.cookie = name + "=" + escape( value) +
	    "; path=/; domain=.aip.org" +
	    ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}


// Get the value from the cookie with the passed in name.
function getCookie( Name)
{
var search = Name + "=";
	if( document.cookie.length > 0) {
		offset = document.cookie.indexOf( search);
		
		if( offset != -1) {
			offset += search.length;

			end = document.cookie.indexOf( ";", offset);

			if( end == -1)
				end = document.cookie.length;

			return unescape( document.cookie.substring( offset, end));
			}
		}
}


// Get a random? number.
function rnd() {
today = new Date();
jran = today.getTime();

	ia = 9301;
	ic = 49297;
	im = 233280;
	jran = ( jran * ia + ic) % im;

	return( jran / (im * 1.0));
}

function random( number)
{
	return Math.ceil( rnd() * number);
}


// If there is no cookie, create one.  re-set the cookie expires time.
function doCookie( value)
{
var randomNumber = 0;
var today = new Date();
var time = today.getTime();
var expires = new Date();

	expires.setTime( today.getTime() + 60*60*24*90*1000);

	// The "expireme" hack is for MSIE!  Yuck!
	if( (value == null) || (value == "expireme"))
		value = random( 130) + "7" + time;

	setCookie( "aipbasket", value, expires);

	return value;
}


// This is the function which is called first.
function addItem( pageSequence)
{
var cookieValue = getCookie( "aipbasket");

	cookieValue = doCookie( cookieValue);

	if( navigator.appName == "Netscape" &&
	    navigator.appVersion.charAt(0) == "3")
		return;

	if( document[  pageSequence + "_1"]) {
		document[  pageSequence + "_1"].src = checkedImage.src;

		if( document[  pageSequence + "_2"]) 
			document[  pageSequence + "_2"].src = checkedImage.src;

		if( document[  pageSequence + "_3"]) 
			document[  pageSequence + "_3"].src = checkedImage.src;
		if( document[  pageSequence + "_4"]) 
			document[  pageSequence + "_4"].src = checkedImage.src;
		}
	else
		document [ pageSequence].src = checkedImage.src;
}

// -->
