/*
 * random.js :: md@northwestern-edu
 * Web Communications :: Northwestern University
 */


// global vars...

var ulurl = new Array() ;
var uldescription = new Array() ;
var url = new Array() ;
var description = new Array() ;
var large = new Array() ;
var width = new Array() ;
var height = new Array() ;
var rand_ulimg = 0 ;
var rand_img = 0 ;
var check = new Array();
var count = 0;

// functions...

function add_ulimage(image_url, image_description) {
	uldescription[ulurl.length] = image_description ;
	ulurl[ulurl.length] = image_url ;
}

function add_image(image_url, image_description, image_large_url, large_width, large_height) {
	description[url.length] = image_description ;
	large[url.length] = image_large_url ;
	width[url.length] = large_width ;
	height[url.length] = large_height ;
	url[url.length] = image_url ;
}

function select_random_ulimg() {
	rand_ulimg = Math.floor(Math.random()*(ulurl.length)) ;
}

function select_random_img() {
	rand_img = Math.floor(Math.random()*(url.length)) ;
	while ((rand_img==check[0]) || (rand_img==check[1]) || (rand_img==check[2])) {
		rand_img = Math.floor(Math.random()*(url.length)) ;
	}
	check[count] = rand_img;
	count += 1;
}

function get_ulimage_url() {
	return ulurl[rand_ulimg] ;
}

function get_image_url() {
	return url[rand_img] ;
}

function get_ulimage_description() {
	return uldescription[rand_ulimg] ;
}

function get_image_description() {
	return description[rand_img] ;
}

function get_large_url() {
	return large[rand_img] ;
}

function get_large_width() {
	return width[rand_img] ;
}

function get_large_height() {
	return height[rand_img] ;
}


// popup window...

function popup (image,width,height,alt) {
	//image = "http://www.northwestern.edu/nucuisine/" + image;
	// fully qualified URL needed for image to display in Opera?
	
	text = '<?xml version="1.0" encoding="iso-8859-1"?>';
	text += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
	text += '<html xmlns="http://www.w3.org/1999/xhtml">';
	text += '<head><title>Dining Services, Northwestern University</title>';
	text += '<link rel="stylesheet" href="../style/popup.css" />';
	text += '</head>';
	text += '<body marginleft="0" margintop="0" marginwidth="0" marginheight="0">';
	text += '<img alt="' + alt + '" src="' + image + '" class="topleft" width="' + width + '" height="' + height + '" />';
	text += '</body></html>';
	
	attribs = "toolbar='no',location='no',directories='no',status='no',menubar='no',scrollbars='no',resizable='no',width=" + width + ",height=" + height + ",top=50,left=50";
	
	newWindow = window.open('','newWin',attribs);
	newWindow.document.write(text);
	newWindow.document.close();
}

