function cookieImage (cookieName, dir, div, doAutoFlip, customArr) {
	if (!customArr) {
		var arr = [
			['gtech1.jpg', '250', '167', 'From the roof of Genentech Hall, the lights of downtown San Francisco beckon. To the right, the illuminated Bay Bridge and the flood lights of SBC Park, home of the San Francisco Giants.'],
			['gtech3.jpg', '250', '167', 'The interior of the Genetics, Development and Behavioral Sciences building is flooded with natural light from above.'],
			['gtech7.jpg', '250', '167', 'An eye-level view of the Genetics, Development and Behavioral Sciences building from the Koret Quad.'],
			['gtech16.jpg', '250', '167', 'The barrel-vaulted entrance to Genentech Hall opens onto a bank of elevators and the light-filled atrium.'],
			['gtech17.jpg', '250', '167', 'Young scientist at Genentech Hall relaxes amidst an architectural environment that suggests the molecular nature of the research within its laboratories.'],
			['gtech18.jpg', '250', '167', 'A 278-seat auditorium on the main floor of Genentech Hall combines intimacy and easy lines of sight for the audience.'],
			['gtech19.jpg', '250', '167', 'A campus bookstore occupies space on the main floor of Genentech Hall.'],
			['gtech23.jpg', '250', '167', 'Lounge areas at Genentech Hall offer open views of the San Francisco skyline as well as their own shadow show.'],
			['gtech25.jpg', '250', '167', 'A dense pattern of rectangles appears on glassy surfaces throughout Genentech Hall. Shown here are those that stamp the glass partitions between one of the interaction spaces and laboratory benches beyond.'],
			['gtech26.jpg', '250', '167', 'Students enjoy the sun on the second floor terrace of Genentech Hall Cafe.'],
			['gtech27.jpg', '250', '167', 'Inside the Genentech Hall Cafe.'],
			['gtech28.jpg', '250', '167', 'Views of downtown San Francisco are a constant reminder of UCSF&rsquo;s urban origins and history.'],
			['gtech30.jpg', '250', '167', 'Through these doors the first wave of UCSF scientists and staff entered Genentech Hall in January 2003, populating one of the most modern laboratory facilities in the world.'],
			["pool.gif", "250", "167", "Aerial view of the UCSF Mission Bay Community Center rooftop pool. <i>Photo by Mark Defeo</i>", "UCSF Community Center Rooftop Pool"],
			["community_center_1.jpg", "250", "169", "The UCSF Mission Bay Community Center. <i>Photo by Lisa Cisneros</i>", "UCSF Community Center"],
			["community_center_3.gif", "250", "333", "Architectural detail of the UCSF Community Center. <i>Photo by Majed</i>", "UCSF Community Center"],
			["hammering_man.jpg", "250", "355", "<b>Hammering Man at 2,903,440</b> by Jonathan Borofsky, on loan to UCSF from the San Francisco Museum of Modern Art. <i>Photo by Mark Citret</i>", "Public Art at UCSF"],
			["genentech_1.jpg", "250", "375", "View looking up from the floor of the atrium. <i>Photo by Majed</i>", "Genentech Hall"],
			["genentech_2.jpg", "250", "333", "Genentech Hall ampitheatre. <i>Photo by Roxanne Malek</i>", "Genentech Hall"],
			["genentech_3.jpg", "250", "373", "Visitors to Genentech Hall look at the expansive atrium that serves as a focal point in the 434,000-square-foot research building. <i>Photo by Christine Jegan</i>", "Genentech Hall"],
			["genentech_4.jpg", "250", "188", "Young researchers enjoy a break in the atrium's main lounge area. <i>Photo by Majed</i>", "Genentech Hall"],
			["genentech_5.jpg", "250", "188", "Laboratory space has been designed for efficiency and ease of movement. <i>Photo by Majed</i>", "Genentech Hall"]
		];
	} else {
		var arr = customArr;
	}
	
	var currNum = parseInt(readCookie(cookieName));
	currNum += flipDirection;
	
	if (isNaN(currNum) || currNum > (arr.length - 1)) currNum = 0;
	if (currNum < 0) currNum = arr.length - 1;
	
	writeCookie(cookieName, currNum, 24 * 365);
	
	var img = dir + "/" + arr[currNum][0];
	var width = arr[currNum][1];
	var height = arr[currNum][2];
	var caption = arr[currNum][3];
	var altText = (arr[currNum][4] != null) ? arr[currNum][4] : "";
	
	var writeDiv = div != false;
	var newDiv = "";
	
	if (writeDiv) newDiv += "<div class=\"pic\" style=\"width: " + width + "px;\">";
	if (writeDiv) newDiv += "<a href=\"javascript:autoFlip(-1)\">&larr;</a>&nbsp;&nbsp;<a href=\"javascript:autoFlip(1)\">&rarr;</a>";
	
	newDiv += "<a class=\"imagelink\" href=\"javascript:autoFlip(1)\"><img border=\"0\" src=\"" + img + "\" width=\"" + width + "\" height=\"" + height + "\" alt=\"" + altText + "\" /></a>";
	
	if (caption !== "") newDiv += "<div class=\"caption\">" + caption + "</div>";
	if (!writeDiv) newDiv += "<div id=\"splash_arrows\" style=\"text-align: center;\"><a href=\"javascript:autoFlip(-1)\">&larr;</a>&nbsp;&nbsp;<a href=\"javascript:autoFlip(1)\">&rarr;</a></div>";
	
	if (writeDiv) newDiv += "</div>";
	
	document.getElementById("cookie_pic").innerHTML = newDiv;
	
	myArr = [cookieName, dir, div, doAutoFlip, customArr];
	if (doAutoFlip) id = setTimeout("autoFlip()", 10000);
}

function autoFlip (dir) {
	flipDirection = (!dir) ? 1 : dir;
	
	clearTimeout(id);
	cookieImage(myArr[0], myArr[1],  myArr[2], myArr[3], myArr[4]);
}

function makeVisible (idStr, boo) {
	var e = document.getElementById(idStr);
	if (!e.style) return;
	
	var str = (boo) ? "inline" : "none";
	e.style.display = str;
}

//GLOBAL VARS
flipDirection = 1;
id = null;
myArr = null;