//helper functions
var counter = 0;
HasNodeAttributeValue = function(node, attributeName, attributeValue)
{        
    if (node != null)
    {
        if (node.getAttribute != null)
        {
            var _attribute = node.getAttribute(attributeName);
            
            if (_attribute != null)
            {
                if (_attribute.indexOf(attributeValue) != -1)
                {
                    return true;
                }
            }
        }
    }
    return false;
}
HasChildNodeWithAttributeValue = function(node, attributeName, attributeValue)
{  
    if (node != null)
    {
        if (HasNodeAttributeValue(node, attributeName, attributeValue))
        {
            return true;
        }    
        if (node.childNodes != null)
        {
            for (var _a = 0; _a < node.childNodes.length; _a++)
            {                
                if (node.childNodes[_a].nodeType == 1 && HasChildNodeWithAttributeValue(node.childNodes[_a], attributeName, attributeValue))
                {    
                    return true;
                }
            }
        }
    }  
    return false;
}
HasParentNodeWithAttributeValue = function(node, attributeName, attributeValue, tabs)
{  
    if (node != null)
    {
        if (HasNodeAttributeValue(node, attributeName, attributeValue))
        {
            return true;
        }    
        if (node.parentNode != null)
        {      
            return HasParentNodeWithAttributeValue(node.parentNode, attributeName, attributeValue, tabs);
        }
    }
    return false;
}

//custom logic
AddHoverFunctions = function()
{
    try
    {
        var _elementsFound = Array();
        var _allElements = document.getElementsByTagName('*');

        for (var _i = 0; _i < _allElements.length; _i++)
        {
            if (HasNodeAttributeValue(_allElements[_i], "class", "bigTarget"))
            {
                _elementsFound[_elementsFound.length] = _allElements[_i];
            }
        }
        for (var _i = 0; _i < _elementsFound.length; _i++)
        {
            if (!HasParentNodeWithAttributeValue(_elementsFound[_i].parentNode, "class", "centerRight", "\t") && _elementsFound[_i].childNodes != null)
            {
                var _addHover = true;
                for (var _a = 0; _a < _elementsFound[_i].childNodes.length; _a++)
                {                    
                    if (_elementsFound[_i].childNodes[_a].nodeType == 1 && HasChildNodeWithAttributeValue(_elementsFound[_i].childNodes[_a], "class", "bigTarget"))
                    {          
                        _addHover = false;
                        break;
                    }
                }
                if (_addHover)
                {   
                    AddHoverToNode(_elementsFound[_i]);
                }
            }     
        }
    }
    catch (exception)
    {        
    }
}
AddHoverToNode = function(node)
{
    var _titlesFound = node.getElementsByTagName('h3');
    for (var _i = 0; _i < _titlesFound.length; _i++)
    {
        var _linksFound = _titlesFound[_i].getElementsByTagName('a');
        if (_linksFound.length > 0 && _linksFound[0].href != null && _linksFound[0].href.length > 0)
        {
            node.onmouseover = function () {this.setAttribute('class',this.getAttribute('class') + ' bigTargetHover');};
            node.onmouseout = function () {this.setAttribute('class',this.getAttribute('class').replace('bigTargetHover',''));};
            node.onclick = function () {OpenUrl(this);};
        }
    }  
}

//eventHandler
OpenUrl = function(node)
{
    try
    {
        var _titlesFound = node.getElementsByTagName('h3');
        for (var _i = 0; _i < _titlesFound.length; _i++)
        {
            var _linksFound = _titlesFound[_i].getElementsByTagName('a');
            if (_linksFound.length > 0 && _linksFound[0].href != null && _linksFound[0].href.length > 0)
            {
                document.location = _linksFound[0].href;
                break;
            }
        }
    }
    catch (exception)
    {
    }
}
AddHoverFunctions();


