var classUnsel = 'galleryThumb';
var classOver = 'galleryThumbOver';
	
// for onmouseover
function rollon(e) 
{
	var srcId, srcElement, srcElementID, targetElement; 
	if (window.event) e = window.event; 
	srcElement = ( e.srcElement ) ? e.srcElement : e.target; 
	srcElementID = String(srcElement.id);
	if (( srcElementID.substring(0,3) == 'img' ) || ( srcElementID.substring(0,3) == 'div' ))
	{	
		borderElement = document.getElementById( 'thm'+srcElementID.substring(3) );
		if ( borderElement.className == classUnsel )
		{
			borderElement.setAttribute("class", classOver); 
			borderElement.setAttribute("className", classOver);
		}
	}
	
}

// for mouseoff
function rolloff(e) 
{
	var srcId, srcElement, srcElementID, targetElement; 
	if (window.event) e = window.event; 
	srcElement = ( e.srcElement ) ? e.srcElement : e.target; 
	srcElementID = String(srcElement.id);
	if (( srcElementID.substring(0,3) == 'img' ) || ( srcElementID.substring(0,3) == 'div' ))
	{		
		borderElement = document.getElementById( 'thm'+srcElementID.substring(3) );
		if ( borderElement.className == classOver )
		{
			borderElement.setAttribute("class", classUnsel); 
			borderElement.setAttribute("className", classUnsel);	
		}			
	}
}

function click(e)
{
	var srcId, srcElement, srcElementID, targetElement; 
	if (window.event) e = window.event; 
	srcElement = ( e.srcElement ) ? e.srcElement : e.target; 
	srcElementID = String(srcElement.id);
	if (( srcElementID.substring(0,3) == 'img' ) || ( srcElementID.substring(0,3) == 'div' ))
	{		
		pictureID = srcElementID.substring(3);
		pictureIDindex = window.location.href.indexOf("picture=");
		if( pictureIDindex > -1 )
			window.location = window.location.href.substring( 0, pictureIDindex -1) + "&picture=" + pictureID;
		else 
			window.location = window.location.href + "&picture=" + pictureID;		
	}
}

// assign rollon() to handle onMouseOver events
document.onmouseover = rollon;

// assign rolloff() to handle onMouseOut events
document.onmouseout = rolloff;

// assign mouseclick() to handle onMouseOut events
document.onclick = click;
