﻿/* Rollover
Requires:
	object id to equal the base name of the image
	over state of image ends with -over
	nav-image.png -> nav-image-over.png
*/

function roll(obj, over)
{
	if (!obj)
		return

	var roll_image_ext = obj.src.substr(obj.src.lastIndexOf('.'), '4')

	if (over)
		src = '/Templates/media/images/' + obj.id + '-over'
	else
		src = '/Templates/media/images/' + obj.id
	
	src = src + roll_image_ext
	
	obj.src = src;
}

/* Rollover helper function for .NET controls 
    This is required for .NET controls, since their IDs are prefixed with control identifiers.
    To use, the ClientId of the control must be passed. */
function rollDotNet(id, clientId, over)
{
    // get object
    var obj = document.getElementById(clientId);
	if (!obj) return;

    // get image extension
	var roll_image_ext = obj.src.substr(obj.src.lastIndexOf('.'), '4');

	if (over)
		src = '/Templates/media/images/' + id + '-over';
	else
		src = '/Templates/media/images/' + id;
	
	src = src + roll_image_ext;
	
	obj.src = src;
}



function Menu() {
	that = this
	
	timer = null
	menu = null
	body = null
}

Menu.prototype.open = function(obj)
{
	that.hold()
	that.close()

	that.menu = obj
	that.body = document.getElementById(obj.id + '_body')
	that.body.style.display = 'block'
}

Menu.prototype.close = function()
{
	if (!that.menu && !that.menu_body)
		return 

	that.body.style.display = 'none'
	that.menu = null
	that.body = null
}

Menu.prototype.start_close = function()
{
	that.timer = window.setTimeout(that.close, 25)
}

Menu.prototype.hold = function()
{
	if (that.timer)
	{
		window.clearTimeout(that.timer)
		that.timer = null
	}
}


