/**
 Code to redirect to a MT-generated anchor
 
 - create a main template called redirectAnchor.js
    - add this to that file
 - add the following to the Main Content template:
    - in the head section:
        <SCRIPT type="text/javascript" src="/faq/redirectAnchor.js"></SCRIPT>
    - at the end of the template (before the </body>)
        <SCRIPT type="text/javascript">redirectAnchor();</SCRIPT>
 
 Olivier Zyngier, 09/23/2009
 
 */
var anchorMap = new Array();
anchorMap['#birthYear'] = '60';
anchorMap['#gender'] = '392';
anchorMap['#userZip'] = '59';
anchorMap['#whyNotSong'] = '25';
anchorMap['#international'] = '79';
anchorMap['#holiday'] = '70';

function redirectAnchor()
{
    var windowUrl = window.location;
    var locationHash = windowUrl.hash;
    if (locationHash)
    {
        for (var toRedirect in anchorMap)
        {
            if (locationHash == toRedirect)
            {
                
                var redirected = anchorMap[toRedirect];
                var scrollToId = "a";
                var redirectedLength = 6 - ("" + redirected).length;
                for (var i = 0 ; i < redirectedLength ; i++)
                {
                    scrollToId += "0";
                }
                scrollToId += "" + redirected;
                //windowUrl = windowUrl.toString().replace(toRedirect , redirected) + "?reload=1";
                //window.location.replace(windowUrl);
                var scrollToElt = document.getElementById(scrollToId);
                scrollToElt.scrollIntoView(true);

                //window.location.href = windowUrl;
                return;
            }
        }
        
        
    }
}





//redirectAnchor();

