function IsIE6()
{
    //return /msie|MSIE 6/.test(navigator.userAgent);
    return (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1);
}

function GetScrollWidth()
{
	if ( !window.scrollbarWidth )
	{
		SetScrollerWidthAndHeight();
	}

	return window.scrollbarWidth;
}

function IE6_AddOnScrollEvent(
objEvent)
{
    if ( IsIE6() &&
         document.documentElement.onscroll == null )
    {
       document.documentElement.onscroll = objEvent;
    }
}

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 GetScrollX()
{
    return self.pageXOffset || (document.documentElement.scrollTop  + document.body.scrollLeft);
}
function GetScrollY()
{
    return self.pageYOffset || (document.documentElement.scrollTop  + document.body.scrollTop);
}

function RegisterEvent(
objToAddEvent,
szEventName,
pEventFunction)
{
	try
	{


		/* Registrar evento segun 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;
}


function GetXmlRequest()
{

    var xhrRequest;
    
    /* Para navegador IE antiguos (<=7) */
    if (window.XMLHttpRequest)
    {
        xhrRequest = new XMLHttpRequest();
    }
    /* Para IE */
    else
    {
        try
        {
            xhrRequest = new ActiveXObject("Msxml2.XMLHTTP");

        }
        catch (e)
        {
            try
            {
                xhrRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                xhrRequest = null;
            }
        }
    }

    /* Se retorna */
    return xhrRequest;
}

function InnerText(
objHtmlNode)
{
    var szInnerText;

    try
    {
        szInnerText = objHtmlNode.textContent;
    }
    catch (e){}
        
    if ( szInnerText == undefined )
    {
        szInnerText = objHtmlNode.innerText;    
    }

    return Trim(szInnerText);
}