/** Determines random picture to be displayed **/
function loadRandom( firstLoad )
{
	if (( document.getElementById("randomPic").complete == true ) || ( firstLoad == true ))
	{
		var pictures = new Array();
		var random_number = Math.round(Math.random()*21);

		pictures[0] = "random_pic_softball.jpg";
		pictures[1] = "random_pic_circle_of_love.jpg";
		pictures[2] = "random_pic_fairmount_park.jpg";
		pictures[3] = "random_pic_alicia_rachael_jason.jpg";
		pictures[4] = "random_pic_asb.jpg";
		pictures[5] = "random_pic_boo_at_zoo.jpg";
		pictures[6] = "random_pic_cwcsp.jpg";
		pictures[7] = "random_pic_cwcsp_2.jpg";
		pictures[8] = "random_pic_dcon_award.jpg";
		pictures[9] = "random_pic_dcon_dance.jpg";
		pictures[10] = "random_pic_kelly_and_lindsey.jpg";
		pictures[11] = "random_pic_meeting.jpg";
		pictures[12] = "random_pic_softball_2.jpg";
		pictures[13] = "random_pic_darby_creek.jpg";
		pictures[14] = "random_pic_discovery_day.jpg";
		pictures[15] = "random_pic_fisher_park.jpg";
		pictures[16] = "random_pic_fisher_park2.jpg";
		pictures[17] = "random_pic_lock_in.jpg";
		pictures[18] = "random_pic_manna_pie_in_sky.jpg";
		pictures[19] = "random_pic_senior_banquet.jpg";
		pictures[20] = "random_pic_cobbs_creek.jpg";
		pictures[21] = "random_pic_cobbs_creek2.jpg";

		document.getElementById("randomPic").src = "images/random/" + pictures[random_number];
		document.getElementById("randomPic").alt = pictures[random_number];
		document.getElementById("randomPic").title = pictures[random_number];
		
		setTimeout("loadRandom(false)",4000);
	}
	else { setTimeout("loadRandom(false)",4000); }
}

/* Builds the mailto: header */
function buildHeader()
{
	var e = 't'
	var b = 'a'
	var g = ':'
	var d = 'l'
	var a = 'm'
	var f = 'o'
	var c = 'i'
	return a + b + c + d + e + f + g
}

/** Displays the e-mail address, with the address as the display text **/
function displayEmailAddress( domain, address )
{
	var full = address + "@" + domain;
	document.write("<a href='" + buildHeader() + full + "'>" + full + "</a>");
}

/** Displays the e-mail address, with the given text as the display text **/
function displayEmailText( domain, address, text )
{
	var full = address + "@" + domain;
	document.write("<a href='" + buildHeader() + full + "'>" + text + "</a>");
}

/** Displays the day of a calendar cell **/
function displayDay( cell )
{
	// offset variable determines when first day of month occurs
	// 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday
	var offset = 0;
	var maxDay = 31;
	var day = cell - offset;
	if (( day > 0) && ( day <= maxDay ))
	{
		document.write("<u>" + day + "</u><p></p>");
	}
	else
	{
		document.write("<p>&nbsp;</p>");
	}
}

/** Displays Photo Gallery's picture **/
function displayPhoto( name )
{
	parent.document.pic.src = "pictures/" + name;
	parent.document.pic.alt = name;
}

/** Validates the user-inputed e-mail address before sending it off to the mailing list **/
function validate()
{
	var email = document.join_mailing_list.user
	
	if (email.value == "")
	{
		alert("You did not enter an e-mail address")
		email.focus()
		return false;
	}
	
	else if (email.value.indexOf("@") == -1)
	{
		alert("You entered an invalid e-mail address")
		email.focus()
		return false;
	}
	
	return true;
}

