﻿/// <reference path="intellisense/jquery-1.3.2-vsdoc2.js" />

/// Added by Colin to delay load of ticker
function showTicker() 
{ 
    var d = document.getElementById('myscroll'); 
    d.style.display = 'block'; 
}

$(function() {
    InitiliazeSiteCommon();
});

function InitiliazeSiteCommon() {

    $('a[rel="external"]').click(function() {
        window.open($(this).attr('href'));
        return false;
    });

    $("#myscroll").mbScrollable({
        dir: "vertical",
        width: 415,
        height: 20,
        elementsInPage: 1,
        elementMargin: 1,
        shadow: false,                 // shadow:"2px 2px 2px 2px",
        controls: "#controls1",
        slideTimer: 1000,
        autoscroll: true,
        scrollTimer: 2900
    });

    $(".stop").click(function() { $(this).toggleClass("none"); $(".start").toggleClass("none"); });
    $(".start").click(function() { $(this).toggleClass("none"); $(".stop").toggleClass("none"); });
    
    $("#newsfeed").click(function() { 
        if ($('#myscroll').hasClass('domainnews'))
        {
            //which link is displayed when newsfeed is clicked?
            var style = $('.scrollableStrip').attr('style');
            var position = 0;
            if (style != '' && style.indexOf('margin-top:',0) > 0)
            {
                var startpos = style.indexOf('margin-top:',0);
                style = jQuery.trim(style.substring(startpos+11, style.indexOf('px;',startpos)));
                position = Math.abs(parseInt(style/19));
            }
            var url = $('.SECont:eq(' + position + ') .scrollEl a').attr('href');
            if (url != null)
            {
                url = url.substring(0,url.indexOf('/rss.xml'));
                window.location = url + '/rss.xml';
            }
        }
        else window.location = '/rss.xml';
    });
    
}

