function GetScrollWidth()
{
	if ( !window.scrollbarWidth )
	{
		SetScrollerWidthAndHeight();
	}

	return window.scrollbarWidth;
}

function GetScrollHeight()
{
	if ( !window.scrollbarHeight )
	{
		SetScrollerWidthAndHeight();
	}

	return window.scrollbarHeight;
}

function SetScrollerWidthAndHeight()
{
	var i = document.createElement("p");
	i.style.width = "100%";
	i.style.height = "200px";

	var o = document.createElement("div");
	o.style.position = "absolute";
	o.style.top = "0px";
	o.style.left = "0px";
	o.style.visibility = "hidden";
	o.style.width = "200px";
	o.style.height = "150px";
	o.style.overflow = "hidden";
	o.appendChild(i);

	document.body.appendChild(o);
	var w1 = i.offsetWidth;
	var h1 = i.offsetHeight;
	o.style.overflow = "scroll";
	var w2 = i.offsetWidth;
	var h2 = i.offsetHeight;
	if (w1 == w2) w2 = o.clientWidth;
	if (h1 == h2) h2 = o.clientWidth;

	document.body.removeChild(o);

	window.scrollbarWidth = w1-w2;
	window.scrollbarHeight = h1-h2;
}

function RegisterEvent(
objToAddEvent,
szEventName,
pEventFunction)
{

	try
	{


		/* Registrar evento según la W3C */
		if (objToAddEvent.addEventListener)
		{
			objToAddEvent.addEventListener(szEventName, pEventFunction, false);
		}

		/* Registrar event para IE */
		else if (objToAddEvent.attachEvent)
		{
			return objToAddEvent.attachEvent("on" + szEventName, pEventFunction);
		}
	    	else
		{
			alert('No se pudo registrar el Evento.\nConsulte con la empresa desarrolladora.\n\n' + objToAddEvent.id + ' - ' + szEventName);
		}
	}
	catch(e){}
}

function GetKey(
event)
{
	/* IE */
	if(window.event)
	{
		return event.keyCode;
	}

	/* W3C */
	else if(event.which)
	{
		return event.which;
	}
}


function GetCtrlKey(
event)
{
	/* IE */
	if(window.event)
	{
		
                return window.event.ctrlKey;
	}

	/* W3C */
	else if(event.which)

	{
                return event.ctrlKey;
	}
}

function GetSrcElementFromEvent(
objEvent)
{
	if (objEvent.srcElement != undefined)
	{
		return objEvent.srcElement;
	}

	/* FireFox */
	else
	{	        
	        return objEvent.target;
	}
}

function KeyEventCancel(
objEvent)
{
        //objEvent.returnValue = false;
        //objEvent.cancel = true;
        //objEvent.cancelBubble = true;
        
	try
	{
		objEvent.preventDefault(); // FireFox.
	}catch(e){}        

        /* Se retorna falso para cancelar */
        return false;
}
