function MM_swapImgRestore() 
{
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("http://www.lincolnharbor.net#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/*
	tableruler()
	written by Chris Heilmann for alistapart.
	enables a rollover of rows for each table with the classname "hlrows"
*/

function tableruler(table_name)
{
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].className == table_name)
			{
				var trs=tables[i].getElementsByTagName('tr');
				
				for(var j=0;j<trs.length;j++)
				{
					if(trs[j].parentNode.nodeName=='TBODY')
					{
						trs[j].onmouseover=function(){this.className='ruled';return false}
						trs[j].onmouseout=function(){this.className='';return false}
					}
				}
			}
		}
	}
}



// This allows the user to show/hide bio information
var ie4 = false; if(document.all) { ie4 = true; }

function getObject(id) { if (ie4) { return document.all[id]; } else { return document.getElementById(id); } }
	
function toggle(link, divId) 
{
	var lText = link.innerHTML; 
	var d = getObject(divId);
	
	if (lText == 'Show Documents') 
	{ 
		link.innerHTML = 'Hide Documents'; d.style.display = 'block'; 
	}
	else if (lText == 'Hide Documents') 
	{ 
		link.innerHTML = 'Show Documents'; d.style.display = 'none';
	}
    else if (lText == 'Show Samples') 
    { 
        link.innerHTML = 'Hide Samples'; d.style.display = 'block';
    }
    else if (lText == 'Hide Samples') 
    { 
        link.innerHTML = 'Show Samples'; d.style.display = 'none';
    }
}


// OBJECT AND STYLE CONTROLS

// Get a reference to an object
function getObj(id) 
{
    //alert (id);
    if (document.getElementById) {return document.getElementById(id);}
	else if (document.all) 		 {return document.all[id];}
	else 		 {return false;}
}


// Get a reference to the style definition of an object
function getStyleObj(id) 
{
   // alert (id);
    if (document.getElementById) {return getObj(id).style;} 
	else {return getObj(id);}
}


function display_set (item, val) 
{
	//alert ("setting display of " + item + " to " + val);
	var el  = getStyleObj(item); 
	el.display = val;
}

// COOKIE CONTROLS FOR RANDOMLY-SELECTED HOME PAGE IMAGES

// Set cookie
function cookie_set (name, value)
{
	var path = "/";
	
	// Set the cookie
	document.cookie = name + "=" + escape (value) + "; path=" + path;
}


// Get a random number between lo and hi that is different from the current value
function rand_val(lo, hi, current_val)
{
	do {rand_num = Math.round(Math.random(1)*10);}
	while (rand_num < lo || rand_num > hi || rand_num == current_val);
	
	return rand_num
}


// Set the value of the cookie
function cookie_val(val, image_max)
{
	// Set a cookie different that the current cookie
	this_cookie_01_val = rand_val(1, image_max, val)		
	
	cookie_set("this_cookie_01", this_cookie_01_val)
}


// The following cookie functions are used to control the intro image
// Check for session cookie
function cookie_get(name) 
{ 
	// Check for cookie 
	var index = document.cookie.indexOf(name + "=");
    	if (index == -1) return null;

	// Extract the cookie
	index = document.cookie.indexOf("=", index) + 1;
	var endstr = document.cookie.indexOf(";", index);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(index, endstr));
}

// Set the cookie
function cookie_init(image_max)
{
	// Declare a cookie var
	this_cookie_01_val = cookie_get("this_cookie_01");
	
	// Set the document.cookie to cookie var
	cookie_val(this_cookie_01_val, image_max);	

	// Set the img_rand var to a new value
	random_seed = this_cookie_01_val;
	
}

function reveal_home_promo(random_seed, object_prefix)
{
	// To reveal a home promo, you set display to block
	display_set (object_prefix + random_seed, "block");
	
}
