/* 
JavaScript Document for OUTOFMYBRAIN ONTHETRAIN.COM

Author : James Thomson [james.thomson@soup.co.uk]
Client : Soup Ltd.
Project : Train Blog

*/

//	id - element object or string identifying element id
//	flag - true appends _ro to image name, false removes it if it exists

function roll_over(id, flag)
{
	var element;

	if (typeof(id) == 'string')
	{
		element = document.getElementById(id);
	}
	else
	{
		element = id;	
	}

	var source = element.src;

	// get the extension of the file so we can deal with all types

	var extension = source.substr(source.length - 3, 3);

	// add in the _ro to the filename

	if (flag)
	{
		source = source.substr(0, source.length - 4) + '_ro.' + extension;
	}
	else
	{
		source = source.substr(0, source.length - 7) + '.' + extension;
	}

	element.src = source;
}

