function formFieldOn(val)
{
	val.className = "formFieldOn";
}

function formFieldOff(val)
{
	val.className = "formFieldOff";
}

function writeYear()
{
	var today = new Date();
	var thisyear = today.getUTCFullYear();
	document.write(thisyear);
}

if (document.images)
{
	var toolbarcommenton = new Image();
	toolbarcommenton.src = "http://www.elawreview.org/images/layout/toolbar_comment_on.gif";
	var toolbaremailon = new Image();
	toolbaremailon.src = "http://www.elawreview.org/images/layout/toolbar_email_on.gif";	
	var toolbarprinton = new Image();
	toolbarprinton.src = "http://www.elawreview.org/images/layout/toolbar_print_on.gif";
}

function imageSwap(img,val)
{
	if (document.images)
	{
		var imageon = new Image();
		imageon.src = "http://www.elawreview.org/images/layout/" + img + "_on.gif";
		var imageoff = new Image();
		imageoff.src = "http://www.elawreview.org/images/layout/" + img + "_off.gif";	
			
		if (val == 0)
			document.images[img].src = imageoff.src;
		else
			document.images[img].src = imageon.src;
	}
}

function onSubmitComments()
{
	if (document.comments_form.author.value == "")
	{
		alert("Please enter your name.");
		document.comments_form.author.focus();
		return (false);
	}
	if (document.comments_form.email.value == "")
	{
		alert("Please enter your e-mail address.");
		document.comments_form.email.focus();
		return (false);
	}	
	if (document.comments_form.text.value == "")
	{
		alert("Please enter your comments.");
		document.comments_form.text.focus();
		return (false);
	}	
	return (true);
}	

function getQueryVariable(variable) 
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");

	for (var i=0;i<vars.length;i++) 
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable) 
		{
			return pair[1];
		}
	} 
}

function setPrintVersion()
{
	if(getQueryVariable("print") == "yes")
	{
		if(navigator.appName.indexOf("Microsoft Internet Explorer") >= 0)
		{
			document.getElementById("header_table").style.display = "none";
			document.getElementById("module_sidebar").style.display = "none";
			document.getElementById("toolbar_table").style.display = "none";			
			document.getElementById("comments_block").style.display = "none";					
		}
		else
		{
			document.getElementById("header_table").style.visibility = "collapse";
			document.getElementById("module_sidebar").style.visibility = "collapse";
			document.getElementById("toolbar_table").style.visibility = "collapse";
			document.getElementById("comments_block").style.visibility = "collapse";
		}
		print();
	}
}

function showPrintVersionSubheader(url)
{
	if(getQueryVariable("print") == "yes")
	{
		document.write("<b>Lewis & Clark Law School's <i>Environmental Law</i></b><br><b>" + url + "</b><p>");
	}
}

function writeRandomPhoto(counter)
{
	//When adding or removing photos, make sure the "numPhotos" number still corresponds
	//	with the total number of photos in the directory on the server.
	var numPhotos = 101;
	
	if(getQueryVariable("print") != "yes")
	{
		var whichImage = Math.round(Math.random()*(numPhotos-1));	
		imgURL = new Image();
		imgURL.src = "http://www.elawreview.org/images/photos/" + whichImage + ".jpg";
	
		var today = new Date();
		var thisyear = today.getUTCFullYear();					
	
		var imgHTML = "<img src='" + imgURL.src + "' title='&copy; " + thisyear + " Troy Payne, all rights reserved'";
		if (counter % 2)
			imgHTML += " align='left'";
		else
			imgHTML += " align='right'";
		imgHTML += " class='photo' hspace=5>";
	
		document.write(imgHTML);
	}
}

function popPrintPage(url)
{
	if (document.all)
	{
		win_width  = ((screen.Width-800)/2);
		win_height = ((screen.Height-500)/2)
	}
	else
	{
		win_width  = ((screen.availWidth-800)/2);
		win_height = ((screen.availHeight-500)/2)
	}

	g_popPrintPage = window.open(url + "?print=yes","g_popPrintPage", "status=no,toolbar=no,location=no,menu=no,width=800,height=500,scrollbars=1,left="+win_width+",screenx="+win_width+",top="+win_height+",screeny="+win_height);
}

function popEmailLink(which, title, url)
{
	if (document.all)
	{
		win_width  = ((screen.Width-600)/2);
		win_height = ((screen.Height-400)/2)
	}
	else
	{
		win_width  = ((screen.availWidth-600)/2);
		win_height = ((screen.availHeight-400)/2)
	}

	g_popEmailLink = window.open("http://www.elawreview.org/common/email_link.html?which=" + escape(which) + "&title=" + escape(title) + "&url=" + escape(url),"g_popEmailLink", "status=no,toolbar=no,location=no,menu=no,width=600,height=400,scrollbars=1,left="+win_width+",screenx="+win_width+",top="+win_height+",screeny="+win_height);
}

function popContact(which)
{
	if (document.all)
	{
		win_width  = ((screen.Width-600)/2);
		win_height = ((screen.Height-410)/2)
	}
	else
	{
		win_width  = ((screen.availWidth-600)/2);
		win_height = ((screen.availHeight-410)/2)
	}
	
	g_popContact = window.open("http://www.elawreview.org/common/" + which + ".html","g_popContact", "status=no,toolbar=no,location=no,menu=no,width=600,height=410,scrollbars=1,left="+win_width+",screenx="+win_width+",top="+win_height+",screeny="+win_height);
}