/*

	File created by Spencer Kellis, Fall Semester 2003
	e-mail: spencerkellis@hotmail.com
	netid: ssk22

*/

/*

	Following function defined so that I can change 
	nav links easily.  Is there a better way?
	
*/

function writeNav() {
	var prev		= "<div class=\"nav_link\"><a onmouseover=\"lmo( this );\" onmouseout=\"lmo( this );\" href='";
	var base		= "";		//include base if you are accessing a folder within the lawreview folder
	//var ext		= "aspx";
	var ext			= ".htm";
	var current		= "http://lawreview.byu.edu/index.htm"
	var upcoming	= "http://lawreview.byu.edu/upcoming.htm"
	var archive		= "http://lawreview.byu.edu/archive.htm"
	var about		= "http://lawreview.byu.edu/about.htm"				
	var masthead	= "http://lawreview.byu.edu/masthead.htm"
	var masthead_a	= "http://lawreview.byu.edu/masthead_archive.htm"
	var bylaws		= "http://lawreview.byu.edu/bylaws.htm"
	var subscript	= "http://lawreview.byu.edu/subscriptions.htm"
	var back		= "http://lawreview.byu.edu/back_issues.htm"
	var permission	= "http://lawreview.byu.edu/permission.htm"
	var submission	= "http://lawreview.byu.edu/submissions.htm"
	var edscreen    = "http://www.law2.byu.edu/lawreview2";
	var network     = "http://netdrv.byu.edu";
	var contact		= "http://lawreview.byu.edu/contact.htm"
	var new_mast	= "http://lawreview.byu.edu/masthead.htm"
	var search		= "http://lawreview.byu.edu/search.htm"
	var news_masthead 	= "http://lawreview.byu.edu/masthead.htm";
	var aftr		= "</a></div>\n";
	var issue_block = "<div class=\"nav_block\"><p style=\"border-bottom:solid 1px white;\">Issues</p>";
	var info_block	= "<div class=\"nav_block\"><p style=\"border-bottom:solid 1px white;\">Information</p>";
	var news_block	= "<div class=\"nav_block\"><p style=\"border-bottom:solid 1px white;\">News</p>";
	
	document.write( issue_block );
	document.write( prev  + current	+ "'>Current Issue"			+ aftr );
	document.write( prev  + upcoming	+ "'>Upcoming Issue"		+ aftr );
	document.write( prev  + archive	+ "'>Archived Issues"		+ aftr + "</div>" );
	document.write( info_block );
	document.write( prev  + about		+ "'>About the Review"		+ aftr );
	document.write( prev  + masthead	+ "'>Masthead"				+ aftr );
	document.write( prev  + masthead_a+ "'>Archived Mastheads"	+ aftr );
	document.write( prev  + bylaws	+ "'>Law Review Bylaws"		+ aftr );
	document.write( prev  + subscript	+ "'>Subscriptions"			+ aftr );
	document.write( prev  + back		+ "'>Back Issues"			+ aftr );
	document.write( prev  + permission+ "'>Permission Requests"	+ aftr );
	document.write( prev  + submission+ "'>Submissions"			+ aftr );
	document.write( prev  + edscreen+ "'>Editorial Screening" + aftr );
	document.write(	prev +		  network	+ "'>Network Access"		+ aftr );
	document.write( prev  + contact	+ "'>Contact Information"	+ aftr );
	document.write( prev  + search	+ "'>Search"				+ aftr + "</div>" );
	//document.write( news_block );
	//document.write( prev  + news_masthead		+ "'>Check out our new Masthead!"		+ aftr + "</div>" );
}

/**************************************************************************

	function purpose: add << before links when the user mouses over the link
	also change border/background color on hover.	
	notes: < is &lt; and > is &gt;
	
***************************************************************************/

function lmo( obj ) 
{
	var parentDiv = obj.parentNode;
	if( obj.innerHTML.indexOf( "&lt;" ) == -1 )
	{
		obj.innerHTML = "<< " + obj.innerHTML;
		parentDiv.style.backgroundColor = "#335689";
		parentDiv.style.borderWidth = "1px";
		parentDiv.style.borderStyle = "solid";
		parentDiv.style.borderColor = "#032659";
	}
	else
	{
		obj.innerHTML = obj.innerHTML.substring( obj.innerHTML.lastIndexOf( "&lt;" ) + 4 );
		parentDiv.style.backgroundColor = "#133669";
		parentDiv.style.borderWidth = "1px";
		parentDiv.style.borderStyle = "solid";
		parentDiv.style.borderColor = "#133669";
	}
}

/************************************************************
	
	Edit the style sheet, property ".issue_element_abstract"
	in order to display/hide the abstract for each article.

************************************************************/

function abst( obj, i ) {

	s = document.styleSheets[0];

	/*ie uses cssRules; nn uses rules, or maybe the other way around*/
	(s.cssRules) ? c = s.cssRules : c = s.rules;
	
	/*if neither is available, we're just giving up*/
	if( !c ) return;
	
	/*locating the .issue_element_abstract element*/
	r = 0;
	while( c[++r].selectorText != ".issue_element_abstract" );
	
	/*editing the stylesheet property (display -> none or -> block)*/
	c[r].style.display == "block" ? c[r].style.display = "none" : c[r].style.display = "block";
	
	/*
	(s.insertRule) ? addRule = s.insertRule : addRule = s.addRule;
	addRule( );
	*/
	
	/*
	MAJOR PROBLEM WITH THIS CODE:
	we need to modify the display property of only one element at a time, not
	every element that has the class ".issue_element_abstract"!
	*/
}

/***************************************************************

	Used on the archive page to load a selected volume/issue

****************************************************************/

function loadArchive() 
{
	//retrieve selected volume and issue values
	var vol = document.forms[ "select_issue" ].elements[ "volume" ].value;
	var iss = document.forms[ "select_issue" ].elements[ "issue"  ].value;
	
	//remember to error check: what issues are not available?
	if( vol == 2004 && iss == 1 )
	{
		//do nothing! issues don't exist in the archive as of 13 Feb 2004
	}
	else
	{
		//load new page by setting window.location property
		window.location = "archives/" + vol + "_" + iss + ".htm";
	}
}