﻿//Bookmarking

function createBookmark(title, url)
{
	//IE
	if (typeof window.external.AddFavorite != "undefined")
	{
		window.external.AddFavorite(url, title);
	}
	
	//else
	else
	{
		alert("Unable to add the bookmark.  Please bookmark manually.");
	}
	
	return false;
}


//Expanding box

function expandFacts()
{
	//Expand the factbox div
	var el = document.getElementById("factBox");
	el.style.height = "400px";
	
	//change the button to collapse
	var img = document.getElementById("expandButton");
	//use "on" version because onmouseout will fire when this function ends
	img.src = "images/collapse-on.gif";
	
	//attach collapse handler
	var btn = document.getElementById("expandLink");
	btn.onclick = function() { return collapseFacts(); };
	
	return false;
}

function collapseFacts()
{
	//Collapse the factbox div
	var el = document.getElementById("factBox");
	el.style.height = "115px";
	
	//change the button to expand
	var img = document.getElementById("expandButton");
	//use "on" version because onmouseout will fire when this function ends
	img.src = "images/expand-on.gif";
	
	//attach expand handler
	var btn = document.getElementById("expandLink");
	btn.onclick = function() { return expandFacts(); };
	
	return false;
}

//Image rollover
//image filenames must be in the format 'filename.ext' and 'filename-on.ext'

Rollover = function()
{
	//empty constructor	
}

//Static function turns on the rollover image
Rollover.turnOn = function(element)
{
	var img = element;
	
	//Get the filename portion minus the extension
	var filename = img.src.substr(0, img.src.lastIndexOf('.'));
	
	//Get the extension portion
	var extension = img.src.substr(img.src.length - 4, 4);
	
	//insert '-on' between the filename and extension and set it as the new src
	img.src = filename + '-on' + extension;
}
	
//Static function turns off the rollover image
Rollover.turnOff = function(element)
{
	var img = element;
	
	//Get the filename portion minus the extension, also removed the '-on'
	var filename = img.src.substr(0, img.src.lastIndexOf('.') - 3);
	
	//Get the extension portion
	var extension = img.src.substr(img.src.length - 4, 4);
	
	//Set the combined name as the new img src
	img.src = filename + extension;
}

//Static function to change the image, use when image filenames can not be in the "-on" format
Rollover.setImage = function(element, href)
{
	var img = element;
	
	img.src = href;
}